代码
科目表目录_Button刷新_Click
Dim tr As WinForm.TreeView = e.Form.Controls("TreeView科目表")
Dim nd As WinForm.TreeNode
Dim dt As DataTable = DataTables("科目表")
tr.StopRedraw()
tr.Nodes.Clear
Dim gz As String = "424"
For Each dr As DataRow In dt.Select("","科目代码")
If dr.IsNull("科目代码") = False AndAlso dr("科目代码").Length = val(gz(0)) Then
nd = tr.Nodes.Add(dr("科目代码"),dr("科目代码") & " " & dr("科目名称"))
Functions.Execute("AddChildren",nd,dt,gz,1)
End If
Next
tr.ResumeRedraw()
自定义函数
AddChildren
Dim nd As WinForm.TreeNode = args(0)
Dim dt As DataTable = args(1)
Dim gz As String = args(2)
Dim idx As Integer = args(3)
If idx < gz.Length Then
For Each dr As DataRow In dt.Select("","科目代码") '按代码顺序添加
Dim km As String = dr("科目代码")
If km.StartsWith(nd.name) AndAlso km.Length = nd.Name.Length + val(gz(idx)) Then
Dim sum As Integer = 0
For i As Integer = 0 To gz.Length - 1
sum += val(gz(i))
If km.Length = sum Then
Dim cd As Winform.TreeNode = nd.Nodes.Add(km,km & " " & dr("科目名称"))
Functions.Execute("AddChildren",cd,dt,gz,idx+1)
Exit For
End If
Next
End If
Next
End If