[求助]扫描了一个条码把一个集合的条码都增加了,应该后面在增加一行才对,这样才可以扫描下一个条码。
发现扫描了一个条码,把整个条码对应的10行数据都增加成功了,但没有新增最后一行,导致没法接着扫下一个序列号。
KeyDownEdithe 和KeyDown都增加了新增行
If e.keyCode = Keys.Enter AndAlso e.Table.Cols(e.Table.colSel).Name = "SN" Then
e.cancel = True
e.Table.addnew
End If
datacolchanged代码:
Dim scsmy As WinForm.TextBox = Forms("生产入库").Controls("TextBox2")
Dim lb As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim gdhhh As WinForm.TextBox = Forms("生产入库").Controls("TextBox3")
Dim id As Integer = gdhhh.text.IndexOf("-")
Dim gdh As String = gdhhh.text.SubString(0,id)
If e.DataCol.name = "SN" Then
Dim nms() As String = {"生产订单号码","工单行号","物料编码","物料名称","类别说明","产品批次","订单号","订单行号","客户","备注","软件版本","状态","产品态"}
If e.NewValue Is Nothing Then
For Each nm As String In nms
e.DataRow(nm) = Nothing
Next
Else
Select Case lb.text
Case "2"
e.DataRow.Save
Dim rr1 As DataRow = DataTables("assemblyMiddle").SQLFind("item_ID = '" & e.DataRow("SN") & "'")
If rr1 IsNot Nothing Then
Dim fdr As DataRow = DataTables("扫描配货明细").Find("SN = '" & e.DataRow("SN") & "' And _Identify <> " & e.DataRow("_Identify"))
If fdr IsNot Nothing Then
If fdr("状态") = "生产结束重复扫描" Or fdr("状态") = "生产结束扫描完成" Then
e.DataRow("数量") = 0
e.DataRow("状态") = "生产结束重复扫描"
e.DataRow.save
e.DataRow.locked = True
Dim drr1 As DataRow = DataTables("生产扫描异常").Find("SN = '" & e.DataRow("SN") & "'")
If drr1 Is Nothing Then
Dim drrr1 As DataRow = DataTables("生产扫描异常").AddNew
drrr1("数量") = 0
drrr1("SN") = e.DataRow("SN")
drrr1("状态") = "生产结束重复扫描"
drrr1.Locked = True
End If
End If
Else
Dim rr2s As List(of DataRow) = DataTables("assemblyMiddle").SQLSelect("id_Flag = '" & rr1("id_Flag") & "'")
SystemReady = False
For Each rr2 As DataRow In rr2s
Dim ndr As DataRow = DataTables("扫描配货明细").AddNew
Dim dr1 As DataRow = DataTables("assemblyProduct").SQLFind("deviceCode = '" & rr2("item_ID") & "' or productno = '" & rr2("item_ID") & "'")
If dr1 IsNot Nothing Then
ndr("SN") = rr2("item_ID")
Dim dr2 As DataRow = DataTables("assemblySubWorkOrder").SQLFind("SID = '" & dr1("subWorkOrder") & "'")
If dr2 IsNot Nothing Then
ndr("工单行号") = dr2("LineFlag")
Dim dr3 As DataRow = DataTables("assemblyWorkOrder").SQLFind("Id = '" & dr2("workOrder") & "'")
ndr("生产订单号码") = dr3("WorkOrderNo")
ndr("生产订单号码工单行号")= ndr("生产订单号码") & "-" & ndr("工单行号")
ndr.Save
If ndr("生产订单号码") = gdh Then
Dim dr5 As DataRow = DataTables("assemblyScriptParamter").SQLFind("workOrderNo = '" & ndr("生产订单号码") & "' and lineFlag = '" & ndr("工单行号") & "'")
If dr5 IsNot Nothing Then
If dr5.IsNull("scriptval8") Then
Dim kwlb As WinForm.ComboBox = Forms("生产入库").Controls("ComboBox1")
Dim rklb As WinForm.ComboBox = Forms("生产入库").Controls("ComboBox2")
ndr("库位类别") = kwlb.text
ndr("入库类别") = rklb.text
ndr("绑外SN") = e.DataRow("SN")
ndr("数量") = 1
ndr("状态") = "生产结束扫描完成"
ndr("入库方式") = "扫描入库"
ndr("生产结束扫描完成时间") = Date.now
ndr("生产扫描员") = scsmy.text
ndr.Save
Else
If dr1("status") = "-1" Then
Dim kwlb As WinForm.ComboBox = Forms("生产入库").Controls("ComboBox1")
Dim rklb As WinForm.ComboBox = Forms("生产入库").Controls("ComboBox2")
ndr("库位类别") = kwlb.text
ndr("入库类别") = rklb.text
ndr("绑外SN") = e.DataRow("SN")
ndr("数量") = 1
ndr("状态") = "生产结束扫描完成"
ndr("入库方式") = "扫描入库"
ndr("生产结束扫描完成时间") = Date.now
ndr("生产扫描员") = scsmy.text
ndr.locked = True
ndr.Save
Else
ndr("数量") = 0
ndr("状态") = "不符合入库条件"
ndr.save
Dim drr12 As DataRow = DataTables("生产扫描异常").Find("SN = '" & ndr("SN") & "' and 生产订单号码工单行号 = '" & e.DataRow("生产订单号码工单行号") & "'")
If drr12 Is Nothing Then
Dim drrr12 As DataRow = DataTables("生产扫描异常").AddNew
drrr12("数量") = 0
drrr12("SN") = ndr("SN")
drrr12.Locked = True
End If
End If
End If
End If
Else
ndr("状态") = "不是同一个工单"
ndr.Locked = True
ndr.save
End If
End If
End If
Next
SystemReady = True
Dim lst1 As List(of DataRow) = DataTables("扫描配货明细").Select("绑外SN = '" & e.DataRow("SN") & "'")
For Each mdr As DataRow In lst1
If mdr("绑外SN") = e.DataRow("SN") Then
mdr("外内") = "外"
Else
mdr("外内") = "内"
End If
mdr.Locked = True
mdr.save
Next
e.DataRow.Delete
End If
End If