1、窗口的AfterLoad事件代码改为:
Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.CommandText = "SELECT DISTINCT Year(日期) As 年, Month(日期) As 月, 产品, XX From {订单}"
dt = cmd.ExecuteReader()
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt, "年|月|产品|XX")
2、目录树的NodeMouseDoubleClick事件代码改为
Dim Value()As String
Dim Filter As String
Dim d1 As Date
Dim d2 As Date
Value = e.Node.FullPath.Split("\")
Select Case e.Node.Level
Case 0
Dim y As Integer = value(0)
d1 = New Date(y,1,1) '取得该年的第一天
d2 = new Date(y,12,31) '取得该年的最后一天
Filter = "日期 >= #" & d1 & "# And 日期 <= #" & d2 & "#"
Case 1
Dim y As Integer = value(0)
Dim m As Integer = value(1)
d1 = New Date(y, m, 1) '取得该月的第一天
d2 = new Date(y, m, Date.DaysInMonth(y,m)) '取得该月的最后一天
Filter = "日期 >= #" & d1 & "# And 日期 <= #" & d2 & "#"
Case 2
Dim y As Integer = value(0)
Dim m As Integer = value(1)
d1 = New Date(y, m, 1) '取得该月的第一天
d2 = new Date(y, m, Date.DaysInMonth(y,m)) '取得该月的最后一天
Filter = "日期 >= #" & d1 & "# And 日期 <= #" & d2 & "# And 产品 = '" & Value(2) & "'"
Case 3
Dim y As Integer = value(0)
Dim m As Integer = value(1)
d1 = New Date(y, m, 1) '取得该月的第一天
d2 = new Date(y, m, Date.DaysInMonth(y,m)) '取得该月的最后一天
Filter = "日期 >= #" & d1 & "# And 日期 <= #" & d2 & "# And 产品 = '" & Value(2) & "' And XX = '" & Value(3) & "'"
End Select
Tables("订单").Filter = Filter
[此贴子已经被作者于2012-6-4 19:03:44编辑过]