筛选树需要有两个筛选功能,分别是员工业绩筛选, 和 折扣分类筛选, 现在设计了对应的l两个按钮双击生成筛选树,试问, 按钮做了两个,那筛选树我是需要放一颗还是两颗了?如只需要一棵筛选树,那代码是如何变化了?我用的是如下代码:
员工业绩按钮代码:
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)
折扣业绩按钮代码:
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)
业绩查询代码(功能已经实现)
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) & "'"
End Select
Tables("托管结算_托管结算").Filter = Filter
望指教!