我正在尝试用VB.NET 制作一个简单的POS 系统,但是由于我不知道如何开始,所以我要求我的朋友给我示例源代码。我计划在我的数据库中使用 MySQL 而不是 Microsoft Access,因为我们学校使用它。以下是源代码的示例代码:
Public Sub FillDGVWithReceiptInfo(ByVal DGV As DataGridView)
DGV.Rows.Clear()
Dim TA As New POSDSTableAdapters.ItemsTableAdapter
For i = 0 To Me.ReceiptDetailsList.Count - 1
Dim T1 = Me.ReceiptDetailsList(i).Barcode
Dim T2 = Me.ReceiptDetailsList(i).ItemBuyPrice
Dim T3 = Me.ReceiptDetailsList(i).ItemCount
Dim T4 = Me.ReceiptDetailsList(i).ItemSellPrice
Dim T5 = T3 * T4
Dim T6 = TA.GetDataByBarcode(T1).Rows(0).Item("ItemName")
DGV.Rows.Add(T1, T6, T2, T4, T3, T5)
Next
End Sub
我正在尝试将其转换为“OdBC”类型的格式。所以我想出了这个(也是,这是我得到一些错误的部分):
Public Sub FillDGVWithReceiptInfo(ByVal DGV As DataGridView)
DGV.Rows.Clear()
For i = 0 To Me.ReceiptDetailsList.Count - 1
Dim T1 = Me.ReceiptDetailsList(i).ganoProdID
Dim T3 = Me.ReceiptDetailsList(i).ItemCount
Dim T4 = Me.ReceiptDetailsList(i).ganoItemPrice
Dim T5 = T3 * T4
Dim TA As New OdbcDataAdapter("SELECT * FROM gano_inventory WHERE gano_proID = " & T1 & ";", conn)
Dim R As New DataTable
TA.Fill(R)
Dim T6 = R.Rows(0).Item("gano_item")
DGV.Rows.Add(T1, T6, T4, T3, T5)
Next
End Sub
这是代码的错误: 不能将行添加到没有列的 DataGridView 控件。必须先添加列。在这一行: DGV.Rows.Add(T1, T6, T4, T3, T5)
有人可以帮我吗?先感谢您!