프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager / Main.cs @ 3cf51d85

이력 | 보기 | 이력해설 | 다운로드 (61.1 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
            //  0  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
            txtFullSearch.TextBoxElement.ClearButton.Click += (snd, evt) =>
204
            {
205
                radGridViewDocuments.MasterTemplate.Refresh(null);
206
            };
207
            
208

    
209
            btnComboColumns.PopupClosed += (snd, evt) =>
210
            {
211
                foreach (RadCheckedListDataItem item in btnComboColumns.Items)
212
                {
213
                    radGridViewDocuments.Columns[item.Value.ToString()].AllowSearching = item.Checked;
214
                }
215
            };
216
            //panel.Children.Add(btnSelect);
217
            //panel.Children.Add(new SeparatorElement());
218
            //panel.Children.Add(btnComboColumns);
219
            btnFilters.HostedItem = btnComboColumns;
220

    
221
            txtFullSearch.TextBoxElement.ClearButton.Click += (snd, ect) =>
222
              {
223
              };
224
        }
225

    
226
        #endregion
227

    
228
        private void OpenProjectView_OpenProjectClick(object sender, EventArgs e)
229
        {
230
            //if (e is ProjectEventArgs)
231
            //{
232
            //    var projectGroup = (e as ProjectEventArgs).ProjectInfo;
233
            //    var projects = (e as ProjectEventArgs).ProjectList;
234

    
235
            //    if (projectGroup != null)
236
            //    {
237
            //        informations.ActiveProject = projectGroup;
238
            //    }
239

    
240
            //    if (projects != null)
241
            //    {
242
            //        informations.ProjectList = projects;
243
            //    }
244
            //}
245

    
246
            this.radRibbonBarBackstageViewID2Manager.Tag = e;
247
            this.radRibbonBarBackstageViewID2Manager.HidePopup();
248
        }
249

    
250
        private void RadRibbonBarBackstageViewID2Manager_BackstageViewOpened(object sender, EventArgs e)
251
        {
252
            this.radRibbonBarBackstageViewID2Manager.SelectedItem = this.backstageTabItemOpenProject;
253

    
254
            foreach ( Control ctrl in this.backstageViewPageOpenProject.Controls)
255
            {
256
                if (ctrl is OpenProjectView)
257
                {
258
                    var openProjectView = ctrl as OpenProjectView;
259
                    openProjectView.GetProjectGroups();
260
                    break;
261
                }
262
            }
263
        }
264

    
265
        private void RadRibbonBarBackstageViewID2Manager_BackstageViewClosed(object sender, EventArgs e)
266
        {
267
            if (this.radRibbonBarBackstageViewID2Manager.Tag is ProjectEventArgs)
268
            {
269
                var prjArgs = this.radRibbonBarBackstageViewID2Manager.Tag as ProjectEventArgs;
270

    
271
                informations.ActiveProject = prjArgs.ProjectInfo;
272
                informations.ProjectList = prjArgs.ProjectList;
273

    
274
                this.radRibbonBarBackstageViewID2Manager.Tag = null;
275

    
276
                this.LoadProject();
277
            }
278
        }
279

    
280
        private void LoadProject()
281
        {
282
            #region 도면
283
            //Project List
284
            if (this.radDropDownListProject.Items.Count > 0)
285
                this.radDropDownListProject.Items.Clear();
286
            informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList()
287
                                    .ForEach(x =>
288
                                    {
289
                                        this.radDropDownListProject.Items.Add(new RadListDataItem(x.Name, x.Code));
290
                                    });
291
            var allProject = new RadListDataItem("== 전체 ==", string.Empty);
292
            this.radDropDownListProject.Items.Insert(0, allProject);
293
            allProject.Selected = true;
294

    
295
            //담당자 List
296
            if (this.radDropDownListPersonInCharge.Items.Count > 0)
297
                this.radDropDownListPersonInCharge.Items.Clear();
298
            informations.UserList.ForEach(x =>
299
            {
300
                if ((new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID))
301
                    this.radDropDownListPersonInCharge.Items.Add(new RadListDataItem(x.Name, x.ID));
302
            });
303
            var allUser = new RadListDataItem("== 전체 ==", string.Empty);
304
            this.radDropDownListPersonInCharge.Items.Insert(0, allUser);
305
            allUser.Selected = true;
306

    
307
            //난이도
308
            if (this.radDropDownListJobLevel.Items.Count > 0)
309
                this.radDropDownListJobLevel.Items.Clear();
310
            informations.JobLevel.ForEach(x =>
311
            {
312
                this.radDropDownListJobLevel.Items.Add(new RadListDataItem(x, x));
313
            });
314
            var allJobLevel = new RadListDataItem("== 전체 ==", string.Empty);
315
            this.radDropDownListJobLevel.Items.Insert(0, allJobLevel);
316
            allJobLevel.Selected = true;
317

    
318
            //도면번호 조회조건
319
            this.radTextBoxDocumentNo.Text = string.Empty;
320
            #endregion
321

    
322
            #region 검토
323
            //ID2 작업가능
324
            if (this.radDropDownListIsID2Work.Items.Count > 0)
325
                this.radDropDownListIsID2Work.Items.Clear();
326
            informations.IsYesNo.ForEach(x =>
327
            {
328
                this.radDropDownListIsID2Work.Items.Add(new RadListDataItem(x, x));
329
            });
330
            var allIsID2Work = new RadListDataItem("== 전체 ==", string.Empty);
331
            this.radDropDownListIsID2Work.Items.Insert(0, allIsID2Work);
332
            allIsID2Work.Selected = true;
333
            #endregion
334

    
335
            #region 작업
336
            //ID2 Status
337
            if (this.radDropDownListID2Status.Items.Count > 0)
338
                this.radDropDownListID2Status.Items.Clear();
339
            informations.JobStatus.ForEach(x =>
340
            {
341
                this.radDropDownListID2Status.Items.Add(new RadListDataItem(x, x));
342
            });
343
            var allID2Status = new RadListDataItem("== 전체 ==", string.Empty);
344
            this.radDropDownListID2Status.Items.Insert(0, allID2Status);
345
            allID2Status.Selected = true;
346

    
347
            //AVEVA Status
348
            if (this.radDropDownListAVEVAStatus.Items.Count > 0)
349
                this.radDropDownListAVEVAStatus.Items.Clear();
350
            informations.JobStatus.ForEach(x =>
351
            {
352
                this.radDropDownListAVEVAStatus.Items.Add(new RadListDataItem(x, x));
353
            });
354
            var allAVEVAStatus = new RadListDataItem("== 전체 ==", string.Empty);
355
            this.radDropDownListAVEVAStatus.Items.Insert(0, allAVEVAStatus);
356
            allAVEVAStatus.Selected = true;
357
            #endregion
358

    
359
            #region 확인
360
            //도프텍 결과
361
            if (this.radDropDownListProdIsResult.Items.Count > 0)
362
                this.radDropDownListProdIsResult.Items.Clear();
363
            informations.ValidationResult.ForEach(x =>
364
            {
365
                this.radDropDownListProdIsResult.Items.Add(new RadListDataItem(x, x));
366
            });
367
            var allProdIsResult = new RadListDataItem("== 전체 ==", string.Empty);
368
            this.radDropDownListProdIsResult.Items.Insert(0, allProdIsResult);
369
            allProdIsResult.Selected = true;
370

    
371
            //삼성 결과
372
            if (this.radDropDownListClientIsResult.Items.Count > 0)
373
                this.radDropDownListClientIsResult.Items.Clear();
374
            informations.ValidationResult.ForEach(x =>
375
            {
376
                this.radDropDownListClientIsResult.Items.Add(new RadListDataItem(x, x));
377
            });
378
            var allClientIsResult = new RadListDataItem("== 전체 ==", string.Empty);
379
            this.radDropDownListClientIsResult.Items.Insert(0, allClientIsResult);
380
            allClientIsResult.Selected = true;
381
            #endregion
382

    
383
            this.GetDocList();
384
            this.DocumentListBinding();
385
        }
