Dim yphsl As WinForm.Button = e.Form.Controls("Button5")
Dim bfhfh As WinForm.Button = e.Form.Controls("Button6")
Dim phwc As WinForm.Button = e.Form.Controls("配货完成")
Dim dr As Row = Tables("销售出库单列表").current
Dim str As String = dr("发货要求")
Dim gdh,gdhh,filter As String
Dim gdsl() As String = str.Split("|")
For Index As Integer = 0 To gdsl.Length - 1
Dim gds() As String = gdsl(Index).Split("_")
filter &= "(" & "物料编码 = '" & dr("存货编码") & "' and 生产订单号码 = '" & gds(0) & "' and 工单行号 = '" & gds(1) & "'" & ")" & " " & "or" & " "
Next
If filter > "" Then
filter = filter.SubString(0,filter.Length -3)
End If
Dim filter1 As String = "(" & filter & ")"
Select Case e.DataCol.name
Case "SN"
If Not e.DataRow.IsNull("SN") Then
Dim drr As DataRow = DataTables("库存明细表").SQLFind("SN = '" & e.DataRow("SN") & "'")
If drr IsNot Nothing Then
If drr("状态") = "配货完成" Then
Dim nms() As String = {"生产订单号码","工单行号","物料编码","物料名称","类别说明","产品批次","订单号","订单行号","客户","备注","软件版本","MAC","HW","入库单号","库位类别","库位编码","入库完成时间","入库方式","在库生命周期"}
For Each nm As String In nms
e.DataRow(nm) = drr(nm)
Next
e.DataRow("状态") = "配货重复扫描"
e.DataRow("数量") = 0
e.DataRow.save
Else
Dim drs As List(Of DataRow) = DataTables("库存明细表").SQLSelect(filter,"在库生命周期 desc")
If dr IsNot Nothing Then
Dim count As Integer = e.DataTable.Compute("count(sn)",filter1 & " And 状态 = '配货完成' and SN is not null")
If count >= dr("挪货数量") Then
dr("配货状态") = True
e.DataRow("数量") = 0
Dim nr As DataRow = DataTables("库存明细表").SQLFind("SN = '" & e.DataRow("SN") & "'")
Dim nms() As String = {"生产订单号码","工单行号","物料编码","物料名称","类别说明","产品批次","订单号","订单行号","客户","备注","软件版本","MAC","HW","入库单号","库位类别","库位编码","入库完成时间","入库方式","在库生命周期"}
For Each nm As String In nms
e.DataRow(nm) = nr(nm)
Next
e.DataRow("状态") = "不符合出库条件"
e.DataRow("在库生命周期") = nr("在库生命周期")
e.DataRow.save
Dim count2 As Integer = e.DataTable.Compute("count(sn)",filter1 & "And 状态 = '不符合出库条件' and SN is not null")
bfhfh.text = "不符合出库SN有" & count2
Tables("配货整理_table4").Filter = filter1 & " And 状态 = '不符合出库条件'"
Return
Else
drr("状态") = "配货完成"
drr("配货完成时间") = Date.now
drr("U8发货单号") = dr("发货单号")
drr("业务员") = dr("业务员")
drr("货运单号") = dr("货运单号")
drr("发货地址") = dr("发货地址")
drr("数量") = 0
drr.Save
Dim nms1() As String = {"生产订单号码","工单行号","物料编码","物料名称","类别说明","产品批次","订单号","订单行号","客户","备注","软件版本","MAC","HW","入库单号","库位类别","库位编码","入库完成时间","入库方式","在库生命周期"}
For Each nm1 As String In nms1
e.DataRow(nm1) = drr(nm1)
Next
e.DataRow("数量") = 1
e.DataRow("状态") = "配货完成"
e.DataRow("配货完成时间") = Date.now
e.DataRow("发货单号") = dr("发货单号")
e.DataRow.save
Dim count33 As Integer = e.DataTable.Compute("count(sn)","状态 = '不符合出库条件' and SN is not null")
bfhfh.text = "不符合出库SN有" & count33
Tables("配货整理_table4").Filter = "状态 = '不符合出库条件'"
Dim mr As DataRow = DataTables("库位数量统计").SQLFind(filter)
If mr IsNot Nothing Then
mr("数量") = mr("数量") -1
mr.save
End If
Dim sum2 As Integer
sum2 = DataTables("配货扫描").SQLCompute("Sum(数量)",filter1 & "And 状态 = '配货完成'")
yphsl.text = "发货单号:" & dr("发货单号") & "已完成配货数量" & "=" & sum2
Dim count1 As Integer = e.DataTable.Compute("count(sn)",filter1 & " And 状态 = '配货完成' and SN is not null")
If count1 = dr("挪货数量") Then
dr("配货状态") = True
dr.save
If dr("配货状态") = False Then
phwc.Enabled = False
Else
phwc.Enabled = True
End If
End If
Return
count += 1
If count >= dr("挪货数量") Then
e.DataRow("数量") = 0
Dim nr As DataRow = DataTables("库存明细表").SQLFind("SN = '" & e.DataRow("SN") & "'")
Dim nms() As String = {"生产订单号码","工单行号","物料编码","物料名称","类别说明","产品批次","订单号","订单行号","客户","备注","软件版本","MAC","HW","入库单号","库位类别","库位编码","入库完成时间","入库方式","在库生命周期"}
For Each nm As String In nms
e.DataRow(nm) = nr(nm)
Next
e.DataRow("状态") = "不符合出库条件"
e.DataRow.save
Dim count3 As Integer = e.DataTable.Compute("count(sn)",filter1 & " And 状态 = '不符合出库条件' and SN is not null")
bfhfh.text = "不符合出库SN有" & count3
Tables("配货整理_table4").Filter = filter1 & " And 状态 = '不符合出库条件'"
Return
End If
End If
End If
End If
Else
e.DataRow("数量") = 0
e.DataRow("状态") = "不符合出库条件"
e.DataRow("物料编码") = dr("存货编码")
e.DataRow.save
Dim count3 As Integer = e.DataTable.Compute("count(sn)","状态 = '不符合出库条件' and SN is not null")
bfhfh.text = "不符合出库SN有" & count3
Tables("配货整理_table4").Filter = "状态 = '不符合出库条件'"
End If
End If
End Select
发现下面蓝色的代码,每次都是找第一行的数量扣减,导致第一行的数量一致递减,而其他行的数量不变,
我的初衷是根据物料编码,生产订单号,工单行号匹配的行,然后扣减数量。
Dim mr As DataRow = DataTables("库位数量统计").SQLFind(filter)
If mr IsNot Nothing Then
mr("数量") = mr("数量") -1
mr.save
End If