Dim bd1 As New GroupTableBuilder("统计表1",DataTables("进库明细"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("物料品号") '根据物料品号分组
bd1.Groups.AddDef("物料名称") '根据物料品号分组
bd1.Groups.AddDef("每箱pc数") '根据物料品号分组
bd1.Totals.AddDef("进库_箱数","进库_箱数") '对数量进行统计
bd1.Totals.AddDef("进库_数量","进库_数量") '对金额进行统计
bd1.Filter = "物料品号 is not null"
dt1 = bd1.BuildDataSource()
Dim bd2 As New GroupTableBuilder("统计表2",DataTables("出库明细"))
Dim dt2 As fxDataSource
bd2.Groups.AddDef("物料品号") '根据物料品号分组
'bd2.Groups.AddDef("物料名称") '根据物料品号分组
'bd2.Groups.AddDef("每箱pc数") '根据物料品号分组
bd2.Totals.AddDef("出库_箱数","出库_箱数") '对数量进行统计
bd2.Totals.AddDef("出库_数量","出库_数量") '对金额进行统计
bd2.Filter = "物料品号 is not null"
dt2 = bd2.BuildDataSource()
dt1.Combine("物料品号",dt2,"物料品号") '将销售统计数据组合到进货统计数据
Tables("库存统计_Table1").DataSource = dt1 '将统计结果绑定到Table
With DataTables("库存统计_Table1").DataCols '用表达式列计算库存数据
.Add("库存_箱数",Gettype(Integer), "IsNull([进库_箱数],0) - ISNULL([出库_箱数],0)")
.Add("库存_数量",Gettype(Integer), "IsNull([进库_数量],0) - ISNULL([出库_数量],0)")
End With