386

    
387
        #region Document List 조회
388
        public void GetDocList()
389
        {
390
            if (this.radDropDownListProject.SelectedValue != null)
391
            {
392
                string projectCode = this.radDropDownListProject.SelectedValue.ToString();
393
                string personIncharge = this.radDropDownListPersonInCharge.SelectedValue.ToString();
394
                string jobLevel = this.radDropDownListJobLevel.SelectedValue.ToString();//
395
                string documentNo = this.radTextBoxDocumentNo.Text.Trim();
396

    
397
                string isID2Work = this.radDropDownListIsID2Work.SelectedValue.ToString();//
398

    
399
                string id2Status = this.radDropDownListID2Status.SelectedValue.ToString();//
400
                string avevaStatus = this.radDropDownListAVEVAStatus.SelectedValue.ToString();//
401

    
402
                string prodIsResult = this.radDropDownListProdIsResult.SelectedValue.ToString();//
403
                string clientIsResult = this.radDropDownListClientIsResult.SelectedValue.ToString();//
404

    
405
                this.documents = new DocumentController().GetAllDocuments(projectCode, personIncharge, jobLevel, documentNo, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult).ToList();
406
                this.orgDocuments = JsonConvert.DeserializeObject<List<Documents>>(JsonConvert.SerializeObject(this.documents));
407
            }
408
        }
409

    
410
        public void DocumentListBinding()
411
        {
412
            GridViewComboBoxColumn ColProjects = this.radGridViewDocuments.Columns["RefProjectCode"] as GridViewComboBoxColumn;
413
            ColProjects.DataSource = informations.ProjectList.Where(x => x.GroupID.Equals(informations.ActiveProject.ProjectID)).ToList();
414
            ColProjects.DisplayMember = "Name";
415
            ColProjects.ValueMember = "Code";
416

    
417
            var workUsers = informations.UserList.Where(x => (new string[] { "Manager", "User" }).Contains(x.Role) && string.IsNullOrEmpty(x.RefProjectID));
418
            var clientUsers = informations.UserList.Where(x => !string.IsNullOrEmpty(x.RefProjectID));
419

    
420
            GridViewComboBoxColumn ColPersonInCharge = this.radGridViewDocuments.Columns["PersonInCharge"] as GridViewComboBoxColumn;
421
            ColPersonInCharge.DataSource = workUsers;
422
            ColPersonInCharge.DisplayMember = "Name";
423
            ColPersonInCharge.ValueMember = "ID";
424

    
425
            GridViewComboBoxColumn ColToCreator = this.radGridViewDocuments.Columns["ToCreator"] as GridViewComboBoxColumn;
426
            ColToCreator.DataSource = workUsers;
427
            ColToCreator.DisplayMember = "Name";
428
            ColToCreator.ValueMember = "ID";
429

    
430
            GridViewComboBoxColumn ColFrCreator = this.radGridViewDocuments.Columns["FrCreator"] as GridViewComboBoxColumn;
431
            ColFrCreator.DataSource = clientUsers;
432
            ColFrCreator.DisplayMember = "Name";
433
            ColFrCreator.ValueMember = "ID";
434

    
435
            GridViewComboBoxColumn ColProdReviewer = this.radGridViewDocuments.Columns["ProdReviewer"] as GridViewComboBoxColumn;
436
            ColProdReviewer.DataSource = workUsers;
437
            ColProdReviewer.DisplayMember = "Name";
438
            ColProdReviewer.ValueMember = "ID";
439

    
440
            GridViewComboBoxColumn ColClientReviewer = this.radGridViewDocuments.Columns["ClientReviewer"] as GridViewComboBoxColumn;
441
            ColClientReviewer.DataSource = clientUsers;
442
            ColClientReviewer.DisplayMember = "Name";
443
            ColClientReviewer.ValueMember = "ID";
444

    
445
            //Data
446
            if (this.radGridViewDocuments.DataSource != null)
447
                this.radGridViewDocuments.DataSource = null;
448
            this.radGridViewDocuments.DataSource = this.documents;
449

    
450
            if (this.radGridViewDocuments.SummaryRowsBottom != null)
451
                this.radGridViewDocuments.SummaryRowsBottom.Clear();
452

    
453
            string totalCount = String.Format("{0:#,###}", this.documents.Count());
454

    
455
            //Summary
456
            GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem()
457
            {
458
                new GridViewSummaryItem("DocumentNo", "{0:#,###} / " + totalCount, GridAggregateFunction.Count)
459
            };
460
            this.radGridViewDocuments.SummaryRowsBottom.Add(summaryRowItem);
461
            this.radGridViewDocuments.MasterView.SummaryRows[0].PinPosition = PinnedRowPosition.Bottom;
462
            this.radGridViewDocuments.MasterTemplate.BottomPinnedRowsMode = GridViewBottomPinnedRowsMode.Fixed;
463
        }
464
        #endregion
465

    
466
        #region Button, Checkbox event
467
        private void RadCheckBox_CheckStateChanged(object sender, EventArgs e)
468
        {
469
            if (sender is RadCheckBox)
470
            {
471
                RadCheckBox checkBox = sender as RadCheckBox;
472

    
473
                if (checkBox.Tag != null)
474
                {
475
                    ColumnGroupsViewDefinition columnGroupsView =  this.radGridViewDocuments.MasterTemplate.ViewDefinition as ColumnGroupsViewDefinition;
476
                    GridViewColumnGroup colGroup = columnGroupsView.GetAllGroups().Where(x => x.Name.Equals(checkBox.Tag.ToString())).FirstOrDefault();
477
                    if (colGroup != null)
478
                        colGroup.IsVisible = checkBox.Checked;
479
                }
480
            }
481

    
482
            //ColumnGroupsViewDefinition columnGroupsView = this.radGridViewDocuments.MasterTemplate.ViewDefinition = columnGroupsView;
483
        }
