📄 depttree.asp
字号:
<%
Class DeptTree
Private IntSpace
Public Function GetDepTree(ObjDB,DeptID)
Dim StrSQL,ObjRS,StrOption
IntSpace = 0
StrSQL = "Select * From t_OA_SYS_Department Where ID = " & DeptID
Set ObjRS = ObjDB.Execute(StrSQL)
'StrOption = StrOption & "<option value=0>--<公共信息>--</option>"
If Not ObjRS.Eof Then
StrOption = StrOption & "<option value=" & DeptID & ">" & ObjRS("DepName") & "</option>"
End If
StrOption = StrOption & GetSubDep(ObjDB,DeptID)
GetDepTree = StrOption
End Function
Private Function GetSubDep(ObjDB,DepID)
Dim IntDepID
Dim ObjRS,StrSQL
Dim SubDep
Dim i
IntDepID = DepID
SubDep = ""
StrSQL = "Select ID,DepName from t_OA_SYS_Department where ParentID = " & DepID
Set ObjRS = ObjDB.execute (StrSQL)
While Not ObjRS.eof
SubDep = SubDep & "<option value=" & ObjRS("ID") & ">"
For i = 1 To IntSpace
SubDep = SubDep & "-"
Next
SubDep = SubDep & " "
SubDep = SubDep & ObjRS("DepName") & "</option>" & Vbcrlf
If GetSubDep(ObjDB,ObjRS("ID"))<>"" Then
IntSpace = IntSpace + 1
SubDep = SubDep & GetSubDep(ObjDB,ObjRS("ID"))
IntSpace = IntSpace - 1
End If
ObjRS.movenext
Wend
ObjRS.close
Set ObjRS = Nothing
GetSubDep = SubDep
End Function
Public Function GetMySubDeptIDs(ObjDB,DepID)
Dim IntDepID
Dim ObjRS,StrSQL
Dim SubDep
Dim i
IntDepID = DepID
SubDep = ""
StrSQL = "Select ID,DepName from t_OA_SYS_Department where ParentID = " & DepID
Set ObjRS = ObjDB.execute (StrSQL)
While Not ObjRS.eof
SubDep = SubDep & ObjRS("ID") & ","
If GetMySubDeptIDs(ObjDB,ObjRS("ID"))<>"" Then
SubDep = SubDep & GetMySubDeptIDs(ObjDB,ObjRS("ID"))
End If
ObjRS.movenext
Wend
ObjRS.close
Set ObjRS = Nothing
GetMySubDeptIDs = SubDep
End Function
Private Function GetMyParentDeptIDs(ObjDB,DepID)
Dim IntDepID
Dim ObjRS,StrSQL
Dim SubDep
Dim i
IntDepID = DepID
SubDep = ""
StrSQL = "Select ParentID from t_OA_SYS_Department where ID = " & DepID
Set ObjRS = ObjDB.execute (StrSQL)
While Not ObjRS.eof
If ObjRS("ParentID")<>0 Then
SubDep = SubDep & ObjRS("ParentID") & ","
If GetMyParentDeptIDs(ObjDB,ObjRS("ParentID"))<>"" Then
SubDep = SubDep & GetMyParentDeptIDs(ObjDB,ObjRS("ParentID"))
End If
End If
ObjRS.movenext
Wend
ObjRS.close
Set ObjRS = Nothing
GetMyParentDeptIDs = SubDep
End Function
Public Function GetMyDeptIDs(ObjDB,DepID)
GetMyDeptIDs = GetMyParentDeptIDs(ObjDB,DepID) & GetMySubDeptIDs(ObjDB,DepID) & DepID & ",0"
End Function
End Class
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -