Dim dt As DataTable
Dim b As New GroupTableBuilder("统计表1",DataTables("隐患排查表"))
b.Groups.AddDef("创建时间",DateGroupEnum.Year,"年")
b.Groups.AddDef("创建时间",DateGroupEnum.Month,"月")
b.Groups.AddDef("区域")
b.Groups.AddDef("专业")
b.Totals.AddDef("班组",AggregateEnum.Count,"隐患数1") '根据班组列来统计记录数,也就是订单数
b.Totals.AddDef("班组",AggregateEnum.Count,"隐患数") '根据班组列来统计记录数,也就是订单数
dt = b.Build(True) '参数设置为True,生成一个临时表,不在主界面显示
'然后根据统计表生成目录树
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView3")
trv.BuildTree(dt, "年|月|区域|专业")
trv.StopRedraw
For Each nd As WinForm.TreeNode In trv.AllNodes
Dim Year As Integer = nd.DataRow("年")
Dim Month As Integer = nd.DataRow("月")
Dim Product As String = nd.DataRow("区域")
Dim Product1 As String = nd.DataRow("专业")
Select Case nd.Level
Case 0
nd.Text = nd.text & "年(" & dt.Compute("Sum(隐患数)","年 = " & Year) & "条)"
Case 1
nd.Text = nd.text & "月(" & dt.Compute("Sum(隐患数)","年 = " & Year & " And 月 = " & Month) & "条)"
Case 2
nd.Text = nd.text & "(" & nd.DataRow("隐患数1") & "条)"
Case 3
nd.Text = nd.text & "(" & nd.DataRow("隐患数") & "条)"
End Select
Next
trv.Nodes.Insert("显示所有行","显示所有行(" & dt.Compute("Sum(隐患数)") & "条)",0)
trv.ResumeRedraw