Dim a As New GroupTableBuilder("入库表1",DataTables("电机壳生产明细"))
Dim a1 As fxDataSource
a.Groups.AddDef("规格")
a.Groups.AddDef("物料编码")
a.Groups.AddDef("入库工序","工序")
a.Totals.AddDef("入库数量","入库_数量")
a1 = a.BuildDataSource()
'a.build
Dim b As New GroupTableBuilder("领用表1",DataTables("电机壳生产明细"))
Dim b1 As fxDataSource
b.Groups.AddDef("规格")
b.Groups.AddDef("物料编码")
b.Groups.AddDef("领用工序","工序")
b.Totals.AddDef("领用数量","领用_数量")
b1 = b.BuildDataSource()
'b.build
Dim c As New GroupTableBuilder("出库表1",DataTables("出库明细表"))
Dim c1 As fxDataSource
c.Groups.AddDef("规格")
c.Groups.AddDef("物料编码")
c.Groups.AddDef("工序")
c.Totals.AddDef("数量","出库_数量")
c1 = c.BuildDataSource()
'c.build
Dim d As New GroupTableBuilder("结存表1",DataTables("结存表"))
Dim d1 As fxDataSource
d.Groups.AddDef("规格")
d.Groups.AddDef("物料编码")
d.Groups.AddDef("工序")
d.Totals.AddDef("上期结存","结存_数量")
d1 = d.BuildDataSource()
'd.build
Dim nms As String()={"规格", "物料编码", "工序"}
a1.Combine(nms, b1,nms)
a1.Combine(nms, c1,nms)
a1.Combine(nms, d1,nms)
'
'
Tables("窗口1_Table1").DataSource = a1 '将统计结果绑定到Table
With DataTables("窗口1_Table1").DataCols '用表达式列计算库存数据
.Add("库存_数量",Gettype(Integer), "IsNull([结存_数量],0) + ISNULL([入库_数量],0) - ISNULL([领用_数量],0) - ISNULL([出库_数量],0) ")
End With