hytos / DTI_PID / ID2PSN / Form / EquipmentSetting.cs @ 284fa2c9
이력 | 보기 | 이력해설 | 다운로드 (21.9 KB)
1 |
using DevExpress.Utils.Drawing; |
---|---|
2 |
using DevExpress.XtraEditors.Controls; |
3 |
using DevExpress.XtraEditors.Repository; |
4 |
using DevExpress.XtraGrid.Columns; |
5 |
using DevExpress.XtraGrid.Views.Grid; |
6 |
using System; |
7 |
using System.Collections.Generic; |
8 |
using System.ComponentModel; |
9 |
using System.Data; |
10 |
using System.Drawing; |
11 |
using System.IO; |
12 |
using System.Linq; |
13 |
using System.Text; |
14 |
using System.Threading.Tasks; |
15 |
using System.Windows.Forms; |
16 |
|
17 |
namespace ID2PSN |
18 |
{ |
19 |
public partial class EquipmentSetting : DevExpress.XtraBars.Ribbon.RibbonForm |
20 |
{ |
21 |
ID2Info ID2Info = ID2Info.GetInstance(); |
22 |
List<EquipmentNoPocketInfo> EquipmentNoPocketInfos = new List<EquipmentNoPocketInfo>(); |
23 |
EquipmentNoPocketInfo currentEquipmentNoPocketInfo = null; |
24 |
private RepositoryItemComboBox repositoryGroupType = new RepositoryItemComboBox(); |
25 |
|
26 |
List<EquipmentAirFinCoolerInfo> EquipmentAirFinCoolerInfos = new List<EquipmentAirFinCoolerInfo>(); |
27 |
EquipmentAirFinCoolerInfo currentEquipmentAirFinCoolerInfo = null; |
28 |
private RepositoryItemComboBox repositoryGroupType2 = new RepositoryItemComboBox(); |
29 |
|
30 |
private RepositoryItemComboBox repositoryAttributeItem = new RepositoryItemComboBox(); |
31 |
private DataTable SymbolList = new DataTable(); |
32 |
public EquipmentSetting() |
33 |
{ |
34 |
InitializeComponent(); |
35 |
|
36 |
InitGridEquipmentNoPocket(); |
37 |
InitGridEquipmentAirFinCooler(); |
38 |
|
39 |
gridViewAirFinCooler.CellValueChanging += new DevExpress.XtraGrid.Views.Base.CellValueChangedEventHandler(gridViewSymbol_CellValueChanged); |
40 |
|
41 |
EquipmentNoPocketInfos = new List<EquipmentNoPocketInfo>(); |
42 |
currentEquipmentNoPocketInfo = new EquipmentNoPocketInfo(); |
43 |
|
44 |
EquipmentAirFinCoolerInfos = new List<EquipmentAirFinCoolerInfo>(); |
45 |
currentEquipmentAirFinCoolerInfo = new EquipmentAirFinCoolerInfo(); |
46 |
|
47 |
InitData(); |
48 |
InitAirFinCoolerData(); |
49 |
} |
50 |
|
51 |
private void gridViewSymbol_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) |
52 |
{ |
53 |
if (e.Column.FieldName == "Type") |
54 |
{ |
55 |
DevExpress.XtraGrid.Views.Base.ColumnView columnView = sender as DevExpress.XtraGrid.Views.Base.ColumnView; |
56 |
if (!string.IsNullOrEmpty(e.Value.ToString())) |
57 |
{ |
58 |
string selectItem = e.Value.ToString(); |
59 |
DataTable dt = gridControlAirFinCooler.DataSource as DataTable; |
60 |
if (selectItem.Contains("Air Fin Cooler")) |
61 |
{ |
62 |
dt.Rows[columnView.FocusedRowHandle]["TagIdentifier"] = "AFC"; |
63 |
} |
64 |
else if (selectItem.Contains("Pump")) |
65 |
{ |
66 |
dt.Rows[columnView.FocusedRowHandle]["TagIdentifier"] = "P"; |
67 |
} |
68 |
} |
69 |
} |
70 |
|
71 |
} |
72 |
|
73 |
public void InitGridEquipmentNoPocket() |
74 |
{ |
75 |
RepositoryItemButtonEdit btnRemove = new RepositoryItemButtonEdit(); |
76 |
btnRemove.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor; |
77 |
btnRemove.ButtonClick += new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(removeSymbolButton_Click); |
78 |
btnRemove.Buttons[0].Kind = DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph; |
79 |
btnRemove.Buttons[0].ImageOptions.Image = ID2PSN.Properties.Resources.cancel_16x16; |
80 |
|
81 |
gridEquipment.RepositoryItems.Add(btnRemove); |
82 |
|
83 |
DataTable dtType = new DataTable(); |
84 |
dtType.Columns.Add("Index"); |
85 |
dtType.Columns.Add("Type"); |
86 |
dtType.Columns.Add("SppidSymbolName"); |
87 |
dtType.Columns.Add(" "); |
88 |
gridEquipment.DataSource = dtType; |
89 |
|
90 |
GridColumn gridColumn = gridViewEquipment.Columns[0]; |
91 |
|
92 |
|
93 |
gridColumn.Name = "Index"; |
94 |
gridColumn.Caption = "Index"; |
95 |
gridColumn.OptionsColumn.AllowEdit = false; |
96 |
gridColumn.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False; |
97 |
gridColumn.VisibleIndex = 0; |
98 |
|
99 |
repositoryGroupType = new RepositoryItemComboBox(); |
100 |
repositoryGroupType.Items.AddRange(new string[] { "Pump", "Vertical Vessel" }); |
101 |
repositoryGroupType.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; |
102 |
|
103 |
gridEquipment.RepositoryItems.Add(repositoryGroupType); |
104 |
gridColumn = gridViewEquipment.Columns[1]; |
105 |
gridColumn.Name = "Type"; |
106 |
gridColumn.Caption = "Equipment Type"; |
107 |
gridColumn.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False; |
108 |
gridColumn.VisibleIndex = 1; |
109 |
gridViewEquipment.Columns["Type"].ColumnEdit = repositoryGroupType; |
110 |
|
111 |
gridColumn = gridViewEquipment.Columns[2]; |
112 |
gridColumn.Name = "SppidSymbolName"; |
113 |
gridColumn.Caption = "ID2 Symbol Name"; |
114 |
gridColumn.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False; |
115 |
gridColumn.VisibleIndex = 2; |
116 |
|
117 |
RepositoryItemTreeListLookUpEdit treeListLookUpEdit = new RepositoryItemTreeListLookUpEdit(); |
118 |
gridEquipment.RepositoryItems.Add(treeListLookUpEdit); |
119 |
SetSymbol(treeListLookUpEdit); |
120 |
|
121 |
gridViewEquipment.Columns["SppidSymbolName"].ColumnEdit = treeListLookUpEdit; |
122 |
|
123 |
gridColumn = gridViewEquipment.Columns[3]; |
124 |
gridColumn.Name = "Remove"; |
125 |
gridColumn.Caption = ""; |
126 |
gridColumn.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False; |
127 |
gridColumn.VisibleIndex = 3; |
128 |
gridColumn.MaxWidth = 16; |
129 |
|
130 |
gridColumn.ColumnEdit = btnRemove; |
131 |
gridColumn.ShowButtonMode = DevExpress.XtraGrid.Views.Base.ShowButtonModeEnum.ShowAlways; |
132 |
} |
133 |
|
134 |
public void InitGridEquipmentAirFinCooler() |
135 |
{ |
136 |
RepositoryItemButtonEdit btnRemove = new RepositoryItemButtonEdit(); |
137 |
btnRemove.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor; |
138 |
btnRemove.ButtonClick += new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(removeAirSymbolButton_Click); |
139 |
btnRemove.Buttons[0].Kind = DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph; |
140 |
btnRemove.Buttons[0].ImageOptions.Image = ID2PSN.Properties.Resources.cancel_16x16; |
141 |
|
142 |
gridControlAirFinCooler.RepositoryItems.Add(btnRemove); |
143 |
|
144 |
DataTable dtType = new DataTable(); |
145 |
dtType.Columns.Add("Index"); |
146 |
dtType.Columns.Add("Type"); |
147 |
dtType.Columns.Add("TagIdentifier"); |
148 |
dtType.Columns.Add("AttributeName"); |
149 |
dtType.Columns.Add("SppidSymbolName"); |
150 |
dtType.Columns.Add(" "); |
151 |
gridControlAirFinCooler.DataSource = dtType; |
152 |
|
153 |
GridColumn gridColumn = gridViewAirFinCooler.Columns[0]; |
154 |
|
155 |
gridColumn.Name = "Index"; |
156 |
gridColumn.Caption = "Index"; |
157 |
gridColumn.OptionsColumn.AllowEdit = false; |
158 |
gridColumn.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False; |
159 |
gridColumn.VisibleIndex = 0; |
160 |
|
161 |
repositoryGroupType2 = new RepositoryItemComboBox(); |
162 |
repositoryGroupType2.Items.AddRange(new string[] { "Air Fin Cooler", "Pump" }); |
163 |
repositoryGroupType2.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; |
164 |
|
165 |
gridControlAirFinCooler.RepositoryItems.Add(repositoryGroupType2); |
166 |
gridColumn = gridViewAirFinCooler.Columns[1]; |
167 |
gridColumn.Name = "Type"; |
168 |
gridColumn.Caption = "Equipment Type"; |
169 |
gridColumn.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False; |
170 |
gridColumn.VisibleIndex = 1; |
171 |
gridViewAirFinCooler.Columns["Type"].ColumnEdit = repositoryGroupType2; |
172 |
|
173 |
gridColumn = gridViewAirFinCooler.Columns[2]; |
174 |
gridColumn.Name = "TagIdentifier"; |
175 |
gridColumn.Caption = "Prefix"; |
176 |
gridColumn.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False; |
177 |
gridColumn.VisibleIndex = 2; |
178 |
|
179 |
repositoryAttributeItem.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; |
180 |
repositoryAttributeItem.AppearanceDropDown.Font = Font; |
181 |
gridControlAirFinCooler.RepositoryItems.Add(repositoryAttributeItem); |
182 |
|
183 |
gridColumn = gridViewAirFinCooler.Columns[3]; |
184 |
gridColumn.Name = "AttributeName"; |
185 |
gridColumn.Caption = "ID2 Attribute Name"; |
186 |
gridColumn.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False; |
187 |
gridColumn.VisibleIndex = 3; |
188 |
gridViewAirFinCooler.Columns["AttributeName"].ColumnEdit = repositoryAttributeItem; |
189 |
|
190 |
gridColumn = gridViewAirFinCooler.Columns[4]; |
191 |
gridColumn.Name = "SppidSymbolName"; |
192 |
gridColumn.Caption = "ID2 Symbol Name"; |
193 |
gridColumn.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False; |
194 |
gridColumn.VisibleIndex = 4; |
195 |
|
196 |
SymbolList = DB.SelectAllSymbolAttribute(); |
197 |
|
198 |
RepositoryItemTreeListLookUpEdit treeListLookUpEdit = new RepositoryItemTreeListLookUpEdit(); |
199 |
gridControlAirFinCooler.RepositoryItems.Add(treeListLookUpEdit); |
200 |
SetSymbol(treeListLookUpEdit); |
201 |
|
202 |
gridViewAirFinCooler.Columns["SppidSymbolName"].ColumnEdit = treeListLookUpEdit; |
203 |
|
204 |
gridColumn = gridViewAirFinCooler.Columns[5]; |
205 |
gridColumn.Name = "Remove"; |
206 |
gridColumn.Caption = ""; |
207 |
gridColumn.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False; |
208 |
gridColumn.VisibleIndex = 5; |
209 |
gridColumn.MaxWidth = 16; |
210 |
|
211 |
gridColumn.ColumnEdit = btnRemove; |
212 |
gridColumn.ShowButtonMode = DevExpress.XtraGrid.Views.Base.ShowButtonModeEnum.ShowAlways; |
213 |
gridViewAirFinCooler.CustomRowCellEditForEditing += GridViewAirFinCooler_CustomRowCellEditForEditing; |
214 |
} |
215 |
|
216 |
private void GridViewAirFinCooler_CustomRowCellEditForEditing(object sender, CustomRowCellEditEventArgs e) |
217 |
{ |
218 |
if (e.Column == (sender as GridView).Columns["AttributeName"]) |
219 |
{ |
220 |
DevExpress.XtraGrid.Views.Base.ColumnView columnView = sender as DevExpress.XtraGrid.Views.Base.ColumnView; |
221 |
DataTable dt = gridControlAirFinCooler.DataSource as DataTable; |
222 |
string SppidSymbolName = dt.Rows[columnView.FocusedRowHandle]["SppidSymbolName"].ToString(); |
223 |
|
224 |
if (string.IsNullOrEmpty(SppidSymbolName)) |
225 |
{ |
226 |
MessageBox.Show("Choose a symbol !", "ID2 " + ID2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information); |
227 |
return; |
228 |
} |
229 |
|
230 |
repositoryAttributeItem.Items.Clear(); |
231 |
repositoryAttributeItem.Items.Add(""); |
232 |
// repositoryAttributeItem.Items.Add("NoSelection"); |
233 |
foreach (DataRow dr in SymbolList.Rows) |
234 |
{ |
235 |
if (dr["SymbolName"].ToString().ToUpper().Equals(SppidSymbolName.ToUpper())) |
236 |
{ |
237 |
repositoryAttributeItem.Items.Add(dr["SymbolAttribute"].ToString()); |
238 |
} |
239 |
} |
240 |
} |
241 |
} |
242 |
|
243 |
private void GridViewKeyword_CustomDrawColumnHeader(object sender, ColumnHeaderCustomDrawEventArgs e) |
244 |
{ |
245 |
if (e.Column == null || (e.Column.AppearanceHeader.BackColor == Color.Empty && !e.Column.AppearanceHeader.Options.UseBackColor)) |
246 |
|
247 |
return; |
248 |
|
249 |
Rectangle rect = e.Bounds; |
250 |
|
251 |
rect.Inflate(-1, -1); |
252 |
|
253 |
// Fill the title color. |
254 |
|
255 |
e.Graphics.FillRectangle(new SolidBrush(e.Column.AppearanceHeader.BackColor), rect); |
256 |
|
257 |
e.Appearance.DrawString(e.Cache, e.Info.Caption, e.Info.CaptionRect); |
258 |
|
259 |
// Draw filter and sort buttons. |
260 |
|
261 |
foreach (DrawElementInfo info in e.Info.InnerElements) |
262 |
|
263 |
{ |
264 |
|
265 |
if (!info.Visible) continue; |
266 |
|
267 |
ObjectPainter.DrawObject(e.Cache, info.ElementPainter, info.ElementInfo); |
268 |
|
269 |
} |
270 |
|
271 |
e.Handled = true; |
272 |
} |
273 |
|
274 |
public void InitData() |
275 |
{ |
276 |
DataTable dt = DB.SelectEquipmentNoPocketSetting(); |
277 |
DataTable typeDT = gridEquipment.DataSource as DataTable; |
278 |
foreach (DataRow row in dt.Rows) |
279 |
{ |
280 |
int index = Convert.ToInt32(row["INDEX"]); |
281 |
string Type = row["TYPE"].ToString(); |
282 |
string SppidSymbolName = row["NAME"].ToString(); |
283 |
|
284 |
typeDT.Rows.Add(index, Type, SppidSymbolName, null); |
285 |
} |
286 |
|
287 |
} |
288 |
|
289 |
public void InitAirFinCoolerData() |
290 |
{ |
291 |
DataTable dt = DB.SelectAirFinCoolerSetting(); |
292 |
DataTable typeDT = gridControlAirFinCooler.DataSource as DataTable; |
293 |
foreach (DataRow row in dt.Rows) |
294 |
{ |
295 |
int index = Convert.ToInt32(row["INDEX"]); |
296 |
string Type = row["TYPE"].ToString(); |
297 |
string TagIdentifier = row["TagIdentifier"].ToString(); |
298 |
string AttributeName = row["AttributeName"].ToString(); |
299 |
string SppidSymbolName = row["NAME"].ToString(); |
300 |
|
301 |
typeDT.Rows.Add(index, Type, TagIdentifier, AttributeName, SppidSymbolName, null); |
302 |
} |
303 |
|
304 |
} |
305 |
|
306 |
private void removeSymbolButton_Click(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) |
307 |
{ |
308 |
DataTable dt = gridEquipment.DataSource as DataTable; |
309 |
DataRow rows = dt.Rows[gridViewEquipment.FocusedRowHandle]; |
310 |
if (rows != null) |
311 |
dt.Rows.Remove(rows); |
312 |
} |
313 |
|
314 |
private void removeAirSymbolButton_Click(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) |
315 |
{ |
316 |
DataTable dt = gridControlAirFinCooler.DataSource as DataTable; |
317 |
DataRow rows = dt.Rows[gridViewAirFinCooler.FocusedRowHandle]; |
318 |
if (rows != null) |
319 |
dt.Rows.Remove(rows); |
320 |
} |
321 |
|
322 |
public void SetSymbol(RepositoryItemTreeListLookUpEdit treeListLookUpEdit) |
323 |
{ |
324 |
string imgPath = ID2Info.ImageDirPath; |
325 |
string[] filesPath = Directory.GetFiles(imgPath, "*.png", SearchOption.AllDirectories); |
326 |
|
327 |
DataTable dt = new DataTable(); |
328 |
dt.Columns.Add("ID", typeof(int)); |
329 |
dt.Columns.Add("ParentID", typeof(int)); |
330 |
dt.Columns.Add("Name", typeof(string)); |
331 |
dt.Columns.Add("Level", typeof(int)); |
332 |
dt.Columns.Add("Image", typeof(Image)); |
333 |
dt.PrimaryKey = new DataColumn[] { dt.Columns["ID"] }; |
334 |
|
335 |
treeListLookUpEdit.DataSource = dt; |
336 |
treeListLookUpEdit.ValueMember = "Name"; |
337 |
treeListLookUpEdit.DisplayMember = "Name"; |
338 |
treeListLookUpEdit.TreeList.Columns["Level"].Visible = false; |
339 |
treeListLookUpEdit.NullText = ""; |
340 |
|
341 |
treeListLookUpEdit.EditValueChanging += new DevExpress.XtraEditors.Controls.ChangingEventHandler(TreeList_BeforeCheckNode); |
342 |
|
343 |
treeListLookUpEdit.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup; |
344 |
|
345 |
bool bLine = true; |
346 |
List<string> level1Index = new List<string>(); |
347 |
foreach (var path in filesPath) |
348 |
{ |
349 |
if (Path.GetFileNameWithoutExtension(path).Contains("_display")) |
350 |
continue; |
351 |
|
352 |
string root = path.Remove(0, imgPath.Length); |
353 |
string[] split = root.Split(new string[] { @"\" }, StringSplitOptions.None); |
354 |
string level1 = split[0]; |
355 |
if (!level1Index.Contains(level1)) |
356 |
{ |
357 |
level1Index.Add(level1); |
358 |
dt.Rows.Add(level1Index.IndexOf(level1) + 1, 0, level1, 0); |
359 |
} |
360 |
|
361 |
int parentId = level1Index.IndexOf(level1) + 1; |
362 |
string level2 = split[1]; |
363 |
//combobox image size 변경 |
364 |
Image image = Image.FromFile(Path.Combine(imgPath, root)); |
365 |
Bitmap imgbitmap = new Bitmap(image); |
366 |
Image resizedImage = resizeImage(imgbitmap, new Size(200, 200)); |
367 |
|
368 |
dt.Rows.Add(filesPath.ToList().IndexOf(path) + 10000, parentId, Path.GetFileNameWithoutExtension(path), 1, resizedImage); |
369 |
|
370 |
if (Path.GetFileNameWithoutExtension(path) == "Connect To Process" && bLine) |
371 |
{ |
372 |
bLine = false; |
373 |
dt.Rows.Add(filesPath.ToList().IndexOf(path) + 20000, parentId, "Primary", 1, resizedImage); |
374 |
dt.Rows.Add(filesPath.ToList().IndexOf(path) + 30000, parentId, "Secondary", 1, resizedImage); |
375 |
} |
376 |
} |
377 |
} |
378 |
|
379 |
public static Image resizeImage(Image imgToResize, Size size) |
380 |
{ |
381 |
return (Image)(new Bitmap(imgToResize, size)); |
382 |
} |
383 |
|
384 |
private void btnAddSymbol_Click(object sender, EventArgs e) |
385 |
{ |
386 |
if (currentEquipmentNoPocketInfo == null) |
387 |
{ |
388 |
currentEquipmentNoPocketInfo = new EquipmentNoPocketInfo(); |
389 |
} |
390 |
|
391 |
DataTable dt = gridEquipment.DataSource as DataTable; |
392 |
dt.Rows.Add(dt.Rows.Count + 1, null, null, null); |
393 |
gridViewEquipment.Columns["Index"].BestFit(); |
394 |
} |
395 |
|
396 |
private void btnAddAirSymbol_Click(object sender, EventArgs e) |
397 |
{ |
398 |
if (currentEquipmentAirFinCoolerInfo == null) |
399 |
{ |
400 |
currentEquipmentAirFinCoolerInfo = new EquipmentAirFinCoolerInfo(); |
401 |
} |
402 |
|
403 |
DataTable dt = gridControlAirFinCooler.DataSource as DataTable; |
404 |
dt.Rows.Add(dt.Rows.Count + 1, null, null, null, null, null); |
405 |
gridViewAirFinCooler.Columns["Index"].BestFit(); |
406 |
} |
407 |
|
408 |
public void ReNumbering(EquipmentNoPocketInfo equipmentNoPocketInfo) |
409 |
{ |
410 |
DataTable dt = gridEquipment.DataSource as DataTable; |
411 |
equipmentNoPocketInfo.EquipmentNoPocketItem.Clear(); |
412 |
for (int i = 0; i < dt.Rows.Count; i++) |
413 |
{ |
414 |
DataRow row = dt.Rows[i]; |
415 |
row["Index"] = i + 1; |
416 |
equipmentNoPocketInfo.EquipmentNoPocketItem.Add(new EquipmentNoPocketItem() |
417 |
{ |
418 |
Index = i + 1, |
419 |
Type = row["Type"].ToString(), |
420 |
Name = row["SppidSymbolName"].ToString() |
421 |
}); |
422 |
} |
423 |
} |
424 |
|
425 |
public void ReNumberingAir(EquipmentAirFinCoolerInfo equipmentAirFinCoolerInfo) |
426 |
{ |
427 |
DataTable dt = gridControlAirFinCooler.DataSource as DataTable; |
428 |
equipmentAirFinCoolerInfo.EquipmentAirFinCoolerItem.Clear(); |
429 |
for (int i = 0; i < dt.Rows.Count; i++) |
430 |
{ |
431 |
DataRow row = dt.Rows[i]; |
432 |
row["Index"] = i + 1; |
433 |
equipmentAirFinCoolerInfo.EquipmentAirFinCoolerItem.Add(new EquipmentAirFinCoolerItem() |
434 |
{ |
435 |
Index = i + 1, |
436 |
Type = row["Type"].ToString(), |
437 |
TagIdentifier = row["TagIdentifier"].ToString(), |
438 |
AttributeName = row["AttributeName"].ToString(), |
439 |
Name = row["SppidSymbolName"].ToString() |
440 |
}); |
441 |
} |
442 |
} |
443 |
|
444 |
|
445 |
|
446 |
private void TreeList_BeforeCheckNode(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e) |
447 |
{ |
448 |
DevExpress.XtraEditors.TreeListLookUpEdit treeListLookUpEdit = sender as DevExpress.XtraEditors.TreeListLookUpEdit; |
449 |
if (treeListLookUpEdit.Properties.TreeList.FocusedNode == null) |
450 |
return; |
451 |
|
452 |
if (treeListLookUpEdit.Properties.TreeList.FocusedNode.Level == 0) |
453 |
e.Cancel = true; |
454 |
|
455 |
|
456 |
} |
457 |
|
458 |
private void btnSave_Click(object sender, EventArgs e) |
459 |
{ |
460 |
if (currentEquipmentNoPocketInfo == null) |
461 |
{ |
462 |
currentEquipmentNoPocketInfo = new EquipmentNoPocketInfo(); |
463 |
} |
464 |
|
465 |
if (currentEquipmentAirFinCoolerInfo == null) |
466 |
{ |
467 |
currentEquipmentAirFinCoolerInfo = new EquipmentAirFinCoolerInfo(); |
468 |
} |
469 |
|
470 |
ReNumbering(currentEquipmentNoPocketInfo); |
471 |
ReNumberingAir(currentEquipmentAirFinCoolerInfo); |
472 |
if (currentEquipmentNoPocketInfo.EquipmentNoPocketItem.Find(x => x.Type == string.Empty || x.Name == string.Empty) != null) |
473 |
{ |
474 |
MessageBox.Show("Please save after entering data.", "ID2 " + ID2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
475 |
return; |
476 |
} |
477 |
|
478 |
if (currentEquipmentAirFinCoolerInfo.EquipmentAirFinCoolerItem.Find(x => x.TagIdentifier == string.Empty || x.AttributeName == string.Empty || x.Name == string.Empty) != null) |
479 |
{ |
480 |
IEnumerable<EquipmentAirFinCoolerItem> lstafc = currentEquipmentAirFinCoolerInfo.EquipmentAirFinCoolerItem.Where(x => x.TagIdentifier == string.Empty || x.AttributeName == string.Empty || x.Name == string.Empty); |
481 |
//Scope Break |
482 |
foreach (EquipmentAirFinCoolerItem vg in lstafc) |
483 |
{ |
484 |
if(vg.Type == string.Empty || vg.Name == string.Empty) |
485 |
{ |
486 |
MessageBox.Show("Please save after entering data.", "ID2 " + ID2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
487 |
return; |
488 |
} |
489 |
} |
490 |
} |
491 |
|
492 |
if (DB.SaveEquipmentNopocketSetting(currentEquipmentNoPocketInfo.EquipmentNoPocketItem) && |
493 |
DB.SaveAirFinCoolerSetting(currentEquipmentAirFinCoolerInfo.EquipmentAirFinCoolerItem)) |
494 |
MessageBox.Show("Save was successful", "ID2 " + ID2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information); |
495 |
else |
496 |
MessageBox.Show("Failed to save", "ID2 " + ID2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
497 |
|
498 |
|
499 |
} |
500 |
|
501 |
private void btnClose_Click(object sender, EventArgs e) |
502 |
{ |
503 |
DialogResult = DialogResult.Cancel; |
504 |
} |
505 |
} |
506 |
} |