hytos / DTI_PID / SPPIDConverter / ConverterForm.cs @ f1c9dbaa
이력 | 보기 | 이력해설 | 다운로드 (22.6 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 |
using Microsoft.VisualBasic; |
11 |
using Converter.BaseModel; |
12 |
using DevExpress.XtraEditors.Repository; |
13 |
using DevExpress.XtraEditors.Controls; |
14 |
using DevExpress.XtraEditors; |
15 |
using System.Globalization; |
16 |
using System.Threading; |
17 |
using System.IO; |
18 |
using Converter.SPPID.Properties; |
19 |
using Converter.SPPID.DB; |
20 |
using Converter.SPPID.Util; |
21 |
using Converter.SPPID.Form; |
22 |
using Converter.SPPID.Model; |
23 |
|
24 |
namespace Converter.SPPID |
25 |
{ |
26 |
public partial class ConverterForm : DevExpress.XtraBars.Ribbon.RibbonForm |
27 |
{ |
28 |
private Dictionary<string, SPPID_Document> _DicDocuments = new Dictionary<string, SPPID_Document>(); |
29 |
private List<SPPID_Document> _Documents = new List<SPPID_Document>(); |
30 |
public List<SPPID_Document> Documents { get { return _Documents; } } |
31 |
private DataTable _ConverterDT = new DataTable(); |
32 |
private DataTable _SPPIDSymbolPathDT = new DataTable(); |
33 |
private DataTable _SPPIDUnitDT = new DataTable(); |
34 |
private RepositoryItemComboBox templateComboBox; |
35 |
|
36 |
|
37 |
private DataTable _ID2SymbolDT = new DataTable(); |
38 |
private DataTable _ID2LineDT = new DataTable(); |
39 |
private DataTable _ID2AssociationDT = new DataTable(); |
40 |
private DataTable _ID2LinePropertyDT = new DataTable(); |
41 |
private DataTable _ID2SymbolTypeDT = new DataTable(); |
42 |
|
43 |
|
44 |
private List<SymbolMapping> symbolMappings = new List<SymbolMapping>(); |
45 |
private List<LineMapping> lineMappings = new List<LineMapping>(); |
46 |
private List<LineNumberMapping> lineNumberMappings = new List<LineNumberMapping>(); |
47 |
private List<AssociationMapping> associationMappings = new List<AssociationMapping>(); |
48 |
|
49 |
public ConverterForm() |
50 |
{ |
51 |
InitializeComponent(); |
52 |
|
53 |
CultureInfo culture = CultureInfo.GetCultureInfo("ko"); |
54 |
Msg.Culture = culture; |
55 |
|
56 |
InitUsedDataTable(); |
57 |
InitGridControl(); |
58 |
InitID2Project(); |
59 |
} |
60 |
|
61 |
private void InitUsedDataTable() |
62 |
{ |
63 |
// Converter Table |
64 |
DataColumn col = _ConverterDT.Columns.Add("colDrawingFileName"); |
65 |
col.Caption = "Drawing File Name"; |
66 |
col = _ConverterDT.Columns.Add("colDrawingFilePath"); |
67 |
col.Caption = "DrawingFilePath"; |
68 |
col = _ConverterDT.Columns.Add("colUnit"); |
69 |
col.Caption = "Unit"; |
70 |
col = _ConverterDT.Columns.Add("colTemplate"); |
71 |
col.Caption = "Template"; |
72 |
col = _ConverterDT.Columns.Add("colDrawingNumber"); |
73 |
col.Caption = "Drawing Number"; |
74 |
col = _ConverterDT.Columns.Add("colDrawingName"); |
75 |
col.Caption = "Drawing Name"; |
76 |
col = _ConverterDT.Columns.Add("colStatus"); |
77 |
col.Caption = "Status"; |
78 |
col = _ConverterDT.Columns.Add("colUID"); |
79 |
|
80 |
col = _ID2LineDT.Columns.Add("UID"); |
81 |
col = _ID2LineDT.Columns.Add("Name"); |
82 |
col.Caption = "Name"; |
83 |
col = _ID2LineDT.Columns.Add("Type"); |
84 |
col.Caption = "Type"; |
85 |
col = _ID2LineDT.Columns.Add("SPPID_SYMBOL_PATH"); |
86 |
col.Caption = "SPPID Symbol Path"; |
87 |
col = _ID2LineDT.Columns.Add("Clear"); |
88 |
col.Caption = ""; |
89 |
} |
90 |
|
91 |
private void InitGridControl() |
92 |
{ |
93 |
#region Converter Page |
94 |
gridViewConverter.OptionsSelection.MultiSelect = true; |
95 |
gridViewConverter.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.CheckBoxRowSelect; |
96 |
|
97 |
gridControlConverter.DataSource = _ConverterDT; |
98 |
|
99 |
templateComboBox = new RepositoryItemComboBox(); |
100 |
templateComboBox.TextEditStyle = TextEditStyles.DisableTextEditor; |
101 |
templateComboBox.EditValueChanged += templateComboBox_EditValueChanged; |
102 |
gridControlConverter.RepositoryItems.Add(templateComboBox); |
103 |
gridViewConverter.Columns["colTemplate"].ColumnEdit = templateComboBox; |
104 |
|
105 |
gridViewConverter.Columns["colUnit"].OptionsColumn.AllowEdit = false; |
106 |
gridViewConverter.Columns["colDrawingFileName"].OptionsColumn.AllowEdit = false; |
107 |
gridViewConverter.Columns["colUnit"].OptionsColumn.ReadOnly = true; |
108 |
gridViewConverter.Columns["colStatus"].OptionsColumn.AllowEdit = false; |
109 |
gridViewConverter.Columns["colDrawingFilePath"].Visible = false; |
110 |
gridViewConverter.Columns["colUID"].Visible = false; |
111 |
|
112 |
gridViewConverter.BestFitColumns(); |
113 |
#endregion |
114 |
} |
115 |
|
116 |
private void templateComboBox_EditValueChanged(object sender, EventArgs e) |
117 |
{ |
118 |
gridViewConverter.CloseEditor(); |
119 |
gridViewConverter.UpdateCurrentRow(); |
120 |
} |
121 |
|
122 |
private void gridViewConverter_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) |
123 |
{ |
124 |
if (e.Column.Name == "colcolTemplate") |
125 |
{ |
126 |
gridViewConverter.ShowEditor(); |
127 |
(gridViewConverter.ActiveEditor as ComboBoxEdit).ShowPopup(); |
128 |
} |
129 |
else if (e.Column.Name == "colcolUnit") |
130 |
{ |
131 |
UnitForm unitForm = new UnitForm(_SPPIDUnitDT); |
132 |
if (unitForm.ShowDialog() == DialogResult.OK) |
133 |
{ |
134 |
gridViewConverter.SetRowCellValue(e.RowHandle, e.Column, unitForm.SelectedUnit); |
135 |
gridViewConverter.CloseEditor(); |
136 |
gridViewConverter.UpdateCurrentRow(); |
137 |
} |
138 |
} |
139 |
} |
140 |
|
141 |
private void btnID2Project_ButtonClick(object sender, ButtonPressedEventArgs e) |
142 |
{ |
143 |
xtraFolderBrowserDialog.SelectedPath = btnID2Project.Text; |
144 |
|
145 |
if (xtraFolderBrowserDialog.ShowDialog() == DialogResult.OK) |
146 |
{ |
147 |
if (xtraFolderBrowserDialog.SelectedPath[xtraFolderBrowserDialog.SelectedPath.Length - 1] == '\\') |
148 |
xtraFolderBrowserDialog.SelectedPath = xtraFolderBrowserDialog.SelectedPath.Remove(xtraFolderBrowserDialog.SelectedPath.Length - 1); |
149 |
Settings.Default.LatestProjectPath = xtraFolderBrowserDialog.SelectedPath; |
150 |
Settings.Default.Save(); |
151 |
if (InitID2Project()) |
152 |
{ |
153 |
MessageBox.Show(Msg.SuccessProjectSelect, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information); |
154 |
} |
155 |
else |
156 |
MessageBox.Show(Msg.FailProjectSelect, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
157 |
} |
158 |
} |
159 |
|
160 |
private bool InitID2Project() |
161 |
{ |
162 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
163 |
_ProjectInfo.DefaultPath = Settings.Default.LatestProjectPath; |
164 |
if (Project_DB.ConnTestAndCreateTable()) |
165 |
{ |
166 |
_ProjectInfo.Enable = true; |
167 |
btnID2Project.Text = _ProjectInfo.DefaultPath; |
168 |
labelID2ProjectName.Text = _ProjectInfo.Name; |
169 |
labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Blue; |
170 |
labelID2ProjectStatus.Text = Msg.ConnectionSuccessful; |
171 |
labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
172 |
layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
173 |
layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; |
174 |
} |
175 |
else |
176 |
{ |
177 |
_ProjectInfo.Enable = false; |
178 |
btnID2Project.Text = ""; |
179 |
labelID2ProjectName.Text = " "; |
180 |
labelID2ProjectName.AppearanceItemCaption.ForeColor = Color.Red; |
181 |
labelID2ProjectStatus.Text = Msg.ConnectionFail; |
182 |
labelID2ProjectStatus.AppearanceItemCaption.ForeColor = Color.Red; |
183 |
layoutControlGroupSPPIDDB.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
184 |
layoutControlGroupItemMapping.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; |
185 |
} |
186 |
|
187 |
InitMapping(); |
188 |
InitSPPIDDB(); |
189 |
|
190 |
return _ProjectInfo.Enable; |
191 |
} |
192 |
|
193 |
private void InitMapping() |
194 |
{ |
195 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
196 |
if (_ProjectInfo.Enable) |
197 |
{ |
198 |
InitID2Symbol(); |
199 |
InitID2Line(); |
200 |
InitID2LineNumber(); |
201 |
InitID2Association(); |
202 |
|
203 |
InitETCSetting(); |
204 |
} |
205 |
} |
206 |
|
207 |
private void InitETCSetting() |
208 |
{ |
209 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
210 |
if (_ProjectInfo.Enable) |
211 |
{ |
212 |
DataTable dt = Project_DB.SelectETCSetting(); |
213 |
if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
214 |
SPPIDUtil.ConvertToETCSetting(dt.Rows[0][0].ToString()); |
215 |
else |
216 |
SPPID_DBInfo.Clear(); |
217 |
} |
218 |
} |
219 |
|
220 |
private void InitID2Symbol() |
221 |
{ |
222 |
using (DataTable symbolDT = Project_DB.SelectProjectSymbol()) |
223 |
{ |
224 |
symbolMappings.Clear(); |
225 |
_ID2SymbolDT = symbolDT; |
226 |
_ID2SymbolDT.Columns.Add("Clear"); |
227 |
_ID2SymbolDT.Columns["Clear"].Caption = ""; |
228 |
foreach (DataRow row in symbolDT.Rows) |
229 |
{ |
230 |
symbolMappings.Add(new SymbolMapping() |
231 |
{ |
232 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
233 |
SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(), |
234 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
235 |
}); |
236 |
} |
237 |
} |
238 |
} |
239 |
|
240 |
private void InitID2Line() |
241 |
{ |
242 |
using (DataTable lineTypes = Project_DB.SelectProjectLine()) |
243 |
{ |
244 |
lineMappings.Clear(); |
245 |
_ID2LineDT.Rows.Clear(); |
246 |
foreach (DataRow row in lineTypes.Rows) |
247 |
{ |
248 |
DataRow newRow = _ID2LineDT.NewRow(); |
249 |
newRow["UID"] = row["UID"] == null ? "" : row["UID"].ToString(); |
250 |
newRow["Name"] = row["Name"] == null ? "" : row["Name"].ToString(); |
251 |
newRow["Type"] = "Line"; |
252 |
newRow["SPPID_SYMBOL_PATH"] = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(); |
253 |
_ID2LineDT.Rows.Add(newRow); |
254 |
|
255 |
lineMappings.Add(new LineMapping() |
256 |
{ |
257 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
258 |
LINENAME = row["Name"] == null ? "" : row["Name"].ToString(), |
259 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
260 |
}); |
261 |
} |
262 |
} |
263 |
} |
264 |
|
265 |
private void InitID2LineNumber() |
266 |
{ |
267 |
using (DataTable linePropertiesDT = Project_DB.SelectProjectLineProperties()) |
268 |
{ |
269 |
lineNumberMappings.Clear(); |
270 |
_ID2LinePropertyDT = linePropertiesDT; |
271 |
_ID2LinePropertyDT.Columns.Add("Type"); |
272 |
foreach (DataRow row in linePropertiesDT.Rows) |
273 |
{ |
274 |
row["Type"] = "Line Property"; |
275 |
lineNumberMappings.Add(new LineNumberMapping() |
276 |
{ |
277 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
278 |
DisplayName = row["DisplayName"] == null ? "" : row["DisplayName"].ToString(), |
279 |
SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(), |
280 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString() |
281 |
}); |
282 |
} |
283 |
} |
284 |
} |
285 |
|
286 |
private void InitID2Association() |
287 |
{ |
288 |
using (DataTable associationDT = Project_DB.SelectProjectAssociation()) |
289 |
{ |
290 |
associationMappings.Clear(); |
291 |
_ID2AssociationDT = associationDT; |
292 |
_ID2AssociationDT.Columns.Add("Clear"); |
293 |
_ID2AssociationDT.Columns["Clear"].Caption = ""; |
294 |
foreach (DataRow row in associationDT.Rows) |
295 |
{ |
296 |
associationMappings.Add(new AssociationMapping() |
297 |
{ |
298 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
299 |
DisplayAttribute = row["DisplayAttribute"] == null ? "" : row["DisplayAttribute"].ToString(), |
300 |
Type = row["Type"] == null ? "" : row["Type"].ToString(), |
301 |
SPPIDATTRIBUTENAME = row["SPPID_ATTRIBUTE"] == null ? "" : row["SPPID_ATTRIBUTE"].ToString(), |
302 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString() |
303 |
}); |
304 |
} |
305 |
} |
306 |
} |
307 |
|
308 |
private void InitSPPIDDB() |
309 |
{ |
310 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
311 |
if (_ProjectInfo.Enable) |
312 |
{ |
313 |
DataTable dt = Project_DB.SelectSPPID_DB_INFO(); |
314 |
if (dt.Columns.Count > 0 && dt.Rows.Count > 0) |
315 |
SPPIDUtil.ConvertToSPPIDInfo(dt.Rows[0][0].ToString()); |
316 |
else |
317 |
SPPID_DBInfo.Clear(); |
318 |
} |
319 |
|
320 |
templateComboBox.Items.Clear(); |
321 |
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
322 |
if (_SPPIDInfo.Enable) |
323 |
{ |
324 |
labelSPPIDPlantName.Text = _SPPIDInfo.SelectedPlant; |
325 |
labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Blue; |
326 |
labelSPPIDDBStatus.Text = Msg.ConnectionSuccessful; |
327 |
labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Blue; |
328 |
|
329 |
string TemplatePath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("PID Template Path"); |
330 |
if (!string.IsNullOrEmpty(TemplatePath)) |
331 |
templateComboBox.Items.AddRange(Directory.GetFiles(TemplatePath, "*.pid").ToList().Select(filePath => Path.GetFileName(filePath)).ToList()); |
332 |
|
333 |
_SPPIDUnitDT = SPPID_DB.GetUnitTree(); |
334 |
|
335 |
layoutControlGroupAutoConverter.Enabled = true; |
336 |
} |
337 |
else |
338 |
{ |
339 |
labelSPPIDPlantName.Text = " "; |
340 |
labelSPPIDPlantName.AppearanceItemCaption.ForeColor = Color.Red; |
341 |
labelSPPIDDBStatus.Text = Msg.ConnectionFail; |
342 |
labelSPPIDDBStatus.AppearanceItemCaption.ForeColor = Color.Red; |
343 |
|
344 |
layoutControlGroupAutoConverter.Enabled = false; |
345 |
} |
346 |
|
347 |
_DicDocuments.Clear(); |
348 |
_ConverterDT.Rows.Clear(); |
349 |
InitSPPIDSymbolTreeTable(); |
350 |
} |
351 |
|
352 |
private void InitSPPIDSymbolTreeTable() |
353 |
{ |
354 |
SPPID_DBInfo _SPPIDInfo = SPPID_DBInfo.GetInstance(); |
355 |
|
356 |
_SPPIDSymbolPathDT = new DataTable(); |
357 |
_SPPIDSymbolPathDT.Columns.Add("ID"); |
358 |
_SPPIDSymbolPathDT.Columns.Add("Parent"); |
359 |
_SPPIDSymbolPathDT.Columns.Add("Name"); |
360 |
_SPPIDSymbolPathDT.Columns.Add("FullPath"); |
361 |
|
362 |
if (_SPPIDInfo.Enable) |
363 |
{ |
364 |
string symbolPath = SPPID_DB.GetPlantPID_T_OPTIONSETTING_Value("Catalog Explorer root path"); |
365 |
DirectoryInfo info = new DirectoryInfo(symbolPath); |
366 |
_SPPIDSymbolPathDT.Rows.Add(new object[] { "0", "-1", info.Name }); |
367 |
loop(info, "0", symbolPath); |
368 |
} |
369 |
} |
370 |
|
371 |
private void loop(DirectoryInfo parentInfo, string parentUID, string defaultPath) |
372 |
{ |
373 |
DirectoryInfo[] infos = parentInfo.GetDirectories(); |
374 |
foreach (DirectoryInfo info in infos) |
375 |
{ |
376 |
string uid = Guid.NewGuid().ToString(); |
377 |
_SPPIDSymbolPathDT.Rows.Add(new object[] { uid, parentUID, info.Name }); |
378 |
loop(info, uid, defaultPath); |
379 |
|
380 |
FileInfo[] files = info.GetFiles("*.sym"); |
381 |
foreach (FileInfo fileInfo in files) |
382 |
{ |
383 |
_SPPIDSymbolPathDT.Rows.Add(new object[] { Guid.NewGuid().ToString(), uid, fileInfo.Name, fileInfo.FullName.Replace(defaultPath, "") }); |
384 |
} |
385 |
} |
386 |
} |
387 |
|
388 |
private void btnLoadFile_Click(object sender, EventArgs e) |
389 |
{ |
390 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
391 |
if (!_ProjectInfo.Enable) |
392 |
{ |
393 |
MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
394 |
return; |
395 |
} |
396 |
|
397 |
xtraOpenFileDialog.InitialDirectory = _ProjectInfo.TempDirPath; |
398 |
if (xtraOpenFileDialog.ShowDialog() == DialogResult.OK) |
399 |
{ |
400 |
foreach (string fileName in xtraOpenFileDialog.FileNames) |
401 |
{ |
402 |
SPPID_Document document = new SPPID_Document(fileName); |
403 |
|
404 |
DataRow[] rows = _ConverterDT.Select(string.Format("colDrawingFilePath = '{0}'", fileName)); |
405 |
DataRow row; |
406 |
if (rows.Length == 0) |
407 |
{ |
408 |
row = _ConverterDT.NewRow(); |
409 |
row["colDrawingFileName"] = Path.GetFileNameWithoutExtension(fileName); |
410 |
row["colDrawingFilePath"] = fileName; |
411 |
row["colDrawingNumber"] = document.DWGNAME; |
412 |
row["colDrawingName"] = document.DWGNAME; |
413 |
if (document.Enable) |
414 |
row["colStatus"] = "Ready"; |
415 |
else |
416 |
row["colStatus"] = "Error"; |
417 |
row["colUID"] = ""; |
418 |
_ConverterDT.Rows.Add(row); |
419 |
} |
420 |
if (!_DicDocuments.ContainsKey(fileName)) |
421 |
_DicDocuments.Add(fileName, null); |
422 |
|
423 |
_DicDocuments[fileName] = document; |
424 |
} |
425 |
} |
426 |
} |
427 |
|
428 |
private void btnRun_Click(object sender, EventArgs e) |
429 |
{ |
430 |
#if DEBUG |
431 |
SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\zIsocynates-325_Page75.xml"); |
432 |
document.SymbolMappings = symbolMappings; |
433 |
document.LineMappings = lineMappings; |
434 |
document.LineNumberMappings = lineNumberMappings; |
435 |
document.AssociationMappings = associationMappings; |
436 |
document.ETCSetting = ETCSetting.GetInstance(); |
437 |
|
438 |
document.SetSPPIDInfo(); |
439 |
|
440 |
if (document.SetSPPIDMapping()) |
441 |
{ |
442 |
AutoModeling modeling = new AutoModeling(document); |
443 |
modeling.Run(); |
444 |
} |
445 |
|
446 |
return; |
447 |
#endif |
448 |
|
449 |
//_Documents.Clear(); |
450 |
|
451 |
//foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
452 |
//{ |
453 |
// string _FilePath = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingFilePath"); |
454 |
// string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
455 |
// string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
456 |
// string _DrawingNumber = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingNumber"); |
457 |
// string _DrawingName = gridViewConverter.GetRowCellDisplayText(rowHandle, "colDrawingName"); |
458 |
// SPPID_Document document = _DicDocuments[_FilePath]; |
459 |
// document.Unit = _Unit; |
460 |
// document.Template = _Template; |
461 |
// document.DrawingNumber = _DrawingNumber; |
462 |
// document.DrawingName = _DrawingName; |
463 |
// _Documents.Add(document); |
464 |
//} |
465 |
|
466 |
DialogResult = DialogResult.OK; |
467 |
} |
468 |
|
469 |
private void btnSPPIDDB_Click(object sender, EventArgs e) |
470 |
{ |
471 |
SPPID_DB_SettingForm form = new SPPID_DB_SettingForm(); |
472 |
if (form.ShowDialog() == DialogResult.OK) |
473 |
InitSPPIDDB(); |
474 |
} |
475 |
|
476 |
private void btnItemMapping_Click(object sender, EventArgs e) |
477 |
{ |
478 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
479 |
if (!_ProjectInfo.Enable) |
480 |
{ |
481 |
MessageBox.Show(Msg.PleaseSetID2ProjectInfo, Msg.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
482 |
return; |
483 |
} |
484 |
|
485 |
MappingForm form = new MappingForm(_ID2SymbolDT,_SPPIDSymbolPathDT, _ID2LineDT, _ID2LinePropertyDT, _ID2AssociationDT); |
486 |
form.ShowDialog(); |
487 |
InitMapping(); |
488 |
} |
489 |
private List<int> prevSelectedList = new List<int>(); |
490 |
|
491 |
private void gridViewConverter_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e) |
492 |
{ |
493 |
if (e.Action == CollectionChangeAction.Add) |
494 |
{ |
495 |
string _Unit = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colUnit"); |
496 |
string _Template = gridViewConverter.GetRowCellDisplayText(e.ControllerRow, "colTemplate"); |
497 |
|
498 |
if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
499 |
gridViewConverter.UnselectRow(e.ControllerRow); |
500 |
} |
501 |
else if (e.Action == CollectionChangeAction.Refresh) |
502 |
{ |
503 |
foreach (int rowHandle in gridViewConverter.GetSelectedRows()) |
504 |
{ |
505 |
string _Unit = gridViewConverter.GetRowCellDisplayText(rowHandle, "colUnit"); |
506 |
string _Template = gridViewConverter.GetRowCellDisplayText(rowHandle, "colTemplate"); |
507 |
|
508 |
if (string.IsNullOrEmpty(_Unit) || string.IsNullOrEmpty(_Template)) |
509 |
gridViewConverter.UnselectRow(rowHandle); |
510 |
} |
511 |
|
512 |
List<int> selectedRowHandleList = gridViewConverter.GetSelectedRows().ToList(); |
513 |
var firstNotSecond = prevSelectedList.Except(selectedRowHandleList).ToList(); |
514 |
var secondNotFirst = selectedRowHandleList.Except(prevSelectedList).ToList(); |
515 |
|
516 |
if (!firstNotSecond.Any() && !secondNotFirst.Any()) |
517 |
{ |
518 |
this.gridViewConverter.SelectionChanged -= new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
519 |
gridViewConverter.ClearSelection(); |
520 |
this.gridViewConverter.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(this.gridViewConverter_SelectionChanged); |
521 |
} |
522 |
} |
523 |
|
524 |
prevSelectedList = gridViewConverter.GetSelectedRows().ToList(); |
525 |
} |
526 |
} |
527 |
} |