hytos / ID2.Manager / ID2.Manager / Controls / OpenProjectView.cs @ a23d0a0c
이력 | 보기 | 이력해설 | 다운로드 (5.06 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 ID2.Manager.Forms; |
12 |
using ID2.Manager.Data.Models; |
13 |
using ID2.Manager.Controller.Controllers; |
14 |
using ID2.Manager.Common; |
15 |
|
16 |
using Telerik.WinControls; |
17 |
using Telerik.WinControls.UI; |
18 |
|
19 |
namespace ID2.Manager.Controls |
20 |
{ |
21 |
public partial class OpenProjectView : UserControl |
22 |
{ |
23 |
public List<ProjectInfo> Projects = new List<ProjectInfo>(); |
24 |
public event EventHandler OpenProjectClick; |
25 |
|
26 |
public OpenProjectView() |
27 |
{ |
28 |
InitializeComponent(); |
29 |
|
30 |
this.Load += OpenProjectView_Load; |
31 |
this.radGridViewGroup.SelectionChanged += RadGridViewGroup_SelectionChanged; |
32 |
this.radGridViewGroup.CellDoubleClick += RadGridViewGroup_CellDoubleClick; |
33 |
this.radButtonNew.Click += RadButtonNew_Click; |
34 |
this.radButtonDelete.Click += RadButtonDelete_Click; |
35 |
this.radButtonOpen.Click += RadButtonOpen_Click; |
36 |
} |
37 |
|
38 |
private void OpenProjectView_Load(object sender, EventArgs e) |
39 |
{ |
40 |
this.GetProjectGroups(); |
41 |
} |
42 |
|
43 |
public void GetProjectGroups() |
44 |
{ |
45 |
this.Projects = new ProjectController().GetAllProjectList().ToList(); |
46 |
|
47 |
if (this.radGridViewGroup.DataSource != null) |
48 |
{ |
49 |
this.radGridViewGroup.DataSource = null; |
50 |
} |
51 |
this.radGridViewGroup.DataSource = this.Projects.Where(x => x.Level.Equals(1)); |
52 |
} |
53 |
|
54 |
private void RadGridViewGroup_SelectionChanged(object sender, EventArgs e) |
55 |
{ |
56 |
if (this.radGridViewProjects.DataSource != null) |
57 |
{ |
58 |
this.radGridViewProjects.DataSource = null; |
59 |
} |
60 |
|
61 |
if (this.radGridViewGroup.SelectedRows.Count == 0) return; |
62 |
|
63 |
var projectGroup = this.radGridViewGroup.SelectedRows[0].DataBoundItem as ProjectInfo; |
64 |
|
65 |
this.radGridViewProjects.DataSource = this.Projects.Where(x => x.Level.Equals(2) && x.GroupID.Equals(projectGroup.ProjectID)); |
66 |
} |
67 |
|
68 |
private void RadGridViewGroup_CellDoubleClick(object sender, GridViewCellEventArgs e) |
69 |
{ |
70 |
if (this.radGridViewGroup.SelectedRows.Count == 0) return; |
71 |
|
72 |
var projectGroup = this.radGridViewGroup.SelectedRows[0].DataBoundItem as ProjectInfo; |
73 |
|
74 |
using (var frm = new SetupProject(this.Projects, projectGroup)) |
75 |
{ |
76 |
if (frm.ShowDialog(this) == DialogResult.OK) |
77 |
{ |
78 |
this.GetProjectGroups(); |
79 |
} |
80 |
} |
81 |
} |
82 |
|
83 |
private void RadButtonNew_Click(object sender, EventArgs e) |
84 |
{ |
85 |
using (var frm = new SetupProject(this.Projects)) |
86 |
{ |
87 |
if (frm.ShowDialog(this) == DialogResult.OK) |
88 |
{ |
89 |
this.GetProjectGroups(); |
90 |
} |
91 |
} |
92 |
} |
93 |
|
94 |
private void RadButtonDelete_Click(object sender, EventArgs e) |
95 |
{ |
96 |
if (this.radGridViewGroup.SelectedRows.Count == 0) |
97 |
{ |
98 |
RadMessageBox.Show("Please select a project.", "Error", MessageBoxButtons.OK, RadMessageIcon.Info); |
99 |
return; |
100 |
} |
101 |
|
102 |
if ( RadMessageBox.Show("Do you want to apply the code tables?", Globals.Name, MessageBoxButtons.YesNo, RadMessageIcon.Question) == DialogResult.Yes) |
103 |
{ |
104 |
var projectGroup = this.radGridViewGroup.SelectedRows[0].DataBoundItem as ProjectInfo; |
105 |
|
106 |
bool result = new ProjectController().SetProjectGroupData(projectGroup); |
107 |
if (result) |
108 |
{ |
109 |
RadMessageBox.Show("Delete is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Info); |
110 |
|
111 |
this.GetProjectGroups(); |
112 |
} |
113 |
} |
114 |
} |
115 |
|
116 |
private void RadButtonOpen_Click(object sender, EventArgs e) |
117 |
{ |
118 |
//OpenProjectClick(this, new CaseEventArgs(this.SelectedProject, this.SelectedCase)); |
119 |
|
120 |
if (this.radGridViewGroup.SelectedRows.Count == 0) |
121 |
{ |
122 |
RadMessageBox.Show("Please select a project.", "Error", MessageBoxButtons.OK, RadMessageIcon.Info); |
123 |
return; |
124 |
} |
125 |
|
126 |
var projectGroup = this.radGridViewGroup.SelectedRows[0].DataBoundItem as ProjectInfo; |
127 |
|
128 |
OpenProjectClick?.Invoke(this, new ProjectEventArgs(projectGroup, this.Projects)); |
129 |
} |
130 |
} |
131 |
|
132 |
public class ProjectEventArgs : EventArgs |
133 |
{ |
134 |
private ProjectInfo _ProjectInfo = null; |
135 |
public ProjectInfo ProjectInfo |
136 |
{ |
137 |
get { return _ProjectInfo; } |
138 |
} |
139 |
|
140 |
private List<ProjectInfo> _ProjectList = null; |
141 |
public List<ProjectInfo> ProjectList |
142 |
{ |
143 |
get { return _ProjectList; } |
144 |
} |
145 |
|
146 |
public ProjectEventArgs(ProjectInfo projectInfo, List<ProjectInfo> projectList) |
147 |
{ |
148 |
this._ProjectInfo = projectInfo; |
149 |
this._ProjectList = projectList; |
150 |
} |
151 |
} |
152 |
} |