款号登记表:
此主题相关图片如下:111.png
窗口
此主题相关图片如下:222.png
AfterLoad
'首先生成统计表
Dim dt As DataTable
Dim b As New SQLGroupTableBuilder("统计表1","款号登记")
b.Con nection Name= "Lucifer"
b.Groups.AddDef("品牌")
b.Groups.AddDef("年份季度")
b.Groups.AddDef("款类")
b.Totals.AddDef("_Identify",AggregateEnum.Count,"款式数量")
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 pp As String = nd.DataRow("品牌")
Dim nj As String = nd.DataRow("年份季度")
Dim Product As String = nd.DataRow("款类")
Select Case nd.Level
Case 0
nd.Text = nd.text & "(" & dt.Compute("Sum(订单数)","品牌 = " & pp) & "条)"
Case 1
nd.Text = nd.text & "(" & dt.Compute("Sum(订单数)","年份季度 = " & nj) & "条)"
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 pp As String = e.Node.DataRow("品牌")
Dim nj As String = e.Node.DataRow("年份季度")
Dim Product As String = e.Node.DataRow("款类")
Select Case e.Node.Level
Case 0
Filter ="品牌 = " & pp
Case 1
Filter ="品牌 = " & pp & " And 年份季节 = " & nj
Case 2
Filter ="品牌 = " & pp & " And 年份季度 = " & nj & " And 款类 = '" & Product & "'"
End Select
End If
DataTables("款号登记").LoadFilter = Filter
DataTables("款号登记").Load()
[此贴子已经被作者于2018/7/13 16:11:13编辑过]