Dim dg As DataTable
Dim b As New SQLGroupTableBuilder("统计表1","劳务人员登记表")
b.C
If User.Name = "开发者" Or User.Name = "管理员" Then
b.Filter = ""
Else
b.Filter = "承包人机构 in ('" & User.Roles.replace(",","','") & "') or 监理机构 in ('" & User.Roles.replace(",","','") & "') or 业主机构 in ('" & User.Roles.replace(",","','") & "') or 劳务队负责人 in ('" & User.Roles.replace(",","','") & "')"
End If
b.Groups.AddDef("项目名称")
b.Groups.AddDef("施工合同段")
b.Groups.AddDef("劳务队名称")
b.Groups.AddDef("工种")
b.Totals.AddDef("姓名",AggregateEnum.Count,"人数") '根据客户列来统计记录数,也就是订单数
dg = b.Build(True) '参数设置为True,生成一个临时表,不在主界面显示
'然后根据统计表生成目录树
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dg,"项目名称|施工合同段|劳务队名称|工种")
trv.StopRedraw
For Each nd As WinForm.TreeNode In trv.AllNodes
Dim Xmmc As String = "'" & nd.DataRow("项目名称") & "'"
Dim Xghtd As String = "'" & nd.DataRow("施工合同段") & "'"
Dim Lwdmc As String = "'" & nd.DataRow("劳务队名称") & "'"
Dim Gz As String = "'" & nd.DataRow("工种") & "'"
Select Case nd.Level
Case 0
nd.Text = nd.text & "(" & dg.Compute("Sum(人数)","项目名称 = " & Xmmc) & "人)"
Case 1
nd.Text = nd.text & "(" & dg.Compute("Sum(人数)","项目名称 = " & Xmmc & " And 施工合同段 = " & Xghtd) & "人)"
Case 2
nd.Text = nd.text & "(" & dg.Compute("Sum(人数)","项目名称 = " & Xmmc & " And 施工合同段 = " & Xghtd & " And 劳务队名称 = " & Lwdmc) & "人)"
Case 3
nd.Text = nd.text & "(" & nd.DataRow("人数") & "人)"
End Select
Next
trv.Nodes.Insert("加载所有数据","加载所有数据(" & dg.Compute("Sum(人数)") & "人)",0)
trv.ResumeRedraw
e.Form.Controls("TextBox5").Value = 1 & "/" & DataTables("劳务人员登记表").TotalPages
vars("劳务人员登记表filter") = DataTables("劳务人员登记表").LoadFilter