Dim bd1 As New GroupTableBuilder("统计表1",DataTables("采购明细"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("项目分类")
bd1.Groups.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.Totals.AddDef("付款金额")
dt2 = bd2.BuildDataSource()
Dim arr() As String = {"项目分类","材料供应商"}
dt1.Combine(arr,dt2,arr)
dt1.show("统计表") '将统计结果绑定到Table
Dim t As Table = Tables("统计表")
With t.DataTable.DataCols '用表达式列计算库存数据
.Add("未付款金额",Gettype(Integer), "IsNull([购进金额],0) - ISNULL([付款金额],0)")
End With
With Tables("统计表")
.MergeMode = MergeModeEnum.Standard
.MergeCols.Clear()
.MergeCols.Add("项目分类")
.MergeCols.Add("材料供应商")
.MergeSort = "项目分类,材料供应商"
.AllowMerge = True
End With
Dim g As Subtotalgroup
t.SubtotalGroups.Clear()
t.GroupAboveData = False
t.TreeVisible = False
t.SpillNode = True
g = New Subtotalgroup
g.Aggregate = AggregateEnum.Sum
g.GroupOn = "*"
g.TotalOn = "购进金额,付款金额,未付款金额"
g.Caption = "总计"
t.SubtotalGroups.Add(g)
t.Subtotal()
MainTable = t