Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.C '数据源
cmd.CommandText = 日期 From {订单表}"
dt = cmd.ExecuteReader()
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt,"日期", "", "日期 DESC")
For Each nd As WinForm.TreeNode In trv.AllNodes
Select Case nd.Level
Case 0
nd.text = nd.name & "(" & DataTables("订单表").Compute("sum(年)","年='" & nd.name & "'") & "元)"
Case 1
nd.text = nd.name & "(" & DataTables("订单表").Compute("sum(年)", "年='" & nd.parentNode.name & "' and 月='" & nd.name & "'") & "元)"
Case 2
nd.text = nd.name & "(" & DataTables("订单表").Compute("sum(月)","月='" & nd.parentNode.parentNode.name & "' and 日='" & nd.parentNode.name & "' and = '" & nd.name & "'") & "元)"
End Select
Next
trv.Nodes.Insert("全部客元", "全部客元(" & DataTables("订单表").Compute("count(用元姓名)") & ")元", 0)
[此贴子已经被作者于2018/6/27 17:56:57编辑过]