麻烦老师帮忙修改一下,谢谢!
Dim dt As DataTable
Dim b As New GroupTableBuilder("统计表2",DataTables("成品出库"))
b.Groups.AddDef("出库日期",DateGroupEnum.Year,"年")
b.Groups.AddDef("出库方式")
b.Groups.AddDef("系列")
b.Totals.AddDef("数量",AggregateEnum.sum,"数量") '根据主键列来统计记录数,也就是订单数
dt = b.Build(False) '参数设置为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 Year As Integer = nd.DataRow("年")
Dim M As String = nd.DataRow("出库方式")
Dim Product As String = nd.DataRow("系列")
Dim dr As DataRow
Select Case nd.Level
Case 0
nd.Text = nd.text & "年(" & dt.Compute("Sum(数量)","年 = " & Year) & "套)"
Case 1
nd.Text = nd.text & "(" & dt.Compute("Sum(数量)"," [出库方式] = '" & dr("出库方式") &"'") & "套)"
Case 2
nd.Text = nd.text & "(" & nd.DataRow("数量") & ")"
End Select
Next
trv.Nodes.Insert("加载所有订单","加载所有订单(" & dt.Compute("Sum(数量)") & "套)",0)
trv.ResumeRedraw
[此贴子已经被作者于2019/12/10 10:35:01编辑过]