在库存明细表,发生变化的应该是SN,不应该是其它的吧。代码如下:
Dim kwbm As WinForm.TextBox = Forms("入库扫描").Controls("TextBox1")
If e.DataCol.Name = "SN" Then
If e.DataRow("SN").contains("-") Then
kwbm.value = e.DataRow("SN")
e.DataRow("SN") = Nothing
Else
Dim nms() As String = {"SN","数量","物料编码","产品型号","类别","产品态","配货单号","工单号","订单号","预入库单号","生产完成日期","入库单号","库位号"}
If e.NewValue Is Nothing Then
For Each nm As String In nms
e.DataRow(nm) = Nothing
Next
Else
Dim drs As List(Of DataRow) = DataTables("待入库").Select("[SN] = '" & e.NewValue & "'")
If drs.Count > 0 Then
SystemReady = False
For Each dr As DataRow In drs
Dim ndr As DataRow = e.DataTable.AddNew
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(扫描顺序)")
If max > "" Then
idx = CInt(max) + 1
Else
idx = 1
End If
ndr("扫描顺序") = idx
If dr("入库提示") = "入库完成" Then
For Each nm As String In nms
ndr(nm) = dr(nm)
Next
ndr("提示") = "重复扫描入库"
dr("入库提示") = "入库完成"
ndr("库位编码") = kwbm.Value
Else
For Each nm As String In nms
ndr(nm) = dr(nm)
Next
If ndr("预入库单号") <> ndr("入库单号") Then
ndr("提示") = "非本入库单物料"
ndr("库位编码") = kwbm.Value
Else
ndr("提示") = "入库完成"
dr("入库提示") = "入库完成"
ndr("库位编码") = kwbm.Value
ndr("入库结束日期") = Date.now
msgbox(6)
If ndr.GetChildRows("库位数量统计").Count = 0 Then
If ndr.IsNull("产品型号") Then
Dim ddr2 As DataRow = DataTables("库位数量统计").Find("物料编码 = '" & ndr("物料编码") & "'")
If ddr2 IsNot Nothing Then
If ddr2("库位编码") = ndr("库位编码") Then
ddr2("数量") = ddr2("数量") + 1
Else
Dim ddr3 As DataRow = DataTables("库位数量统计").AddNew()
ddr3("物料编码") = ndr("物料编码")
ddr3("库位编码") = ndr("库位编码")
ddr3("库位号") = ndr("库位号")
ddr3("订单号") = ndr("订单号")
ddr3("数量") = 1
ddr3("产品态") = ndr("产品态")
End If
msgbox(7)
Else
Dim ddr1 As DataRow = DataTables("库位数量统计").AddNew()
ddr1("物料编码") = ndr("物料编码")
ddr1("库位编码") = ndr("库位编码")
ddr1("库位号") = ndr("库位号")
ddr1("订单号") = ndr("订单号")
ddr1("产品态") = ndr("产品态")
ddr1("数量") = 1
End If
Else
Dim ddr2 As DataRow = DataTables("库位数量统计").Find("物料编码 = '" & ndr("物料编码") & "' and 产品型号 = '" & ndr("产品型号") & "'")
If ddr2 IsNot Nothing Then
If ddr2("库位编码") = ndr("库位编码") Then
ddr2("数量") = ddr2("数量") + 1
Else
Dim ddr3 As DataRow = DataTables("库位数量统计").AddNew()
ddr3("物料编码") = ndr("物料编码")
ddr3("库位编码") = ndr("库位编码")
ddr3("库位号") = ndr("库位号")
ddr3("订单号") = ndr("订单号")
ddr3("产品型号") = ndr("产品型号")
ddr3("数量") = 1
ddr3("产品态") = ndr("产品态")
End If
Else
Dim ddr1 As DataRow = DataTables("库位数量统计").AddNew()
ddr1("物料编码") = ndr("物料编码")
ddr1("库位编码") = ndr("库位编码")
ddr1("库位号") = ndr("库位号")
ddr1("订单号") = ndr("订单号")
ddr1("产品型号") = ndr("产品型号")
ddr1("产品态") = ndr("产品态")
ddr1("数量") = 1
End If
End If
End If
End If
End If
Next
e.DataRow.Delete
SystemReady = True
Else
e.DataRow("提示") = "序列号不存在"
End If
End If
End If
End If