我写了一个计算库存数据的模块,用原料代码作为不重复值计算的,但是我想找到原料代码这一行对应的”供应商”列填充到库存表中,我用下面代码统计的,供应商列、原料名称列,含税价列,数据填充不进去不知道怎么实现?我试了几条语句都没通过。请专家指教!
Dim dtb As New DataTableBuilder("统计")
dtb.AddDef("供应商", Gettype(String), 8)
dtb.AddDef("原料名称", Gettype(String), 12)
dtb.AddDef("原料代码", Gettype(String), 10)
dtb.AddDef("含税价", Gettype(Double))
dtb.AddDef("期初_数量", Gettype(Double))
dtb.AddDef("期初_重量", Gettype(Double))
dtb.AddDef("期初_含税额", Gettype(Double))
dtb.AddDef("入库_数量", Gettype(Double))
dtb.AddDef("入库_重量", Gettype(Double))
dtb.AddDef("入库_含税额", Gettype(Double))
dtb.AddDef("出库_数量", Gettype(Double))
dtb.AddDef("出库_重量", Gettype(Double))
dtb.AddDef("出库_含税额", Gettype(Double))
dtb.Build()
'计算原料期初数据
For Each nm As String In DataTables("yljgb").GetValues("yldm")
Dim dr As DataRow = DataTables("统计").AddNew()
dr("原料代码") = nm
dr("期初_数量") = DataTables("ylqcb").Compute("Sum(期初_数量)","[yldm] = '" & dr("原料代码") & "'")
dr("期初_重量") = DataTables("ylqcb").Compute("Sum(期初_重量)","[yldm] = '" & dr("原料代码") & "'")
dr("期初_含税额") = DataTables("ylqcb").Compute("Sum(期初_含税额)","[yldm] = '" & dr("原料代码") & "'")
dr("入库_数量") = DataTables("ylrkb").Compute("Sum(入库_数量)","[yldm] = '" & dr("原料代码") & "'")
dr("入库_重量") = DataTables("ylrkb").Compute("Sum(入库_重量)","[yldm] = '" & dr("原料代码") & "'")
dr("入库_含税额") = DataTables("ylrkb").Compute("Sum(入库_含税额)","[yldm] = '" & dr("原料代码") & "'")
dr("出库_数量") = DataTables("ylckb").Compute("Sum(出库_数量)","[yldm] = '" & dr("原料代码") & "'")
dr("出库_重量") = DataTables("ylckb").Compute("Sum(出库_重量)","[yldm] = '" & dr("原料代码") & "'")
dr("出库_含税额") = DataTables("ylckb").Compute("Sum(出库_含税额)","[yldm] = '" & dr("原料代码") & "'")
Next
With DataTables("统计").DataCols '用表达式列计算库存数据
.Add("库存_数量",Gettype(Double), "IsNull([期初_数量],0)+isnull([入库_数量],0)-ISNULL([出库_数量],0)")
.Add("库存_重量",Gettype(Double), "IsNull([期初_重量],0)+isnull([入库_重量],0)-ISNULL([出库_重量],0)")
.Add("库存_含税额",Gettype(Double), "IsNull([期初_含税额],0)+isnull([入库_含税额],0)-ISNULL([出库_含税额],0)")
End With
MainTable= Tables("统计")