12-02-19, 03:33 AM
كود :
Dim dt1 As New DataTable
Dim cmd As New SqlCommand("select * from Products where ProductBarcode = '" + ProductBarcode.Text + "'", con)
con.Open()
Dim da As New SqlDataAdapter(cmd)
da.Fill(dt1)
If dt1.Rows.Count > 0 Then
Dim A As Integer = Val(Qyt.Text)
Dim cmdupdate As New SqlCommand
With cmdupdate
.Connection = con
.CommandType = CommandType.Text
.CommandText = "update Products set Qyt = Qyt + " & A & " where ProductBarcode = " & ProductBarcode.Text & ""
End With
Try
If con.State = 1 Then con.Close()
con.Open()
cmdupdate.ExecuteNonQuery()
con.Close()
MsgBox("اسم المادة المدخلة موجود مسبقا - تم عملية التحديث بنجاح", MsgBoxStyle.Information, "تحديث كمية المادة")
cmdupdate = Nothing
Catch ex As Exception
con.Close()
MsgBox(Err.Description, MsgBoxStyle.Information)
Finally
If con.State = ConnectionState.Open Then con.Close()
End Try
Else
insert_products(ProductID.Text, ProductName.Text, ProductBarcode.Text, CatID.Text, UnitID.Text, Qyt.Text, BuyPrice.Text, SellPrice.Text, ImporterID.Text)
End If
clearcontroal()
ProductID.Text = getmaxid("Products", "ProductID")