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