484

    
485
        private void RadTextBoxDocumentNo_KeyDown(object sender, KeyEventArgs e)
486
        {
487
            if (e.KeyCode == Keys.Enter)
488
            {
489
                this.radButtonSearch.Focus();
490
                this.radButtonSearch.PerformClick();
491
            }
492
        }
493

    
494
        private void RadButtonSearch_Click(object sender, EventArgs e)
495
        {
496
            this.GetDocList();
497
            this.DocumentListBinding();
498
        }
499

    
500
        private void BackstageButtonItemUserRegistration_Click(object sender, EventArgs e)
501
        {
502
            using (var frm = new SetupUser())
503
            {
504
                if (frm.ShowDialog(this) == DialogResult.OK)
505
                {
506
                    
507
                }
508
            }
509
        }
510

    
511
        private void BackstageButtonItemExit_Click(object sender, EventArgs e)
512
        {
513
            Application.Exit();
514
        }
515
        #endregion
516

    
517
        #region Grid event
518
        private void RadGridViewDocuments_CommandCellClick(object sender, GridViewCellEventArgs e)
519
        {
520
            if (e.Row is GridViewNewRowInfo)
521
            {
522
                
523
            }
524
            else
525
            {
526
                string extension = string.Empty;
527

    
528
                switch (e.Column.Name)
529
                {
530
                    case "AutoCADLink":
531
                        {
532
                            Controls.AutoCADViewer viewer = null;
533
                            foreach (var control in this.tableLayoutPanelRight.Controls)
534
                            {
535
                                if (control is Controls.AutoCADViewer _viewer)
536
                                {
537
                                    viewer = _viewer;
538
                                    break;
539
                                }
540
                            }
541

    
542
                            if (viewer == null)
543
                            {
544
                                viewer = new Controls.AutoCADViewer() { Dock = DockStyle.Fill };
545
                                this.tableLayoutPanelRight.Controls.Add(viewer);
546
                            }
547
                            else
548
                            {
549
                                viewer.Visible = true;
550
                            }
551

    
552
                            if (e.Row.DataBoundItem is Documents doc)
553
                            {
554
                                extension = "dwg";
555
                                string filePath = Path.Combine(informations.FindID2LocalPath(doc.RefProjectCode), $"{doc.DocumentNo}.{extension}");
556

    
557
                                if (File.Exists(filePath) && viewer != null) viewer.ReadDWG(filePath);
558
                            }
559
                        }
560
                        break;
561
                    case "PDFLink":
562
                        MessageBox.Show($"{e.Column.Name} 실행");
563
                        break;
564
                    case "MarkupLink":
565
                        {
566
                            if (e.Row.DataBoundItem is Documents doc)
567
                            {
568
                                if (!string.IsNullOrWhiteSpace(doc.RefProjectCode) && !string.IsNullOrWhiteSpace(doc.DocumentNo) && !string.IsNullOrWhiteSpace(doc.PersonInCharge))
569
                                {
570
                                    bool result = MarkusHelper.Start(doc.RefProjectCode, doc.DocumentNo, doc.PersonInCharge);
571
                                }
572
                            }
573
                        }
574
                        break;
575
                    case "AVEVALink":
576
                    case "AVEVAConnection":
577
                        MessageBox.Show($"{e.Column.Name} 실행");
578
                        break;
579
                    case "ReviewFileName"://일단주석
580
                        MessageBox.Show($"{e.Column.Name} 실행");
581
                        break;
582
                    case "SystemLink":
583
                        MessageBox.Show($"{e.Column.Name} 실행");
584
                        break;
585
                    case "ToCapturePath":
586
                    case "FrCapturePath":
587

    
588
                        if (e.Row.DataBoundItem is Documents dd)
589
                        {
590
                            using (var frm = new ImageView(dd.DocID))
591
                            {
592
                                frm.ShowDialog(this);
593
                            }
594
                        }
595
                        break;
596
                    case "ID2Connection":
597
                        try
598
                        {
599
                            if (e.Row.DataBoundItem is Documents doc)
600
                            {
601
                                ID2Helper.OpenPID(doc.DocumentNo, string.Empty, Properties.Settings.Default.ID2Port);
602
                            }
603
                        }
604
                        catch (Exception ex)
605
                        {
606
                            RadMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
607
                        }
608
                        break;
609
                }
610
            }
611
        }
612

    
613
        private void RadGridViewDocuments_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
614
        {
615
            if (e.ActiveEditor is RadDropDownListEditor)
616
            {
617
                switch (e.Column.Name)
618
                {
619
                    case "JobLevel":
620
                        GridViewComboBoxColumn ColJobLevel = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
621
                        ColJobLevel.DataSource = informations.JobLevel;
622
                        break;
623
                    case "IsTypical":
624
                    case "ToIsDiscussion":
625
                    case "ToIsMarkup":
626
                    case "FrIsMarkup":
627
                    case "IsID2Work":
628
                    case "DTIsGateWay":
629
                    case "DTIsImport":
630
                    case "DTIsRegSystem":
631
                        GridViewComboBoxColumn ColYesNo = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
632
                        ColYesNo.DataSource = (new string[] { string.Empty }).Union<string>(informations.IsYesNo);
633
                        break;
634
                    case "ID2Status":
635
                    case "AVEVAStatus":
636
                        GridViewComboBoxColumn ColJobStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
637
                        ColJobStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.JobStatus);
638
                        break;
639
                    case "FrReviewStatus"://삼성의견status
640
                        GridViewComboBoxColumn ColClientStatus = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
641
                        ColClientStatus.DataSource = (new string[] { string.Empty }).Union<string>(informations.ClientStatus);
642
                        break;
643
                    case "ProdIsResult":
644
                    case "ClientIsResult":
645
                        GridViewComboBoxColumn ColResult = this.radGridViewDocuments.Columns[e.Column.Name] as GridViewComboBoxColumn;
646
                        ColResult.DataSource = (new string[] { string.Empty }).Union<string>(informations.ValidationResult);
647
                        break;
648
                }
649
            }
650
        }
651

    
652
        private void RadGridViewDocuments_ViewCellFormatting(object sender, CellFormattingEventArgs e)
