我的数据表名称:通知,数据列包括:发布时间(datatime类型)、发布人(字符型)、标题(字符型)、内容(字符型)、接收人(字符型)、接收时间(datatime类型)
我的编程代码是:
以下内容为程序代码:
1 3、窗口的AfterLoad事件设为
2
3 '首先生成统计表
4 Dim dt As DataTable
5 Dim b As New SQLGroupTableBuilder("统计表1","通知")
6 b.Groups.AddDef("发布时间",DateGroupEnum.Year,"年")
7 b.Groups.AddDef("发布时间",DateGroupEnum.Month,"月")
8 b.Groups.AddDef("标题")
9 b.Totals.AddDef("_Identify",AggregateEnum.Count,"通知数") '根据主键列来统计记录数,也就是订单数
10 dt = b.Build(False) '参数设置为False,生成一个临时表,不在主界面显示
11 '然后根据统计表生成目录树
12 Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
13 trv.BuildTree(dt, "年|月|标题")
14 trv.StopRedraw
15 For Each nd As WinForm.TreeNode In trv.AllNodes
16 Dim Year As Integer = nd.DataRow("年")
17 Dim Month As Integer = nd.DataRow("月")
18 Dim Product As String = nd.DataRow("标题")
19 Select Case nd.Level
20 Case 0
21 nd.Text = nd.text & "年(" & dt.Compute("Sum(通知数)","年 = " & Year) & "条)"
22 Case 1
23 nd.Text = nd.text & "月(" & dt.Compute("Sum(通知数)","年 = " & Year & " And 月 = " & Month) & "条)"
24 Case 2
25 nd.Text = nd.text & "(" & nd.DataRow("通知数") & ")"
26 End Select
27 Next
28 trv.Nodes.Insert("加载所有行","加载所有行(" & dt.Compute("Sum(通知数)") & "条)",0)
29 trv.ResumeRedraw
30
31 4、将目录树的NodeMouseDoubleClick事件设为:
32
33 Dim Filter As String = ""
34 If e.Node.Name <> "加载所有行" Then
35 Dim Year As Integer = e.Node.DataRow("年")
36 Dim Month As Integer = e.Node.DataRow("月")
37 Dim Product As String = e.Node.DataRow("标题")
38 Select Case e.Node.Level
39 Case 0
40 Filter ="Year(发布时间) = " & Year
41 Case 1
42 Filter ="Year(发布时间) = " & Year & " And Month(发布时间) = " & Month
43 Case 2
44 Filter ="Year(发布时间) = " & Year & " And Month(发布时间) = " & Month & " And 标题 = '" & Product & "'"
45 End Select
46 End If
47 DataTables("通知").LoadFilter = Filter
48 DataTables("通知").Load()
49
[此贴子已经被作者于2015/2/26 19:02:58编辑过]