''---------------------------------试验工时表筛选树--------------------------------------------
'首先生成统计表
Dim dt8 As DataTable
Dim b8 As New sqlGroupTableBuilder("统计表工时表1","工时表")
b8.C
b8.Groups.AddDef("日期",DateGroupEnum.Year,"年")
b8.Groups.AddDef("日期",DateGroupEnum.Month,"月")
b8.Groups.AddDef("日期",DateGroupEnum.day,"日")
b8.Groups.AddDef("生产工段")
b8.Groups.AddDef("考勤班组")
b8.Groups.AddDef("考勤员")
b8.Groups.AddDef("零件序号")
b8.Groups.AddDef("操作人")
b8.Groups.AddDef("商品全名")
b8.Totals.AddDef("零件序号",AggregateEnum.Count,"次数") '根据客户列来统计记录数,也就是订单数
dt8 = b8.Build(True) '参数设置为True,生成一个临时表,不在主界面显示
'然后根据统计表生成目录树
Dim trv8 As WinForm.TreeView = e.Form.Controls("TreeView5")
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 Product8 As String = nd.DataRow("生产工段")
Dim Product9 As String = nd.DataRow("零件序号")
Dim Product10 As String = nd.DataRow("操作人")
Dim Product11 As String = nd.DataRow("考勤班组")
Dim Product12 As String = nd.DataRow("考勤员")
Dim Product13 As String = nd.DataRow("商品全名")
Select Case nd.Level
Case 0
nd.Text = nd.text & "年(" & dt8.Compute("Count(零件序号)","年 = " & Year) & " )"
Case 1
nd.Text = nd.text & "月(" & dt8.Compute("Count(零件序号)","年 = " & Year & " And 月 = " & Month) & " )"
Case 2
nd.Text = nd.text & "日(" & dt8.Compute("Count(零件序号)","年 = " & Year & " And 月 = " & Month & " And 日= " & day) & " )"
Case 3
nd.Text = nd.text & "(" & dt8.Compute("Count(零件序号)","年 = " & Year & " And 月 = " & Month & " And 日= " & day & " And 生产工段 = '" & Product8 & "'") & ")"
Case 4
nd.Text = nd.text & "(" & dt8.Compute("Count(零件序号)","年 = " & Year & " And 月 = " & Month & " And 日= " & day & " And 生产工段 = '" & Product8 & "'And 考勤班组= '" & Product11 & "'") & ")"
Case 5
nd.Text = nd.text & "(" & dt8.Compute("Count(零件序号)","年 = " & Year & " And 月 = " & Month & " And 日= " & day & " And 生产工段 = '" & Product8 & "'And 考勤班组= '" & Product11 & "'And 考勤员= '" & Product12 & "'") & ")"
Case 6
nd.Text = nd.text & "(" & dt8.Compute("Count(零件序号)","年 = " & Year & " And 月 = " & Month & " And 日= " & day & " And 生产工段 = '" & Product8 & "'And 考勤班组= '" & Product11 & "'And 考勤员= '" & Product12 & "'And 操作人= '" & Product10 & "'") & ")"
End Select
Next
trv8.Nodes.Insert("显示所有行","显示所有行(" & dt8.Compute("Count(次数)") & ")",0)
trv8.ResumeRedraw