老师,如下,用了很长时间了,以前都没有问题,就这几天出现了。
Dim pn As String = args(0)
Dim qty As String = args(1)
Dim idx As Decimal = args(8)
Dim dic1 = vars("dic1")
Dim dic2 = vars("dic2")
'Dim dic3 = vars("dic3")
Dim dic4 = vars("dic4")
Dim m1 As Decimal = args(9)
For Each dr As DataRow In DataTables("BOM").Select("FNumber='" & pn & "'")
Dim ndr As DataRow = DataTables("物料需求").AddNew
ndr("PartNo") = dr("PN")
ndr("ETD") = args(3)
ndr("批号") = args(4)
ndr("company") = args(10)
ndr("SOP") = args(11)
ndr("BOM") = args(12)
ndr("ETA") = args(13)
ndr("CustomerPO") = args(14)
ndr("EndCustomer") = args(15)
ndr("ShippingTerms") = args(16)
ndr("Project") = args(17)
ndr("RequestETA") = args(18)
ndr("ConfirmedETA") = args(19)
ndr("GSS") = args(20)
' ndr("PartDesc") = dr("FName1")
ndr("Demand") = dr("FQty") * qty
ndr("层次") = "第" & idx & "层"
Dim mq As Decimal = m1 * dr("FQty")
Dim m2 As Decimal = args(6)+ args(7) - qty
Dim flag = args(5) ' And m1 < 0
If m1 <> 0 Then
If dic1.ContainsKey(ndr("PartNo")) Then
If m1 < 0 Then
Dim aa As Decimal = mq*-1
If dic1(ndr("PartNo")) >= aa Then
ndr("Stock") = aa
ndr("库存剩余数量")= aa
Else
ndr("Stock") = dic1(ndr("PartNo"))
ndr("库存剩余数量")= dic1(ndr("PartNo"))
End If
flag = False
ElseIf dic1(ndr("PartNo")) > 0 Then
ndr("Stock") = dic1(ndr("PartNo"))
ndr("库存剩余数量")= dic1(ndr("PartNo"))
End If
dic1(ndr("PartNo")) -= ndr("Stock")
ndr("库存剩余数量")= dic1(ndr("PartNo"))
If dic1(ndr("PartNo"))< 0 Then dic1(ndr("PartNo")) = 0
End If
End If
If dic2.ContainsKey(ndr("PartNo")) Then
If flag = True And m1 > 0 Then
Dim qty1 = ndr("Demand") - ndr("stock")
If qty1 > 0 Then
If dic2(ndr("PartNo")) >= qty1 Then
ndr("QC") = qty1
dic2(ndr("PartNo")) -= ndr("QC")
ndr("QC剩余数量") = dic2(ndr("PartNo"))
ElseIf dic2(ndr("PartNo")) > 0 Then
ndr("QC") = dic2(ndr("PartNo"))
dic2(ndr("PartNo")) -= ndr("QC")
ndr("QC剩余数量") = dic2(ndr("PartNo"))
End If
End If
ElseIf m1 < 0 Then
Dim aa As Decimal = mq*-1
If dic2(ndr("PartNo")) > aa - ndr("Stock")
ndr("QC") = aa - ndr("Stock")
ndr("QC剩余数量") = dic2(ndr("PartNo"))
Else
ndr("QC") = dic2(ndr("PartNo"))
ndr("QC剩余数量") = dic2(ndr("PartNo"))
End If
dic2(ndr("PartNo")) -= ndr("QC")
ndr("QC剩余数量") = dic2(ndr("PartNo"))
End If
End If
'If flag = True And m1 > 0 Then
' If dic3.ContainsKey(ndr("PartNo")) Then
' Dim qty2 = ndr("Demand") - ndr("stock") - ndr("QC")
' If qty2 > 0 Then
' If dic3(ndr("PartNo")) >= qty2 Then
' ndr("purchasingorder") = qty2
' dic3(ndr("PartNo")) -= ndr("purchasingorder")
' ElseIf dic3(ndr("PartNo")) > 0 Then
' ndr("purchasingorder") = dic3(ndr("PartNo"))
' dic3(ndr("PartNo")) -= ndr("purchasingorder")
' End If
' End If
' End If
'End If
If flag = True AndAlso m1 > 0 Then
ndr("MissingQty") = ndr("Stock")+ndr("QC") -ndr("Demand")+args(6)*dr("FQty")
Else
If m1 < 0 AndAlso mq*-1 > ndr("Stock")+ndr("QC")
ndr("MissingQty") = mq + (ndr("Stock")+ndr("QC"))
Else
ndr("MissingQty") = 0
End If
End If
If dic4.ContainsKey(ndr("PartNo")) = False Then
dic4.add(ndr("PartNo"), ndr("MissingQty"))
Else
dic4(ndr("PartNo")) += ndr("MissingQty")
End If
ndr("SumMissing") = dic4(ndr("partno"))
Functions.Execute("sumChild",dr("PN"),ndr("Demand"), args(2), args(3),args(4),flag, ndr("Stock"),ndr("QC"),idx+1,ndr("MissingQty"),args(10),args(11),args(12),args(13),args(14),args(15),args(16),args(17),args(18),args(19),args(20))
Next