最简单,按照顺序出货,先理解这个,再去做根据天数的。
Select Case e.DataCol.name
Case "SN"
If Not e.DataRow.IsNull("SN") Then
Dim dr As Row = Tables("销售出库单").current
Dim drs As List(Of DataRow) = DataTables("库存明细表").Select(CExp("订单号='{0}' and 物料编码='{1}' and 状态='入库完成'", dr("订单号") ,dr("物料编码")),"在库生命周期 desc")
If dr IsNot Nothing Then
Dim count As Integer = e.DataTable.Compute("count(sn)","订单号='" & dr("订单号") & "' and 物料编码='" & dr("物料编码") & "' and SN is not null")
If count >= dr("预发货数量") Then
dr("配货状态") = True
msgbox("已经扫描完")
Return
End If
For Each fdr As DataRow In drs
If fdr("SN") = e.DataRow("SN") Then
fdr("状态") = "出库"
e.DataRow("订单号") = fdr("订单号")
e.DataRow("物料编码") = fdr("物料编码")
msgbox("SN可以出货")
Return
End If
count += fdr("数量")
If count >= dr("预发货数量") Then
msgbox("SN不能出货")
Return
End If
Next
End If
End If
End Select