If User.Name = "开发者" Or User.Name = "管理员" Then
Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.C
cmd.CommandText = "S ELECT DISTINCT 项目名称,县,乡镇,村屯,屯,组 F rom {S迁纪录房屋}"
dt = cmd.ExecuteReader()
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt,"项目名称|县|乡镇|村屯|屯|组")
trv.Nodes.Insert("加载所有数据",0)
Else
Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.C
cmd.CommandText = "S ELECT DISTINCT 项目名称,县,乡镇,村屯,屯,组 F rom {S迁纪录房屋} where 乡镇 = '" & User.Name & "' or 县 = '" & User.Name & "' or 项目名称 = '" & User.Name & "'"
dt = cmd.ExecuteReader()
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt, "项目名称|县|乡镇|村屯|屯|组")
trv.Nodes.Insert("显示所有行",0)
End If
vars("filter") = DataTables("S迁纪录房屋").LoadFilter
(2)窗口中加载树代码:
Dim Filter As String = "1=1"
Dim dr = e.node.FullPath.split("\") '获取生成此节点的行
If e.Node.Text <> "显示所有行" Then
Select Case e.Node.Level
Case 0
Filter = "[项目名称] = '" & dr(0) & "'"
Case 1
Filter = "[项目名称] = '" & dr(0) & "' And [县] = '" & dr(1) & "'"
Case 2
Filter = "[项目名称] = '" & dr(0) & "' And [县] = '" & dr(1) & "' And [乡镇] = '" & dr(2) & "'"
Case 3
Filter = "[项目名称] = '" & dr(0) & "' And [县] = '" & dr(1) & "' And [乡镇] = '" & dr(2) & "' And [村屯] = '" & dr(3) & "'"
Case 4
Filter = "[项目名称] = '" & dr(0) & "' And [县] = '" & dr(1) & "' And [乡镇] = '" & dr(2) & "' And [村屯] = '" & dr(3) & "' And [屯] = '" & dr(4) & "'"
Case 5
Filter = "[项目名称] = '" & dr(0) & "' And [县] = '" & dr(1) & "' And [乡镇] = '" & dr(2) & "' And [村屯] = '" & dr(3) & "' And [屯] = '" & dr(4) & "'And [组] = '" & dr(5) & "'"
End Select
End If
If User.Name = "开发者" Or User.Name = "管理员" Then
DataTables("S迁纪录房屋").LoadFilter = filter
DataTables("S迁纪录房屋").LoadOver="协议书编号"
DataTables("S迁纪录房屋").LoadReverse = True
DataTables("S迁纪录房屋").LoadTop= 5
DataTables("S迁纪录房屋").Load
Tables("S迁纪录房屋").sort="协议书编号"
Else
DataTables("S迁纪录房屋").loadfilter = "(乡镇 = '" & User.Name & "' or 县 = '" & User.Name & "' or 项目名称 = '" & User.Name & "') and " & Filter
DataTables("S迁纪录房屋").LoadOver="协议书编号"
DataTables("S迁纪录房屋").LoadReverse = True
DataTables("S迁纪录房屋").LoadTop= 5
DataTables("S迁纪录房屋").Load
Tables("S迁纪录房屋").sort="协议书编号"
End If
vars("filter") = DataTables("S迁纪录房屋").LoadFilter
e.Form.Controls("TextBox1").Value = 1 & "/" & DataTables("S迁纪录房屋").TotalPages
(3)窗口中“开始筛选”按钮代码:
Dim Filter As String
With e.Form.Controls("DateTimePicker1")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "支付日期 >= '" & .Value & "'"
End If
End With
With e.Form.Controls("DateTimePicker2")
If .Value IsNot Nothing Then
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "支付日期 <= '" & .Value & "'"
End If
End With
If e.Form.Controls("RadioButton8").Checked = True ' 如果付款状态选择了"已付"
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "支付日期 Is Not Null"
End If
If e.Form.Controls("RadioButton9").Checked = True ' 如果付款状态选择了"未付"
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "支付日期 Is Null"
End If
If e.Form.Controls("RadioButton5").Checked = True ' 如果付款状态选择了"已付"
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "乡镇审核 = 1"
End If
If e.Form.Controls("RadioButton6").Checked = True ' 如果付款状态选择了"未付"
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "乡镇审核 = 0 Or 乡镇审核 Is Null"
End If
If e.Form.Controls("RadioButton2").Checked = True ' 如果付款状态选择了"已付"
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "县办审核 = 1"
End If
If e.Form.Controls("RadioButton3").Checked = True ' 如果付款状态选择了"未付"
If Filter >"" Then
Filter = Filter & " And "
End If
Filter = Filter & "县办审核 = 0 Or 县办审核 Is Null"
End If
If Filter = "" Then filter = "1=1"
Dim f As String = vars("filter")
f = iif(f > "", f & " and " & filter, filter)
Tables("S迁纪录房屋").DataTable.LoadFilter = f
Tables("S迁纪录房屋").DataTable.Load
Tables("S迁纪录房屋").sort="协议书编号"
e.Form.Controls("TextBox1").Value = 1 & "/" & DataTables("S迁纪录房屋").TotalPages
(4)窗口中“撤消筛选”按钮代码:
With DataTables("S迁纪录房屋")
.LoadFilter = vars("filter")
.LoadPage = 0 '加载第一页
.Load()
e.Form.Controls("TextBox1").Value = 1 & "/" & .TotalPages
End With
Tables("S迁纪录房屋").sort="协议书编号"
其它两个窗口中的代码类似。