'投料量计算模块
If e.DataTable.datacols.Contains("审核") AndAlso e.DataTable.datacols.Contains("工序") Then
If e.DataCol.Name = "审核" Then
Dim drs As List(Of DataRow) = _dt工序合并表.SQLS elect("母卷号 = '" & e.DataRow("母卷号") & "'", "", "卷号,起始时间")
If drs.Count = 0 Then
ElseIf drs.Count=1 Then
drs(0)("投料量")=drs(0)("重量")
For i As Integer = 0 To drs.Count - 1
drs(i)("成材率") = drs(i)("重量") / drs(i)("投料量")
Next
Else
drs(0)("投料量")=drs(0)("重量")
Dim tll As Double = drs(0)("重量")
Dim dic As New Dictionary(Of String, Double())
Dim Dic_dr As new Dictionary(of DataRow, Double)
For i As Integer = 1 To drs.Count - 1
If drs(i)("卷号") = drs(i-1)("卷号")
Dic_dr.Add(drs(i), tll)
Else
Dim str As String = drs(i)("卷号").Substring(0,drs(i)("卷号").length - 1)
If dic.ContainsKey(str) = False Then
Dim fdr As DataRow = _dt工序合并表.SQLFind("卷号 = '" & str & "'", "起始时间")
If fdr IsNot Nothing Then
Dim drs_temp As List(of DataRow) = _dt工序合并表.SQLSelect("substring(卷号,1," & drs(i)("卷号").Length - 1 & ") = '" & fdr("卷号") & "' and len(卷号) = " & drs(i)("卷号").Length, "卷号")
Dim zl As Double = drs_temp(0)("重量")
For j As Integer = 1 To drs_temp.Count - 1
If drs_temp(j)("卷号") <> drs_temp(j-1)("卷号") Then
zl += drs_temp(j)("重量")
End If
Next
dic.Add(str, new Double(){zl, tll})
Else
tll = drs(i)("重量")
Dic_dr.Add(drs(i), tll)
Continue For
End If
End If
tll = drs(i)("重量") / dic(str)(0) * dic(str)(1)
Dic_dr.Add(drs(i), tll)
End If
Next
For Each dr As DataRow In dic_dr.Keys
dr("投料量") = dic_dr(dr)
Next
For i As Integer = 0 To drs.Count - 1
drs(i)("成材率") = drs(i)("重量") / drs(i)("投料量")
Next
End If
_dt工序合并表.SQLUpdate(drs)
End If
End If