Dim dt1 As DataTable = DataTables("产品") Dim dt2 As DataTable = DataTables("bom") Dim dt3 As DataTable = DataTables("材料") For Each dr1 As DataRow In dt1.Select("") Dim sum As Double = 0 For Each dr2 As DataRow In dt2.Select("产品代码 = '" & dr1("产品代码") & "'") For Each dr3 As DataRow In dt3.Select("材料代码 = '" & dr2("材料代码") & "'") sum += dr2("产品用料") * dr3("材料单价") Next Next dr1("材料成本") = sum Next
|