653
        {
654
            if (e.Row is GridViewDataRowInfo)
655
            {
656
                if (e.CellElement is GridRowHeaderCellElement)
657
                {
658
                    if (e.CellElement.RowIndex > -1)
659
                        e.CellElement.Text = (e.CellElement.RowIndex + 1).ToString();
660
                }
661
                else
662
                {
663
                    var result = e.Row.DataBoundItem as Documents;
664
                    if (result != null || e.Row is GridViewNewRowInfo)
665
                    {
666
                        switch (e.CellElement.ColumnInfo.Name)
667
                        {
668
                            case "AutoCADLink":
669
                            case "PDFLink":
670
                            case "MarkupLink":
671
                            case "AVEVALink":
672
                            case "AVEVAConnection":
673
                            case "ReviewFileName"://일단주석
674
                            case "SystemLink":
675
                            case "ToCapturePath":
676
                            case "FrCapturePath":
677
                            case "ID2Connection":
678
                                this.GetCommandColBtnElement(e.CellElement.Children[0], e.CellElement.ColumnInfo.Name);
679
                                break;
680
                        }
681
                    }
682
                    else
683
                    {
684

    
685
                    }
686
                }
687
            }
688
            else if (e.Row is GridViewSummaryRowInfo)
689
            {
690
                if (e.CellElement is GridRowHeaderCellElement)
691
                {
692
                    e.CellElement.Text = "Count";
693
                }
694
                else if (e.CellElement is GridSummaryCellElement)
695
                {
696
                    e.CellElement.ForeColor = this._SummaryColor;
697
                    e.CellElement.TextAlignment = ContentAlignment.BottomRight;
698
                    e.CellElement.Font = new Font(e.CellElement.Font, FontStyle.Bold);
699
                }
700
                else
701
                {
702

    
703
                }
704
            }
705
            else
706
            {
707

    
708
            }
709
        }
710

    
711
        private RadButtonElement GetCommandColBtnElement(RadElement elem, string colName)
712
        {
713
            RadButtonElement btnElem = null;
714
            Bitmap bitmap = null; ;
715

    
716
            switch (colName)
717
            {
718
                case "AutoCADLink":
719
                    bitmap = new Bitmap(Properties.Resources.cad18);
720
                    break;
721
                case "PDFLink":
722
                    bitmap = new Bitmap(Properties.Resources.pdf18);
723
                    break;
724
                case "MarkupLink":
725
                    bitmap = new Bitmap(Properties.Resources.markus18);
726
                    break;
727
                case "AVEVALink":
728
                case "AVEVAConnection":
729
                    bitmap = new Bitmap(Properties.Resources.aveva_net18);
730
                    break;
731
                case "ReviewFileName"://일단주석
732
                    bitmap = new Bitmap(Properties.Resources.pdf18);
733
                    break;
734
                case "SystemLink":
735
                    bitmap = new Bitmap(Properties.Resources.link18_yellow);
736
                    break;
737
                case "ToCapturePath":
738
                case "FrCapturePath":
739
                    bitmap = new Bitmap(Properties.Resources.files18);
740
                    break;
741
                case "ID2Connection":
742
                    bitmap = new Bitmap(Properties.Resources.id218);
743
                    break;
744
            }
745

    
746
            switch (colName)
747
            {
748
                case "AutoCADLink":
749
                case "PDFLink":
750
                case "MarkupLink":
751
                case "AVEVALink":
752
                case "AVEVAConnection":
753
                case "ReviewFileName"://일단주석
754
                case "SystemLink":
755
                case "ToCapturePath":
756
                case "FrCapturePath":
757
                case "ID2Connection":
758
                    btnElem = (RadButtonElement)elem;
759
                    btnElem.Margin = new Padding(0);
760
                    btnElem.Padding = new Padding(0);
761
                    btnElem.BorderElement.Opacity = 0;
762
                    btnElem.Alignment = ContentAlignment.MiddleCenter;
763
                    btnElem.DisplayStyle = DisplayStyle.Image;
764
                    btnElem.Image = bitmap;
765
                    btnElem.ImageAlignment = ContentAlignment.MiddleCenter;
766
                    btnElem.MaxSize = bitmap.Size;
767
                    break;
768
            }
769

    
770
            return btnElem;
771
        }
772
        #endregion
773

    
774
        #region Excel
775
        private UserInfo GetUser(string user)
776
        {
777
            UserInfo userInfo = informations.UserList.Where(x => x.ID.Equals(user)).FirstOrDefault();
778
            if (userInfo != null) return userInfo;
779

    
780
            userInfo = informations.UserList.Where(x => x.Name.Equals(user)).FirstOrDefault();
781
            if (userInfo != null) return userInfo;
782

    
783
            return userInfo ?? new UserInfo();
784
        }
785

    
786
        private ProjectInfo GetProject(string project)
787
        {
788
            ProjectInfo prjInfo = informations.ProjectList.Where(x => x.ProjectID.Equals(project)).FirstOrDefault();
789
            if (prjInfo != null) return prjInfo;
790

    
791
            prjInfo = informations.ProjectList.FirstOrDefault(x => x.Name.Equals(project));
792
            if (prjInfo != null) return prjInfo;
793

    
794
            return prjInfo ?? new ProjectInfo();
795
        }
796

    
797
        private void RadButtonElementExcelImport_Click(object sender, EventArgs e)
