Dim g As New SQLGroupTableBuilder("TJB", "订单")
g.Groups.AddDef("产品")
g.Groups.AddDef("客户")
g.Groups.AddDef("雇员")
g.Totals.AddDef("_Identify", AggregateEnum.Count, "行数")
Dim gt As DataTable = g.Build(False)
Dim dt As DataTable
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt, "产品|客户|雇员")
trv.StopRedraw
For Each nd As WinForm.TreeNode In trv.AllNodes
Dim s1 As String = nd.DataRow("产品")
Dim s2 As String = nd.DataRow("客户")
Dim s3 As String = nd.DataRow("雇员")
Select Case nd.Level
Case 0
nd.Text = nd.text & "产品(" & dt.Compute("Sum(行数)", "产品 = " & s1) & "条)"
Case 1
nd.Text = nd.text & "客户(" & dt.Compute("Sum(行数)", "客户 = " & s1 & " And 客户 = " & s2) & "条)"
Case 2
nd.Text = nd.text & "雇员(" & dt.Compute("Sum(行数)", "产品 = " & s1 & " And 客户= " & s2 & " And 雇员 = " & s3) & "条)"
End Select
Next
trv.Nodes.Insert("[加载所有数据]", "加载所有数据(" & Val(dt.Compute("Sum(行数)")) & "条)", 0)
trv.ResumeRedraw