Dim bd1 As New GroupTableBuilder("统计表1",DataTables("销售记录"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("日期", DateGroupEnum.Year, "年")
bd1.Groups.AddDef("日期", "月")
bd1.Groups.AddDef("姓名") '根据型号分组
bd1.Totals.AddDef("金额","销售金额") '对金额进行统计
bd1.Totals.AddDef("实发金额") '对金额进行统计
bd1.Totals.AddDef("提留金额") '对金额进行统计
dt1 = bd1.BuildDataSource()
Dim bd2 As New GroupTableBuilder("统计表2",DataTables("奖罚记录"))
Dim dt2 As fxDataSource
bd2.Groups.AddDef("日期", DateGroupEnum.Year, "年")
bd2.Groups.AddDef("日期", "月")
bd2.Groups.AddDef("姓名") '根据型号分组
bd2.Totals.AddDef("奖励") '对数量进行统计
bd2.Totals.AddDef("罚款") '对金额进行统计
dt2 = bd2.BuildDataSource()
Dim bd3 As New GroupTableBuilder("统计表3",DataTables("业务员信息"))
Dim dt3 As fxDataSource
bd3.Groups.AddDef("姓名") '根据型号分组
bd3.Totals.AddDef("底薪") '对金额进行统计
dt3 = bd3.BuildDataSource()
Dim nms1 As String() = {"姓名","年","月"} '指定连接列
Dim nms2 As String() = {"姓名"} '指定连接列
dt1.Combine(nms1,dt2,nms1) '将销售统计数据组合到进货统计数据
dt1.Combine(nms2,dt3,nms2) '将销售统计数据组合到进货统计数据
Tables("工资_Table1").DataSource = dt1 '将统计结果绑定到Table
With DataTables("工资_Table1").DataCols '用表达式列计算库存数据
.Add("实发工资",Gettype(Double), " IsNull([实发金额],0) + IsNull([奖励],0) +IsNull([底薪],0) -IsNull([罚款],0)")
End With
Dim t As Table = Forms("工资").controls("Table1").Table
t.DataSource = dt1 '将统计结果绑定到Table
t.DataTable.DataCols.Add("日期",Gettype(Date))
t.Cols("日期").Visible = False
For Each r As Row In t.Rows
r("日期") = new Date(r("年"),r("月"),1)
Next
Dim at1 As Table = Tables("工资_Table1")
For Each c11 As Col In at1.Cols
c11.TextAlign = TextAlignEnum.Center
Next