30-05-21, 12:48 AM
اصدقائي الاعزاء
لدي جدول يوجد في سجلات واريد الاسنتعلام من FlowLayoutPanel.
في حالة السجل موجود مسبقا في قاعدة البيانات يتم التعديل عليه
وفي حالة غير مودو يتم اضافه الي القاعدة
لدي جدول يوجد في سجلات واريد الاسنتعلام من FlowLayoutPanel.
في حالة السجل موجود مسبقا في قاعدة البيانات يتم التعديل عليه
وفي حالة غير مودو يتم اضافه الي القاعدة
كود :
For i As Integer = 0 To frm_Conversion_store.FlowLayoutPanel3.Controls.Count - 1
Dim Cmd As New SqlCommand("SELECT * FROM Tbl_all_store WHERE Bar_code=" & frm_Conversion_store.FlowLayoutPanel3.Controls(i).Controls("lbl_barcode").Text & "and ID_STORE=" & frm_Conversion_store.Label10.Text & "", conn)
Dim DR As SqlDataReader
'Cmd.Transaction = trans
DR = Cmd.ExecuteReader
If DR.HasRows Then
While DR.Read
'Dim a As Integer = frm_Conversion_store.FlowLayoutPanel3.Controls(i).Controls("Label2").Text
'Dim Cmd5 As New SqlCommand("Update Tbl_all_store set Quantitys=Quantitys + " & a & " where Bar_code=" & frm_Conversion_store.FlowLayoutPanel3.Controls(i).Controls("lbl_barcode").Text & "and ID_STORE=" & frm_Conversion_store.Label10.Text & "", conn)
'Cmd5.Transaction = trans
'Cmd5.ExecuteNonQuery()
End While
Dim Com1 As New SqlCommand("insert into Tbl_all_store(id_Store,Bar_code,ItemName,GroupName,UnitsName,ExpirationDate,PurchasePrice,SalePrice,SalePrice2,DiscountRatio,DiscountValue,Profits,LessAmount,Quantitys,Store_Name,Itemimg)values(@id_Store,@Bar_code,@ItemName,@GroupName,@UnitsName,@ExpirationDate,@PurchasePrice,@SalePrice,@SalePrice2,@DiscountRatio,@DiscountValue,@Profits,@LessAmount,@Quantitys,@Store_Name,@Itemimg)", conn)
Com1.Parameters.AddWithValue("@id_Store", frm_Conversion_store.Label10.Text)
Com1.Parameters.AddWithValue("@Store_Name", frm_Conversion_store.BunifuButton2.Text)
Com1.Parameters.AddWithValue("@Bar_code", frm_Conversion_store.FlowLayoutPanel3.Controls(i).Controls("lbl_barcode").Text)
Com1.Parameters.AddWithValue("@ItemName", frm_Conversion_store.FlowLayoutPanel3.Controls(i).Controls("btn").Text)
Com1.Parameters.AddWithValue("@GroupName", frm_Conversion_store.FlowLayoutPanel3.Controls(i).Controls("Label13").Text)
Com1.Parameters.AddWithValue("@UnitsName", frm_Conversion_store.FlowLayoutPanel3.Controls(i).Controls("Label14").Text)
Com1.Parameters.AddWithValue("@ExpirationDate", frm_Conversion_store.FlowLayoutPanel3.Controls(i).Controls("Label5").Text)
Com1.Parameters.AddWithValue("@PurchasePrice", frm_Conversion_store.FlowLayoutPanel3.Controls(i).Controls("Label6").Text)
Com1.Parameters.AddWithValue("@SalePrice", frm_Conversion_store.FlowLayoutPanel3.Controls(i).Controls("Label2").Text)
Com1.Parameters.AddWithValue("@SalePrice2", frm_Conversion_store.FlowLayoutPanel3.Controls(i).Controls("Label8").Text)
Com1.Parameters.AddWithValue("@DiscountRatio", frm_Conversion_store.FlowLayoutPanel3.Controls(i).Controls("Label9").Text)
Com1.Parameters.AddWithValue("@DiscountValue", frm_Conversion_store.FlowLayoutPanel3.Controls(i).Controls("Label10").Text)
Com1.Parameters.AddWithValue("@Profits", frm_Conversion_store.FlowLayoutPanel3.Controls(i).Controls("Label11").Text)
Com1.Parameters.AddWithValue("@LessAmount", frm_Conversion_store.FlowLayoutPanel3.Controls(i).Controls("Label12").Text)
Com1.Parameters.AddWithValue("@Quantitys", frm_Conversion_store.FlowLayoutPanel3.Controls(i).Controls("Label3").Text)
'com1.Parameters.AddWithValue("@Itemimg", picbyte)
'Com1.Transaction = trans
Com1.ExecuteNonQuery()
End If
DR.Close()
Next