采购立项窗体筛选目录树NodeMouseClick事件
Dim e As Object = Args(0)
Dim Filter As String = ""
Dim trv As WinForm.TreeView = e.Form.Controls("trv_cglx")
Dim node As WinForm.TreeNode=trv.SelectedNode
If node.Name <> "显示所有采购立项" Then '要用Name属性,不能用Text属性
Dim d1 As Date
Dim d2 As Date
Dim Year As Integer = node.DataRow("年")
Dim Month As Integer = node.DataRow("月")
Dim Product As String = node.DataRow("立项类别")
Dim pric As String=node.DataRow("立项单位")
Select Case node.Level
Case 0
d1 = New Date(Year,1,1) '取得该年的第一天
d2 = new Date(Year,12,31) '取得该年的最后一天
Filter = "rq >= #" & d1 & "# And rq <= #" & d2 & "#"
Case 1
Dim q As Integer = (Month- 1) \ 3 + 1 '计算现在是第几个季度
d1 = New Date(Year, 3 * (q - 1) + 1, 1) '获取本季度的第一天
d2 = New Date(Year, 3 * q, Date.DaysInMonth(Year,3 * q)) '获取本季度的最后一天
Filter = "rq >= #" & d1 & "# And rq <= #" & d2 & "#"
Case 2
d1 = New Date(Year, Month, 1) '取得该月的第一天
d2 = new Date(Year, Month, Date.DaysInMonth(Year,Month)) '取得该月的最后一天
Filter = "rq >= #" & d1 & "# And rq <= #" & d2 & "#"
Case 3
d1 = New Date(Year, Month, 1) '取得该月的第一天
d2 = new Date(Year, Month, Date.DaysInMonth(Year,Month)) '取得该月的最后一天
Filter = "rq >= #" & d1 & "# And rq <= #" & d2 & "# And dwlb = '" & Product & "'"
Case 4
d1 = New Date(Year, Month, 1) '取得该月的第一天
d2 = new Date(Year, Month, Date.DaysInMonth(Year,Month)) '取得该月的最后一天
Filter = "rq >= #" & d1 & "# And rq <= #" & d2 & "# And dwlb = '" & Product & "' and cgdw = '" & pric & "'"
End Select
End If
Tables("tblcglx").Filter=Filter