hytos / DTI_PID / SPPIDConverter / Mapping.vb @ c64c95df
이력 | 보기 | 이력해설 | 다운로드 (4.94 KB)
1 | 6ba3e887 | Gyusu | |
---|---|---|---|
2 | |||
3 | Imports DevExpress.XtraEditors.Repository |
||
4 | |||
5 | Public Class Mapping |
||
6 | |||
7 | Dim oPidSymbolCombobox As DevExpress.XtraEditors.Repository.RepositoryItemComboBox |
||
8 | Dim _PID_Ds As DataSet |
||
9 | Dim _PIDSymbol_Dt As DataTable = New DataTable |
||
10 | Dim _Gembox As New CGembox() |
||
11 | |||
12 | Sub New(ByVal oDt As DataTable) |
||
13 | ' 디자이너에서 이 호출이 필요합니다. |
||
14 | InitializeComponent() |
||
15 | _PIDSymbol_Dt = oDt |
||
16 | LoadSymbolLibrary() |
||
17 | ' InitializeComponent() 호출 뒤에 초기화 코드를 추가하세요. |
||
18 | End Sub |
||
19 | |||
20 | |||
21 | Private Function LoadSymbolDataset() As DataSet |
||
22 | Dim oPID_Ds As DataSet |
||
23 | _Gembox.isLoadFile(My.Settings.SymbolLibrary) |
||
24 | oPID_Ds = _Gembox.LoadFileFunc() |
||
25 | Return oPID_Ds |
||
26 | End Function |
||
27 | |||
28 | Private Sub LoadSymbolLibrary() |
||
29 | |||
30 | _Gembox.isLoadFile(My.Settings.SymbolLibrary) |
||
31 | _PID_Ds = _Gembox.LoadFileFunc() |
||
32 | |||
33 | XtraTabControl1.TabPages.Clear() |
||
34 | For Each oDt As DataTable In _PID_Ds.Tables |
||
35 | |||
36 | Dim bCheckImageColumn As Boolean = False |
||
37 | 'Image Pid ComboBox 추가 |
||
38 | For Each oColumn As DataColumn In oDt.Columns |
||
39 | If oColumn.ColumnName = _Column_ImageSymbol Then |
||
40 | bCheckImageColumn = True |
||
41 | End If |
||
42 | Next |
||
43 | If bCheckImageColumn = False Then |
||
44 | Try |
||
45 | Dim iIndex As Integer = oDt.Columns(oDt.Columns.Count - 1).Namespace + 1 |
||
46 | Dim oAddCol As DataColumn = oDt.Columns.Add(_Column_ImageSymbol) |
||
47 | oAddCol.Namespace = iIndex |
||
48 | Catch ex As Exception |
||
49 | |||
50 | End Try |
||
51 | |||
52 | End If |
||
53 | |||
54 | Dim oTabPage As New DevExpress.XtraTab.XtraTabPage |
||
55 | oTabPage.Name = oDt.TableName |
||
56 | oTabPage.Text = oDt.TableName |
||
57 | Dim oGridControl As New DevExpress.XtraGrid.GridControl |
||
58 | Dim oGridview As New DevExpress.XtraGrid.Views.Grid.GridView |
||
59 | ' oGridview.CustomRowCellEdit += New DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventHandler(GridView_Mapping_CustomRowCellEdit); |
||
60 | |||
61 | oGridControl.ViewCollection.Add(oGridview) |
||
62 | oGridControl.MainView = oGridview |
||
63 | oGridControl.DataSource = oDt |
||
64 | oGridControl.BindingContext = New BindingContext() |
||
65 | oGridControl.ForceInitialize() |
||
66 | oGridview.Columns(_Column_ImageSymbol).ColumnEdit = GetComboEdit(oDt.TableName) |
||
67 | oGridview.OptionsView.BestFitMode = DevExpress.XtraGrid.Views.Grid.GridBestFitMode.Full |
||
68 | oGridview.OptionsView.ColumnAutoWidth = False |
||
69 | oGridview.BestFitColumns() |
||
70 | oGridControl.Dock = DockStyle.Fill |
||
71 | oTabPage.Controls.Add(oGridControl) |
||
72 | XtraTabControl1.TabPages.Add(oTabPage) |
||
73 | Next |
||
74 | End Sub |
||
75 | |||
76 | Private Function GetComboEdit(ByVal sType As String) As RepositoryItemComboBox |
||
77 | Dim oSymbolCombo As New RepositoryItemComboBox() |
||
78 | oSymbolCombo.DropDownRows = 30 |
||
79 | Dim oDataRows() As DataRow = _PIDSymbol_Dt.Select("category = '" & sType & "'") |
||
80 | |||
81 | For Each oRow In oDataRows |
||
82 | |||
83 | Dim sCategory As String = oRow("name").ToString() |
||
84 | oSymbolCombo.Items.Add(sCategory) |
||
85 | Next |
||
86 | |||
87 | Return oSymbolCombo |
||
88 | |||
89 | End Function |
||
90 | |||
91 | Private Sub GridView_Mapping_CustomRowCellEdit(ByVal oObject As Object, ByVal e As DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs) |
||
92 | If e.Column.FieldName = _Column_ImageSymbol Then |
||
93 | e.RepositoryItem = oPidSymbolCombobox |
||
94 | Else |
||
95 | Return |
||
96 | End If |
||
97 | End Sub |
||
98 | |||
99 | Private Sub TabControl_Mapping_Paint(sender As Object, e As PaintEventArgs) Handles TabControl_Mapping.Paint |
||
100 | |||
101 | End Sub |
||
102 | |||
103 | Private Sub TabControl_Mapping_MouseDown(sender As Object, e As MouseEventArgs) Handles TabControl_Mapping.MouseDown |
||
104 | |||
105 | End Sub |
||
106 | |||
107 | Private Sub Btn_Save_Click(sender As Object, e As EventArgs) Handles Btn_Save.Click |
||
108 | |||
109 | 'Dim oSaveFileDialog As New SaveFileDialog |
||
110 | 'oSaveFileDialog.Filter = "xlsx Files (*.xlsx)|*.xlsx" |
||
111 | 'If oSaveFileDialog.ShowDialog() = DialogResult.OK Then |
||
112 | ' If oSaveFileDialog.FileName <> "" Then |
||
113 | |||
114 | ' End If |
||
115 | 'End If |
||
116 | If _PID_Ds IsNot Nothing Then |
||
117 | Dim iAddColCnt As Integer = 0 |
||
118 | Dim oPidSymbol_Dt As DataTable = _Gembox.AddImageLibrary(_PID_Ds, _PIDSymbol_Dt) |
||
119 | For Each oDt As DataTable In _PID_Ds.Tables |
||
120 | 'Dim oGembox As New CGembox |
||
121 | _Gembox.SaveSymbolLibrary(oDt, oPidSymbol_Dt) |
||
122 | '_Gembox.outputToExcelFile(oDt, oDt.TableName, oSaveFileDialog.FileName) |
||
123 | _Gembox.SetSaveFile(My.Settings.SymbolLibrary) |
||
124 | Next |
||
125 | MessageBox.Show("저장 완료") |
||
126 | ' System.Diagnostics.Process.Start(My.Settings.SymbolLibrary) |
||
127 | Else |
||
128 | MessageBox.Show("Symbol DB가 없습니다.") |
||
129 | End If |
||
130 | End Sub |
||
131 | |||
132 | Private Sub Btn_Load_Click(sender As Object, e As EventArgs) Handles Btn_Load.Click |
||
133 | |||
134 | End Sub |
||
135 | End Class |