手动设计筛选树,对账单窗口的AfterLoad事件代码:
'首先生成统计表
Dim dt As DataTable
Dim b As New GroupTableBuilder("统计表1",DataTables("客户表"))
b.Groups.AddDef("客户")
b.Groups.AddDef("工序")
b.Groups.AddDef("品名规格")
b.Totals.AddDef("客户",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 Product As String = nd.DataRow("客户")
Dim gx As String = nd.DataRow("工序")
Dim pmgg As String = nd.DataRow("品名规格")
Select Case nd.Level
Case 0
nd.Text = nd.text & "(" & dt.Compute("Sum(个数)","客户 = '" & Product & "'") & "条)"
Case 1
nd.Text = nd.text & "(" & dt.Compute("Sum(个数)","客户 = '" & Product & "' And 工序 = '" & gx & "'") & "条)"
Case 2
nd.Text = nd.text & "(" & dt.Compute("Sum(个数)","客户 = '" & Product & "' And 工序 = '" & gx & "' And 品名规格 = '" & pmgg & "'") & "条)"
Case 3
nd.Text = nd.text & "(" & nd.DataRow("个数") & "条)"
End Select
Next
trv.Nodes.Insert("显示所有行","显示所有行(" & dt.Compute("Sum(个数)") & "条)",0)
trv.ResumeRedraw
目录树控件的NodeMouseDoubleClick事件代码:
Dim Filter As String
Dim dr As DataRow = e.Node.DataRow '获取生成此节点的行
If e.Node.Text <> "显示所有行" Then
Select Case e.Node.Level
Case 0
Filter = "[客户] = '" & dr("客户") & "'"
Case 1
Filter = "[客户] = '" & dr("客户") & "' And [工序] = '" & dr("工序") & "'"
Case 2
Filter = "[客户] = '" & dr("客户") & "' And [工序] = '" & dr("工序") & "' And [品名规格] = '" & dr("品名规格") & "'"
End Select
End If
e.Form.controls("对账单").Table.Filter = Filter
测试结果:
用户“入库员”打开窗口后,出现错误提示:
此主题相关图片如下:1.png
问题项目上传:
[此贴子已经被作者于2017/2/23 10:35:54编辑过]