'筛选党员
DataTables("党员资料").LoadFilter = "[入党时间] is not null"
DataTables("党员资料").Load
'生成统计表
Dim dt As DataTable
Dim b As New GroupTableBuilder("统计表1",DataTables("党员资料"))
b.Groups.AddDef("单位")
b.Groups.AddDef("性别")
b.Totals.AddDef("姓名",AggregateEnum.Count,"党员数") '根据客户列来统计记录数,也就是订单数
dt = b.Build '参数设置为False,生成一个临时表,不在主界面显示
'然后根据统计表生成目录树
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt,"单位|性别")
trv.StopRedraw
For Each nd As WinForm.TreeNode In trv.AllNodes
Dim bm As String = nd.DataRow("单位")
Dim xb As String = nd.DataRow("性别")
Select Case nd.Level
Case 0
nd.Text = nd.text & "(" & dt.Compute("Sum(党员数)","单位 = '" & bm & "'") & ")"
Case 1
nd.Text = nd.text & "性别(" & dt.Compute("Sum(党员数)","单位 = '" & bm & "' And 性别 = '" & xb & "'") & ")"
End Select
Next
trv.ResumeRedraw