以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 求筛选树的代码错误在那里? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=129122) |
|
-- 作者:zsslly -- 发布时间:2018/12/21 21:13:00 -- 求筛选树的代码错误在那里? Dim dt As DataTable Dim b As New GroupTableBuilder("责任人任务管理_table1",DataTables("客户跟踪仿甘特图")) b.Groups.AddDef("责任人") b.Groups.AddDef("事件日期",DateGroupEnum.Year,"年") b.Groups.AddDef("事件日期",DateGroupEnum.Month,"月") 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 Month As Integer = nd.DataRow("年") Dim day As Integer = nd.DataRow("月") Dim Product As String = nd.DataRow("第几周") Select Case nd.Level Case 0 nd.Text = nd.text & "责任人(" & nd.DataRow("Sum(订单数)","责任人 ") & "条)" Case 1 nd.Text = nd.text & "年(" & dt.Compute("Sum(订单数)","责任人 And 年 = " & Year) & "条)" Case 2 nd.Text = nd.text & "月(" & dt.Compute("Sum(订单数)","责任人 And 年 = " & Year & " And 月 = " & Month & " ) & "条)" Case 3 nd.Text = nd.text & "(" & nd.DataRow("订单数") & "条)" End Select Next trv.Nodes.Insert("显示所有行","显示所有行(" & dt.Compute("Sum(订单数)") & "条)",0) trv.ResumeRedraw Dim zz As New GroupTableBuilder("temp",DataTables("客户跟踪仿甘特图")) 求助大侠,错在那里?
|
|
-- 作者:有点蓝 -- 发布时间:2018/12/21 21:32:00 -- 参考:http://www.foxtable.com/webhelp/scr/1284.htm For Each nd As WinForm.TreeNode In trv.AllNodes Dim Product As String= nd.DataRow("责任人") Dim Year As Integer = nd.DataRow("年") Dim Month As Integer = nd.DataRow("月") Select Case nd.Level Case 0 nd.Text = nd.text & "责任人(" & nd.DataRow("Sum(订单数)","责任人 =\'" & Product & "\' ") & "条)" Case 1 nd.Text = nd.text & "年(" & dt.Compute("Sum(订单数)","责任人=\'" & Product & "\' And 年 = " & Year) & "条)" Case 2 这里自己参考改 Case 3 nd.Text = nd.text & "(" & nd.DataRow("订单数") & "条)" End Select Next |
|
-- 作者:zsslly -- 发布时间:2018/12/21 21:47:00 -- 改好了,说是未知编驿错误,如下: Dim dt As DataTable Dim b As New GroupTableBuilder("责任人任务管理_table1",DataTables("客户跟踪仿甘特图")) b.Groups.AddDef("责任人") b.Groups.AddDef("事件日期",DateGroupEnum.Year,"年") b.Groups.AddDef("事件日期",DateGroupEnum.Month,"月") 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 Year As Integer = nd.DataRow("年") Dim Month As Integer = nd.DataRow("月") Dim Product As String = nd.DataRow("第几周") Select Case nd.Level Case 0 nd.Text = nd.text & "责任人(" & nd.DataRow("Sum(订单数)","责任人 =\'" & Product & "\' ") & "条)" Case 1 nd.Text = nd.text & "年(" & dt.Compute("Sum(订单数)","责任人=\'" & Product & "\' And 年 = " & Year &") & "条)" Case 2 nd.Text = nd.text & "月(" & dt.Compute("Sum(订单数)","责任人=\'" & Product & "\' And 年 = " & Year & " And 月 = " & Month &") & "条)" Case 3 nd.Text = nd.text & "(" & nd.DataRow("订单数") & "条)" End Select Next trv.Nodes.Insert("显示所有行","显示所有行(" & dt.Compute("Sum(订单数)") & "条)",0) trv.ResumeRedraw 求助?
|
|
-- 作者:zsslly -- 发布时间:2018/12/21 21:54:00 -- 这样改了,也不行 Case 0 nd.Text = nd.text & "责任人(" & nd.DataRow("Sum(订单数)","责任人 =\'" & Product & "\' ") & "条)" Case 1 nd.Text = nd.text & "年(" & dt.Compute("Sum(订单数)","责任人=\'" & Product & "\' And 年 = " & Year ) & "条)" Case 2 nd.Text = nd.text & "月(" & dt.Compute("Sum(订单数)","责任人=\'" & Product & "\' And 年 = " & Year & " And 月 = " & Month ) & "条)" Case 3 nd.Text = nd.text & "(" & nd.DataRow("订单数") & "条)" End Select Next |
|
-- 作者:有点蓝 -- 发布时间:2018/12/21 22:18:00 -- Dim Product As String = nd.DataRow("第几周")去掉 |
|
-- 作者:有点蓝 -- 发布时间:2018/12/21 22:20:00 -- 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 年 = " & Year ) & "条)" Case 2 nd.Text = nd.text & "月(" & dt.Compute("Sum(订单数)","责任人=\'" & Product & "\' And 年 = " & Year & " And 月 = " & Month ) & "条)" Case 3 nd.Text = nd.text & "(" & nd.DataRow("订单数") & "条)" End Select
[此贴子已经被作者于2018/12/21 22:20:05编辑过]
|
|
-- 作者:zsslly -- 发布时间:2018/12/21 22:32:00 --
|
|
-- 作者:有点蓝 -- 发布时间:2018/12/21 22:34:00 -- 这个就是:nd.Text = nd.text & "(" & nd.DataRow("订单数") & "条)" 截图不也有吗,认真核对好吗
|
|
-- 作者:zsslly -- 发布时间:2018/12/21 22:37:00 -- 我的错,看晕了!跪谢老师! |
|
-- 作者:zsslly -- 发布时间:2018/12/21 22:49:00 -- 不好意思,这么晚还打扰老师 Dim Filter As String = "" If e.node.Name <> "显示所有行" Then \'要用Name属性,不能用Text属性 Dim d1 As Date Dim d2 As Date Dim Product As String = e.Node.DataRow("责任人") Dim Year As Integer = e.Node.DataRow("年") Dim Month As Integer = e.Node.DataRow("月") Select Case e.Node.Level Case 0 d1 = new Date(e.Node.DataRow("责任人")) Filter = "责任人 = \'" & Product & "\'" Case 1 d1 = New Date(Year,1,1) \'取得该年的第一天 d2 = new Date(Year,12,31) \'取得该年的最后一天 Filter = "事件日期 >= #" & d1 & "# And 事件日期 <= #" & d2 & "#" Case 2 d1 = New Date(Year, Month, 1) \'取得该月的第一天 d2 = new Date(Year, Month, Date.DaysInMonth(Year,Month)) \'取得该月的最后一天 Filter = "事件日期 >= #" & d1 & "# And 事件日期 <= #" & d2 & "#" Case 3 d1 = New Date(Year, Month, 1) \'取得该月的第一天 d2 = new Date(Year, Month, Date.DaysInMonth(Year,Month)) \'取得该月的最后一天 Filter = "事件日期 >= #" & d1 & "# And 事件日期 <= #" & d2 & "# and 第几周 = \'" & Product & "\'" End Select End If Tables("责任人任务管理_Table1").Filter = Filter \'隐藏副本表开始 Tables("责任人任务管理_table1").FIlter="False" \'隐藏副本表结束 错误:1/从字符串"徐小康"到类型"Long"的转换无效.2/查到第几周时没有结果. |