以文本方式查看主题
- Foxtable(狐表) (http://foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2)
---- 加载树显示统计数据 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=43776)
|
-- 作者:Liangcai
-- 发布时间:2013/12/14 22:34:00
-- 加载树显示统计数据
Dim cmd As New SQLCommand Dim dt As DataTable cmd.CommandText = "SELECT 产品,客户,雇员, Count([_Identify]) As 订单数 From {订单} Group By 产品,客户,雇员" dt = cmd.ExecuteReader() Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") trv.BuildTree(dt, "产品|客户|雇员") trv.StopRedraw For Each nd As WinForm.TreeNode In trv.AllNodes Dim Value()As String Dim Filter As String
Value = nd.FullName.Split("\\") \'注意这里用FullName属性,不能用FullPath属性 Select Case nd.Level Case 0 nd.text = nd.text & "产品" Filter = "产品 = " & value(0) Case 1 nd.text = nd.text & "客户" Filter = "产品 = " & value(0) & " And 客户 = " & value(1) Case 2 Filter = "产品 = " & value(0) & " And 客户 = " & value(1) & " And 雇员 = \'" & Value(2) & "\'" End Select nd.Text = nd.text & "(" & dt.Compute("Sum(订单数)",Filter) & "条)" Next trv.Nodes.Insert("加载所有行","加载所有行(" & dt.Compute("Sum(订单数)") & "条)",0) trv.ResumeRedraw
怎么不能实现?请指教
|
-- 作者:有点甜
-- 发布时间:2013/12/14 23:02:00
--
呃,哪里不行?
|
-- 作者:Liangcai
-- 发布时间:2013/12/14 23:10:00
--
师傅出现这样错误
此主题相关图片如下:qq截图20131214230941.png
[此贴子已经被作者于2013-12-15 10:30:49编辑过]
|
-- 作者:有点甜
-- 发布时间:2013/12/15 20:30:00
--
条件需要加入单引号
Select Case nd.Level Case 0 nd.text = nd.text & "产品" Filter = "产品 = \'" & value(0) & "\'" Case 1 nd.text = nd.text & "客户" Filter = "产品 = \'" & value(0) & "\' And 客户 = \'" & value(1) & "\'" Case 2 Filter = "产品 = \'" & value(0) & "\' And 客户 = \'" & value(1) & "\' And 雇员 = \'" & Value(2) & "\'" End Select
|
-- 作者:Liangcai
-- 发布时间:2013/12/15 22:10:00
--
Dim cmd As New SQLCommand Dim dt As DataTable cmd.CommandText = "SELECT 产品,客户,雇员, Count([_Identify]) As 订单数 From {订单} WHERE 产品 = \'PD01\' Group By 产品,客户,雇员" dt = cmd.ExecuteReader() Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") trv.BuildTree(dt, "产品|客户|雇员") trv.StopRedraw For Each nd As WinForm.TreeNode In trv.AllNodes Dim Value()As String Dim Filter As String
Value = nd.FullPath.Split("\\") \'注意这里用FullName属性,不能用FullPath属性 Select Case nd.Level Case 0 nd.text = nd.text & "产品" Filter = "产品 = \'" & value(0) & "\'" Case 1 nd.text = nd.text & "客户" Filter = "产品 = \'" & value(0) & "\' And 客户 = \'" & value(1) & "\'" Case 2 Filter = "产品 = \'" & value(0) & "\' And 客户 = \'" & value(1) & "\' And 雇员 = \'" & Value(2) & "\'" End Select nd.Text = nd.text & "(" & DataTables("订单").Compute("Count([_Identify])",Filter) & "条)" Next trv.ResumeRedraw
生成结果只能产品统计,客户、雇员没有统计
此主题相关图片如下:qq截图20131215220837.png
|
-- 作者:有点甜
-- 发布时间:2013/12/15 22:14:00
--
Dim cmd As New SQLCommand Dim dt As DataTable cmd.CommandText = "SELECT 产品,客户,雇员, Count([_Identify]) As 订单数 From {订单} WHERE 产品 = \'PD01\' Group By 产品,客户,雇员" dt = cmd.ExecuteReader() Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") trv.BuildTree(dt, "产品|客户|雇员") trv.StopRedraw For Each nd As WinForm.TreeNode In trv.AllNodes Dim Value()As String Dim Filter As String Value = nd.FullName.Split("\\") \'注意这里用FullName属性,不能用FullPath属性 Select Case nd.Level Case 0 nd.text = nd.text & "产品" Filter = "产品 = \'" & value(0) & "\'" Case 1 nd.text = nd.text & "客户" Filter = "产品 = \'" & value(0) & "\' And 客户 = \'" & value(1) & "\'" Case 2 Filter = "产品 = \'" & value(0) & "\' And 客户 = \'" & value(1) & "\' And 雇员 = \'" & Value(2) & "\'" End Select nd.Text = nd.text & "(" & DataTables("订单").Compute("Count([_Identify])",Filter) & "条)" Next trv.ResumeRedraw
|
-- 作者:Liangcai
-- 发布时间:2013/12/15 22:31:00
--
谢谢
|