注:产品id,产品型号均改為字符型!
If e.DataCol.Name ="入库" Then
Dim dr,dr1 As DataRow
dr = e.DataRow
If dr.isnull("产品id") Then
MessageBox.Show("产品id不能为空!")
Else
Dim s As String = "产品id = '" & dr("产品id") & "'and 产品型号 = '" & dr("产品型号") & "'"
dr1= DataTables("仓库").find(s)
If dr1 IsNot Nothing Then
Dim val As Integer = dr("生产数量")
If dr("入库") = False Then
val = -val
End If
dr1("累计入库")+ = val
dr1.Save()
Else
Dim Ls As String() = {"产品ID","产品名称","规格","单位"}
dr1 = DataTables("仓库").AddNew()
For Each s In Ls
dr1(s) = dr(s)
Next
dr1("累计入库") = dr("生产数量")
dr1.Save()
End If
dr.Save()
End If
End If