hytos / ID2.Manager / ID2.Manager / Main.cs @ 08ea0584
이력 | 보기 | 이력해설 | 다운로드 (60.5 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.ComponentModel; |
4 |
using System.Data; |
5 |
using System.Drawing; |
6 |
using System.Linq; |
7 |
using System.Text; |
8 |
using System.Threading.Tasks; |
9 |
using System.Windows.Forms; |
10 |
|
11 |
using System.IO; |
12 |
using System.Reflection; |
13 |
|
14 |
using ID2.Manager.Controls; |
15 |
using ID2.Manager.Common; |
16 |
using ID2.Manager.Classes; |
17 |
using ID2.Manager.Data.Models; |
18 |
using ID2.Manager.Forms; |
19 |
using ID2.Manager.Controller.Controllers; |
20 |
using static ID2.Manager.Data.Models.Documents; |
21 |
|
22 |
using Telerik.WinControls; |
23 |
using Telerik.WinControls.UI; |
24 |
using Telerik.WinControls.Data; |
25 |
|
26 |
using GemBox.Spreadsheet; |
27 |
|
28 |
using Newtonsoft.Json; |
29 |
using System.Diagnostics; |
30 |
|
31 |
namespace ID2.Manager |
32 |
{ |
33 |
public partial class Main : RadRibbonForm |
34 |
{ |
35 |
readonly Informations informations = Informations.Instance; |
36 |
|
37 |
List<Documents> documents = new List<Documents>(); |
38 |
List<Documents> orgDocuments = null; |
39 |
|
40 |
private readonly Color _SummaryColor = Color.FromArgb(255, 108, 55); |
41 |
|
42 |
public Main() |
43 |
{ |
44 |
InitializeComponent(); |
45 |
|
46 |
//RadControlSpyForm radControlSpyForm = new RadControlSpyForm(); |
47 |
//radControlSpyForm.Show(); |
48 |
|
49 |
SpreadsheetInfo.SetLicense(Properties.Settings.Default.GemBoxLicense); |
50 |
|
51 |
this.Load += Main_Load; |
52 |
this.radButtonElementSave.Click += RadButtonElementSave_Click; |
53 |
this.radButtonElementExcelImport.Click += RadButtonElementExcelImport_Click; |
54 |
this.radButtonElementExcelExport.Click += RadButtonElementExcelExport_Click; |
55 |
|
56 |
this.radCheckBox1.CheckStateChanged += RadCheckBox_CheckStateChanged; |
57 |
this.radCheckBox2.CheckStateChanged += RadCheckBox_CheckStateChanged; |
58 |
this.radCheckBox3.CheckStateChanged += RadCheckBox_CheckStateChanged; |
59 |
this.radCheckBox4.CheckStateChanged += RadCheckBox_CheckStateChanged; |
60 |
|
61 |
this.radTextBoxDocumentNo.KeyDown += RadTextBoxDocumentNo_KeyDown; |
62 |
this.radButtonSearch.Click += RadButtonSearch_Click; |
63 |
|
64 |
this.radGridViewDocuments.ViewCellFormatting += RadGridViewDocuments_ViewCellFormatting; |
65 |
this.radGridViewDocuments.CellBeginEdit += RadGridViewDocuments_CellBeginEdit; |
66 |
this.radGridViewDocuments.CommandCellClick += RadGridViewDocuments_CommandCellClick; |
67 |
|
68 |
this.radGridViewDocuments.MasterView.TableHeaderRow.MinHeight = 36; |
69 |
this.radGridViewDocuments.TableElement.RowHeaderColumnWidth = 36; |
70 |
this.radGridViewDocuments.MasterView.TableSearchRow.IsVisible = false; |
71 |
|
72 |
var openProjectView = new OpenProjectView() |
73 |
{ |
74 |
Dock = DockStyle.Fill |
75 |
}; |
76 |
this.backstageViewPageOpenProject.Controls.Add(openProjectView); |
77 |
openProjectView.OpenProjectClick += OpenProjectView_OpenProjectClick; |
78 |
this.backstageButtonItemUserRegistration.Click += BackstageButtonItemUserRegistration_Click; |
79 |
this.backstageButtonItemExit.Click += BackstageButtonItemExit_Click; |
80 |
this.radRibbonBarBackstageViewID2Manager.BackstageViewOpened += RadRibbonBarBackstageViewID2Manager_BackstageViewOpened; |
81 |
this.radRibbonBarBackstageViewID2Manager.BackstageViewClosed += RadRibbonBarBackstageViewID2Manager_BackstageViewClosed; |
82 |
|
83 |
this.InitColumnGroupsViewDefinition(this.radGridViewDocuments); |
84 |
|
85 |
this.Initialize(); |
86 |
} |
87 |
|
88 |
#region Init, Load |
89 |
private void Initialize() |
90 |
{ |
91 |
IEnumerable<UserInfo> allUserList = new UserController().GetAllUserInfo(); |
92 |
allUserList.ToList().ForEach(x => informations.UserList.Add(x.DeepCopy(x))); |
93 |
|
94 |
this.radLabelElementUser.Text = $"{informations.ActiveUser.ID} {informations.ActiveUser.Name}"; |
95 |
|
96 |
if ((new string[] { "Manager", "User" }).Contains(informations.ActiveUser.Role) && string.IsNullOrEmpty(informations.ActiveUser.RefProjectID)) |
97 |
{ |
98 |
this.backstageViewPageOpenProject.Controls[0].Visible = true; |
99 |
this.backstageTabItemOpenProject.Visibility = ElementVisibility.Visible; |
100 |
this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Visible; |
101 |
} |
102 |
else |
103 |
{ |
104 |
foreach(Control ctrl in this.backstageViewPageOpenProject.Controls) |
105 |
{ |
106 |
ctrl.Visible = false; |
107 |
} |
108 |
this.backstageTabItemOpenProject.Visibility = ElementVisibility.Collapsed; |
109 |
this.backstageButtonItemUserRegistration.Visibility = ElementVisibility.Collapsed; |
110 |
} |
111 |
} |
112 |
|
113 |
protected override void OnLoad(EventArgs e) |
114 |
{ |
115 |
if (informations.ActiveUser != null && !string.IsNullOrEmpty(informations.ActiveUser.RefProjectID)) |
116 |
{ |
117 |
informations.ActiveProject = new ProjectController().GetProjectInfo(informations.ActiveUser.RefProjectID); |
118 |
informations.ProjectList = new ProjectController().GetAllProjectList().ToList(); |
119 |
|
120 |
this.LoadProject(); |
121 |
} |
122 |
else |
123 |
{ |
124 |
this.radRibbonBarBackstageViewID2Manager.ShowPopup(this.GetBackstageLocation(), this.ID2ManagerRadRibbonBar.RibbonBarElement); |
125 |
} |
126 |
|
127 |
base.OnLoad(e); |
128 |
} |
129 |
|
130 |
public Point GetBackstageLocation() |
131 |
{ |
132 |
Point location = this.ID2ManagerRadRibbonBar.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Location; |
133 |
location.Offset(new Point(0, this.ID2ManagerRadRibbonBar.RibbonBarElement.ApplicationButtonElement.ControlBoundingRectangle.Height)); |
134 |
location.Offset(this.ID2ManagerRadRibbonBar.Location); |
135 |
|
136 |
return location; |
137 |
} |
138 |
|
139 |
private void Main_Load(object sender, EventArgs e) |
140 |
{ |
141 |
this.radGridViewDocuments.DataSource = this.documents; |
142 |
|
143 |
InitializeSearch(); |
144 |
} |
145 |
|
146 |
private void InitializeSearch() |
147 |
{ |
148 |
lbSearch.Text = "\ue13E"; |
149 |
btnSearchNext.Text = "\ue006"; |
150 |
btnSearchPrevious.Text = "\ue004"; |
151 |
|
152 |
var chkbox = new RadCheckBoxElement(); |
153 |
chkbox.Text = "Match Case"; |
154 |
chkbox.CheckStateChanged += (snd, evt) => { radGridViewDocuments.MasterView.TableSearchRow.CaseSensitive = chkbox.Checked; }; |
155 |
|
156 |
btnMatchCase.HostedItem = chkbox; |
157 |
|
158 |
var chkbox2 = new RadCheckBoxElement(); |
159 |
chkbox2.Text = "Search from current position"; |
160 |
chkbox2.CheckStateChanged += (snd, evt) => { radGridViewDocuments.MasterView.TableSearchRow.SearchFromCurrentPosition = chkbox.Checked; }; |
161 |
|
162 |
btnSearchFormCurrent.HostedItem = chkbox2; |
163 |
|
164 |
var columns = radGridViewDocuments.Columns.Where(x=> x.AllowSearching).Select(x => |
165 |
new FilterColumn |
166 |
{ |
167 |
Name = x.HeaderText, |
168 |
FieldName = x.FieldName, |
169 |
IsSelect = x.AllowSearching |
170 |
}); |
171 |
|
172 |
var panel = new StackLayoutElement(); |
173 |
panel.Orientation = Orientation.Vertical; |
174 |
|
175 |
var btnSelect = new RadCheckBoxElement { Text = "Select All", Checked = true, AccessibleDescription = "SelectAll" }; |
176 |
|
177 |
var btnComboColumns = new RadCheckedDropDownListElement(); |
178 |
btnComboColumns.ShowCheckAllItems = true; |
179 |
btnComboColumns.CheckAllItem.Checked = true; |
180 |
|
181 |
btnComboColumns.AutoCompleteEditableAreaElement.NullText = "Search in Columns"; |
182 |
btnComboColumns.AutoCompleteEditableAreaElement.AutoCompleteTextBox.IsReadOnly = true; |
183 |
|
184 |
//btnComboColumns.AutoCompleteDisplayMember = "Name"; |
185 |
|
186 |
btnComboColumns.DropDownMinSize = new Size(200, 200); |
187 |
btnComboColumns.DropDownSizingMode = SizingMode.UpDownAndRightBottom; |
188 |
//foreach (var item in columns) |
189 |
//{ |
190 |
// item.CheckStateChanged += (snd, evt) => { radGridViewDocuments.Columns[item.AccessibleDescription].AllowSearching = item.Checked; }; |
191 |
// btnFilterColumns.Items.Add(item); |
192 |
|
193 |
//} |
194 |
btnComboColumns.DisplayMember = "Name"; |
195 |
btnComboColumns.CheckedMember = "IsSelect"; |
196 |
btnComboColumns.ValueMember = "FieldName"; |
197 |
|
198 |
var font1 = ThemeResolutionService.GetCustomFont("TelerikWebUI"); |
199 |
btnComboColumns.TextBox.CustomFont = font1.Name; |
200 |
btnComboColumns.TextBox.Text = "\ue13A"; |
201 |
|
202 |
btnComboColumns.DataSource = columns; |
203 |
|
204 |
btnComboColumns.PopupClosed += (snd, evt) => |
205 |
{ |
206 |
foreach (RadCheckedListDataItem item in btnComboColumns.Items) |
207 |
{ |
208 |
radGridViewDocuments.Columns[item.Value.ToString()].AllowSearching = item.Checked; |
209 |
} |
210 |
}; |
211 |
//panel.Children.Add(btnSelect); |
212 |
//panel.Children.Add(new SeparatorElement()); |
213 |
//panel.Children.Add(btnComboColumns); |
214 |
btnFilters.HostedItem = btnComboColumns; |
215 |
} |
216 |
|
217 |
#endregion |
218 |
|
219 |
private void OpenProjectView_OpenProjectClick(object sender, EventArgs e) |
220 |
{ |
221 |
//if (e is ProjectEventArgs) |
222 |
//{ |
223 |
// var projectGroup = (e as ProjectEventArgs).ProjectInfo; |
224 |
// var projects = (e as ProjectEventArgs).ProjectList; |
225 |
|
226 |
// if (projectGroup != null) |
227 |
// { |
228 |
// informations.ActiveProject = projectGroup; |
229 |
// } |
230 |
|
231 |
// if (projects != null) |
232 |
// { |
233 |
// informations.ProjectList = projects; |
234 |
// } |
235 |
//} |
236 |
|
237 |
this.radRibbonBarBackstageViewID2Manager.Tag = e; |
238 |
this.radRibbonBarBackstageViewID2Manager.HidePopup(); |
239 |
} |
240 |
|
241 |
private void RadRibbonBarBackstageViewID2Manager_BackstageViewOpened(object sender, EventArgs e) |
242 |
{ |
243 |
this.radRibbonBarBackstageViewID2Manager.SelectedItem = this.backstageTabItemOpenProject; |
244 |
|
245 |
foreach ( Control ctrl in this.backstageViewPageOpenProject.Controls) |
246 |
{ |
247 |
if (ctrl is OpenProjectView) |
248 |
{ |
249 |
var openProjectView = ctrl as OpenProjectView; |
250 |
openProjectView.GetProjectGroups(); |
251 |
break; |
252 |
} |
253 |
} |
254 |
} |
255 |
|
256 |
private void RadRibbonBarBackstageViewID2Manager_BackstageViewClosed(object sender, EventArgs e) |
257 |
{ |
258 |
if (this.radRibbonBarBackstageViewID2Manager.Tag is ProjectEventArgs) |
259 |
{ |
260 |
var prjArgs = this.radRibbonBarBackstageViewID2Manager.Tag as ProjectEventArgs; |
261 |
|
262 |
informations.ActiveProject = prjArgs.ProjectInfo; |
263 |
informations.ProjectList = prjArgs.ProjectList; |
264 |
|
265 |
this.radRibbonBarBackstageViewID2Manager.Tag = null; |
266 |
|
267 |
this.LoadProject(); |
268 |
} |
269 |
} |
270 |
|
271 |
private void LoadProject() |
272 |
{ |
273 |
#region 도면 |
274 |
//Project List |
275 |
if (this.radDropDownListProject.Items.Count > 0) |
276 |
this.radDropDownListProject.Items.Clear(); |
277 |
informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList() |
278 |
.ForEach(x => |
279 |
{ |
280 |
this.radDropDownListProject.Items.Add(new RadListDataItem(x.Name, x.ProjectID)); |
281 |
}); |
282 |
var allProject = new RadListDataItem("== 전체 ==", string.Empty); |
283 |
this.radDropDownListProject.Items.Insert(0, allProject); |
284 |
allProject.Selected = true; |
285 |
|
286 |
//담당자 List |
287 |
if (this.radDropDownListPersonInCharge.Items.Count > 0) |
288 |
this.radDropDownListPersonInCharge.Items.Clear(); |
289 |
informations.UserList.ForEach(x => |
290 |
{ |
291 |
if ((new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID)) |
292 |
this.radDropDownListPersonInCharge.Items.Add(new RadListDataItem(x.Name, x.ID)); |
293 |
}); |
294 |
var allUser = new RadListDataItem("== 전체 ==", string.Empty); |
295 |
this.radDropDownListPersonInCharge.Items.Insert(0, allUser); |
296 |
allUser.Selected = true; |
297 |
|
298 |
//난이도 |
299 |
if (this.radDropDownListJobLevel.Items.Count > 0) |
300 |
this.radDropDownListJobLevel.Items.Clear(); |
301 |
informations.JobLevel.ForEach(x => |
302 |
{ |
303 |
this.radDropDownListJobLevel.Items.Add(new RadListDataItem(x, x)); |
304 |
}); |
305 |
var allJobLevel = new RadListDataItem("== 전체 ==", string.Empty); |
306 |
this.radDropDownListJobLevel.Items.Insert(0, allJobLevel); |
307 |
allJobLevel.Selected = true; |
308 |
|
309 |
//도면번호 조회조건 |
310 |
this.radTextBoxDocumentNo.Text = string.Empty; |
311 |
#endregion |
312 |
|
313 |
#region 검토 |
314 |
//ID2 작업가능 |
315 |
if (this.radDropDownListIsID2Work.Items.Count > 0) |
316 |
this.radDropDownListIsID2Work.Items.Clear(); |
317 |
informations.IsYesNo.ForEach(x => |
318 |
{ |
319 |
this.radDropDownListIsID2Work.Items.Add(new RadListDataItem(x, x)); |
320 |
}); |
321 |
var allIsID2Work = new RadListDataItem("== 전체 ==", string.Empty); |
322 |
this.radDropDownListIsID2Work.Items.Insert(0, allIsID2Work); |
323 |
allIsID2Work.Selected = true; |
324 |
#endregion |
325 |
|
326 |
#region 작업 |
327 |
//ID2 Status |
328 |
if (this.radDropDownListID2Status.Items.Count > 0) |
329 |
this.radDropDownListID2Status.Items.Clear(); |
330 |
informations.JobStatus.ForEach(x => |
331 |
{ |
332 |
this.radDropDownListID2Status.Items.Add(new RadListDataItem(x, x)); |
333 |
}); |
334 |
var allID2Status = new RadListDataItem("== 전체 ==", string.Empty); |
335 |
this.radDropDownListID2Status.Items.Insert(0, allID2Status); |
336 |
allID2Status.Selected = true; |
337 |
|
338 |
//AVEVA Status |
339 |
if (this.radDropDownListAVEVAStatus.Items.Count > 0) |
340 |
this.radDropDownListAVEVAStatus.Items.Clear(); |
341 |
informations.JobStatus.ForEach(x => |
342 |
{ |
343 |
this.radDropDownListAVEVAStatus.Items.Add(new RadListDataItem(x, x)); |
344 |
}); |
345 |
var allAVEVAStatus = new RadListDataItem("== 전체 ==", string.Empty); |
346 |
this.radDropDownListAVEVAStatus.Items.Insert(0, allAVEVAStatus); |
347 |
allAVEVAStatus.Selected = true; |
348 |
#endregion |
349 |
|
350 |
#region 확인 |
351 |
//도프텍 결과 |
352 |
if (this.radDropDownListProdIsResult.Items.Count > 0) |
353 |
this.radDropDownListProdIsResult.Items.Clear(); |
354 |
informations.ValidationResult.ForEach(x => |
355 |
{ |
356 |
this.radDropDownListProdIsResult.Items.Add(new RadListDataItem(x, x)); |
357 |
}); |
358 |
var allProdIsResult = new RadListDataItem("== 전체 ==", string.Empty); |
359 |
this.radDropDownListProdIsResult.Items.Insert(0, allProdIsResult); |
360 |
allProdIsResult.Selected = true; |
361 |
|
362 |
//삼성 결과 |
363 |
if (this.radDropDownListClientIsResult.Items.Count > 0) |
364 |
this.radDropDownListClientIsResult.Items.Clear(); |
365 |
informations.ValidationResult.ForEach(x => |
366 |
{ |
367 |
this.radDropDownListClientIsResult.Items.Add(new RadListDataItem(x, x)); |
368 |
}); |
369 |
var allClientIsResult = new RadListDataItem("== 전체 ==", string.Empty); |
370 |
this.radDropDownListClientIsResult.Items.Insert(0, allClientIsResult); |
371 |
allClientIsResult.Selected = true; |
372 |
#endregion |
373 |
|
374 |
this.GetDocList(); |
375 |
this.DocumentListBinding(); |
376 |
} |
377 |
|
378 |
#region Document List 조회 |
379 |
public void GetDocList() |
380 |
{ |
381 |
if (this.radDropDownListProject.SelectedValue != null) |
382 |
{ |
383 |
string projectId = this.radDropDownListProject.SelectedValue.ToString(); |
384 |
string personIncharge = this.radDropDownListPersonInCharge.SelectedValue.ToString(); |
385 |
string jobLevel = this.radDropDownListJobLevel.SelectedValue.ToString();// |
386 |
string documentNo = this.radTextBoxDocumentNo.Text.Trim(); |
387 |
|
388 |
string isID2Work = this.radDropDownListIsID2Work.SelectedValue.ToString();// |
389 |
|
390 |
string id2Status = this.radDropDownListID2Status.SelectedValue.ToString();// |
391 |
string avevaStatus = this.radDropDownListAVEVAStatus.SelectedValue.ToString();// |
392 |
|
393 |
string prodIsResult = this.radDropDownListProdIsResult.SelectedValue.ToString();// |
394 |
string clientIsResult = this.radDropDownListClientIsResult.SelectedValue.ToString();// |
395 |
|
396 |
this.documents = new DocumentController().GetAllDocuments(projectId, personIncharge, jobLevel, documentNo, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult).ToList(); |
397 |
this.orgDocuments = JsonConvert.DeserializeObject<List<Documents>>(JsonConvert.SerializeObject(this.documents)); |
398 |
} |
399 |
} |
400 |
|
401 |
public void DocumentListBinding() |
402 |
{ |
403 |
GridViewComboBoxColumn ColProjects = this.radGridViewDocuments.Columns["RefProjectID"] as GridViewComboBoxColumn; |
404 |
ColProjects.DataSource = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList(); |
405 |
ColProjects.DisplayMember = "Name"; |
406 |
ColProjects.ValueMember = "ProjectID"; |
407 |
|
408 |
var workUsers = informations.UserList.Where(x => (new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID)); |
409 |
var clientUsers = informations.UserList.Where(x => !string.IsNullOrEmpty(x.RefProjectID)); |
410 |
|
411 |
GridViewComboBoxColumn ColPersonInCharge = this.radGridViewDocuments.Columns["PersonInCharge"] as GridViewComboBoxColumn; |
412 |
ColPersonInCharge.DataSource = workUsers; |
413 |
ColPersonInCharge.DisplayMember = "Name"; |
414 |
ColPersonInCharge.ValueMember = "ID"; |
415 |
|
416 |
GridViewComboBoxColumn ColToModifier = this.radGridViewDocuments.Columns["ToModifier"] as GridViewComboBoxColumn; |
417 |
ColToModifier.DataSource = workUsers; |
418 |
ColToModifier.DisplayMember = "Name"; |
419 |
ColToModifier.ValueMember = "ID"; |
420 |
|
421 |
GridViewComboBoxColumn ColFrModifier = this.radGridViewDocuments.Columns["FrModifier"] as GridViewComboBoxColumn; |
422 |
ColFrModifier.DataSource = clientUsers; |
423 |
ColFrModifier.DisplayMember = "Name"; |
424 |
ColFrModifier.ValueMember = "ID"; |
425 |
|
426 |
GridViewComboBoxColumn ColProdReviewer = this.radGridViewDocuments.Columns["ProdReviewer"] as GridViewComboBoxColumn; |
427 |
ColProdReviewer.DataSource = workUsers; |
428 |
ColProdReviewer.DisplayMember = "Name"; |
429 |
ColProdReviewer.ValueMember = "ID"; |
430 |
|
431 |
GridViewComboBoxColumn ColClientReviewer = this.radGridViewDocuments.Columns["ClientReviewer"] as GridViewComboBoxColumn; |
432 |
ColClientReviewer.DataSource = clientUsers; |
433 |
ColClientReviewer.DisplayMember = "Name"; |
434 |
ColClientReviewer.ValueMember = "ID"; |
435 |
|
436 |
//Data |
437 |
if (this.radGridViewDocuments.DataSource != null) |
438 |
this.radGridViewDocuments.DataSource = null; |
439 |
this.radGridViewDocuments.DataSource = this.documents; |
440 |
|
441 |
if (this.radGridViewDocuments.SummaryRowsBottom != null) |
442 |
this.radGridViewDocuments.SummaryRowsBottom.Clear(); |
443 |
|
444 |
string totalCount = String.Format("{0:#,###}", this.documents.Count()); |
445 |
|
446 |
//Summary |
447 |
GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem() |
448 |
{ |
449 |
new GridViewSummaryItem("DocumentNo", "{0:#,###} / " + totalCount, GridAggregateFunction.Count) |
450 |
}; |
451 |
this.radGridViewDocuments.SummaryRowsBottom.Add(summaryRowItem); |
452 |
this.radGridViewDocuments.MasterView.SummaryRows[0].PinPosition = PinnedRowPosition.Bottom; |
453 |
this.radGridViewDocuments.MasterTemplate.BottomPinnedRowsMode = GridViewBottomPinnedRowsMode.Fixed; |
454 |
} |
455 |
#endregion |
456 |
|
457 |
#region Button, Checkbox event |
458 |
private void RadCheckBox_CheckStateChanged(object sender, EventArgs e) |
459 |
{ |
460 |
if (sender is RadCheckBox) |
461 |
{ |
462 |
RadCheckBox checkBox = sender as RadCheckBox; |
463 |
|
464 |
if (checkBox.Tag != null) |
465 |
{ |
466 |
ColumnGroupsViewDefinition columnGroupsView = this.radGridViewDocuments.MasterTemplate.ViewDefinition as ColumnGroupsViewDefinition; |
467 |
GridViewColumnGroup colGroup = columnGroupsView.GetAllGroups().Where(x => x.Name.Equals(checkBox.Tag.ToString())).FirstOrDefault(); |
468 |
if (colGroup != null) |
469 |
colGroup.IsVisible = checkBox.Checked; |
470 |
} |
471 |
} |
472 |
|
473 |
//ColumnGroupsViewDefinition columnGroupsView = this.radGridViewDocuments.MasterTemplate.ViewDefinition = columnGroupsView; |
474 |
} |
475 |
|
476 |
private void RadTextBoxDocumentNo_KeyDown(object sender, KeyEventArgs e) |
477 |
{ |
478 |
if (e.KeyCode == Keys.Enter) |
479 |
{ |
480 |
this.radButtonSearch.Focus(); |
481 |
this.radButtonSearch.PerformClick(); |
482 |
} |
483 |
} |
484 |
|
485 |
private void RadButtonSearch_Click(object sender, EventArgs e) |
486 |
{ |
487 |
this.GetDocList(); |
488 |
this.DocumentListBinding(); |
489 |
} |
490 |
|
491 |
private void BackstageButtonItemUserRegistration_Click(object sender, EventArgs e) |
492 |
{ |
493 |
using (var frm = new SetupUser()) |
494 |
{ |
495 |
if (frm.ShowDialog(this) == DialogResult.OK) |
496 |
{ |
497 |
|
498 |
} |
499 |
} |
500 |
} |
501 |
|
502 |
private void BackstageButtonItemExit_Click(object sender, EventArgs e) |
503 |
{ |
504 |
Application.Exit(); |
505 |
} |
506 |
#endregion |
507 |
|
508 |
#region Grid event |
509 |
private void RadGridViewDocuments_CommandCellClick(object sender, GridViewCellEventArgs e) |
510 |
{ |
511 |
if (e.Row is GridViewNewRowInfo) |
512 |
{ |
513 |
|
514 |
} |
515 |
else |
516 |
{ |
517 |
switch (e.Column.Name) |
518 |
{ |
519 |
case "AutoCADLink": |
520 |
{ |
521 |
Controls.AutoCADViewer viewer = null; |
522 |
foreach (var control in this.tableLayoutPanelRight.Controls) |
523 |
{ |
524 |
if (control is Controls.AutoCADViewer _viewer) |
525 |
{ |
526 |
viewer = _viewer; |
527 |
break; |
528 |
} |
529 |
} |
530 |
|
531 |
if (viewer == null) |
532 |
{ |
533 |
viewer = new Controls.AutoCADViewer() { Dock = DockStyle.Fill }; |
534 |
this.tableLayoutPanelRight.Controls.Add(viewer); |
535 |
} |
536 |
else |
537 |
{ |
538 |
viewer.Visible = true; |
539 |
} |
540 |
|
541 |
if (e.Row.DataBoundItem is Documents doc) |
542 |
{ |
543 |
if (File.Exists(doc.DocFilePath) && viewer != null) viewer.ReadDWG(doc.DocFilePath); |
544 |
} |
545 |
} |
546 |
break; |
547 |
case "PDFLink": |
548 |
MessageBox.Show($"{e.Column.Name} 실행"); |
549 |
break; |
550 |
case "MarkupLink": |
551 |
{ |
552 |
if (e.Row.DataBoundItem is Documents doc) |
553 |
{ |
554 |
if (!string.IsNullOrWhiteSpace(this.GetProject(doc.RefProjectID).Code) && !string.IsNullOrWhiteSpace(doc.DocumentNo) && !string.IsNullOrWhiteSpace(doc.PersonInCharge)) |
555 |
{ |
556 |
bool result = MarkusHelper.Start(this.GetProject(doc.RefProjectID).Code, doc.DocumentNo, doc.PersonInCharge); |
557 |
} |
558 |
} |
559 |
} |
560 |
break; |
561 |
case "AVEVALink": |
562 |
case "AVEVAConnection": |
563 |
MessageBox.Show($"{e.Column.Name} 실행"); |
564 |
break; |
565 |
case "ReviewFileName"://일단주석 |
566 |
MessageBox.Show($"{e.Column.Name} 실행"); |
567 |
break; |
568 |
case "SystemLink": |
569 |
MessageBox.Show($"{e.Column.Name} 실행"); |
570 |
break; |
571 |
case "ToCapturePath": |
572 |
case "FrCapturePath": |
573 |
|
574 |
if (e.Row.DataBoundItem is Documents dd) |
575 |
{ |
576 |
using (var frm = new ImageView(dd.DocID)) |
577 |
{ |
578 |
frm.ShowDialog(this); |
579 |
} |
580 |
} |
581 |
break; |
582 |
case "ID2Connection": |
583 |
try |
584 |
{ |
585 |
if (e.Row.DataBoundItem is Documents doc) |
586 |
{ |
587 |
ID2Helper.OpenPID(doc.DocumentNo, string.Empty, Properties.Settings.Default.ID2Port); |
588 |
} |
589 |
} |
590 |
catch (Exception ex) |
591 |
{ |
592 |
RadMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, RadMessageIcon.Error); |
593 |
} |
594 |
break; |
595 |
} |
596 |
} |
597 |
} |
598 |
|
599 |
private void RadGridViewDocuments_CellBeginEdit(object sender, GridViewCellCancelEventArgs e) |
600 |
{ |
601 |
if (e.ActiveEditor is RadDropDownListEditor) |
602 |
{ |
603 |
switch (e.Column.Name) |
604 |
{ |
605 |
case "JobLevel": |
606 |
GridViewComboBoxColumn ColJobLevel = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn; |
607 |
ColJobLevel.DataSource = informations.JobLevel; |
608 |
break; |
609 |
case "IsTypical": |
610 |
case "ToIsDiscussion": |
611 |
case "ToIsMarkup": |
612 |
case "FrIsMarkup": |
613 |
case "IsID2Work": |
614 |
case "DTIsGateWay": |
615 |
case "DTIsImport": |
616 |
case "DTIsRegSystem": |
617 |
GridViewComboBoxColumn ColYesNo = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn; |
618 |
ColYesNo.DataSource = (new string[] { string.Empty }).Union<string>(informations.IsYesNo); |
619 |
break; |
620 |
case "ID2Status": |
621 |
case "AVEVAStatus": |
622 |
GridViewComboBoxColumn ColJobStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn; |
623 |
ColJobStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.JobStatus); |
624 |
break; |
625 |
case "FrReviewStatus"://삼성의견status |
626 |
GridViewComboBoxColumn ColClientStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn; |
627 |
ColClientStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.ClientStatus); |
628 |
break; |
629 |
case "ProdIsResult": |
630 |
case "ClientIsResult": |
631 |
GridViewComboBoxColumn ColResult = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn; |
632 |
ColResult.DataSource = (new string[] { string.Empty }).Union<string>(informations.ValidationResult); |
633 |
break; |
634 |
} |
635 |
} |
636 |
} |
637 |
|
638 |
private void RadGridViewDocuments_ViewCellFormatting(object sender, CellFormattingEventArgs e) |
639 |
{ |
640 |
if (e.Row is GridViewDataRowInfo) |
641 |
{ |
642 |
if (e.CellElement is GridRowHeaderCellElement) |
643 |
{ |
644 |
if (e.CellElement.RowIndex > -1) |
645 |
e.CellElement.Text = (e.CellElement.RowIndex + 1).ToString(); |
646 |
} |
647 |
else |
648 |
{ |
649 |
var result = e.Row.DataBoundItem as Documents; |
650 |
if (result != null || e.Row is GridViewNewRowInfo) |
651 |
{ |
652 |
switch (e.CellElement.ColumnInfo.Name) |
653 |
{ |
654 |
case "AutoCADLink": |
655 |
case "PDFLink": |
656 |
case "MarkupLink": |
657 |
case "AVEVALink": |
658 |
case "AVEVAConnection": |
659 |
case "ReviewFileName"://일단주석 |
660 |
case "SystemLink": |
661 |
case "ToCapturePath": |
662 |
case "FrCapturePath": |
663 |
case "ID2Connection": |
664 |
this.GetCommandColBtnElement(e.CellElement.Children[0], e.CellElement.ColumnInfo.Name); |
665 |
break; |
666 |
} |
667 |
} |
668 |
else |
669 |
{ |
670 |
|
671 |
} |
672 |
} |
673 |
} |
674 |
else if (e.Row is GridViewSummaryRowInfo) |
675 |
{ |
676 |
if (e.CellElement is GridRowHeaderCellElement) |
677 |
{ |
678 |
e.CellElement.Text = "Count"; |
679 |
} |
680 |
else if (e.CellElement is GridSummaryCellElement) |
681 |
{ |
682 |
e.CellElement.ForeColor = this._SummaryColor; |
683 |
e.CellElement.TextAlignment = ContentAlignment.BottomRight; |
684 |
e.CellElement.Font = new Font(e.CellElement.Font, FontStyle.Bold); |
685 |
} |
686 |
else |
687 |
{ |
688 |
|
689 |
} |
690 |
} |
691 |
else |
692 |
{ |
693 |
|
694 |
} |
695 |
} |
696 |
|
697 |
private RadButtonElement GetCommandColBtnElement(RadElement elem, string colName) |
698 |
{ |
699 |
RadButtonElement btnElem = null; |
700 |
Bitmap bitmap = null; ; |
701 |
|
702 |
switch (colName) |
703 |
{ |
704 |
case "AutoCADLink": |
705 |
bitmap = new Bitmap(Properties.Resources.cad18); |
706 |
break; |
707 |
case "PDFLink": |
708 |
bitmap = new Bitmap(Properties.Resources.pdf18); |
709 |
break; |
710 |
case "MarkupLink": |
711 |
bitmap = new Bitmap(Properties.Resources.markus18); |
712 |
break; |
713 |
case "AVEVALink": |
714 |
case "AVEVAConnection": |
715 |
bitmap = new Bitmap(Properties.Resources.aveva_net18); |
716 |
break; |
717 |
case "ReviewFileName"://일단주석 |
718 |
bitmap = new Bitmap(Properties.Resources.pdf18); |
719 |
break; |
720 |
case "SystemLink": |
721 |
bitmap = new Bitmap(Properties.Resources.link18_yellow); |
722 |
break; |
723 |
case "ToCapturePath": |
724 |
case "FrCapturePath": |
725 |
bitmap = new Bitmap(Properties.Resources.files18); |
726 |
break; |
727 |
case "ID2Connection": |
728 |
bitmap = new Bitmap(Properties.Resources.id218); |
729 |
break; |
730 |
} |
731 |
|
732 |
switch (colName) |
733 |
{ |
734 |
case "AutoCADLink": |
735 |
case "PDFLink": |
736 |
case "MarkupLink": |
737 |
case "AVEVALink": |
738 |
case "AVEVAConnection": |
739 |
case "ReviewFileName"://일단주석 |
740 |
case "SystemLink": |
741 |
case "ToCapturePath": |
742 |
case "FrCapturePath": |
743 |
case "ID2Connection": |
744 |
btnElem = (RadButtonElement)elem; |
745 |
btnElem.Margin = new Padding(0); |
746 |
btnElem.Padding = new Padding(0); |
747 |
btnElem.BorderElement.Opacity = 0; |
748 |
btnElem.Alignment = ContentAlignment.MiddleCenter; |
749 |
btnElem.DisplayStyle = DisplayStyle.Image; |
750 |
btnElem.Image = bitmap; |
751 |
btnElem.ImageAlignment = ContentAlignment.MiddleCenter; |
752 |
btnElem.MaxSize = bitmap.Size; |
753 |
break; |
754 |
} |
755 |
|
756 |
return btnElem; |
757 |
} |
758 |
#endregion |
759 |
|
760 |
#region Excel |
761 |
private UserInfo GetUser(string user) |
762 |
{ |
763 |
UserInfo userInfo = informations.UserList.Where(x => x.ID.Equals(user)).FirstOrDefault(); |
764 |
if (userInfo != null) return userInfo; |
765 |
|
766 |
userInfo = informations.UserList.Where(x => x.Name.Equals(user)).FirstOrDefault(); |
767 |
if (userInfo != null) return userInfo; |
768 |
|
769 |
return userInfo ?? new UserInfo(); |
770 |
} |
771 |
|
772 |
private ProjectInfo GetProject(string project) |
773 |
{ |
774 |
ProjectInfo prjInfo = informations.ProjectList.Where(x => x.ProjectID.Equals(project)).FirstOrDefault(); |
775 |
if (prjInfo != null) return prjInfo; |
776 |
|
777 |
prjInfo = informations.ProjectList.FirstOrDefault(x => x.Name.Equals(project)); |
778 |
if (prjInfo != null) return prjInfo; |
779 |
|
780 |
return prjInfo ?? new ProjectInfo(); |
781 |
} |
782 |
|
783 |
private void RadButtonElementExcelImport_Click(object sender, EventArgs e) |
784 |
{ |
785 |
using (OpenFileDialog ofd = new OpenFileDialog() |
786 |
{ |
787 |
Filter = "Excel files (*.xlsx)|*.xlsx", |
788 |
Title = "Open an Excel File", |
789 |
RestoreDirectory = true |
790 |
}) |
791 |
{ |
792 |
if (ofd.ShowDialog() == DialogResult.OK) |
793 |
{ |
794 |
//Error Message |
795 |
StringBuilder sbErrMsg = new StringBuilder(); |
796 |
|
797 |
var exFile = ExcelFile.Load(ofd.FileName); |
798 |
var ws = exFile.Worksheets[0]; |
799 |
|
800 |
int rowCount = ws.Rows.Count; |
801 |
int columnCount = ws.CalculateMaxUsedColumns(); |
802 |
int exRow = 8; |
803 |
|
804 |
#region Excel 유효성검사 |
805 |
|
806 |
//Excel 포멧체크 |
807 |
if (rowCount <= 10 || columnCount != 45) |
808 |
{ |
809 |
RadMessageBox.Show("Please, check the excel.\n", "Information", MessageBoxButtons.OK, RadMessageIcon.Info); |
810 |
return; |
811 |
} |
812 |
|
813 |
#region 엑셀 필수값 체크(도면 : 이름,담당자, 난이도, Typical) |
814 |
ws.Rows.SelectMany(row => row.AllocatedCells) |
815 |
.Where(col => col.Column.Index > 5 && col.Column.Index < 10 && col.Row.Index > exRow && col.Value == null) |
816 |
.ToList() |
817 |
.ForEach(p => sbErrMsg.Append(", " + p.Column.Name + p.Row.Name)); |
818 |
|
819 |
if (sbErrMsg.Length > 0) |
820 |
{ |
821 |
string errMsg = sbErrMsg.ToString().Substring(2); |
822 |
if (errMsg.Length > 100) |
823 |
{ |
824 |
errMsg = $"{errMsg.Substring(0, 100)}..."; |
825 |
} |
826 |
|
827 |
RadMessageBox.Show($"Please, check null value in excel.\n{errMsg}", "Information", MessageBoxButtons.OK, RadMessageIcon.Info); |
828 |
return; |
829 |
} |
830 |
#endregion |
831 |
|
832 |
#region 엑셀 도명명 중복 값 체크 |
833 |
ws.Rows.SelectMany(row => row.AllocatedCells) |
834 |
.Where(col => col.Column.Index == 6 && col.Row.Index > exRow) |
835 |
.GroupBy(g => g.Row.Index) |
836 |
.Select(p => new { |
837 |
rowIndex = p.Key, |
838 |
docNo = p.Select(x => x.Value.ToString()).FirstOrDefault() |
839 |
}) |
840 |
.GroupBy(g => g.docNo) |
841 |
.Where(p => p.Count() > 1) |
842 |
.Select(p => p.Select(x => (x.rowIndex + 1).ToString()) |
843 |
.Aggregate((x, y) => x.ToString() + "," + y.ToString()) |
844 |
.ToString()) |
845 |
.ToList().ForEach(p => sbErrMsg.Append("\n" + p.ToString())); |
846 |
if (sbErrMsg.Length > 0) |
847 |
{ |
848 |
sbErrMsg.Insert(0, "\n중복 된 도면명 Excel row : "); |
849 |
string errMsg = sbErrMsg.ToString(); |
850 |
if (errMsg.Length > 100) |
851 |
{ |
852 |
errMsg = $"{errMsg.Substring(0, 100)}..."; |
853 |
} |
854 |
|
855 |
RadMessageBox.Show($"Please, check the duplicate value in excel.\n{errMsg}", "Information", MessageBoxButtons.OK, RadMessageIcon.Info); |
856 |
return; |
857 |
} |
858 |
#endregion |
859 |
|
860 |
#endregion |
861 |
|
862 |
List<Documents> appendDocuments = new List<Documents>(); |
863 |
|
864 |
ws.Rows.Where(row => row.Index > exRow) |
865 |
.ToList() |
866 |
.ForEach(p => appendDocuments.Add(new Documents() |
867 |
{ |
868 |
//UID = string.Empty, |
869 |
//Type = this.radTextBoxInsulationType.Text, |
870 |
//TempFrom = ws.Rows[exRow].Cells[p.Column.Index].Value == null ? 0 : Convert.ToSingle(ws.Rows[exRow].Cells[p.Column.Index].Value), |
871 |
//TempTo = ws.Rows[exRow + 2].Cells[p.Column.Index].Value == null ? 0 : Convert.ToSingle(ws.Rows[exRow + 2].Cells[p.Column.Index].Value), |
872 |
//NPS = ws.Rows[p.Row.Index].Cells[0].Value == null ? 0 : Convert.ToSingle(ws.Rows[p.Row.Index].Cells[0].Value), |
873 |
//Thickness = p.Value == null ? 0 : Convert.ToSingle(p.Value) |
874 |
|
875 |
RefProjectID = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : this.GetProject(ws.Rows[p.Index].Cells[5].Value.ToString()).Name, |
876 |
//Place = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
877 |
DocumentNo = ws.Rows[p.Index].Cells[6].Value == null ? string.Empty : ws.Rows[p.Index].Cells[6].Value.ToString(), |
878 |
PersonInCharge = ws.Rows[p.Index].Cells[7].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[7].Value.ToString()).ID, |
879 |
JobLevel = ws.Rows[p.Index].Cells[8].Value == null ? string.Empty : ws.Rows[p.Index].Cells[8].Value.ToString(), |
880 |
IsTypical = ws.Rows[p.Index].Cells[9].Value == null ? string.Empty : ws.Rows[p.Index].Cells[9].Value.ToString(), |
881 |
RevisonNo = ws.Rows[p.Index].Cells[10].Value == null ? string.Empty : ws.Rows[p.Index].Cells[10].Value.ToString(), |
882 |
ToIsDiscussion = ws.Rows[p.Index].Cells[11].Value == null ? string.Empty : ws.Rows[p.Index].Cells[11].Value.ToString(), |
883 |
ToRemarks = ws.Rows[p.Index].Cells[12].Value == null ? string.Empty : ws.Rows[p.Index].Cells[12].Value.ToString(), |
884 |
ToCreator = ws.Rows[p.Index].Cells[13].Value == null ? string.Empty : ws.Rows[p.Index].Cells[13].Value.ToString(), |
885 |
//ToCapturePath = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
886 |
//ToIsMarkup = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
887 |
FrReviewStatus = ws.Rows[p.Index].Cells[16].Value == null ? string.Empty : ws.Rows[p.Index].Cells[16].Value.ToString(), |
888 |
FrRemarks = ws.Rows[p.Index].Cells[17].Value == null ? string.Empty : ws.Rows[p.Index].Cells[17].Value.ToString(), |
889 |
FrCreator = ws.Rows[p.Index].Cells[18].Value == null ? string.Empty : ws.Rows[p.Index].Cells[18].Value.ToString(), |
890 |
//FrCapturePath = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
891 |
//FrIsMarkup = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
892 |
IsID2Work = ws.Rows[p.Index].Cells[21].Value == null ? string.Empty : ws.Rows[p.Index].Cells[21].Value.ToString(), |
893 |
//ID2Connection = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
894 |
//ID2StartDate = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
895 |
//ID2EndDate = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
896 |
//ID2JobTime = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
897 |
ID2Status = ws.Rows[p.Index].Cells[26].Value == null ? string.Empty : ws.Rows[p.Index].Cells[26].Value.ToString(), |
898 |
ID2Issues = ws.Rows[p.Index].Cells[27].Value == null ? string.Empty : ws.Rows[p.Index].Cells[27].Value.ToString(), |
899 |
//AVEVAConnection = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
900 |
//AVEVAConvertDate = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
901 |
//AVEVAReviewDate = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(), |
902 |
AVEVAStatus = ws.Rows[p.Index].Cells[31].Value == null ? string.Empty : ws.Rows[p.Index].Cells[31].Value.ToString(), |
903 |
AVEVAIssues = ws.Rows[p.Index].Cells[32].Value == null ? string.Empty : ws.Rows[p.Index].Cells[32].Value.ToString(), |
904 |
ProdReviewer = ws.Rows[p.Index].Cells[35].Value == null ? string.Empty : ws.Rows[p.Index].Cells[35].Value.ToString(), |
905 |
ProdIsResult = ws.Rows[p.Index].Cells[36].Value == null ? string.Empty : ws.Rows[p.Index].Cells[36].Value.ToString(), |
906 |
ProdRemarks = ws.Rows[p.Index].Cells[37].Value == null ? string.Empty : ws.Rows[p.Index].Cells[37].Value.ToString(), |
907 |
ClientReviewer = ws.Rows[p.Index].Cells[38].Value == null ? string.Empty : ws.Rows[p.Index].Cells[38].Value.ToString(), |
908 |
ClientIsResult = ws.Rows[p.Index].Cells[39].Value == null ? string.Empty : ws.Rows[p.Index].Cells[39].Value.ToString(), |
909 |
ClientRemarks = ws.Rows[p.Index].Cells[40].Value == null ? string.Empty : ws.Rows[p.Index].Cells[40].Value.ToString(), |
910 |
DTIsGateWay = ws.Rows[p.Index].Cells[41].Value == null ? string.Empty : ws.Rows[p.Index].Cells[41].Value.ToString(), |
911 |
DTIsImport = ws.Rows[p.Index].Cells[42].Value == null ? string.Empty : ws.Rows[p.Index].Cells[42].Value.ToString(), |
912 |
DTIsRegSystem = ws.Rows[p.Index].Cells[43].Value == null ? string.Empty : ws.Rows[p.Index].Cells[43].Value.ToString(), |
913 |
DTRemarks = ws.Rows[p.Index].Cells[44].Value == null ? string.Empty : ws.Rows[p.Index].Cells[44].Value.ToString() |
914 |
})); |
915 |
|
916 |
this.documents.AddRange(appendDocuments); |
917 |
if (this.orgDocuments == null) this.orgDocuments = new List<Documents>(); |
918 |
this.DocumentListBinding(); |
919 |
|
920 |
//foreach (Documents appDoc in appendDocuments) |
921 |
//{ |
922 |
// GridViewRowInfo rowInfo = this.radGridViewDocuments.Rows.AddNew(); |
923 |
|
924 |
// foreach (FieldInfo fieldInfo in appDoc.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly)) |
925 |
// { |
926 |
// if (fieldInfo.GetValue(appDoc) != null) |
927 |
// { |
928 |
// var cols = rowInfo.Cells.Where(x => fieldInfo.Name.Contains($"<{x.ColumnInfo.Name}>")); |
929 |
|
930 |
// if (cols.Any()) |
931 |
// { |
932 |
// cols.FirstOrDefault().Value = fieldInfo.GetValue(appDoc); |
933 |
// } |
934 |
// } |
935 |
// } |
936 |
//} |
937 |
} |
938 |
} |
939 |
} |
940 |
|
941 |
private void RadButtonElementExcelExport_Click(object sender, EventArgs e) |
942 |
{ |
943 |
string sPrefixName = "Samsung Elec Task Management"; |
944 |
string extension = ".xlsx"; |
945 |
|
946 |
using (SaveFileDialog sfd = new SaveFileDialog() |
947 |
{ |
948 |
FileName = $"{sPrefixName}_{DateTime.Now:yyyyMMddhhmmss}{extension}", |
949 |
Filter = "Excel|*.xlsx", |
950 |
Title = "Save an Excel File", |
951 |
CheckFileExists = false, |
952 |
CheckPathExists = true, |
953 |
OverwritePrompt = true |
954 |
}) |
955 |
{ |
956 |
if (sfd.ShowDialog() == DialogResult.OK) |
957 |
{ |
958 |
string fileName = $"{sPrefixName}{extension}"; |
959 |
string templateFolder = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Template"); |
960 |
string templateFilePath = Path.Combine(templateFolder, fileName); |
961 |
if (!File.Exists(templateFilePath)) |
962 |
{ |
963 |
RadMessageBox.Show(this, $"There is no {fileName} in {templateFolder}", "Error", MessageBoxButtons.OK, RadMessageIcon.Error); |
964 |
return; |
965 |
} |
966 |
|
967 |
if (this.radGridViewDocuments.Rows.Count > 0) |
968 |
{ |
969 |
var templateExcelFile = ExcelFile.Load(templateFilePath); |
970 |
var templateWorksheets = templateExcelFile.Worksheets; |
971 |
var templateWorksheet = templateWorksheets[0]; |
972 |
|
973 |
int rowIndex = 9; |
974 |
//int colIndex = 1; |
975 |
|
976 |
foreach (var row in this.radGridViewDocuments.Rows) |
977 |
{ |
978 |
var doc = row.DataBoundItem as Documents; |
979 |
|
980 |
templateWorksheet.Cells[rowIndex, 0].Value = doc.Seq; |
981 |
//templateWorksheet.Cells[rowIndex, 1].Value = doc.DocumentNo; |
982 |
//templateWorksheet.Cells[rowIndex, 2].Value = doc.DocumentNo; |
983 |
//templateWorksheet.Cells[rowIndex, 3].Value = doc.DocumentNo; |
984 |
//templateWorksheet.Cells[rowIndex, 4].Value = doc.DocumentNo; |
985 |
//templateWorksheet.Cells[rowIndex, 5].Value = doc.Place; |
986 |
templateWorksheet.Cells[rowIndex, 5].Value = this.GetProject(doc.RefProjectID).Name; |
987 |
templateWorksheet.Cells[rowIndex, 6].Value = doc.DocumentNo; |
988 |
templateWorksheet.Cells[rowIndex, 7].Value = this.GetUser(doc.PersonInCharge).ID; |
989 |
templateWorksheet.Cells[rowIndex, 8].Value = doc.JobLevel; |
990 |
templateWorksheet.Cells[rowIndex, 9].Value = doc.IsTypical; |
991 |
templateWorksheet.Cells[rowIndex, 10].Value = doc.RevisonNo; |
992 |
templateWorksheet.Cells[rowIndex, 11].Value = doc.ToIsDiscussion; |
993 |
templateWorksheet.Cells[rowIndex, 12].Value = doc.ToRemarks; |
994 |
templateWorksheet.Cells[rowIndex, 13].Value = doc.ToCreator; |
995 |
templateWorksheet.Cells[rowIndex, 14].Value = doc.ToCapturePath; |
996 |
templateWorksheet.Cells[rowIndex, 15].Value = doc.ToIsMarkup; |
997 |
templateWorksheet.Cells[rowIndex, 16].Value = doc.FrReviewStatus; |
998 |
templateWorksheet.Cells[rowIndex, 17].Value = doc.FrRemarks; |
999 |
templateWorksheet.Cells[rowIndex, 18].Value = doc.FrCreator; |
1000 |
templateWorksheet.Cells[rowIndex, 19].Value = doc.FrCapturePath; |
1001 |
templateWorksheet.Cells[rowIndex, 20].Value = doc.FrIsMarkup; |
1002 |
templateWorksheet.Cells[rowIndex, 21].Value = doc.IsID2Work; |
1003 |
templateWorksheet.Cells[rowIndex, 22].Value = doc.ID2Connection; |
1004 |
templateWorksheet.Cells[rowIndex, 23].Value = doc.ID2StartDate; |
1005 |
templateWorksheet.Cells[rowIndex, 24].Value = doc.ID2EndDate; |
1006 |
templateWorksheet.Cells[rowIndex, 25].Value = doc.ID2JobTime; |
1007 |
templateWorksheet.Cells[rowIndex, 26].Value = doc.ID2Status; |
1008 |
templateWorksheet.Cells[rowIndex, 27].Value = doc.ID2Issues; |
1009 |
templateWorksheet.Cells[rowIndex, 28].Value = doc.AVEVAConnection; |
1010 |
templateWorksheet.Cells[rowIndex, 29].Value = doc.AVEVAConvertDate; |
1011 |
templateWorksheet.Cells[rowIndex, 30].Value = doc.AVEVAReviewDate; |
1012 |
templateWorksheet.Cells[rowIndex, 31].Value = doc.AVEVAStatus; |
1013 |
templateWorksheet.Cells[rowIndex, 32].Value = doc.AVEVAIssues; |
1014 |
//templateWorksheet.Cells[rowIndex, 33].Value = doc.DocumentNo; |
1015 |
//templateWorksheet.Cells[rowIndex, 34].Value = doc.DocumentNo; |
1016 |
templateWorksheet.Cells[rowIndex, 35].Value = doc.ProdReviewer; |
1017 |
templateWorksheet.Cells[rowIndex, 36].Value = doc.ProdIsResult; |
1018 |
templateWorksheet.Cells[rowIndex, 37].Value = doc.ProdRemarks; |
1019 |
templateWorksheet.Cells[rowIndex, 38].Value = doc.ClientReviewer; |
1020 |
templateWorksheet.Cells[rowIndex, 39].Value = doc.ClientIsResult; |
1021 |
templateWorksheet.Cells[rowIndex, 40].Value = doc.ClientRemarks; |
1022 |
templateWorksheet.Cells[rowIndex, 41].Value = doc.DTIsGateWay; |
1023 |
templateWorksheet.Cells[rowIndex, 42].Value = doc.DTIsImport; |
1024 |
templateWorksheet.Cells[rowIndex, 43].Value = doc.DTIsRegSystem; |
1025 |
templateWorksheet.Cells[rowIndex, 44].Value = doc.DTRemarks; |
1026 |
rowIndex++; |
1027 |
} |
1028 |
|
1029 |
templateExcelFile.Save(sfd.FileName); |
1030 |
RadMessageBox.Show("Exporting 'ID2 Document List' is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info); |
1031 |
} |
1032 |
} |
1033 |
} |
1034 |
} |
1035 |
#endregion |
1036 |
|
1037 |
#region Save event |
1038 |
private void RadButtonElementSave_Click(object sender, EventArgs e) |
1039 |
{ |
1040 |
List <Documents> setDocuments = new List<Documents>(); |
1041 |
List<Documents> delDocuments = new List<Documents>(); |
1042 |
|
1043 |
var worker = new DocumentsWorker(this.documents, this.orgDocuments, setDocuments, delDocuments, this.radGridViewDocuments); |
1044 |
worker.OnWorkCompletedHandler += () => |
1045 |
{ |
1046 |
bool result = new DocumentController().SetDocumentData(setDocuments, delDocuments); |
1047 |
|
1048 |
bool markusResult = new MarkusInfoController().SetMarkusInfo(this.documents); |
1049 |
|
1050 |
if (result && markusResult) |
1051 |
{ |
1052 |
RadMessageBox.Show("Save is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info); |
1053 |
|
1054 |
this.GetDocList(); |
1055 |
} |
1056 |
else if(!result) |
1057 |
{ |
1058 |
RadMessageBox.Show("Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error); |
1059 |
} |
1060 |
else if (!markusResult) |
1061 |
{ |
1062 |
RadMessageBox.Show("Markus Data Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error); |
1063 |
} |
1064 |
}; |
1065 |
worker.StartWork(); |
1066 |
} |
1067 |
#endregion |
1068 |
|
1069 |
#region ColumnGroup |
1070 |
private void InitColumnGroupsViewDefinition(RadGridView gridView) |
1071 |
{ |
1072 |
ColumnGroupsViewDefinition columnGroupsView = new ColumnGroupsViewDefinition(); |
1073 |
|
1074 |
List<string> docLinkColNames = new List<string>() { "AutoCADLink", "PDFLink", "MarkupLink", "AVEVALink" }; |
1075 |
List<string> docInfoColNames = new List<string>() { "RefProjectID", "DocumentNo", "PersonInCharge", "JobLevel", "IsTypical", "RevisonNo" }; |
1076 |
List<string> rvToColNames = new List<string>() { "ToIsDiscussion", "ToRemarks", "ToModifier", "ToCapturePath", "ToIsMarkup" }; |
1077 |
List<string> rvFrColNames = new List<string>() { "FrReviewStatus", "FrRemarks", "FrModifier", "FrCapturePath", "FrIsMarkup" }; |
1078 |
List<string> rvEtcColNames = new List<string>() { "IsID2Work" }; |
1079 |
List<string> wkID2ColNames = new List<string>() { "ID2Connection", "ID2StartDate", "ID2EndDate", "ID2JobTime", "ID2Status", "ID2Issues" }; |
1080 |
List<string> wkAVEVAColNames = new List<string>() { "AVEVAConnection", "AVEVAConvertDate", "AVEVAReviewDate", "AVEVAStatus", "AVEVAIssues" }; |
1081 |
List<string> valLinkColNames = new List<string>() { "ReviewFileName", "SystemLink" }; |
1082 |
List<string> valProdColNames = new List<string>() { "ProdReviewer", "ProdIsResult", "ProdRemarks" }; |
1083 |
List<string> valCntColNames = new List<string>() { "ClientReviewer", "ClientIsResult", "ClientRemarks" }; |
1084 |
List<string> dtColNames = new List<string>() { "DTIsGateWay", "DTIsImport", "DTIsRegSystem", "DTRemarks" }; |
1085 |
|
1086 |
//도면 |
1087 |
GridViewColumnGroup docColGrp = new GridViewColumnGroup("도면 "); |
1088 |
GridViewColumnGroup docLinkColGrp = new GridViewColumnGroup("파일링크"); |
1089 |
GridViewColumnGroup docInfoColGrp = new GridViewColumnGroup("도면정보"); |
1090 |
|
1091 |
GridViewColumnGroupRow docLinkColGrpRow = new GridViewColumnGroupRow(); |
1092 |
docLinkColGrpRow.ColumnNames.AddRange(docLinkColNames); |
1093 |
|
1094 |
GridViewColumnGroupRow docInfoColGrpRow = new GridViewColumnGroupRow(); |
1095 |
docInfoColGrpRow.ColumnNames.AddRange(docInfoColNames); |
1096 |
|
1097 |
docLinkColGrp.Rows.Add(docLinkColGrpRow); |
1098 |
docColGrp.Groups.Add(docLinkColGrp); |
1099 |
docInfoColGrp.Rows.Add(docInfoColGrpRow); |
1100 |
docColGrp.Groups.Add(docInfoColGrp); |
1101 |
|
1102 |
//검토 |
1103 |
GridViewColumnGroup rvColGrp = new GridViewColumnGroup("검토", "review"); |
1104 |
GridViewColumnGroup rvToColGrp = new GridViewColumnGroup("도프텍"); |
1105 |
GridViewColumnGroup rvFrColGrp = new GridViewColumnGroup("삼성"); |
1106 |
GridViewColumnGroup rvEtcColGrp = new GridViewColumnGroup("기타"); |
1107 |
|
1108 |
GridViewColumnGroupRow rvToColGrpRow = new GridViewColumnGroupRow(); |
1109 |
rvToColGrpRow.ColumnNames.AddRange(rvToColNames); |
1110 |
|
1111 |
GridViewColumnGroupRow rvFrColGrpRow = new GridViewColumnGroupRow(); |
1112 |
rvFrColGrpRow.ColumnNames.AddRange(rvFrColNames); |
1113 |
|
1114 |
GridViewColumnGroupRow rvEtcColGrpRow = new GridViewColumnGroupRow(); |
1115 |
rvEtcColGrpRow.ColumnNames.AddRange(rvEtcColNames); |
1116 |
|
1117 |
rvToColGrp.Rows.Add(rvToColGrpRow); |
1118 |
rvFrColGrp.Rows.Add(rvFrColGrpRow); |
1119 |
rvEtcColGrp.Rows.Add(rvEtcColGrpRow); |
1120 |
|
1121 |
|
1122 |
rvColGrp.Groups.Add(rvToColGrp); |
1123 |
rvColGrp.Groups.Add(rvFrColGrp); |
1124 |
rvColGrp.Groups.Add(rvEtcColGrp); |
1125 |
|
1126 |
|
1127 |
//작업 |
1128 |
GridViewColumnGroup wkColGrp = new GridViewColumnGroup("작업", "work"); |
1129 |
GridViewColumnGroup wkID2ColGrp = new GridViewColumnGroup("ID2"); |
1130 |
GridViewColumnGroup wkAVEVAColGrp = new GridViewColumnGroup("AVEVA"); |
1131 |
|
1132 |
GridViewColumnGroupRow wkID2ColGrpRow = new GridViewColumnGroupRow(); |
1133 |
wkID2ColGrpRow.ColumnNames.AddRange(wkID2ColNames); |
1134 |
|
1135 |
GridViewColumnGroupRow wkAVEVAColGrpRow = new GridViewColumnGroupRow(); |
1136 |
wkAVEVAColGrpRow.ColumnNames.AddRange(wkAVEVAColNames); |
1137 |
|
1138 |
wkID2ColGrp.Rows.Add(wkID2ColGrpRow); |
1139 |
wkAVEVAColGrp.Rows.Add(wkAVEVAColGrpRow); |
1140 |
|
1141 |
wkColGrp.Groups.Add(wkID2ColGrp); |
1142 |
wkColGrp.Groups.Add(wkAVEVAColGrp); |
1143 |
|
1144 |
|
1145 |
//Validation |
1146 |
GridViewColumnGroup valColGrp = new GridViewColumnGroup("Validation", "validation"); |
1147 |
GridViewColumnGroup valLinkColGrp = new GridViewColumnGroup("파일링크"); |
1148 |
GridViewColumnGroup valProdColGrp = new GridViewColumnGroup("도프텍"); |
1149 |
GridViewColumnGroup valCntColGrp = new GridViewColumnGroup("삼성전자"); |
1150 |
|
1151 |
GridViewColumnGroupRow valLinkColGrpRow = new GridViewColumnGroupRow(); |
1152 |
valLinkColGrpRow.ColumnNames.AddRange(valLinkColNames); |
1153 |
|
1154 |
GridViewColumnGroupRow valProdColGrpRow = new GridViewColumnGroupRow(); |
1155 |
valProdColGrpRow.ColumnNames.AddRange(valProdColNames); |
1156 |
|
1157 |
GridViewColumnGroupRow valCntColGrpRow = new GridViewColumnGroupRow(); |
1158 |
valCntColGrpRow.ColumnNames.AddRange(valCntColNames); |
1159 |
|
1160 |
valLinkColGrp.Rows.Add(valLinkColGrpRow); |
1161 |
valProdColGrp.Rows.Add(valProdColGrpRow); |
1162 |
valCntColGrp.Rows.Add(valCntColGrpRow); |
1163 |
|
1164 |
valColGrp.Groups.Add(valLinkColGrp); |
1165 |
valColGrp.Groups.Add(valProdColGrp); |
1166 |
valColGrp.Groups.Add(valCntColGrp); |
1167 |
|
1168 |
//AVEVA Net |
1169 |
GridViewColumnGroup dtColGrp = new GridViewColumnGroup("AVEVA Net\n(Digital Twin)", "avevanet"); |
1170 |
|
1171 |
GridViewColumnGroupRow dtColGrpRow = new GridViewColumnGroupRow(); |
1172 |
dtColGrpRow.ColumnNames.AddRange(dtColNames); |
1173 |
|
1174 |
dtColGrp.Rows.Add(dtColGrpRow); |
1175 |
|
1176 |
//Group 추가 |
1177 |
columnGroupsView.ColumnGroups.Add(docColGrp); |
1178 |
columnGroupsView.ColumnGroups.Add(rvColGrp); |
1179 |
columnGroupsView.ColumnGroups.Add(wkColGrp); |
1180 |
columnGroupsView.ColumnGroups.Add(valColGrp); |
1181 |
columnGroupsView.ColumnGroups.Add(dtColGrp); |
1182 |
|
1183 |
gridView.MasterTemplate.ViewDefinition = columnGroupsView; |
1184 |
} |
1185 |
#endregion |
1186 |
|
1187 |
class DocumentsWorker : BaseWorker |
1188 |
{ |
1189 |
public delegate void OnWorkCompleted(); |
1190 |
public OnWorkCompleted OnWorkCompletedHandler; |
1191 |
|
1192 |
List<Documents> docList { get; set; } |
1193 |
List<Documents> orgList { get; set; } |
1194 |
List<Documents> setList { get; set; } |
1195 |
List<Documents> delList { get; set; } |
1196 |
|
1197 |
public DocumentsWorker(List<Documents> docList, List<Documents> orgDocList, List<Documents> setDocList, List<Documents> delDocList, Control parent = null) : base(parent) |
1198 |
{ |
1199 |
this.docList = docList; |
1200 |
this.orgList = orgDocList; |
1201 |
this.setList = setDocList; |
1202 |
this.delList = delDocList; |
1203 |
} |
1204 |
protected override void DoWork(BackgroundWorker worker) |
1205 |
{ |
1206 |
//수정리스트 |
1207 |
this.docList.Where(x => !this.orgList.Any(y => y.Equals(x))) |
1208 |
.ToList().ForEach(x => this.setList.Add(x)); |
1209 |
//삭제리스트 |
1210 |
this.delList.AddRange(this.orgList.Except(this.docList, new DocumentsKeyComparer())); |
1211 |
} |
1212 |
|
1213 |
protected override void WorkCompleted() |
1214 |
{ |
1215 |
if (this.OnWorkCompletedHandler != null) this.OnWorkCompletedHandler(); |
1216 |
} |
1217 |
} |
1218 |
|
1219 |
private void txtFullSearch_TextChanged(object sender, EventArgs e) |
1220 |
{ |
1221 |
txtFullSearch.TextBoxElement.ShowClearButton = !string.IsNullOrWhiteSpace(txtFullSearch.Text); |
1222 |
radGridViewDocuments.MasterView.TableSearchRow.Search(txtFullSearch.Text); |
1223 |
} |
1224 |
|
1225 |
private void btnSearchPrevious_Click(object sender, EventArgs e) |
1226 |
{ |
1227 |
|
1228 |
radGridViewDocuments.MasterView.TableSearchRow.SelectPreviousSearchResult(); |
1229 |
} |
1230 |
|
1231 |
private void btnSearchNext_Click(object sender, EventArgs e) |
1232 |
{ |
1233 |
radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult(); |
1234 |
} |
1235 |
} |
1236 |
} |
1237 |
|
1238 |
public class FilterColumn |
1239 |
{ |
1240 |
public string Name { get; set; } |
1241 |
public string FieldName { get; set; } |
1242 |
public bool IsSelect { get; set; } |
1243 |
} |