早上好,我有一个看起来像这样的程序。
我有一个名为的按钮Multiple Select
,当我单击该按钮时,该按钮将调用SaveCheckedRecords()
,这是它的代码
Public Sub SaveCheckedRecords()
Dim failed = False
For Each row As DataGridViewRow In DataGridView1.Rows
If row.Cells(0).Value = True Then
Dim i As Integer
i = DataGridView1.CurrentRow.Index
Label2.Text = DataGridView1.Item("ItemCode", i).Value
Label3.Text = DataGridView1.Item("Description", i).Value
Label4.Text = DataGridView1.Item("ReflectedQty", i).Value
Label5.Text = DataGridView1.Item("UOM", i).Value
Label6.Text = DataGridView1.Item("UnitPrice", i).Value
Label7.Text = DataGridView1.Item("Total", i).Value
Label8.Text = DataGridView1.Item("Remarks", i).Value
standard() '<------------- Call this Sub
insert() '<------------- Call this Sub
failed = True
Exit For
End If
Next
If Not failed Then
MsgBox("Please select an item to receive")
End If
End Sub
现在我基于上面的代码的目标是将数据从 datagridview 行传输到标签并调用一些Subs
这是和的standard
代码insert
Private Sub standard()
Dim con As MySqlConnection = New MySqlConnection("server=localhost;userid=root;password=admin1950;database=inventory")
Dim cmd As MySqlCommand = New MySqlCommand("select StandardUOM,QtyPerUoM from item_master_list where ItemCode = '" & Label2.Text & "'", con)
Dim reader As MySqlDataReader
con.Open()
reader = cmd.ExecuteReader
While reader.Read
Label9.Text = reader.GetString("StandardUOM")
Label10.Text = reader.GetString("QtyPerUoM")
End While
End Sub
Private Sub insert()
DataGridView1.Columns.RemoveAt(0)
Dim con1 As MySqlConnection = New MySqlConnection("datasource=localhost;database=inventory;userid=root;password=admin1950")
Dim cmdinsert As MySqlCommand = New MySqlCommand("insert into receiving (RINo,PONo,ItemCode,Description,QtyPack,PackUoM,UnitPrice,Total,Remarks,ExpiryDate,QtyStan,StanUoM,PCS) values ('" & frm_Add_Receiving_Items.TextBox1.Text & "','" & Label1.Text & "','" & Label2.Text & "','" & Label3.Text & "','" & Label11.Text & "','" & Label5.Text & "','" & Label6.Text & "','" & Label7.Text & "','" & Label8.Text & "','" & DateTime.Now.ToString("yyyy-MM-dd") & "','" & Label12.Text & "','" & Label9.Text & "','" & Label10.Text & "')", con1)
con1.Open()
cmdinsert.ExecuteNonQuery()
con1.Close()
frm_Add_Receiving_Items.generate_rec_form()
updateRI()
loadlist1()
frm_Add_Receiving_Items.Button6.Enabled = False
Label2.Text = "Label2"
End Sub
我想要做的就是保存 datagridview 的值什么时候checkboxcolumn(0)
是 True 我的代码有什么问题?
TYSM