下列代码运行出错,不知道什么原因,我想建立四层目录树,请赐教。
1、窗口的AfterLoad事件代码为:
Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.CommandText = "SELECT DISTINCT 公务参照区分 ,Year(生成日期) As 年, Month(生成日期) As 月, 审签序号 From {公务信息表}"
dt = cmd.ExecuteReader()
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt, "公务参照区分|年|月|审签序号")
trv.Nodes.Insert("显示所有行",0)
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
If e.Node.Text = "显示所有行" Then
Tables("审签表_查询").Filter = ""
Else
Tables("审签表_查询").Filter = "[公务参照区分] = '" & Value(0) & "'"
End If
Case 1
Dim y As Integer = value(1)
d1 = New Date(y,1,1) '取得该年的第一天
d2 = new Date(y,12,31) '取得该年的最后一天
Filter = "生成日期 >= #" & d1 & "# And 生成日期 <= #" & d2 & "#"
Case 2
Dim y As Integer = value(1)
Dim m As Integer = value(2)
d1 = New Date(y, m, 1) '取得该月的第一天
d2 = new Date(y, m, Date.DaysInMonth(y,m)) '取得该月的最后一天
Filter = "生成日期 >= #" & d1 & "# And 生成日期 <= #" & d2 & "#"
Case 3
Dim y As Integer = value(1)
Dim m As Integer = value(2)
d1 = New Date(y, m, 1) '取得该月的第一天
d2 = new Date(y, m, Date.DaysInMonth(y,m)) '取得该月的最后一天
Filter = "生成日期 >= #" & d1 & "# And 生成日期 <= #" & d2 & "# And 审签序号 = '" & Value(3) & "'"
End Select
Tables("审签表_查询").Filter = Filter