Dim rks As Double = DataTables("rukudan").sqlCompute("sum(shuliang)", "name = '" & e.DataRow("name") & "'")
Dim rks1 As Double = DataTables("weixin").sqlCompute("sum(shuliang)", "name = '" & e.DataRow("name") & "'")
Dim cks As Double = e.DataTable.sqlCompute("sum(shuliang)", "name = '" & e.DataRow("name") & "'")
If cks + rks1 > rks Then
'msgbox("无法出库,库存不足")
Else
Dim count As Integer = 0
Dim drs As List(Of DataRow) = DataTables("rukudan").Select("name = '" & e.DataRow("name") & "'", "_Identify")
For i As Integer = 0 To drs.count - 1
Dim dr As DataRow = drs(i)
count += dr("shuliang")
Dim sy As Integer = count - (cks + rks1 - e.DataRow("shuliang"))
If sy >= 0 Then
Dim cb, cbs As Double
count = 0
For j As Integer = i To drs.count - 1
dr = drs(j)
If j = i Then
count += sy
cb = sy * dr("price")
Else
count += dr("shuliang")
cb = dr("shuliang") * dr("price")
sy = dr("shuliang")
End If
If count >= e.DataRow("shuliang") Then
cbs += (e.DataRow("shuliang") - (count - sy)) * dr("price")
e.DataRow("cb")=cb
e.DataRow("cbs")=cbs
e.DataRow("bb") = count
' msgbox(cbs & count)
e.DataRow("lirun") = e.DataRow("shuliang") * e.DataRow("price") - cbs
Exit For
Else
cbs += cb
End If
Next
Exit For
End If
Next
' End If
End If
此主题相关图片如下:捕获.png