Select Case e.DataCol.Name
Case "产品","生产数量","需求日期"
If e.DataRow.IsNull("产品") = False AndAlso e.DataRow.IsNull("生产数量") = False andalso e.DataRow.IsNull("需求日期") = False Then
Dim d2 As DataRow
For Each dr As DataRow In DataTables("零件用量").Select("产品='" & e.DataRow("产品") & "'")
d2 = DataTables("零件需求").Find("产品='" & e.DataRow("产品") & "' and 零件='" & dr("零件") & "' and 生产数量='" & e.DataRow("生产数量") & "' and 需求日期='" & e.DataRow("需求日期") & "'")
If d2 Is Nothing Then
d2 = DataTables("零件需求").AddNew
d2("产品") = e.DataRow("产品")
d2("零件") = dr("零件")
d2("生产数量") = e.DataRow("生产数量")
d2("需求日期") = e.DataRow("需求日期") End If
d2("需求数量") = e.DataRow("生产数量") * dr("用量")
Next
End If
End Select