Good Morning I have a program that looks like this.
I have a button named Multiple Select
and when I click that the button will call SaveCheckedRecords()
and here is the code for it
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
Now my goal based on the code above is to transfer the data from datagridview rows to labels and call some Subs
Here is the code for the standard
and 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
All I want to do is to save the value of datagridview when checkboxcolumn(0)
is True whats wrong with my code?
TYSM