''---------------------------------设置工艺卡筛选树(按日期显示)--------------------------------------------
''首先生成统计表
Dim dt8 As DataTable
Dim b8 As New sqlGroupTableBuilder("统计表零件目录","零件目录表")
b8.C
b8.Groups.AddDef("日期",DateGroupEnum.Year,"年")
b8.Groups.AddDef("日期",DateGroupEnum.Month,"月")
b8.Groups.AddDef("日期",DateGroupEnum.day,"日")
b8.Groups.AddDef("零件序号")
b8.Totals.AddDef("零件序号",AggregateEnum.Count,"次数") '根据客户列来统计记录数,也就是订单数
dt8 = b8.Build(True) '参数设置为True,生成一个临时表,不在主界面显示
'然后根据统计表生成目录树
Dim trv8 As WinForm.TreeView = e.Form.Controls("TreeView2")
trv8.BuildTree(dt8, "年|月|日|零件序号")
trv8.StopRedraw
For Each nd As WinForm.TreeNode In trv8.AllNodes
Dim Year As Integer = nd.DataRow("年")
Dim Month As Integer = nd.DataRow("月")
Dim day As Integer = nd.DataRow("日")
Dim Product5 As String = nd.DataRow("零件序号")
Select Case nd.Level
Case 0
nd.Text = nd.text & "年(" & dt8.Compute("Sum(次数)","年 = " & Year) & ")"
Case 1
nd.Text = nd.text & "月(" & dt8.Compute("Sum(次数)","年 = " & Year & " And 月 = " & Month) & ")"
Case 2
nd.Text = nd.text & "日(" & dt8.Compute("Sum(次数)","年 = " & Year & " And 月 = " & Month & " and 日 = " & day) & ")"
Case 3
nd.Text = nd.text & "#(" & dt8.Compute("Sum(次数)","年 = " & Year & " And 月 = " & Month & " and 日 = " & day & " And 零件序号 = '" & nd.Text & "'") & ")"
Case 4
nd.Text = nd.text & "(" & nd.DataRow("次数") & ")"
End Select
Next
trv8.Nodes.Insert("所有行","所有行(" & dt8.Compute("Sum(次数)") & ")",0)
trv8.ResumeRedraw