Dim bd1 As New GroupTableBuilder("统计表1",DataTables("盘点单据"), "[盘点部门] = '" & bm("盘点部门") & "'And [盘点单号] = '" & txt & "'")
Dim dt1 As fxDataSource
bd1.Groups.AddDef("商品编码")
bd1.Groups.AddDef("商品名称")'根据商品编码和商品名称分组
bd1.Totals.AddDef("溯源码",AggregateEnum.Count, "盘点库存") '对数量进行统计
dt1 = bd1.BuildDataSource()
Dim bd2 As New GroupTableBuilder("统计表2",DataTables("溯源码"), "[当前所在部门] = '" & bm("盘点部门") &"' And [是否可用] = 1")
Dim dt2 As fxDataSource
bd2.Groups.AddDef("商品编码")
bd2.Groups.AddDef("商品名称")'根据商品编码和商品名称分组
bd2.Totals.AddDef("子溯源码", AggregateEnum.Count, "核销前总库存", True)'对应选择部门可用子溯源码计数统计
dt2 = bd2.BuildDataSource()
Dim nms As String() = {"商品编码","商品名称"}
dt1.Combine(nms,dt2,nms) '将盘点统计数据组合到溯源码统计数据
Tables("盘点核销_Table1").DataSource = dt1 '将统计结果绑定到Table
With DataTables("盘点核销_Table1").DataCols '用表达式列计算核销库存数据
.Add("核销库存",Gettype(Integer), "[核销前总库存] - [盘点库存] ")
End With