Dim t As Table = Tables("表A")
Dim fdt As DataTable = DataTables("表B")
Dim llsl As Integer = t.Rows(0)("领料")
For i As Integer = 0 To t.Rows.Count - 1
For Each c As Col In t.Cols
If c.Name Like "不良原因分类_*" AndAlso t.Rows(i)(c.name) IsNot Nothing Then
Dim filter As String = "相关工序 = '" & t.Rows(i)("工序") & "' and 不良原因名称 = '" & c.Name.Split("_")(1) & "'"
Dim fdr As DataRow = fdt.Find(filter)
If fdr IsNot Nothing Then
Dim hg As String = fdr("计算公式设置_减合格工序")
Dim hgbl As String = fdr("计算公式设置_比例1")
Dim ll As String = fdr("计算公式设置_减领料工序")
Dim llbl As String = fdr("计算公式设置_比例2")
If hg IsNot Nothing Then
Dim ary1() As String = hg.Split(",")
Dim ary2() As String = hgbl.split(",")
For j As Integer = 0 To ary1.length - 1
Dim idx As Integer = t.FindRow("工序 = '" & ary1(j) & "'", 0, False)
If idx > -1 Then
t.Rows(idx)("实际合格") -= val(ary2(j)) * t.Rows(i)(c.name)
End If
Next
End If
t.Rows(i)("合格") -= t.Rows(i)(c.name)
If ll IsNot Nothing Then
Dim ary1() As String = ll.Split(",")
Dim ary2() As String = llbl.split(",")
For j As Integer = 0 To ary1.length - 1
Dim idx As Integer = t.FindRow("工序 = '" & ary1(j) & "'", 0, False)
If idx > -1 Then
t.Rows(idx)("实际领料") -= val(ary2(j)) * t.Rows(i)(c.name)
End If
Next
End If
End If
End If
Next
t.Rows(i)("合格") += llsl
t.Rows(i)("实际领料") += llsl
t.Rows(i)("实际合格") += llsl
t.Rows(i)("领料") = llsl
llsl = t.Rows(i)("合格")
Next