Dim bd1 As New GroupTableBuilder("统计表1",DataTables("成品进仓表"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("仓库名称") '根据型号分组
bd1.Groups.AddDef("箱号")
bd1.Groups.AddDef("入库条码")
bd1.Groups.AddDef("型号")
bd1.Groups.AddDef("规格")
'bd1.Groups.AddDef("厂商代号")
'bd1.Groups.AddDef("单边方向")
'bd1.Groups.AddDef("进仓日期")
'bd1.Groups.AddDef("冻结")
bd1.Filter = "仓库名称 = '单边仓' And 冻结 = 1 "
bd1.Totals.AddDef("只数","进仓只数") '对数量进行统计
bd1.Totals.AddDef("净重","进仓重量") '对金额进行统计
dt1 = bd1.BuildDataSource()
Dim bd2 As New GroupTableBuilder("统计表2",DataTables("成品出仓表"))
Dim dt2 As fxDataSource
bd2.Groups.AddDef("仓库名称") '根据型号分组
bd2.Groups.AddDef("箱号") '根据型号分组
bd2.Groups.AddDef("入库条码")
bd2.Groups.AddDef("型号") '根据型号分组
bd2.Groups.AddDef("规格") '根据型号分组
'bd2.Groups.AddDef("厂商代号") '根据型号分组
'bd2.Groups.AddDef("出仓日期") '根据型号分组
bd2.Filter = "确认日期 is not null"
bd2.Totals.AddDef("只数","出仓只数") '对数量进行统计
bd2.Totals.AddDef("净重","出仓重量") '对金额进行统计
dt2 = bd2.BuildDataSource()
Dim nms As String() = {"仓库名称","箱号","入库条码","型号","规格"}
dt1.Combine(nms,dt2,nms) '将销售统计数据组合到进货统计数据
Tables("选择单边_单边库存表").DataSource = dt1 '将统计结果绑定到Table
With DataTables("选择单边_单边库存表").DataCols '用表达式列计算库存数据
.Add("当前库存只数",Gettype(Double), "IsNull([进仓只数],0) - ISNULL([出仓只数],0)")
.Add("当前库存重量",Gettype(Double), "IsNull([进仓重量],0) - ISNULL([出仓重量],0)")
End With