Dim dt1 As DataTable = DataTables("汇总") Dim dt2 As DataTable = DataTables("手术室") Dim dt3 As DataTable = DataTables("外科") For Each dr1 As DataRow In dt2.Select("") Dim dr2 As DataRow = dt1.Find("编码 = '" & dr1("编码") & "'") If dr2 Is Nothing Then dr2 = dt1.addnew For Each dc As DataCol In dt2.DataCols dr2(dc.Name) = dr1(dc.name) Next dr2("数量") = dt2.Compute("sum(数量)", "编码 = '" & dr1("编码") & "'") + dt3.Compute("sum(数量)", "编码 = '" & dr1("编码") & "'") Next For Each dr1 As DataRow In dt3.Select("") Dim dr2 As DataRow = dt1.Find("编码 = '" & dr1("编码") & "'") If dr2 Is Nothing Then dr2 = dt1.addnew For Each dc As DataCol In dt2.DataCols dr2(dc.Name) = dr1(dc.name) Next dr2("数量") = dt2.Compute("sum(数量)", "编码 = '" & dr1("编码") & "'") + dt3.Compute("sum(数量)", "编码 = '" & dr1("编码") & "'") Next
|