Imports System.Windows.Forms Public Class dlg_AddSupplier Dim m_Supplier As New CSupplier Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click If Save() = True Then Me.DialogResult = System.Windows.Forms.DialogResult.OK Me.Close() End If End Sub Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click Me.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.Close() End Sub '获取所有表对应的字段名称列表 Private Function GetSectionNameList() As Boolean Dim rTable As New Data.DataTable Dim result As Boolean = True rTable.Columns.Clear() rTable.Rows.Clear() rTable.Clear() Grid1.Cols = 2 Grid1.Rows = 1 Grid1.Column(0).Width = 200 Grid1.Column(1).Width = 200 Grid1.Column(0).Alignment = FlexCell.AlignmentEnum.LeftCenter Grid1.Column(1).Alignment = FlexCell.AlignmentEnum.LeftCenter Grid1.Cell(0, 0).Text = "字段名称" Grid1.Cell(0, 1).Text = "值" If SQL_Query(COL_RIGHTS.供应商管理, "SELECT * FROM `" & CSupplier.cst_TABLE_NAME & "` WHERE 0", rTable) = True Then Dim rowindex As Integer = 1 For i As Integer = 0 To rTable.Columns.Count - 1 Grid1.Rows += 1 Grid1.Cell(rowindex, 0).Text = rTable.Columns.Item(i).ColumnName rowindex += 1 Next If Grid1.Rows > 1 Then Grid1.Cell(1, 1).Locked = True End If Else result = False End If Return result End Function Private Sub dlg_AddSupplier_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load GetSectionNameList() End Sub Private Function Save() As Boolean Dim RowCount As Integer = Grid1.Rows - 2 Dim SectionName(RowCount) As String Dim Values(RowCount) As String Dim tableindex As Integer = 1 For row As Integer = 0 To RowCount SectionName(row) = Grid1.Cell(tableindex, 0).Text Values(row) = Grid1.Cell(tableindex, 1).Text tableindex += 1 Next Dim result As ERROR_CODE = m_Supplier.AddItem(SectionName, Values) If result = ERROR_CODE.SUCCESS Then Return True Else MsgBox(GetErrorCodeString(result)) End If Return False End Function End Class