markus / ConvertService / ServiceController / Markus.Service.StationController / ViewModel / ConvertAddDialogViewModel.cs @ 5c387707
이력 | 보기 | 이력해설 | 다운로드 (8.4 KB)
1 | 5c387707 | semi | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Threading.Tasks; |
||
6 | using Telerik.Windows.Controls; |
||
7 | using System.IO; |
||
8 | using Microsoft.Win32; |
||
9 | using Markus.Service.Extensions; |
||
10 | using System.Windows; |
||
11 | using System.Windows.Controls; |
||
12 | using System.ComponentModel; |
||
13 | using Markus.Service.StationController.Data; |
||
14 | using System.Collections.ObjectModel; |
||
15 | |||
16 | namespace Markus.Service.StationController.ViewModel |
||
17 | { |
||
18 | class ConvertAddDialogViewModel : Mvvm.ToolKit.ViewModelBase |
||
19 | { |
||
20 | #region Construrtor |
||
21 | |||
22 | public ConvertAddDialogViewModel() |
||
23 | { |
||
24 | ProjectName(); |
||
25 | ConverAdd_OKCommand = new DelegateCommand(ConverAdd_OK); |
||
26 | } |
||
27 | |||
28 | private async void ProjectName() |
||
29 | { |
||
30 | if (ProjectNames.Count() == 0) |
||
31 | { |
||
32 | foreach (var x in await WcfClient.GET_SELECT_RUN_PROJECTSAsync(0)) |
||
33 | { |
||
34 | ProjectName projectName = new ProjectName(x.PROJECT_NO, x.PROJECT_NAME); |
||
35 | ProjectNames.Add(projectName); |
||
36 | } |
||
37 | } |
||
38 | } |
||
39 | #endregion |
||
40 | |||
41 | #region Propertise |
||
42 | |||
43 | DataService.DataServiceClient WcfClient = new DataService.DataServiceClient(); |
||
44 | |||
45 | private string _ConverAdd_DOCUMENT_ID; |
||
46 | public string ConverAdd_DOCUMENT_ID |
||
47 | { |
||
48 | get { return _ConverAdd_DOCUMENT_ID; } |
||
49 | set |
||
50 | { |
||
51 | if (_ConverAdd_DOCUMENT_ID != value) |
||
52 | { |
||
53 | _ConverAdd_DOCUMENT_ID = value; |
||
54 | OnPropertyChanged(() => ConverAdd_DOCUMENT_ID); |
||
55 | } |
||
56 | } |
||
57 | } |
||
58 | |||
59 | private string _ConverAdd_DOCUMENT_URL; |
||
60 | public string ConverAdd_DOCUMENT_URL |
||
61 | { |
||
62 | get { return _ConverAdd_DOCUMENT_URL; } |
||
63 | set |
||
64 | { |
||
65 | if (_ConverAdd_DOCUMENT_URL != value) |
||
66 | { |
||
67 | _ConverAdd_DOCUMENT_URL = value; |
||
68 | OnPropertyChanged(() => ConverAdd_DOCUMENT_URL); |
||
69 | } |
||
70 | } |
||
71 | } |
||
72 | |||
73 | private string _Project_NO_Border = "#FF000000"; |
||
74 | public string Project_NO_Border |
||
75 | { |
||
76 | get { return _Project_NO_Border; } |
||
77 | set |
||
78 | { |
||
79 | if (ProjectNames.Contains(ProjectNumberFilter)) |
||
80 | { |
||
81 | _Project_NO_Border = "#FF000000"; |
||
82 | OnPropertyChanged(() => Project_NO_Border); |
||
83 | } |
||
84 | else |
||
85 | { |
||
86 | _Project_NO_Border = "#FFFF0000"; |
||
87 | OnPropertyChanged(() => Project_NO_Border); |
||
88 | } |
||
89 | } |
||
90 | } |
||
91 | |||
92 | private string _DOCUMENT_ID_Border = "#FF000000"; |
||
93 | public string DOCUMENT_ID_Border |
||
94 | { |
||
95 | get { return _DOCUMENT_ID_Border; } |
||
96 | set |
||
97 | { |
||
98 | if (ConverAdd_DOCUMENT_ID != null) |
||
99 | { |
||
100 | _DOCUMENT_ID_Border = "#FF000000"; |
||
101 | OnPropertyChanged(() => DOCUMENT_ID_Border); |
||
102 | } |
||
103 | else |
||
104 | { |
||
105 | _DOCUMENT_ID_Border = "#FFFF0000"; |
||
106 | OnPropertyChanged(() => DOCUMENT_ID_Border); |
||
107 | } |
||
108 | } |
||
109 | } |
||
110 | |||
111 | private string _DOCUMENT_URL_Border = "#FF000000"; |
||
112 | public string DOCUMENT_URL_Border |
||
113 | { |
||
114 | get { return _DOCUMENT_URL_Border; } |
||
115 | set |
||
116 | { |
||
117 | if (ConverAdd_DOCUMENT_URL != null) |
||
118 | { |
||
119 | _DOCUMENT_URL_Border = "#FF000000"; |
||
120 | OnPropertyChanged(() => DOCUMENT_URL_Border); |
||
121 | } |
||
122 | else |
||
123 | { |
||
124 | _DOCUMENT_URL_Border = "#FFFF0000"; |
||
125 | OnPropertyChanged(() => DOCUMENT_URL_Border); |
||
126 | } |
||
127 | } |
||
128 | } |
||
129 | |||
130 | private string _Project_NO_Color = "#FFFFFFFF"; |
||
131 | public string Project_NO_Color |
||
132 | { |
||
133 | get { return _Project_NO_Color; } |
||
134 | set |
||
135 | { |
||
136 | if (ProjectNames.Contains(ProjectNumberFilter)) |
||
137 | { |
||
138 | _Project_NO_Color = "#FFFFFFFF"; |
||
139 | OnPropertyChanged(() => Project_NO_Color); |
||
140 | } |
||
141 | else |
||
142 | { |
||
143 | _Project_NO_Color = "#FFFF0000"; |
||
144 | OnPropertyChanged(() => Project_NO_Color); |
||
145 | } |
||
146 | } |
||
147 | } |
||
148 | |||
149 | private string _DOCUMENT_ID_Color = "#FFFFFFFF"; |
||
150 | public string DOCUMENT_ID_Color |
||
151 | { |
||
152 | get { return _DOCUMENT_ID_Color; } |
||
153 | set |
||
154 | { |
||
155 | if (ConverAdd_DOCUMENT_ID != null) |
||
156 | { |
||
157 | _DOCUMENT_ID_Color = "#FFFFFFFF"; |
||
158 | OnPropertyChanged(() => DOCUMENT_ID_Color); |
||
159 | } |
||
160 | else |
||
161 | { |
||
162 | _DOCUMENT_ID_Color = "#FFFF0000"; |
||
163 | OnPropertyChanged(() => DOCUMENT_ID_Color); |
||
164 | } |
||
165 | } |
||
166 | } |
||
167 | |||
168 | private string _DOCUMENT_URL_Color = "#FFFFFFFF"; |
||
169 | public string DOCUMENT_URL_Color |
||
170 | { |
||
171 | get { return _DOCUMENT_URL_Color; } |
||
172 | set |
||
173 | { |
||
174 | if (ConverAdd_DOCUMENT_URL != null) |
||
175 | { |
||
176 | _DOCUMENT_URL_Color = "#FFFFFFFF"; |
||
177 | OnPropertyChanged(() => DOCUMENT_URL_Color); |
||
178 | } |
||
179 | else |
||
180 | { |
||
181 | _DOCUMENT_URL_Color = "#FFFF0000"; |
||
182 | OnPropertyChanged(() => DOCUMENT_URL_Color); |
||
183 | } |
||
184 | } |
||
185 | } |
||
186 | |||
187 | public ObservableCollection<ProjectName> _ProjectNames; |
||
188 | public ObservableCollection<ProjectName> ProjectNames |
||
189 | { |
||
190 | get |
||
191 | { |
||
192 | if (_ProjectNames == null) |
||
193 | { |
||
194 | _ProjectNames = new System.Collections.ObjectModel.ObservableCollection<ProjectName>(); |
||
195 | } |
||
196 | |||
197 | return _ProjectNames; |
||
198 | } |
||
199 | set |
||
200 | { |
||
201 | _ProjectNames = value; |
||
202 | OnPropertyChanged(() => ProjectNames); |
||
203 | } |
||
204 | } |
||
205 | |||
206 | public ProjectName _ProjectNumberFilter; |
||
207 | public ProjectName ProjectNumberFilter |
||
208 | { |
||
209 | get |
||
210 | { |
||
211 | if (_ProjectNumberFilter == null) |
||
212 | { |
||
213 | _ProjectNumberFilter = new ProjectName(); |
||
214 | } |
||
215 | return _ProjectNumberFilter; |
||
216 | } |
||
217 | set |
||
218 | { |
||
219 | _ProjectNumberFilter = value; |
||
220 | OnPropertyChanged(() => ProjectNumberFilter); |
||
221 | } |
||
222 | } |
||
223 | #endregion |
||
224 | |||
225 | #region Command |
||
226 | |||
227 | public DelegateCommand ConverAdd_OKCommand { get; private set; } |
||
228 | |||
229 | #endregion |
||
230 | |||
231 | #region Fuction |
||
232 | |||
233 | #region ConverAdd_OK |
||
234 | /// <summary> |
||
235 | /// 그리드 상단 Conver 추가 버튼 |
||
236 | /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 |
||
237 | /// </summary> |
||
238 | public async void ConverAdd_OK(object obj) |
||
239 | { |
||
240 | if (String.IsNullOrEmpty(ProjectNumberFilter.Project_NO) || String.IsNullOrEmpty(ConverAdd_DOCUMENT_URL) || String.IsNullOrEmpty(ConverAdd_DOCUMENT_ID)) |
||
241 | { |
||
242 | Project_NO_Border = ""; |
||
243 | DOCUMENT_ID_Border = ""; |
||
244 | DOCUMENT_URL_Border = ""; |
||
245 | Project_NO_Color = ""; |
||
246 | DOCUMENT_ID_Color = ""; |
||
247 | DOCUMENT_URL_Color = ""; |
||
248 | } |
||
249 | else |
||
250 | { |
||
251 | try |
||
252 | { |
||
253 | string ConverAdd_ID = GuidExtension.shortGuid(); |
||
254 | var items = await WcfClient.GET_SELECT_CONVERT_INSERTAsync(ConverAdd_ID, ProjectNumberFilter.Project_NO, ConverAdd_DOCUMENT_URL, ConverAdd_DOCUMENT_ID); |
||
255 | System.Diagnostics.Debug.WriteLine(items); |
||
256 | |||
257 | MessageBox.Show("데이터베이스에 추가 완료! "); |
||
258 | } |
||
259 | catch (Exception ex) |
||
260 | { |
||
261 | MessageBox.Show(ex.ToString()); |
||
262 | } |
||
263 | Project_NO_Border = ""; |
||
264 | DOCUMENT_ID_Border = ""; |
||
265 | DOCUMENT_URL_Border = ""; |
||
266 | Project_NO_Color = ""; |
||
267 | DOCUMENT_ID_Color = ""; |
||
268 | DOCUMENT_URL_Color = ""; |
||
269 | |||
270 | ConverAdd_DOCUMENT_ID = null; |
||
271 | ConverAdd_DOCUMENT_URL = null; |
||
272 | } |
||
273 | } |
||
274 | |||
275 | #endregion |
||
276 | |||
277 | #endregion |
||
278 | } |
||
279 | } |