以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 关于带自动统计的筛选树的问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=173453) |
||||
-- 作者:xuxingbo -- 发布时间:2021/11/30 17:46:00 -- 关于带自动统计的筛选树的问题 我创建了一个筛选树,做的是四级显示,在第三级统计的时候数据一直不对,请大神帮忙看看错在什么地方!! Dim dt As DataTable Dim b As New GroupTableBuilder("统计表1",DataTables("隐患排查表")) b.Groups.AddDef("创建时间",DateGroupEnum.Year,"年") b.Groups.AddDef("创建时间",DateGroupEnum.Month,"月") b.Groups.AddDef("区域") b.Groups.AddDef("专业") b.Totals.AddDef("班组",AggregateEnum.Count,"隐患数1") \'根据班组列来统计记录数,也就是订单数 b.Totals.AddDef("班组",AggregateEnum.Count,"隐患数") \'根据班组列来统计记录数,也就是订单数 dt = b.Build(True) \'参数设置为True,生成一个临时表,不在主界面显示 \'然后根据统计表生成目录树 Dim trv As WinForm.TreeView = e.Form.Controls("TreeView3") trv.BuildTree(dt, "年|月|区域|专业") trv.StopRedraw For Each nd As WinForm.TreeNode In trv.AllNodes Dim Year As Integer = nd.DataRow("年") Dim Month As Integer = nd.DataRow("月") Dim Product As String = nd.DataRow("区域") Dim Product1 As String = nd.DataRow("专业") Select Case nd.Level Case 0 nd.Text = nd.text & "年(" & dt.Compute("Sum(隐患数)","年 = " & Year) & "条)" Case 1 nd.Text = nd.text & "月(" & dt.Compute("Sum(隐患数)","年 = " & Year & " And 月 = " & Month) & "条)" Case 2 nd.Text = nd.text & "(" & nd.DataRow("隐患数1") & "条)" Case 3 nd.Text = nd.text & "(" & nd.DataRow("隐患数") & "条)" End Select Next trv.Nodes.Insert("显示所有行","显示所有行(" & dt.Compute("Sum(隐患数)") & "条)",0) trv.ResumeRedraw |
||||
-- 作者:有点蓝 -- 发布时间:2021/11/30 20:12:00 -- Case 2 nd.Text = nd.text & "(" & dt.Compute("Sum(隐患数)","年 = " & Year & " And 月 = " & Month & “ and 区域=\'" & Product & "\'”) & "条)" Case 3 nd.Text = nd.text & "(" & 参考上面的方法再添加专业作为条件 & "条)" End Select
|
||||
-- 作者:xuxingbo -- 发布时间:2021/12/1 9:21:00 -- 求助, .NET Framework 版本:4.0.30319.296 Foxtable 版本:2020.5.29.8 错误所在事件:窗口,隐患排查表,AfterLoad 详细错误信息: Object reference not set to an instance of an object. 按照上面的代码输入好用了,但是每次打开项目会有这个错误,但是打开窗口预览就没问题 我的AfterLoad代码是: Dim trv2 As WinForm.TreeView=e.Form.controls("TreeView2") trv2.buildtree("隐患排查表", "类型") trv2.Nodes.Insert("显示所有行",0) \'首先生成统计表 Dim dt As DataTable Dim b As New GroupTableBuilder("统计表1",DataTables("隐患排查表")) b.Groups.AddDef("创建时间",DateGroupEnum.Year,"年") b.Groups.AddDef("创建时间",DateGroupEnum.Month,"月") b.Groups.AddDef("区域") b.Groups.AddDef("专业") b.Totals.AddDef("班组",AggregateEnum.Count,"隐患数1") \'根据班组列来统计记录数,也就是订单数 b.Totals.AddDef("班组",AggregateEnum.Count,"隐患数") \'根据班组列来统计记录数,也就是订单数 dt = b.Build(True) \'参数设置为True,生成一个临时表,不在主界面显示 \'然后根据统计表生成目录树 Dim trv As WinForm.TreeView = e.Form.Controls("TreeView3") trv.BuildTree(dt, "年|月|区域|专业") trv.StopRedraw For Each nd As WinForm.TreeNode In trv.AllNodes Dim Year As Integer = nd.DataRow("年") Dim Month As Integer = nd.DataRow("月") Dim Product As String = nd.DataRow("区域") Dim Product1 As String = nd.DataRow("专业") Select Case nd.Level Case 0 nd.Text = nd.text & "年(" & dt.Compute("Sum(隐患数)","年 = " & Year) & "条)" Case 1 nd.Text = nd.text & "月(" & dt.Compute("Sum(隐患数)","年 = " & Year & " And 月 = " & Month) & "条)" Case 2 nd.Text = nd.text & "(" & dt.Compute("Sum(隐患数)","年 = " & Year & " And 月 = " & Month & " And 区域=\'" & Product & "\'") & "条)" Case 3 nd.Text = nd.text & "(" & dt.Compute("Sum(隐患数)","年 = " & Year & " And 月 = " & Month & " And 区域=\'" & Product & "\'And 专业=\'" & Product1 & "\'") & "条)" End Select Next trv.Nodes.Insert("显示所有行","显示所有行(" & dt.Compute("Sum(隐患数)") & "条)",0) trv.ResumeRedraw \'首先生成统计表 Dim dt1 As DataTable Dim b1 As New GroupTableBuilder("统计表2",DataTables("隐患排查表")) b1.Groups.AddDef("创建时间",DateGroupEnum.Year,"年") b1.Groups.AddDef("创建时间",DateGroupEnum.Month,"月") b1.Groups.AddDef("区域") b1.Groups.AddDef("专业") b1.Totals.AddDef("班组",AggregateEnum.Count,"隐患数2") \'根据客户列来统计记录数,也就是订单数 dt1 = b1.Build(True) \'参数设置为True,生成一个临时表,不在主界面显示 \'然后根据统计表生成目录树 Dim trv1 As WinForm.TreeView = e.Form.Controls("TreeView1") trv1.BuildTree(dt1, "年|区域|专业") trv1.StopRedraw For Each nd1 As WinForm.TreeNode In trv1.AllNodes Dim Year1 As Integer = nd1.DataRow("年") Dim Product2 As String = nd1.DataRow("区域") Dim Product3 As String = nd1.DataRow("专业") Select Case nd1.Level Case 0 nd1.Text = nd1.text & "年(" & dt1.Compute("Sum(隐患数2)","年 = " & Year1) & "条)" Case 1 nd1.Text = nd1.text & "(" & dt1.Compute("Sum(隐患数2)","年 = " & Year1 & "And 区域=\'" & Product2 & "\'") & "条)" Case 2 nd1.Text = nd1.text & "(" & dt1.Compute("Sum(隐患数2)","年 = " & Year1 & "And 区域=\'" & Product2 & "\'And 专业=\'" & Product3 & "\'") & "条)" End Select Next trv1.Nodes.Insert("显示所有行","显示所有行(" & dt1.Compute("Sum(隐患数2)") & "条)",0) trv1.ResumeRedraw Tables("隐患排查表").AutoSizeRows() |
||||
-- 作者:有点蓝 -- 发布时间:2021/12/1 9:25:00 -- 调试技巧:http://www.foxtable.com/webhelp/scr/1485.htm,看哪一句代码出错 |
||||
-- 作者:xuxingbo -- 发布时间:2021/12/1 10:58:00 -- 问题找到了 dt1 = b1.Build(True) \'参数设置为True,生成一个临时表,不在主界面显示 这个代码未通过,好像是无法生成这个表,这个应该怎么修改,请大神指教
|
||||
-- 作者:有点蓝 -- 发布时间:2021/12/1 11:07:00 -- 看不出什么问题,请上传实例测试 |
||||
-- 作者:xuxingbo -- 发布时间:2021/12/1 11:55:00 --
密码:110001
|
||||
-- 作者:有点蓝 -- 发布时间:2021/12/1 13:37:00 -- 连接不到数据库无法测试。新建项目,把("隐患排查表)导入内部表,导入测试窗口,然后再在发上来 |