If e.DataCol.Name.StartsWith("工序") Then
Dim filter As String = "产品名称 = '" & e.DataRow("产品名称") & "'"
Dim fdr As DataRow = DataTables("产品信息").Find(filter)
If fdr IsNot Nothing Then
Dim fdr2 As DataRow = DataTables("工时统计").Find(filter & " and 单号 = '" & e.DataRow("单号") & "'")
If fdr2 Is Nothing Then
fdr2 = DataTables("工时统计").AddNew
fdr2("产品名称") = e.DataRow("产品名称")
fdr2("日期") = e.DataRow("日期")
fdr2("单号") = e.DataRow("单号")
fdr2("数量") = e.DataRow("数量")
Else
For Each dc As DataCol In DataTables("工时统计").DataCols
If dc.Name <> "日期" AndAlso dc.name <> "产品名称" AndAlso dc.name <> "单号" AndAlso dc.Name <> "数量" Then
fdr2(dc.name) = Nothing
End If
Next
End If
For Each dc As DataCol In e.DataTable.DataCols
If dc.Name.StartsWith("工序") AndAlso e.DataRow(dc.name) > "" Then
Dim names() As String = e.DataRow(dc.name).split(",")
For Each name As String In names
Dim sum As Double = e.DataTable.Compute("sum(数量)", filter & " and 单号 = '" & e.DataRow("单号") & "' and " & dc.Name & " like '*" & name & "*'")
sum = sum * fdr(e.DataCol.Name)
If DataTables("工时统计").DataCols.Contains(name) Then
fdr2(name) += sum
End If
Next
End If
Next
Else
msgbox("没有找到【产品信息】对应的数据!")
End If
End If