以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 统计加载数统计数量不对的问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=126123) |
-- 作者:aza520 -- 发布时间:2018/10/15 9:16:00 -- 统计加载数统计数量不对的问题 加载树的代码如下,但有些项统计的数量不对,如图,“搅拌站”统计的是3个,其实是有4个,请问老师,可能是什么问题? Dim Filter As String = "1=1" If e.Node.Name <> "加载所有数据" Then Dim Xmmc As String = e.Node.DataRow("项目名称") Dim Xghtd As String = e.Node.DataRow("施工合同段") Dim Lwdmc As String = e.Node.DataRow("劳务队名称") Dim Gz As String = e.Node.DataRow("工种") Select Case e.Node.Level Case 0 Filter = "[项目名称] = \'" & Xmmc & "\'" Case 1 Filter = "[项目名称] = \'" & Xmmc & "\'And [施工合同段] = \'" & Xghtd & "\'" Case 2 Filter = "[项目名称] = \'" & Xmmc & "\'And [施工合同段] = \'" & Xghtd & "\' And [劳务队名称] = \'" & Lwdmc & "\'" Case 3 Filter = "[项目名称] = \'" & Xmmc & "\'And [施工合同段] = \'" & Xghtd & "\' And [劳务队名称] = \'" & Lwdmc & "\'And [工种] = \'" & Gz & "\'" End Select End If 图一: |
-- 作者:有点甜 -- 发布时间:2018/10/15 9:18:00 -- 贴出你afterLoad事件代码
做一个实例发上来测试 |
-- 作者:aza520 -- 发布时间:2018/10/15 9:23:00 -- 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 |
-- 作者:有点甜 -- 发布时间:2018/10/15 9:24:00 -- 你统计的时候,是不是加上了这个条件?
b.Filter = "承包人机构 in (\'" & User.Roles.replace(",","\',\'") & "\') or 监理机构 in (\'" & User.Roles.replace(",","\',\'") & "\') or 业主机构 in (\'" & User.Roles.replace(",","\',\'") & "\') or 劳务队负责人 in (\'" & User.Roles.replace(",","\',\'") & "\')"
如果是,那么,你筛选的时候,也要加上这个条件。 |
-- 作者:aza520 -- 发布时间:2018/10/15 9:30:00 -- 我加载树完整的代码是这个,刚才没有贴出来完 Dim Filter As String = "1=1" If e.Node.Name <> "加载所有数据" Then Dim Xmmc As String = e.Node.DataRow("项目名称") Dim Xghtd As String = e.Node.DataRow("施工合同段") Dim Lwdmc As String = e.Node.DataRow("劳务队名称") Dim Gz As String = e.Node.DataRow("工种") Select Case e.Node.Level Case 0 Filter = "[项目名称] = \'" & Xmmc & "\'" Case 1 Filter = "[项目名称] = \'" & Xmmc & "\'And [施工合同段] = \'" & Xghtd & "\'" Case 2 Filter = "[项目名称] = \'" & Xmmc & "\'And [施工合同段] = \'" & Xghtd & "\' And [劳务队名称] = \'" & Lwdmc & "\'" Case 3 Filter = "[项目名称] = \'" & Xmmc & "\'And [施工合同段] = \'" & Xghtd & "\' And [劳务队名称] = \'" & Lwdmc & "\'And [工种] = \'" & Gz & "\'" End Select End If If User.Name = "开发者" Or User.Name = "管理员" Then DataTables("劳务人员登记表").LoadFilter = filter \'DataTables("劳务人员登记表").LoadOver = "工种" DataTables("劳务人员登记表").LoadTop = 10 DataTables("劳务人员登记表").LoadPage = 0 DataTables("劳务人员登记表").LoadOver = "_Identify" DataTables("劳务人员登记表").Load Tables("劳务人员登记表").sort="工种" Tables("劳务人员登记表.劳务人员工资发放记录表").sort="工资所属月份 DESC" Else DataTables("劳务人员登记表").loadfilter = "(承包人机构 in (\'" & User.Roles.replace(",","\',\'") & "\') or 监理机构 in (\'" & User.Roles.replace(",","\',\'") & "\') or 业主机构 in (\'" & User.Roles.replace(",","\',\'") & "\') or 劳务队负责人 in (\'" & User.Roles.replace(",","\',\'") & "\')) and " & Filter \'DataTables("劳务人员登记表").LoadOver = "工种" DataTables("劳务人员登记表").LoadTop = 10 DataTables("劳务人员登记表").LoadPage = 0 DataTables("劳务人员登记表").LoadOver = "_Identify" DataTables("劳务人员登记表").Load Tables("劳务人员登记表").sort="工种" Tables("劳务人员登记表.劳务人员工资发放记录表").sort="工资所属月份 DESC" End If e.Form.Controls("TextBox5").Value = 1 & "/" & DataTables("劳务人员登记表").TotalPages vars("劳务人员登记表filter") = DataTables("劳务人员登记表").LoadFilter |
-- 作者:有点甜 -- 发布时间:2018/10/15 9:36:00 -- 代码逻辑上没有问题,做个实例发上来测试。 |
-- 作者:aza520 -- 发布时间:2018/10/15 9:53:00 -- 我在项目属性AfterOpenProject事件还设有以下代码,是不是因为这个问题 Dim filter As String = "1=1" If User.Name = "开发者" Or User.Name = "管理员" Then DataTables("劳务人员登记表").LoadFilter = filter \'DataTables("劳务人员登记表").LoadOver = "工种" DataTables("劳务人员登记表").LoadTop = 10 DataTables("劳务人员登记表").LoadPage = 0 DataTables("劳务人员登记表").LoadOver = "_Identify" DataTables("劳务人员登记表").Load Tables("劳务人员登记表").sort="工种" Tables("劳务人员登记表.劳务人员工资发放记录表").sort="工资所属月份 DESC" Else DataTables("劳务人员登记表").loadfilter = "(承包人机构 in (\'" & User.Roles.replace(",","\',\'") & "\') or 监理机构 in (\'" & User.Roles.replace(",","\',\'") & "\') or 业主机构 in (\'" & User.Roles.replace(",","\',\'") & "\') or 劳务队负责人 in (\'" & User.Roles.replace(",","\',\'") & "\')) and " & Filter \'DataTables("劳务人员登记表").LoadOver = "工种" DataTables("劳务人员登记表").LoadTop = 10 DataTables("劳务人员登记表").LoadPage = 0 DataTables("劳务人员登记表").LoadOver = "_Identify" DataTables("劳务人员登记表").Load Tables("劳务人员登记表").sort="工种" Tables("劳务人员登记表.劳务人员工资发放记录表").sort="工资所属月份 DESC" End If vars("劳务人员登记表filter") = DataTables("劳务人员登记表").LoadFilter |
-- 作者:有点甜 -- 发布时间:2018/10/15 10:14:00 -- 1、在命令窗口执行代码生成统计表,看数据是否正确(看统计的数据是3还是4)
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,"人数") \'根据客户列来统计记录数,也就是订单数
b.Build
2、执行目录树筛选以后,在命令窗口输出loadfilter看看是否正确
output.show(DataTables("劳务人员登记表").LoadFilter)
|