完整代码:
Dim dr2 As DataRow
Dim Lms As String() ={"语文","数学","英语","体育"}
Dim bd1 As New GroupTableBuilder("统计",DataTables("表A"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("语文老师", "姓名")
bd1.Totals.AddDef("语文老师", AggregateEnum.Count, "语文")
bd1.Totals.AddDef("总学费", AggregateEnum.sum, "语文总学费")
dt1 = bd1.BuildDataSource()
bd1 = New GroupTableBuilder("统计",DataTables("表A"))
Dim dt2 As fxDataSource
bd1.Groups.AddDef("数学老师", "姓名")
bd1.Totals.AddDef("数学老师", AggregateEnum.Count, "数学")
bd1.Totals.AddDef("总学费", AggregateEnum.sum, "数学总学费")
dt2 = bd1.BuildDataSource()
bd1 = New GroupTableBuilder("统计",DataTables("表A"))
Dim dt3 As fxDataSource
bd1.Groups.AddDef("英语老师", "姓名")
bd1.Totals.AddDef("英语老师", AggregateEnum.Count, "英语")
bd1.Totals.AddDef("总学费", AggregateEnum.sum, "英语总学费")
dt3 = bd1.BuildDataSource()
bd1 = New GroupTableBuilder("统计",DataTables("表A"))
Dim dt4 As fxDataSource
bd1.Groups.AddDef("体育老师", "姓名")
bd1.Totals.AddDef("体育老师", AggregateEnum.Count, "体育")
bd1.Totals.AddDef("总学费", AggregateEnum.sum, "体育总学费")
dt4 = bd1.BuildDataSource()
dt1.Combine("姓名",dt2,"姓名")
dt1.Combine("姓名",dt3,"姓名")
dt1.Combine("姓名",dt4,"姓名")
Dim t3 As Table = Tables("窗口1_Table1")
t3.DataSource = dt1 '将统计结果绑定到Table
t3.StopRedraw
With t3.DataTable.DataCols '
.Add("提成总计金额",Gettype(Double))
End With
Dim v1 As Double
For Each r3 As Row In t3.Rows
v1=0
For Each c1 As String In Lms
dr2 = DataTables("设置").Find("课程 ='" & c1 & "'")
If dr2 IsNot Nothing Then
v1+ = r3(c1 & "总学费") * dr2("提成")*r3(c1)
End If
Next c1
r3("提成总计金额")=v1
Next r3
t3.ResumeRedraw