798
        {
799
            using (OpenFileDialog ofd = new OpenFileDialog()
800
            {
801
                Filter = "Excel files (*.xlsx)|*.xlsx",
802
                Title = "Open an Excel File",
803
                RestoreDirectory = true
804
            })
805
            {
806
                if (ofd.ShowDialog() == DialogResult.OK)
807
                {
808
                    //Error Message
809
                    StringBuilder sbErrMsg = new StringBuilder();
810

    
811
                    var exFile = ExcelFile.Load(ofd.FileName);
812
                    var ws = exFile.Worksheets[0];
813

    
814
                    int rowCount = ws.Rows.Count;
815
                    int columnCount = ws.CalculateMaxUsedColumns();
816
                    int exRow = 8;
817

    
818
                    #region Excel 유효성검사
819

    
820
                    //Excel 포멧체크
821
                    if (rowCount < 10 || columnCount != 45)
822
                    {
823
                        RadMessageBox.Show("Please, check the excel.\n", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
824
                        return;
825
                    }
826

    
827
                    #region 엑셀 필수값 체크(도면 : 이름,담당자, 난이도, Typical)
828
                    ws.Rows.SelectMany(row => row.AllocatedCells)
829
                           .Where(col => col.Column.Index > 5 && col.Column.Index < 10 && col.Row.Index > exRow && col.Value == null)
830
                           .ToList()
831
                           .ForEach(p => sbErrMsg.Append(", " + p.Column.Name + p.Row.Name));
832

    
833
                    if (sbErrMsg.Length > 0)
834
                    {
835
                        string errMsg = sbErrMsg.ToString().Substring(2);
836
                        if (errMsg.Length > 100)
837
                        {
838
                            errMsg = $"{errMsg.Substring(0, 100)}...";
839
                        }
840

    
841
                        RadMessageBox.Show($"Please, check null value in excel.\n{errMsg}", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
842
                        return;
843
                    }
844
                    #endregion
845

    
846
                    #region 엑셀 도명명 중복 값 체크
847
                    ws.Rows.SelectMany(row => row.AllocatedCells)
848
                                                 .Where(col => col.Column.Index == 6 && col.Row.Index > exRow)
849
                                                 .GroupBy(g => g.Row.Index)
850
                                                 .Select(p => new {
851
                                                     rowIndex = p.Key,
852
                                                     docNo = p.Select(x => x.Value.ToString()).FirstOrDefault()
853
                                                 })
854
                                                 .GroupBy(g => g.docNo)
855
                                                 .Where(p => p.Count() > 1)
856
                                                 .Select(p => p.Select(x => (x.rowIndex + 1).ToString())
857
                                                                                            .Aggregate((x, y) => x.ToString() + "," + y.ToString())
858
                                                                                            .ToString())
859
                                                 .ToList().ForEach(p => sbErrMsg.Append("\n" + p.ToString()));
860
                    if (sbErrMsg.Length > 0)
861
                    {
862
                        sbErrMsg.Insert(0, "\n중복 된 도면명 Excel row : ");
863
                        string errMsg = sbErrMsg.ToString();
864
                        if (errMsg.Length > 100)
865
                        {
866
                            errMsg = $"{errMsg.Substring(0, 100)}...";
867
                        }
868

    
869
                        RadMessageBox.Show($"Please, check the duplicate value in excel.\n{errMsg}", "Information", MessageBoxButtons.OK, RadMessageIcon.Info);
870
                        return;
871
                    }
872
                    #endregion
873

    
874
                    #endregion
875

    
876
                    List<Documents> appendDocuments = new List<Documents>();
877

    
878
                    ws.Rows.Where(row => row.Index > exRow)
879
                           .ToList()
880
                           .ForEach(p => appendDocuments.Add(new Documents()
881
                           {
882
                               //UID = string.Empty,
883
                               //Type = this.radTextBoxInsulationType.Text,
884
                               //TempFrom = ws.Rows[exRow].Cells[p.Column.Index].Value == null ? 0 : Convert.ToSingle(ws.Rows[exRow].Cells[p.Column.Index].Value),
885
                               //TempTo = ws.Rows[exRow + 2].Cells[p.Column.Index].Value == null ? 0 : Convert.ToSingle(ws.Rows[exRow + 2].Cells[p.Column.Index].Value),
886
                               //NPS = ws.Rows[p.Row.Index].Cells[0].Value == null ? 0 : Convert.ToSingle(ws.Rows[p.Row.Index].Cells[0].Value),
887
                               //Thickness = p.Value == null ? 0 : Convert.ToSingle(p.Value)
888

    
889
                               RefProjectCode = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
890
                               DocumentNo = ws.Rows[p.Index].Cells[6].Value == null ? string.Empty : ws.Rows[p.Index].Cells[6].Value.ToString(),
891
                               PersonInCharge = ws.Rows[p.Index].Cells[7].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[7].Value.ToString()).ID,
892
                               JobLevel = ws.Rows[p.Index].Cells[8].Value == null ? string.Empty : ws.Rows[p.Index].Cells[8].Value.ToString(),
893
                               IsTypical = ws.Rows[p.Index].Cells[9].Value == null ? string.Empty : ws.Rows[p.Index].Cells[9].Value.ToString(),
894
                               RevisonNo = ws.Rows[p.Index].Cells[10].Value == null ? string.Empty : ws.Rows[p.Index].Cells[10].Value.ToString(),
895
                               ToIsDiscussion = ws.Rows[p.Index].Cells[11].Value == null ? string.Empty : ws.Rows[p.Index].Cells[11].Value.ToString(),
896
                               ToRemarks = ws.Rows[p.Index].Cells[12].Value == null ? string.Empty : ws.Rows[p.Index].Cells[12].Value.ToString(),
897
                               ToCreator = ws.Rows[p.Index].Cells[13].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[13].Value.ToString()).ID,
898
                               //ToCapturePath = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
899
                               //ToIsMarkup = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
900
                               FrReviewStatus = ws.Rows[p.Index].Cells[16].Value == null ? string.Empty : ws.Rows[p.Index].Cells[16].Value.ToString(),
901
                               FrRemarks = ws.Rows[p.Index].Cells[17].Value == null ? string.Empty : ws.Rows[p.Index].Cells[17].Value.ToString(),
902
                               FrCreator = ws.Rows[p.Index].Cells[18].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[18].Value.ToString()).ID,
903
                               //FrCapturePath = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
904
                               //FrIsMarkup = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
905
                               IsID2Work = ws.Rows[p.Index].Cells[21].Value == null ? string.Empty : ws.Rows[p.Index].Cells[21].Value.ToString(),
906
                               //ID2Connection = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
907
                               ID2StartDate = ws.Rows[p.Index].Cells[23].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[23].Value?.ToString()),
908
                               ID2EndDate = ws.Rows[p.Index].Cells[24].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[24].Value?.ToString()),
909
                               //ID2JobTime = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
910
                               ID2Status = ws.Rows[p.Index].Cells[26].Value == null ? string.Empty : ws.Rows[p.Index].Cells[26].Value.ToString(),
911
                               ID2Issues = ws.Rows[p.Index].Cells[27].Value == null ? string.Empty : ws.Rows[p.Index].Cells[27].Value.ToString(),
912
                               //AVEVAConnection = ws.Rows[p.Index].Cells[5].Value == null ? string.Empty : ws.Rows[p.Index].Cells[5].Value.ToString(),
913
                               AVEVAConvertDate = ws.Rows[p.Index].Cells[29].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[29].Value.ToString()),
914
                               AVEVAReviewDate = ws.Rows[p.Index].Cells[30].Value == null ? (DateTime?)null : Convert.ToDateTime(ws.Rows[p.Index].Cells[30].Value.ToString()),
915
                               AVEVAStatus = ws.Rows[p.Index].Cells[31].Value == null ? string.Empty : ws.Rows[p.Index].Cells[31].Value.ToString(),
916
                               AVEVAIssues = ws.Rows[p.Index].Cells[32].Value == null ? string.Empty : ws.Rows[p.Index].Cells[32].Value.ToString(),
917
                               ProdReviewer = ws.Rows[p.Index].Cells[35].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[35].Value.ToString()).ID,
918
                               ProdIsResult = ws.Rows[p.Index].Cells[36].Value == null ? string.Empty : ws.Rows[p.Index].Cells[36].Value.ToString(),
919
                               ProdRemarks = ws.Rows[p.Index].Cells[37].Value == null ? string.Empty : ws.Rows[p.Index].Cells[37].Value.ToString(),
920
                               ClientReviewer = ws.Rows[p.Index].Cells[38].Value == null ? string.Empty : this.GetUser(ws.Rows[p.Index].Cells[38].Value.ToString()).ID,
921
                               ClientIsResult = ws.Rows[p.Index].Cells[39].Value == null ? string.Empty : ws.Rows[p.Index].Cells[39].Value.ToString(),
922
                               ClientRemarks = ws.Rows[p.Index].Cells[40].Value == null ? string.Empty : ws.Rows[p.Index].Cells[40].Value.ToString(),
923
                               DTIsGateWay = ws.Rows[p.Index].Cells[41].Value == null ? string.Empty : ws.Rows[p.Index].Cells[41].Value.ToString(),
924
                               DTIsImport = ws.Rows[p.Index].Cells[42].Value == null ? string.Empty : ws.Rows[p.Index].Cells[42].Value.ToString(),
925
                               DTIsRegSystem = ws.Rows[p.Index].Cells[43].Value == null ? string.Empty : ws.Rows[p.Index].Cells[43].Value.ToString(),
926
                               DTRemarks = ws.Rows[p.Index].Cells[44].Value == null ? string.Empty : ws.Rows[p.Index].Cells[44].Value.ToString()
927
                           }));
