Select Case e.DataCol.name Case "发生年月","物料编号","责任部门","责任人","数量" If e.DataRow.Isnull("发生年月")=False AndAlso e.DataRow.Isnull("物料编号") = False AndAlso e.DataRow.Isnull("数量")=False AndAlso e.DataRow.Isnull("责任部门") = False AndAlso e.DataRow.Isnull("责任人") = False Then Dim drs As List (of DataRow) = DataTables("清单表").Select("产品编号= '" & e.DataRow("物料编号") & "' and 使用状态= '使用'") If drs.count = 0 Then msgbox("清单表没有,请先增加") Else For Each dr As DataRow In drs Dim dr1 As DataRow = DataTables("物料表").find("物料编号 = '" & dr("物料编号") & "' and 发生年月 = '" & e.DataRow("发生年月") & "'and 责任人 = '" & e.DataRow("责任人") & "'and 责任部门 = '" & e.DataRow("责任部门") & "'") If dr1 Is Nothing Then dr1 = DataTables("物料表").addnew dr1("发生年月")=e.DataRow("发生年月") dr1("责任部门")=e.DataRow("责任部门") dr1("责任人")=e.DataRow("责任人") dr1("物料编号")=dr("物料编号") dr1("物料名称")=dr("物料名称") dr1("规格型号")=dr("规格型号") dr1("基本单位")=dr("基本单位") dr1("数量")=dr("数量")*e.DataRow("数量") Else Dim sum As Double = 0 For Each jh As DataRow In e.DataTable.Select("物料编号 = '" & e.DataRow("物料编号") & "' and 发生年月 = '" & e.DataRow("发生年月") & "'and 责任人 = '" & e.DataRow("责任人") & "'and 责任部门 = '" & e.DataRow("责任部门") & "' ") sum += dr("数量")*jh("数量") Next dr1("数量") = sum End If Next End If End If End Select
|