For Each nm As String In DataTables("ylqcb").GetValues("ylggddm")
Dim dr As DataRow = DataTables("ylkcb").find("ylggddm='" & nm & "'")
If dr Is Nothing Then
dr =DataTables("ylkcb").AddNew()
Dim pr As DataRow = DataTables("ylqcb").find("ylggddm='" & nm & "'")
If pr IsNot Nothing Then
dr("供应商") = pr("供应商")
dr("ylmc") = pr("ylmc")
dr("原料规格") =pr("原料规格")
dr("ylggddm")=nm
dr("yldm") = pr("yldm")
dr("长") = pr("长")
dr("宽") = pr("宽")
dr("厚") = pr("厚")
dr("含税价")=pr("含税价")
End If
End If
Next
For Each nm As String In DataTables("ylrkb").GetValues("ylggddm")
Dim dr As DataRow = DataTables("ylkcb").find("ylggddm='" & nm & "'")
If dr Is Nothing Then
dr =DataTables("ylkcb").AddNew()
Dim wr As DataRow = DataTables("ylrkb").find("ylggddm='" & nm & "'")
If wr IsNot Nothing Then
dr("供应商") = wr("供应商")
dr("ylmc") = wr("ylmc")
dr("原料规格") =wr("原料规格")
dr("ylggddm")=nm
dr("yldm") = wr("yldm")
dr("长") = wr("长")
dr("宽") = wr("宽")
dr("厚") = wr("厚")
dr("含税价")=wr("含税价")
End If
End If
Next
For Each nm As String In DataTables("ylkcb").GetValues("ylggddm")
Dim dr As DataRow = DataTables("ylkcb").find("ylggddm='" & nm & "'")
dr("期初_数量") = DataTables("ylqcb").Compute("Sum(期初_数量)","[ylggddm] = '" & dr("ylggddm") & "'")
dr("期初_重量") = DataTables("ylqcb").Compute("Sum(期初_重量)","[ylggddm] = '" & dr("ylggddm") & "'")
dr("期初_含税额") = DataTables("ylqcb").Compute("Sum(期初_含税额)","[ylggddm] = '" & dr("ylggddm") & "'")
dr("入库_数量") = DataTables("ylrkb").Compute("Sum(入库_数量)","[ylggddm] = '" & dr("ylggddm") & "'")
dr("入库_重量") = DataTables("ylrkb").Compute("Sum(入库_重量)","[ylggddm] = '" & dr("ylggddm") & "'")
dr("入库_含税额") = DataTables("ylrkb").Compute("Sum(入库_含税额)","[ylggddm] = '" & dr("ylggddm") & "'")
dr("出库_数量") = DataTables("ylckb").Compute("Sum(出库_数量)","[ylggddm] = '" & dr("ylggddm") & "'")
dr("出库_重量") = DataTables("ylckb").Compute("Sum(出库_重量)","[ylggddm] = '" & dr("ylggddm") & "'")
dr("出库_含税额") = DataTables("ylckb").Compute("Sum(出库_含税额)","[ylggddm] = '" & dr("ylggddm") & "'")
dr("库存_数量")=dr("期初_数量")+dr("入库_数量")-dr("出库_数量")
dr("库存_重量")=dr("期初_重量")+dr("入库_重量")-dr("出库_重量")
dr("库存_含税额")=dr("期初_含税额")+dr("入库_含税额")-dr("出库_含税额")
Next
messagebox.show("计算完毕")
MainTable= Tables("ylkcb")