If e.DataCol.name = "SN" Then
Dim nms2() As String = {"生产订单号码","工单行号","物料编码","物料名称","类别说明","产品批次","订单号","订单行号","客户","备注","软件版本","状态","数量","MAC","HW","入库单号","库位类别","库位编码","收货完成时间","体态","SN"}
If Not e.DataRow.IsNull("SN") Then
Dim mr As DataRow = DataTables("库存明细表").SQLFind("SN = '" & e.DataRow("SN") & "'")
If mr IsNot Nothing Then
For Each nm2 As String In nms2
e.DataRow(nm2) = mr(nm2)
Next
Next
Dim rs As List(Of DataRow) = DataTables("库存明细表").SQLGetValues("在库生命周期","订单号 = '" & Vars("xsddh") & "' And 物料编码 = '" & vars("chbm") & "' and (状态='入库完成' or 状态='配货完成')","在库生命周期" )
Dim drs As List(Of DataRow) = DataTables("库存明细表").Select(CExp("订单号='{0}' and 物料编码='{1}' and 状态='入库完成'", Vars("xsddh") ,vars("chbm")),"在库生命周期 desc")
For Each dr As DataRow In drs
Dim sum As Integer
sum = sum + dr("数量")
If sum = '" & vars("zsl") & "' Then 'vars("zsl") 是需要发货的数量
For cach r As Row In rs
If r("在库生命周期") > dr("在库生命周期") Then
Dim rts1 As List(of DataRow) = DataTables("库存明细表").SQLSelect("订单号 = '" & Vars("xsddh") & "' And 物料编码 = '" & vars("chbm") & "' and 状态='入库完成' and 在库生命周期 > = r("在库生命周期") ")
Dim rts2 As List(of DataRow) = DataTables("库存明细表").SQLSelect("订单号 = '" & Vars("xsddh") & "' And 物料编码 = '" & vars("chbm") & "' and 状态='入库完成' and 在库生命周期 = dr("在库生命周期") ")
Dim ct1 As Integer
ct1 = rtsl.count
Dim ct2 As Integer
ct2 = vars("zsl") - ct1
End If
Return
Next
End If
If rts1.Contains(e.DataRow) Then
e.DataRow("数量") = 1
e.DataRow("状态") = "配货完成"
e.DataRow.save
Dim nr As DataRow = DataTables("库存明细表").SQLFind("SN = '" & e.DataRow("SN")")
If nr IsNot Nothing Then
nr("状态") = "配货完成"
End If
Dim sum2 As Integer
sum2 = sum2 + 1
If sum2 > ct1 Then
e.DataRow("数量") = 0
e.DataRow("状态") = "重复扫描"
End If
End If
If rts2.Contains(e.DataRow) Then
Dim sum3 As Integer
sum3 = sum3 + 1
If sum3 < = ct2 Then
Dim lr As DataRow = DataTables("配货扫描").find("SN = '" & e.DataRow("SN") & "'", "_Identify <> '" & e.DataRow("_Identify") & "'" )
If lr IsNot Nothing Then
e.DataRow("数量") = 0
e.DataRow("状态") = "重复扫描"
e.DataRow.save
Else
e.DataRow("数量") = 1
e.DataRow("状态") = "配货完成"
e.DataRow.save
End If
Else
e.DataRow("数量") = 0
e.DataRow("状态") = "不属于配货发货条件"
e.DataRow.save
End If
If rts1.Contains(e.DataRow) = False Or rts2.Contains(e.DataRow) = False Then
e.DataRow("数量") = 0
e.DataRow("状态") = "不属于配货发货条件"
e.DataRow.save
End If
End If
End If
Next
Return
End If
Next
End If
End If
我就按照这个思路来写,写不下去了。能帮忙给看看么。怎么写简单直观明了呢。一看就明白,我上面写的看着就头疼。