老师,我在目录树的代码需要加一层筛选,在领料单位下面还有领料人,点击领料单位是正常的,怎么把领料人加上?试了好多次也不行,请您指导。Dim Filter As String = ""
If e.node.Name <> "所有行" Then '要用Name属性,不能用Text属性
Dim d1 As Date
Dim d2 As Date
Dim Year As Integer = e.Node.DataRow("年")
Dim Month As Integer = e.Node.DataRow("月")
Dim day As Integer = e.Node.DataRow("日")
Dim Product As String = e.Node.DataRow("领料单位")
Dim Product1 As String = e.Node.DataRow("领料人")
'Dim Product2 As String = e.Node.DataRow("考勤员")
Select Case e.Node.Level
Case 0
d1 = New Date(Year,1,1) '取得该年的第一天
d2 = new Date(Year,12,31) '取得该年的最后一天
Filter = "日期 >= '" & d1 & "' And 日期 <= '" & d2 & "'"
Case 1
d1 = New Date(Year, Month, 1) '取得该月的第一天
d2 = new Date(Year, Month, Date.DaysInMonth(Year,Month)) '取得该月的最后一天
Filter = "日期 >= '" & d1 & "' And 日期 <= '" & d2 & "'"
Case 2
Filter = "[领料单位] = '" & e.Node.DataRow("领料单位") & "'and Year(日期) = " & Year & " And Month(日期) = " & Month
Case 3
Filter = "[领料单位] = '" & e.Node.DataRow("领料单位") & "'and Year(日期) = " & Year & " And Month(日期) = " & Month & " And day(日期) = " & day
Case 4
上面的正常,这个是我加的,不行 Filter = "[领料单位] = '" & e.Node.DataRow("领料单位") & "'and [领料人] = '" & e.Node.DataRow("领料人") & "'and Year(日期) = " & Year & " And Month(日期) = " & Month & " And day(日期) = " & day
End Select
End If
DataTables("材料领用表").LoadFilter = Filter
DataTables("材料领用表").Load()
''首先生成统计表
Dim dt5 As DataTable
Dim b5 As New sqlGroupTableBuilder("统计表材料领用表","材料领用表")
b5.C
b5.Groups.AddDef("日期",DateGroupEnum.Year,"年")
b5.Groups.AddDef("日期",DateGroupEnum.Month,"月")
b5.Groups.AddDef("日期",DateGroupEnum.day,"日")
b5.Groups.AddDef("领料单位")
b5.Groups.AddDef("序号")
b5.Groups.AddDef("领料人")
b5.Totals.AddDef("序号",AggregateEnum.Count,"次数") '根据客户列来统计记录数,也就是订单数
dt5 = b5.Build(True) '参数设置为True,生成一个临时表,不在主界面显示
'然后根据统计表生成目录树
Dim trv5 As WinForm.TreeView = e.Form.Controls("TreeView1")
trv5.BuildTree(dt5, "年|月|领料单位|领料人")
trv5.StopRedraw
For Each nd As WinForm.TreeNode In trv5.AllNodes
Dim Year As Integer = nd.DataRow("年")
Dim Month As Integer = nd.DataRow("月")
Dim day As Integer = nd.DataRow("日")
Dim Product51 As String = nd.DataRow("领料单位")
Dim Product52 As String = nd.DataRow("序号")
Dim Product6 As String = nd.DataRow("领料人")
Select Case nd.Level
Case 0
nd.Text = nd.text & "(" & dt5.Compute("Sum(次数)","年 = " & Year) & ")"
Case 1
nd.Text = nd.text & "(" & dt5.Compute("Sum(次数)","年 = " & Year & " And 月 = " & Month) & ")"
Case 2
nd.Text = nd.text & "(" & dt5.Compute("Sum(次数)","年 = " & Year & " And 月 = " & Month & " And 领料单位 = '" & nd.Text & "'") & ")"
Case 3
nd.Text = nd.text & "(" & dt5.Compute("Sum(次数)","年 = " & Year & " And 月 = " & Month & " And 领料单位 = '" & Product51 & "' And 领料人 = '" & nd.Text & "'") & ")"
Case 4
nd.Text = nd.text & "(" & nd.DataRow("次数") & ")"
End Select
Next
trv5.Nodes.Insert("所有行","所有行(" & dt5.Compute("Sum(次数)") & ")",0)
trv5.ResumeRedraw
生成目录树的时候没有包含【日】这个列呀:trv5.BuildTree(dt5, "
年|月|领料单位|领料人")
所以筛选条件里就不应该包含【日】的条件,再说只有4层节点,不存在Case 4的吧
老师,这里就是故意没有包含(日),需要修改哪里呢?