Dim bd1 As New GroupTableBuilder("统计表1",DataTables("营业收入"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("店面名称") '根据店面名称分组
bd1.Groups.AddDef("月度", DateGroupEnum.Year, "年度")
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("月度", DateGroupEnum.Year, "年度")
bd2.Groups.AddDef("月度") '根据月度分组
bd2.Totals.AddDef("支出金额","支出总金额") '对支出金额进行统计
dt2 = bd2.BuildDataSource()
Dim bd3 As New GroupTableBuilder("统计表3",DataTables("费用支出"))
Dim dt3 As fxDataSource
bd3.Groups.AddDef("店面名称") '根据店面名称分组
bd3.Groups.AddDef("月度", DateGroupEnum.Year, "年度")
bd3.Groups.AddDef("月度") '根据月度分组
bd3.Totals.AddDef("费用金额","费用总金额") '对费用金额进行统计
dt3 = bd3.BuildDataSource()
Dim bd4 As New GroupTableBuilder("统计表4",DataTables("成本支出"))
Dim dt4 As fxDataSource
bd4.Groups.AddDef("店面名称") '根据店面名称分组
bd4.Groups.AddDef("月度", DateGroupEnum.Year, "年度")
bd4.Groups.AddDef("月度") '根据月度分组
bd4.Totals.AddDef("成本金额","成本总金额") '对成本金额进行统计
dt4 = bd4.BuildDataSource()
Dim nms As String() = {"店面名称","年度","月度"} '指定连接列
dt1.Combine(nms,dt2,nms) '将支出总金额组合到营业收入统计数据
dt1.Combine(nms,dt3,nms) '将费用总金额组合到营业收入统计数据
dt1.Combine(nms,dt4,nms) '将成本总金额组合到营业收入统计数据
Tables("窗口1_Table11").DataSource = dt1 '将统计结果绑定到Table
With DataTables("窗口1_Table11").DataCols '用表达式列计算当月利润数据
.Add("当月利润",Gettype(Integer), "IsNull([收入总金额],0) - ISNULL([支出总金额],0) - ISNULL([费用总金额],0) - ISNULL([成本总金额],0)")
End With