/递规函数 Public Sub sang_ProTree(ByVal sTreeV As TreeView, ByVal sPKey As TreeNode, _ ByVal sKey As String, ByVal sText As String, ByVal sUser As String, ByVal str As String) '生成树结构 '树,父节点,自己,文字,用户,查询结果集 Dim sChildN As Long Dim sRsql As String Dim tn As New TreeNode If sPKey Is Nothing Then tn.Text = sText tn.ImageUrl = "images\tree_2.gif" If str <> "" Then tn.NavigateUrl = str ' "tyquery.aspx?luN='" & sKey & "'" End If tn.ID = sKey tn.Target = "right" sTreeV.Nodes.Add(tn) Else tn.Text = sText tn.ImageUrl = "images\tree_3.gif" If str <> "" Then tn.NavigateUrl = str '"tyquery.aspx?luN='" & sKey & "'" End If tn.ID = sKey tn.Target = "right" sPKey.Nodes.Add(tn) End If '再准备处理孩子 If InStr(sKey, "lu") <> 0 Then sRsql = "select * from " & Owner & "LK_TREE_TAB where PAR_K='" & sKey & _ "' And USER_N like '%" & sUser & "%' and ITEM_N='物资管理' order by to_number(substr(owe_k,3))" ' order by ITEM_N ASC" Else sRsql = "select * from " & Owner & "LK_TREE_TAB where PAR_K IS Null And USER_N like '%" & sUser & "%' and ITEM_N='物资管理' order by to_number(substr(owe_k,3))" ' order by ITEM_N ASC" End If Dim oledbcn As New OleDb.OleDbConnection(Global.con) Dim oledbcmd As New OleDb.OleDbCommand(sRsql) Dim oledbdr As OleDb.OleDbDataReader oledbcmd.Connection = oledbcn If oledbcmd.Connection.State = ConnectionState.Closed Then oledbcmd.Connection.Open() End If oledbdr = oledbcmd.ExecuteReader(CommandBehavior.Default) While oledbdr.Read() '处理孩子 If Not IsDBNull(oledbdr("FILE_P")) Then Call sang_ProTree(sTreeV, tn, oledbdr("OWE_K"), oledbdr("QUE_N"), sUser, oledbdr("FILE_P")) Else Call sang_ProTree(sTreeV, tn, oledbdr("OWE_K"), oledbdr("QUE_N"), sUser, "") End If End While oledbdr.Close() oledbcn.Close() End Sub 别人的一个函数
Public Sub sang_ProTree(ByVal sTreeV As TreeView, ByVal sPKey As TreeNode, _
ByVal sKey As String, ByVal sText As String, ByVal sUser As String, ByVal str As String) '生成树结构 '树,父节点,自己,文字,用户,查询结果集 Dim sChildN As Long
Dim sRsql As String
Dim tn As New TreeNode If sPKey Is Nothing Then tn.Text = sText
tn.ImageUrl = "images\tree_2.gif"
If str <> "" Then
tn.NavigateUrl = str ' "tyquery.aspx?luN='" & sKey & "'"
End If
tn.ID = sKey
tn.Target = "right"
sTreeV.Nodes.Add(tn) Else
tn.Text = sText
tn.ImageUrl = "images\tree_3.gif"
If str <> "" Then
tn.NavigateUrl = str '"tyquery.aspx?luN='" & sKey & "'"
End If
tn.ID = sKey
tn.Target = "right"
sPKey.Nodes.Add(tn)
End If '再准备处理孩子
If InStr(sKey, "lu") <> 0 Then sRsql = "select * from " & Owner & "LK_TREE_TAB where PAR_K='" & sKey & _
"' And USER_N like '%" & sUser & "%' and ITEM_N='物资管理' order by to_number(substr(owe_k,3))" ' order by ITEM_N ASC"
Else
sRsql = "select * from " & Owner & "LK_TREE_TAB where PAR_K IS Null And USER_N like '%" & sUser & "%' and ITEM_N='物资管理' order by to_number(substr(owe_k,3))" ' order by ITEM_N ASC" End If Dim oledbcn As New OleDb.OleDbConnection(Global.con)
Dim oledbcmd As New OleDb.OleDbCommand(sRsql)
Dim oledbdr As OleDb.OleDbDataReader oledbcmd.Connection = oledbcn
If oledbcmd.Connection.State = ConnectionState.Closed Then
oledbcmd.Connection.Open()
End If
oledbdr = oledbcmd.ExecuteReader(CommandBehavior.Default) While oledbdr.Read()
'处理孩子 If Not IsDBNull(oledbdr("FILE_P")) Then
Call sang_ProTree(sTreeV, tn, oledbdr("OWE_K"), oledbdr("QUE_N"), sUser, oledbdr("FILE_P"))
Else
Call sang_ProTree(sTreeV, tn, oledbdr("OWE_K"), oledbdr("QUE_N"), sUser, "")
End If End While
oledbdr.Close()
oledbcn.Close() End Sub
别人的一个函数