窗口表事件
窗口与控件事件
订刊分级统计表_AfterLoad
'首先生成统计表
Dim dt As DataTable
Dim b As New GroupTableBuilder("订刊分级统计表",DataTables("订户信息表"))
b.Groups.AddDef("一级")
b.Groups.AddDef("二级")
b.Groups.AddDef("三级")
b.Totals.AddDef("份数") '添加份数列用于统计
b.Build '生成统计表
'MainTable = Tables("订刊分级统计表") '打开生成的统计表 '参数设置为False,生成一个临时表,不在主界面显示
'然后根据统计表生成目录树
dt = b.Build(False) '参数设置为False,生成一个临时表,不在主界面显示
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt, "一级|二级|三级")
trv.StopRedraw
For Each nd As WinForm.TreeNode In trv.AllNodes
Dim one As String = nd.DataRow("一级")
Dim two As String = nd.DataRow("二级")
Dim three As String = nd.DataRow("三级")
Select Case nd.Level
Case 0
nd.Text = nd.text & "(" & dt.Compute("Sum(份数)","一级 = " & one) & "份)"
Case 1
nd.Text = nd.text & "(" & dt.Compute("Sum(份数)","一级 = " & one & " And 二级 = " & two) & "份)"
Case 2
nd.Text = nd.text & "(" & nd.DataRow("份数") & "份)"
End Select
Next
trv.Nodes.Insert("加载所有行","加载所有行(" & dt.Compute("Sum(份数)") & "份)",0)
trv.ResumeRedraw
订刊分级统计表_TreeView1_NodeMouseDoubleClick
Dim Filter As String = ""
If e.Node.Name <> "加载所有行" Then '要用Name属性,不能用Text属性
Dim one As String = e.Node.DataRow("一级")
Dim Two As String = e.Node.DataRow("二级")
Dim three As String = e.Node.DataRow("三级")
Select Case e.Node.Level
Case 0
Filter ="一级 = " & one
Case 1
Filter ="一级 = " & one & " And 二级 = " & two
Case 2
Filter ="一级 = " & one & " And 二级 = " & two & " And 三级 = '" & three & "'"
End Select
End If
DataTables("订户信息表").LoadFilter = Filter
DataTables("订户信息表").Load()