928

    
929
                    this.documents.AddRange(appendDocuments);
930
                    if (this.orgDocuments == null) this.orgDocuments = new List<Documents>();
931
                    this.DocumentListBinding();
932

    
933
                    //foreach (Documents appDoc in appendDocuments)
934
                    //{
935
                    //    GridViewRowInfo rowInfo = this.radGridViewDocuments.Rows.AddNew();
936

    
937
                    //    foreach (FieldInfo fieldInfo in appDoc.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly))
938
                    //    {
939
                    //        if (fieldInfo.GetValue(appDoc) != null)
940
                    //        {
941
                    //            var cols = rowInfo.Cells.Where(x => fieldInfo.Name.Contains($"<{x.ColumnInfo.Name}>"));
942

    
943
                    //            if (cols.Any())
944
                    //            {
945
                    //                cols.FirstOrDefault().Value = fieldInfo.GetValue(appDoc);
946
                    //            }
947
                    //        }
948
                    //    }
949
                    //}
950
                }
951
            }
952
        }
953

    
954
        private void RadButtonElementExcelExport_Click(object sender, EventArgs e)
955
        {
956
            string sPrefixName = "Samsung Elec Task Management";
957
            string extension = ".xlsx";
958

    
959
            using (SaveFileDialog sfd = new SaveFileDialog()
960
            {
961
                FileName = $"{sPrefixName}_{DateTime.Now:yyyyMMddhhmmss}{extension}",
962
                Filter = "Excel|*.xlsx",
963
                Title = "Save an Excel File",
964
                CheckFileExists = false,
965
                CheckPathExists = true,
966
                OverwritePrompt = true
967
            })
968
            {
969
                if (sfd.ShowDialog() == DialogResult.OK)
970
                {
971
                    string fileName = $"{sPrefixName}{extension}";
972
                    string templateFolder = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Template");
973
                    string templateFilePath = Path.Combine(templateFolder, fileName);
974
                    if (!File.Exists(templateFilePath))
975
                    {
976
                        RadMessageBox.Show(this, $"There is no {fileName} in {templateFolder}", "Error", MessageBoxButtons.OK, RadMessageIcon.Error);
977
                        return;
978
                    }
979

    
980
                    if (this.radGridViewDocuments.Rows.Count > 0)
981
                    {
982
                        var templateExcelFile = ExcelFile.Load(templateFilePath);
983
                        var templateWorksheets = templateExcelFile.Worksheets;
984
                        var templateWorksheet = templateWorksheets[0];
985

    
986
                        int rowIndex = 9;
987
                        //int colIndex = 1;
988

    
989
                        foreach (var row in this.radGridViewDocuments.Rows)
990
                        {
991
                            var doc = row.DataBoundItem as Documents;
992

    
993
                            templateWorksheet.Cells[rowIndex, 0].Value = doc.Seq;
994
                            //templateWorksheet.Cells[rowIndex, 1].Value = doc.DocumentNo;
995
                            //templateWorksheet.Cells[rowIndex, 2].Value = doc.DocumentNo;
996
                            //templateWorksheet.Cells[rowIndex, 3].Value = doc.DocumentNo;
997
                            //templateWorksheet.Cells[rowIndex, 4].Value = doc.DocumentNo;
998
                            templateWorksheet.Cells[rowIndex, 5].Value = doc.RefProjectCode;
999
                            templateWorksheet.Cells[rowIndex, 6].Value = doc.DocumentNo;
1000
                            templateWorksheet.Cells[rowIndex, 7].Value = this.GetUser(doc.PersonInCharge).Name;
1001
                            templateWorksheet.Cells[rowIndex, 8].Value = doc.JobLevel;
1002
                            templateWorksheet.Cells[rowIndex, 9].Value = doc.IsTypical;
1003
                            templateWorksheet.Cells[rowIndex, 10].Value = doc.RevisonNo;
1004
                            templateWorksheet.Cells[rowIndex, 11].Value = doc.ToIsDiscussion;
1005
                            templateWorksheet.Cells[rowIndex, 12].Value = doc.ToRemarks;
1006
                            templateWorksheet.Cells[rowIndex, 13].Value = this.GetUser(doc.ToCreator).Name;
1007
                            templateWorksheet.Cells[rowIndex, 14].Value = doc.ToCapturePath;
1008
                            templateWorksheet.Cells[rowIndex, 15].Value = doc.ToIsMarkup;
1009
                            templateWorksheet.Cells[rowIndex, 16].Value = doc.FrReviewStatus;
1010
                            templateWorksheet.Cells[rowIndex, 17].Value = doc.FrRemarks;
1011
                            templateWorksheet.Cells[rowIndex, 18].Value = this.GetUser(doc.FrCreator).Name;
1012
                            templateWorksheet.Cells[rowIndex, 19].Value = doc.FrCapturePath;
1013
                            templateWorksheet.Cells[rowIndex, 20].Value = doc.FrIsMarkup;
1014
                            templateWorksheet.Cells[rowIndex, 21].Value = doc.IsID2Work;
1015
                            templateWorksheet.Cells[rowIndex, 22].Value = doc.ID2Connection;
1016
                            templateWorksheet.Cells[rowIndex, 23].Value = $"{doc.ID2StartDate:yyyy/MM/dd hh:mm:ss}";
1017
                            templateWorksheet.Cells[rowIndex, 24].Value = $"{doc.ID2EndDate:yyyy/MM/dd hh:mm:ss}";
1018
                            templateWorksheet.Cells[rowIndex, 25].Value = doc.ID2JobTime;
1019
                            templateWorksheet.Cells[rowIndex, 26].Value = doc.ID2Status;
1020
                            templateWorksheet.Cells[rowIndex, 27].Value = doc.ID2Issues;
1021
                            templateWorksheet.Cells[rowIndex, 28].Value = doc.AVEVAConnection;
1022
                            templateWorksheet.Cells[rowIndex, 29].Value = $"{doc.AVEVAConvertDate:yyyy/MM/dd}";
1023
                            templateWorksheet.Cells[rowIndex, 30].Value = $"{doc.AVEVAReviewDate:yyyy/MM/dd}";
1024
                            templateWorksheet.Cells[rowIndex, 31].Value = doc.AVEVAStatus;
1025
                            templateWorksheet.Cells[rowIndex, 32].Value = doc.AVEVAIssues;
1026
                            //templateWorksheet.Cells[rowIndex, 33].Value = doc.DocumentNo;
1027
                            //templateWorksheet.Cells[rowIndex, 34].Value = doc.DocumentNo;
1028
                            templateWorksheet.Cells[rowIndex, 35].Value = this.GetUser(doc.ProdReviewer).Name;
1029
                            templateWorksheet.Cells[rowIndex, 36].Value = doc.ProdIsResult;
1030
                            templateWorksheet.Cells[rowIndex, 37].Value = doc.ProdRemarks;
1031
                            templateWorksheet.Cells[rowIndex, 38].Value = this.GetUser(doc.ClientReviewer).Name;
1032
                            templateWorksheet.Cells[rowIndex, 39].Value = doc.ClientIsResult;
1033
                            templateWorksheet.Cells[rowIndex, 40].Value = doc.ClientRemarks;
1034
                            templateWorksheet.Cells[rowIndex, 41].Value = doc.DTIsGateWay;
1035
                            templateWorksheet.Cells[rowIndex, 42].Value = doc.DTIsImport;
1036
                            templateWorksheet.Cells[rowIndex, 43].Value = doc.DTIsRegSystem;
1037
                            templateWorksheet.Cells[rowIndex, 44].Value = doc.DTRemarks;
1038
                            rowIndex++;
1039
                        }
1040

    
1041
                        templateExcelFile.Save(sfd.FileName);
1042
                        RadMessageBox.Show("Exporting 'ID2 Document List' is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1043
                    }
1044
                }
1045
            }
1046
        }
1047
        #endregion
1048

    
1049
        #region Save event
1050
        private void RadButtonElementSave_Click(object sender, EventArgs e)
1051
        {
1052
            List <Documents> setDocuments = new List<Documents>();
1053
            List<Documents> delDocuments = new List<Documents>();
1054

    
1055
            var worker = new DocumentsWorker(this.documents, this.orgDocuments, setDocuments, delDocuments, this.radGridViewDocuments);
1056
            worker.OnWorkCompletedHandler += () =>
1057
            {
1058
                bool result = new DocumentController().SetDocumentData(setDocuments, delDocuments);
1059

    
1060
                bool markusResult = new MarkusInfoController().SetMarkusInfo(this.documents);
1061

    
1062
                if (result && markusResult)
1063
                {
1064
                    RadMessageBox.Show("Save is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info);
1065

    
1066
                    this.GetDocList();
1067
                }
1068
                else if(!result)
1069
                {
1070
                    RadMessageBox.Show("Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1071
                }
1072
                else if (!markusResult)
1073
                {
1074
                    RadMessageBox.Show("Markus Data Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error);
1075
                }
1076
            };
1077
            worker.StartWork();
1078
        }
1079
        #endregion
1080

    
1081
        #region ColumnGroup
1082
        private void InitColumnGroupsViewDefinition(RadGridView gridView)
1083
        {
1084
            ColumnGroupsViewDefinition columnGroupsView = new ColumnGroupsViewDefinition();
1085

    
1086
            List<string> docLinkColNames = new List<string>() { "AutoCADLink", "PDFLink", "MarkupLink", "AVEVALink" };
1087
            List<string> docInfoColNames = new List<string>() { "RefProjectCode", "DocumentNo", "PersonInCharge", "JobLevel", "IsTypical", "RevisonNo" };
1088
            List<string> rvToColNames = new List<string>() { "ToIsDiscussion", "ToRemarks", "ToCreator", "ToCapturePath", "ToIsMarkup" };
1089
            List<string> rvFrColNames = new List<string>() { "FrReviewStatus", "FrRemarks", "FrCreator", "FrCapturePath", "FrIsMarkup" };
1090
            List<string> rvEtcColNames = new List<string>() { "IsID2Work" };
1091
            List<string> wkID2ColNames = new List<string>() { "ID2Connection", "ID2StartDate", "ID2EndDate", "ID2JobTime", "ID2Status", "ID2Issues" };
1092
            List<string> wkAVEVAColNames = new List<string>() { "AVEVAConnection", "AVEVAConvertDate", "AVEVAReviewDate", "AVEVAStatus", "AVEVAIssues" };
1093
            List<string> valLinkColNames = new List<string>() { "ReviewFileName", "SystemLink" };
1094
            List<string> valProdColNames = new List<string>() { "ProdReviewer", "ProdIsResult", "ProdRemarks" };
1095
            List<string> valCntColNames = new List<string>() { "ClientReviewer", "ClientIsResult", "ClientRemarks" };
1096
            List<string> dtColNames = new List<string>() { "DTIsGateWay", "DTIsImport", "DTIsRegSystem", "DTRemarks" };
1097

    
1098
            //도면
1099
            GridViewColumnGroup docColGrp = new GridViewColumnGroup("도면 ");
1100
            GridViewColumnGroup docLinkColGrp = new GridViewColumnGroup("파일링크");
1101
            GridViewColumnGroup docInfoColGrp = new GridViewColumnGroup("도면정보");
1102

    
1103
            GridViewColumnGroupRow docLinkColGrpRow = new GridViewColumnGroupRow();
1104
            docLinkColGrpRow.ColumnNames.AddRange(docLinkColNames);
1105

    
1106
            GridViewColumnGroupRow docInfoColGrpRow = new GridViewColumnGroupRow();
1107
            docInfoColGrpRow.ColumnNames.AddRange(docInfoColNames);
1108

    
1109
            docLinkColGrp.Rows.Add(docLinkColGrpRow);
1110
            docColGrp.Groups.Add(docLinkColGrp);
1111
            docInfoColGrp.Rows.Add(docInfoColGrpRow);
1112
            docColGrp.Groups.Add(docInfoColGrp);
1113

    
1114
            //검토
1115
            GridViewColumnGroup rvColGrp = new GridViewColumnGroup("검토", "review");
1116
            GridViewColumnGroup rvToColGrp = new GridViewColumnGroup("도프텍");
1117
            GridViewColumnGroup rvFrColGrp = new GridViewColumnGroup("삼성");
1118
            GridViewColumnGroup rvEtcColGrp = new GridViewColumnGroup("기타");
1119

    
1120
            GridViewColumnGroupRow rvToColGrpRow = new GridViewColumnGroupRow();
1121
            rvToColGrpRow.ColumnNames.AddRange(rvToColNames);
1122

    
1123
            GridViewColumnGroupRow rvFrColGrpRow = new GridViewColumnGroupRow();
1124
            rvFrColGrpRow.ColumnNames.AddRange(rvFrColNames);
1125

    
1126
            GridViewColumnGroupRow rvEtcColGrpRow = new GridViewColumnGroupRow();
1127
            rvEtcColGrpRow.ColumnNames.AddRange(rvEtcColNames);
1128

    
1129
            rvToColGrp.Rows.Add(rvToColGrpRow);
1130
            rvFrColGrp.Rows.Add(rvFrColGrpRow);
1131
            rvEtcColGrp.Rows.Add(rvEtcColGrpRow);
1132

    
1133

    
1134
            rvColGrp.Groups.Add(rvToColGrp);
1135
            rvColGrp.Groups.Add(rvFrColGrp);
1136
            rvColGrp.Groups.Add(rvEtcColGrp);
1137

    
1138

    
1139
            //작업
1140
            GridViewColumnGroup wkColGrp = new GridViewColumnGroup("작업", "work");
1141
            GridViewColumnGroup wkID2ColGrp = new GridViewColumnGroup("ID2");
1142
            GridViewColumnGroup wkAVEVAColGrp = new GridViewColumnGroup("AVEVA");
1143

    
1144
            GridViewColumnGroupRow wkID2ColGrpRow = new GridViewColumnGroupRow();
1145
            wkID2ColGrpRow.ColumnNames.AddRange(wkID2ColNames);
1146

    
1147
            GridViewColumnGroupRow wkAVEVAColGrpRow = new GridViewColumnGroupRow();
1148
            wkAVEVAColGrpRow.ColumnNames.AddRange(wkAVEVAColNames);
1149

    
1150
            wkID2ColGrp.Rows.Add(wkID2ColGrpRow);
1151
            wkAVEVAColGrp.Rows.Add(wkAVEVAColGrpRow);
1152

    
1153
            wkColGrp.Groups.Add(wkID2ColGrp);
1154
            wkColGrp.Groups.Add(wkAVEVAColGrp);
1155

    
1156

    
1157
            //Validation
1158
            GridViewColumnGroup valColGrp = new GridViewColumnGroup("Validation", "validation");
1159
            GridViewColumnGroup valLinkColGrp = new GridViewColumnGroup("파일링크");
1160
            GridViewColumnGroup valProdColGrp = new GridViewColumnGroup("도프텍");
1161
            GridViewColumnGroup valCntColGrp = new GridViewColumnGroup("삼성전자");
1162

    
1163
            GridViewColumnGroupRow valLinkColGrpRow = new GridViewColumnGroupRow();
1164
            valLinkColGrpRow.ColumnNames.AddRange(valLinkColNames);
1165

    
1166
            GridViewColumnGroupRow valProdColGrpRow = new GridViewColumnGroupRow();
1167
            valProdColGrpRow.ColumnNames.AddRange(valProdColNames);
1168

    
1169
            GridViewColumnGroupRow valCntColGrpRow = new GridViewColumnGroupRow();
1170
            valCntColGrpRow.ColumnNames.AddRange(valCntColNames);
1171

    
1172
            valLinkColGrp.Rows.Add(valLinkColGrpRow);
1173
            valProdColGrp.Rows.Add(valProdColGrpRow);
1174
            valCntColGrp.Rows.Add(valCntColGrpRow);
1175

    
1176
            valColGrp.Groups.Add(valLinkColGrp);
1177
            valColGrp.Groups.Add(valProdColGrp);
1178
            valColGrp.Groups.Add(valCntColGrp);
1179

    
1180
            //AVEVA Net
1181
            GridViewColumnGroup dtColGrp = new GridViewColumnGroup("AVEVA Net\n(Digital Twin)", "avevanet");
1182

    
1183
            GridViewColumnGroupRow dtColGrpRow = new GridViewColumnGroupRow();
1184
            dtColGrpRow.ColumnNames.AddRange(dtColNames);
1185

    
1186
            dtColGrp.Rows.Add(dtColGrpRow);
1187

    
1188
            //Group 추가
1189
            columnGroupsView.ColumnGroups.Add(docColGrp);
1190
            columnGroupsView.ColumnGroups.Add(rvColGrp);
1191
            columnGroupsView.ColumnGroups.Add(wkColGrp);
1192
            columnGroupsView.ColumnGroups.Add(valColGrp);
1193
            columnGroupsView.ColumnGroups.Add(dtColGrp);
1194

    
1195
            gridView.MasterTemplate.ViewDefinition = columnGroupsView;
1196
        }
1197
        #endregion
1198

    
1199
        class DocumentsWorker : BaseWorker
1200
        {
1201
            public delegate void OnWorkCompleted();
1202
            public OnWorkCompleted OnWorkCompletedHandler;
1203

    
1204
            List<Documents> docList { get; set; }
1205
            List<Documents> orgList { get; set; }
1206
            List<Documents> setList { get; set; }
1207
            List<Documents> delList { get; set; }
1208

    
1209
            public DocumentsWorker(List<Documents> docList, List<Documents> orgDocList, List<Documents> setDocList, List<Documents> delDocList, Control parent = null) : base(parent)
1210
            {
1211
                this.docList = docList;
1212
                this.orgList = orgDocList;
1213
                this.setList = setDocList;
1214
                this.delList = delDocList;
1215
            }
1216
            protected override void DoWork(BackgroundWorker worker)
1217
            {
1218
                //수정리스트
1219
                this.docList.Where(x => !this.orgList.Any(y => y.Equals(x)))
1220
                              .ToList().ForEach(x => this.setList.Add(x));
1221
                //삭제리스트
1222
                this.delList.AddRange(this.orgList.Except(this.docList, new DocumentsKeyComparer()));
1223
            }
1224

    
1225
            protected override void WorkCompleted()
1226
            {
1227
                if (this.OnWorkCompletedHandler != null) this.OnWorkCompletedHandler();
1228
            }
1229
        }
1230

    
1231
        private void txtFullSearch_TextChanged(object sender, EventArgs e)
1232
        {
1233
           if(string.IsNullOrWhiteSpace(txtFullSearch.Text))
1234
                radGridViewDocuments.MasterTemplate.Refresh(null);
1235

    
1236
            txtFullSearch.TextBoxElement.ShowClearButton = !string.IsNullOrWhiteSpace(txtFullSearch.Text);
1237
            radGridViewDocuments.MasterView.TableSearchRow.Search(txtFullSearch.Text);
1238

    
1239
        }
1240

    
1241
        private void btnSearchPrevious_Click(object sender, EventArgs e)
1242
        {
1243
            
1244
            radGridViewDocuments.MasterView.TableSearchRow.SelectPreviousSearchResult();
1245
        }
1246

    
1247
        private void btnSearchNext_Click(object sender, EventArgs e)
1248
        {
1249
            radGridViewDocuments.MasterView.TableSearchRow.SelectNextSearchResult();
1250
        }
1251
    }
1252
}
1253

    
1254
public class FilterColumn
1255
{
1256
    public string Name { get; set; }
1257
    public string FieldName { get; set; }
1258
    public bool IsSelect { get; set; }
1259
}
클립보드 이미지 추가 (최대 크기: 500 MB)