1楼是用“入职日期”来显示加载树统计数据
我现在用“课室”、“组别”、“班别”生成统计数据
窗口应用时没有问题,显示的资料都是正确的,但窗口设计-->文件-->预览,又弹出“菜单的SystemIdle事件执行过程.....”,窗口一直跳出来,停不下来
请问:哪里需要修改?
另外,在目录树生成,还没有选择节点前,会显示所有人员,包括已离职的人员。
窗口 Afterload事件:
Dim dt As DataTable
Dim b As New SQLGroupTableBuilder("统计表1","员工名册") '首先生成统计表
b.C '这里是数据库名称,在论坛无法正常显示
b.Filter = "离职 = 0"
b.Groups.AddDef("课室")
b.Groups.AddDef("组别")
b.Groups.AddDef("班别")
b.Totals.AddDef("工号",AggregateEnum.Count,"工号") '根据工号列来统计记录数,也就是人数
b.Build()
dt = DataTables("统计表1") '生成统计表
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt,"课室|组别|班别") '然后根据统计表生成目录树
trv.StopRedraw
For Each nd As WinForm.TreeNode In trv.AllNodes
Dim ke As String = nd.DataRow("课室")
Dim zu As String = nd.DataRow("组别")
Dim ban As String = nd.DataRow("班别")
Select Case nd.Level
Case 0
nd.Text = nd.text & "(" & dt.Compute("Sum(工号)","课室 = '" & ke & "'" ) & "人)"
Case 1
nd.Text = nd.text & "(" & dt.Compute("Sum(工号)","课室 = '" & ke & "' And 组别 = '" & zu & "'" ) & "人)"
Case 2
nd.text = nd.text & "(" & dt.Compute("Sum(工号)","课室 = '" & ke & "' And 组别 = '" & zu & "' And 班别 = '" & ban & "'" ) & "人)"
End Select
Next
trv.Nodes.Insert("加载所有行","加载所有行(" & dt.Compute("Sum(工号)") & "人)",0)
trv.ResumeRedraw
目录树 NodeMouseClick事件:
Dim Filter As String = "离职日期 is null "
If e.Node.Name <> "加载所有行" Then '要用Name属性,不能用Text属性
Dim ke As String = e.Node.DataRow("课室")
Dim zu As String = e.Node.DataRow("组别")
Dim ban As String = e.Node.DataRow("班别")
Select Case e.Node.Level
Case 0
Filter = "课室 = '" & ke & "'and 离职日期 is null"
Case 1
Filter = "课室 = '" & ke & "' and 组别 = '" & zu & "'"
Case 2
Filter = "课室 = '" & ke & "' and 组别 = '" & zu & "'and 班别 = '" & ban & "'"
End Select
End If
DataTables("员工名册").LoadFilter = filter
DataTables("员工名册").Load()
[此贴子已经被作者于2015/7/9 15:33:03编辑过]