-- 作者:身份不明
-- 发布时间:2014/6/9 15:40:00
--
窗口afterload事件:
Dim cmd As New SQLCommand Dim dt As DataTable cmd.C 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)
\'加载第一页数据 With DataTables("辅材出库管理") .LoadFilter = "" \'清除加载条件 .LoadPage = 0 \'加载第一页 .LoadTop = 10 \'每页10行 .Load() e.Form.Controls("TextBox1").Value = 1 & "/" & .TotalPages End With
记载树的NodeMouseClick:
Dim Filter As String
If e.Node.Text = "加载所有数据" Then Filter = "" Else Dim dr As DataRow = e.Node.DataRow \'获取生成此节点的行 Dim Year As Integer = dr("年") Dim Month As Integer = dr("月") Dim Product As String = dr("领料班组") Select Case e.Node.Level Case 0 Filter ="Year(出库日期) = " & Year Case 1 Filter ="Year(出库日期) = " & Year & " And Month(出库日期) = " & Month Case 2 Filter ="Year(出库日期) = " & Year & " And Month(出库日期) = " & Month & " And 领料班组 = \'" & Product & "\'" End Select End If
With DataTables("辅材出库管理") .LoadFilter = Filter .LoadPage = 0 .LoadTop = 10 .Load() e.Form.Controls("TextBox1").Value = 1 & "/" & .TotalPages End With
下一页代码:
With DataTables("辅材出库管理") If .LoadPage < .TotalPages - 1 .LoadPage = .LoadPage + 1 .Load() e.Form.Controls("TextBox1").Value = (.LoadPage + 1) & "/" & .TotalPages End If End With
|