以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 筛选树目录列示到年月日 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=146307) |
-- 作者:15666282205 -- 发布时间:2020/2/21 7:51:00 -- 筛选树目录列示到年月日 老师,我设计的筛选树目录显示年和月,还想进一步显示到日,请指教。 \'\'---------------------------------设置生产计划表筛选树(按提交人-日期显示)-------------------------------------------- \'首先生成统计表 Dim dt2 As DataTable Dim b2 As New sqlGroupTableBuilder("统计表生产计划表","生产计划表") b2.C b2.Groups.AddDef("日期",DateGroupEnum.Year,"年") b2.Groups.AddDef("日期",DateGroupEnum.Month,"月") b2.Groups.AddDef("提交人") b2.Groups.AddDef("序号") b2.Totals.AddDef("序号",AggregateEnum.Count,"次数") \'根据客户列来统计记录数,也就是订单数 dt2 = b2.Build(True) \'参数设置为True,生成一个临时表,不在主界面显示 \'然后根据统计表生成目录树 Dim trv2 As WinForm.TreeView = e.Form.Controls("TreeView3") trv2.BuildTree(dt2, "提交人|年|月") trv2.StopRedraw For Each nd As WinForm.TreeNode In trv2.AllNodes Dim Year As Integer = nd.DataRow("年") Dim Month As Integer = nd.DataRow("月") Dim Product4 As String = nd.DataRow("提交人") Dim Product5 As String = nd.DataRow("序号") Select Case nd.Level Case 0 nd.Text = nd.text & "(" & dt2.Compute("Sum(次数)","提交人 = \'" & Product4 & "\'") & ")" Case 1 nd.Text = nd.text & "年(" & dt2.Compute("Sum(次数)","年 = " & Year) & ")" Case 2 nd.Text = nd.text & "月(" & dt2.Compute("Sum(次数)","年 = " & Year & " And 月 = " & Month) & ")" End Select Next trv2.Nodes.Insert("显示所有行","显示所有行(" & dt2.Compute("Sum(次数)") & ")",0) trv2.ResumeRedraw [此贴子已经被作者于2020/2/21 8:50:32编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/2/21 11:29:00 -- Dim dt2 As DataTable Dim b2 As New sqlGroupTableBuilder("统计表生产计划表","生产计划表") b2.C b2.Groups.AddDef("日期",DateGroupEnum.Year,"年") b2.Groups.AddDef("日期",DateGroupEnum.Month,"月") b2.Groups.AddDef("日期",DateGroupEnum.day,"日") b2.Groups.AddDef("提交人") b2.Groups.AddDef("序号") b2.Totals.AddDef("序号",AggregateEnum.Count,"次数") \'根据客户列来统计记录数,也就是订单数 dt2 = b2.Build(True) \'参数设置为True,生成一个临时表,不在主界面显示 \'然后根据统计表生成目录树 Dim trv2 As WinForm.TreeView = e.Form.Controls("TreeView3") trv2.BuildTree(dt2, "提交人|年|月|日") trv2.StopRedraw For Each nd As WinForm.TreeNode In trv2.AllNodes Dim Year As Integer = nd.DataRow("年") Dim Month As Integer = nd.DataRow("月") Dim d As Integer = nd.DataRow("日") Dim Product4 As String = nd.DataRow("提交人") Dim Product5 As String = nd.DataRow("序号") Select Case nd.Level Case 0 nd.Text = nd.text & "(" & dt2.Compute("Sum(次数)","提交人 = \'" & Product4 & "\'") & ")" Case 1 nd.Text = nd.text & "年(" & dt2.Compute("Sum(次数)","年 = " & Year) & ")" Case 2 nd.Text = nd.text & "月(" & dt2.Compute("Sum(次数)","年 = " & Year & " And 月 = " & Month) & ")" Case 3 nd.Text = nd.text & "日(" & dt2.Compute("Sum(次数)","年 = " & Year & " And 月 = " & Month) & " and 日= " & d & ")" End Select Next trv2.Nodes.Insert("显示所有行","显示所有行(" & dt2.Compute("Sum(次数)") & ")",0) trv2.ResumeRedraw |
-- 作者:15666282205 -- 发布时间:2020/2/21 15:11:00 -- 请老师再看看 老师,我运行以下代码出现两个问题:1,目录不显示“日”这个字;2、目录显示的数量,一级目录提交人正确,二级目录购买单位正确,三级目录日期年以及往下的不正确,不分目录全部列示,请您指点。应该是case 2往下的代码不对,我试了好多次也改不对。 \'首先生成统计表 Dim dt2 As DataTable Dim b2 As New sqlGroupTableBuilder("统计表生产计划表","生产计划表") b2.C b2.Groups.AddDef("日期",DateGroupEnum.Year,"年") b2.Groups.AddDef("日期",DateGroupEnum.Month,"月") b2.Groups.AddDef("日期",DateGroupEnum.day,"日") b2.Groups.AddDef("提交人") b2.Groups.AddDef("序号") b2.Groups.AddDef("购买单位") b2.Totals.AddDef("序号",AggregateEnum.Count,"次数") \'根据客户列来统计记录数,也就是订单数 dt2 = b2.Build(True) \'参数设置为True,生成一个临时表,不在主界面显示 \'然后根据统计表生成目录树 Dim trv2 As WinForm.TreeView = e.Form.Controls("TreeView3") trv2.BuildTree(dt2, "提交人|购买单位|年|月|日") trv2.StopRedraw For Each nd As WinForm.TreeNode In trv2.AllNodes Dim Year As Integer = nd.DataRow("年") Dim Month As Integer = nd.DataRow("月") Dim day As Integer = nd.DataRow("日") Dim Product4 As String = nd.DataRow("提交人") Dim Product5 As String = nd.DataRow("序号") Dim Product6 As String = nd.DataRow("购买单位") Select Case nd.Level Case 0 nd.Text = nd.text & "(" & dt2.Compute("Sum(次数)","提交人 = \'" & Product4 & "\'") & ")" Case 1 nd.Text = nd.text & "(" & dt2.Compute("Sum(次数)","购买单位 = \'" & Product6 & "\'") & ")" Case 2 \'nd.Text = nd.text & "(" & dt2.Compute("Sum(次数)","提交人 = \'" & Product4 & " And 购买单位 = \'" & Product6 & "\' And 年 = " & Year) & ")" \' nd.Text = nd.text & "年(" & dt2.Compute("Sum(次数)","年 = " & Year) & ")" Case 3 nd.Text = nd.text & "月(" & dt2.Compute("Sum(次数)","年 = " & Year & " And 月 = " & Month) & ")" Case 3 nd.Text = nd.text & "日(" & dt2.Compute("Sum(次数)","年 = " & Year & " And 月 = " & Month) & " and 日= " & day & ")" End Select Next trv2.Nodes.Insert("显示所有行","显示所有行(" & dt2.Compute("Sum(次数)") & ")",0) trv2.ResumeRedraw |
-- 作者:有点蓝 -- 发布时间:2020/2/21 15:18:00 -- Select Case nd.Level Case 0 nd.Text = nd.text & "(" & dt2.Compute("Sum(次数)","提交人 = \'" & Product4 & "\'") & ")" Case 1 nd.Text = nd.text & "(" & dt2.Compute("Sum(次数)","购买单位 = \'" & Product6 & "\'") & ")" Case 2 nd.Text = nd.text & "(" & dt2.Compute("Sum(次数)","提交人 = \'" & Product4 & " And 购买单位 = \'" & Product6 & "\' And 年 = " & Year) & ")" Case 3 nd.Text = nd.text & "月(" & dt2.Compute("Sum(次数)","提交人 = \'" & Product4 & " And 购买单位 = \'" & Product6 & "\' And 年 = " & Year and 月 = " & Month) & ")" Case 4 nd.Text = nd.text & "日(" & dt2.Compute("Sum(次数)","提交人 = \'" & Product4 & " And 购买单位 = \'" & Product6 & "\' And 年 = " & Year & " And 月 = " & Month & " and 日= " & day) & ")" End Select
|
-- 作者:15666282205 -- 发布时间:2020/2/22 9:28:00 -- 老师,提示:语法错误,“购买单位”运算符后缺少操作数。应该是case2有问题,我注释这个代码就不提示错误了。 |
-- 作者:有点蓝 -- 发布时间:2020/2/22 9:38:00 -- 提交人 = \'" & Product4 & "\' And 购买单位 = \'" & Product6 & "\' |
-- 作者:15666282205 -- 发布时间:2020/2/22 11:40:00 -- 目录树代码 老师,下面是目录树代码,至case2正常,case3运行后提示:日期后的引号不完整,您看看。 Dim Filter As String = "" If e.node.Name <> "显示所有行" Then \'要用Name属性,不能用Text属性 Dim d1 As Date Dim d2 As Date Dim Year As Integer = e.Node.DataRow("年") Dim Month As Integer = e.Node.DataRow("月") Dim day As Integer = e.node.DataRow("日") Dim Product As String = e.Node.DataRow("购买单位") Dim Product1 As String = e.Node.DataRow("提交人") \'Dim Product2 As String = e.Node.DataRow("考勤员") Select Case e.Node.Level Case 0 Filter = "[提交人] = \'" & e.Node.DataRow("提交人") & "\'" Case 1 Filter = "[提交人] = \'" & e.Node.DataRow("提交人") & "\'And 购买单位 = \'" & Product & "\'" Case 2 Filter = "[提交人] = \'" & e.Node.DataRow("提交人") & "\'And 购买单位 = \'" & Product & "\'and Year(日期) = " & Year Case 3 Filter = "[提交人] = \'" & e.Node.DataRow("提交人") & "\'And 购买单位 = \'" & Product & "\'and Year(日期) = " & Year & "\'And Month(日期) = " & Month \'Filter ="Year(日期) = " & Year & " And Month(日期) = " & Month End Select End If DataTables("生产计划表").LoadFilter = Filter DataTables("生产计划表").Load()
|
-- 作者:有点蓝 -- 发布时间:2020/2/22 11:42:00 -- 多了个单引号 Filter = "[提交人] = \'" & e.Node.DataRow("提交人") & "\' And 购买单位 = \'" & Product & "\' and Year(日期) = " & Year & " And ....
|