ajax+asp無限級分類樹型結構(帶數據庫)
2024-05-04 11:00:17
供稿:網友
IE測試通過,FF有點小BUG
Cls_Leibie.asp
復制代碼 代碼如下:
<%
'數據庫字段為類屬性,添加、刪除、修改、操作檢查等函數為類的方法
Class Cls_Leibie
Private nClassID,sClassName,nParentID,sParentPath,nDepth,nRootID,nChild,nOrderID,sFilePath '定義私有變量(類的屬性,即數據庫字段對應的變量)
Private rs,sql,ErrorStr
Private Sub Class_Initialize()
ErrorStr="" '初始化錯誤信息為空
End Sub
Private Sub Class_Terminate() '銷毀類時關閉數據庫連接
If IsObject(Conn) Then
Conn.Close
Set Conn = Nothing
End If
End Sub
'*******************設置各個屬性******************************************************
Public Property Let ClassID(str) '獲取類別ID(主鍵)
nClassID=str
call ClassProperty() '獲取類別ID時調用此函數讀出類的所有屬性
End Property
Public Property Let ClassName(str) '獲取類別名稱
sClassName=str
End Property
Public Property Get ClassName
ClassName=sClassName
End Property
Public Property Let ParentID(str) '獲取類別父ID
nParentID=str
End Property
Public Property Get ParentID
ParentID=nParentID
End Property
Public Property Let ParentPath(str) '獲取父路徑ID
sParentPath=str
End Property
Public Property Get ParentPath
ParentPath=sParentPath
End Property
Public Property Let Depth(str) '獲取類別深度
nDepth=str
End Property
Public Property Get Depth
Depth=nDepth
End Property
Public Property Let RootID(str) '獲取類別根ID
nRootID=str
End Property
Public Property Get RootID
RootID=nRootID
End Property
Public Property Let Child(str) '子類別個數
nChild=str
End Property
Public Property Get Child
Child=nChild
End Property
Public Property Let OrderID(str) '排序ID
nOrderID=str
End Property
Public Property Get OrderID
OrderID=nOrderID
End Property
Public Property Let FilePath(str) '類別文件根目錄(生成靜態文件路徑,小站老楊Web技術博客用的是生成靜態,故設置此字段)
sFilePath=str
End Property
Public Property Get FilePath
FilePath=sFilePath
End Property
'******************************************************************************
Private Sub ClassProperty() '讀取類的所有屬性
sql="select * from ArticleClass where ClassID="& nClassID
set rs=conn.execute(sql)
if not rs.eof then
sClassName=trim(rs("ClassName"))
nParentID=trim(rs("ParentID"))
sParentPath=trim(rs("ParentPath"))
nDepth=trim(rs("Depth"))
nRootID=trim(rs("RootID"))
nChild=trim(rs("Child"))
nOrderID=trim(rs("OrderID"))
sFilePath=trim(rs("FilePath"))
end if
set rs=nothing
End Sub
Public Function FAddCheck() '類別添加檢查函數,結果為0表示通過檢查,為1表示有錯誤發生,有錯誤發生時退出函數,將錯誤信息寫入錯誤變量ErrorStr