以下是筛选树代码,能否该成按年、月、日统计筛选窗口afterload
'首先生成统计表
Dim dt As DataTable
Dim b As New GroupTableBuilder("监检统计",DataTables("信息主表"))
b.Groups.AddDef("监检日期",DateGroupEnum.Year,"年")
b.Groups.AddDef("监检日期",DateGroupEnum.Month,"月")
b.Groups.AddDef("监检日期",DateGroupEnum.Day,"日")
b.Groups.AddDef("气柜规格及厂家")
b.Totals.AddDef("底盘号",AggregateEnum.Count,"辆") '根据底盘号列来统计记录数,也就是辆
dt = b.Build(True) '参数设置为True,生成一个临时表,不在主界面显示
'然后根据统计表生成目录树
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 Month As Integer = nd.DataRow("月")
Dim Day As Integer = nd.DataRow("日")
Dim Product As String = nd.DataRow("气柜规格及厂家")
Select Case nd.Level
Case 0
nd.Text = nd.text & "年(" & dt.Compute("Sum(辆)","年 = " & Year) & "辆)"
Case 1
nd.Text = nd.text & "月(" & dt.Compute("Sum(辆)","年 = " & Year & " And 月 = " & Month) & "辆)"
Case 2
nd.Text = nd.text & "月(" & dt.Compute("Sum(辆)","年 = " & Year & " And 月 = " & Month & " And 日 = " & Day) & "辆)"
Case 3
nd.Text = nd.text & "(" & nd.DataRow("辆") & "辆)"
End Select
Next
trv.Nodes.Insert("显示所有行","显示所有行(" & dt.Compute("Sum(辆)") & "辆)",0)
trv.ResumeRed
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 Product 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
d1 = New Date(Year, Month, 1) '取得该月的第一天
d2 = new Date(Year, Month, Date.DaysInMonth(Year,Month)) '取得该月的最后一天
Filter = "监检日期 >= #" & d1 & "# And 监检日期 <= #" & d2 & "# And 气柜规格及厂家 = '" & Product & "'"
End Select
End If
Tables("信息主表").Filter = Filter
本人菜鸟,请各位大神帮忙,谢谢1