-- 作者:上水道的
-- 发布时间:1/26/2005 10:02:00 PM
--
<% Class clsClass Private Conn Private i Private outPut '----------------------------------------------------------------------------------- '初始化当前页的值 Private Sub Class_Initialize End Sub '----------------------------------------------------------------------------------- '----------------------------------------------------------------------------------- '设置 Terminate 事件。 Private Sub Class_Terminate End Sub '----------------------------------------------------------------------------------- '################################################################################### '# 属性设置 '################################################################################### '----------------------------------------------------------------------------------- '属性,设置数据库连接对象 Public Property Let Connection(Obj_Conn) Set Conn = Obj_Conn End Property '----------------------------------------------------------------------------------- '----------------------------------------------------------------------------------- '属性,得到输出的树目录 Public Property Get Value() Value = outPut End Property '----------------------------------------------------------------------------------- '################################################################################### '# 函数 '################################################################################### '----------------------------------------------------------------------------------- '增加新分类 Public Function newClass(Pid,Name) Dim CMD,Rs Set CMD = Server.CreateObject("ADODB.COMMAND") CMD.ActiveConnection = Conn CMD.CommandType = 4 CMD.CommandText = "Blog_NewClass" On Error Resume Next Set Rs = CMD.Execute ( ,Array(Pid,Name)) Set CMD = Nothing If Err.number <> 0 Then newClass = -1 Else newClass = 0 End If Set Rs = Nothing Call refresh() End Function '----------------------------------------------------------------------------------- '----------------------------------------------------------------------------------- '修改分类 Public Function modiClass(Name,Id) Dim CMD,Rs Set CMD = Server.CreateObject("ADODB.COMMAND") CMD.ActiveConnection = Conn CMD.CommandType = 4 CMD.CommandText = "Blog_ModiClass" On Error Resume Next Set Rs = CMD.Execute ( ,Array(Name,Id)) Set CMD = Nothing If Err.number <> 0 Then modiClass = -1 Else modiClass = 0 End If Set Rs = Nothing Call refresh() End Function '----------------------------------------------------------------------------------- '----------------------------------------------------------------------------------- '删除分类 Public Function delClass(Id) Dim tempRs set tempRs = listClass(cint(Id)) do while not tempRs.Eof '递归删除子目录 delClass(CInt(tempRs(0))) tempRs.MoveNext loop Dim CMD,Rs Set CMD = Server.CreateObject("ADODB.COMMAND") CMD.ActiveConnection = Conn CMD.CommandType = 4 CMD.CommandText = "Blog_DelClass" On Error Resume Next Set Rs = CMD.Execute ( ,Array(Id)) Set CMD = Nothing If Err.number <> 0 Then delClass = -1 Else delClass = 0 End If Set Rs = Nothing tempRs.close set tempRs = nothing Call refresh() End Function '----------------------------------------------------------------------------------- '----------------------------------------------------------------------------------- '修改分类排序 Public Function orderClass(Order,Id) Dim CMD,Rs Set CMD = Server.CreateObject("ADODB.COMMAND") CMD.ActiveConnection = Conn CMD.CommandType = 4 CMD.CommandText = "Blog_OrderClass" On Error Resume Next Set Rs = CMD.Execute ( ,Array(Order,Id)) Set CMD = Nothing If Err.number <> 0 Then orderClass = -1 Else orderClass = 0 End If Set Rs = Nothing Call refresh() End Function '----------------------------------------------------------------------------------- '----------------------------------------------------------------------------------- '分类列表 Public Function listClass(Pid) Dim CMD,Rs Set CMD=Server.CreateObject("ADODB.COMMAND") CMD.ActiveConnection = Conn CMD.CommandType = 4 CMD.CommandText = "Blog_ClassList" Set Rs = CMD.Execute ( ,Array(Pid)) Set CMD = Nothing Set listClass = Rs End Function '----------------------------------------------------------------------------------- '----------------------------------------------------------------------------------- '根据C_Id得到C_Name Public Function getCName(Id) Dim CMD,Rs Set CMD = Server.CreateObject("ADODB.COMMAND") CMD.ActiveConnection = Conn CMD.CommandType = 4 CMD.CommandText = "Blog_getCName" Set Rs = CMD.Execute ( ,Array(Id)) Set CMD = Nothing getCName = Rs(0) End Function '----------------------------------------------------------------------------------- '----------------------------------------------------------------------------------- '生成树目录 Public Function nodeUser(parent) dim rs,j,innerPic,eventCancel,shutEvent shutEvent = " onclick=""javascript:event.cancelBubble = true;"" onmouseover=""javascript:event.cancelBubble = true;"" onmouseout=""javascript:event.cancelBubble = true;""" set rs = listClass(parent) do while not rs.Eof i=i+1 innerPic = istail(cint(rs(0))) if instr(innerPic,"nochild") <> 0 then eventCancel = "getPID(" & rs(0) & ")" else eventCancel = "changeshow(" & rs(0) & ")" end if outPut = outPut & "<table bgcolor=""#FFFBFF"" border=""0"" width=""100%"" style=""cursor:hand"" cellpadding=""0"" cellspacing=""0"">" outPut = outPut & "<tr onclick=""" & eventCancel & """ onmouseover=""overtree()"" onmouseout=""outtree()""><td id=""node"" name=""node"">" for j=1 to i outPut = outPut & (" ") next outPut = outPut & innerPic outPut = outPut & getCName(cint(rs(0))) outPut = outPut & "</td></tr>" outPut = outPut & "<tr style=""display:none""><td id=""node"" name=""node"">" '递归来显示出为根的树型结构 nodeUser(rs(0)) outPut = outPut & "</td></tr></table>" rs.MoveNext loop i=i-1 rs.close set rs=nothing End Function '----------------------------------------------------------------------------------- '----------------------------------------------------------------------------------- '是否末端 Private function istail(parentID) Dim rs,shutEvent shutEvent = " onclick=""javascript:event.cancelBubble = true;"" onmouseover=""javascript:event.cancelBubble = true;"" onmouseout=""javascript:event.cancelBubble = true;""" set rs = listClass(parentID) if rs.Eof then istail = "<img src=""/images/treeview/nochild.gif"" border=""0"" " & shutEvent & " style=""cursor:default;""> <img src=""/images/treeview/page.gif"" border=""0"" " & shutEvent & " style=""cursor:default;""> " else istail = "<img src=""/images/treeview/plus.gif"" border=""0"" " & shutEvent & " style=""cursor:default;""> <img src=""/images/treeview/folder.gif"" border=""0"" " & shutEvent & " style=""cursor:default;""> " end if end function '----------------------------------------------------------------------------------- '----------------------------------------------------------------------------------- '刷新Cache Private Sub refresh() Dim BlogCache Set BlogCache = New clsCache With BlogCache .Connection = Conn .Name = "Blog_Class" .cheType = "Class" .Update() End With Set BlogCache = Nothing end Sub '----------------------------------------------------------------------------------- End Class %>
|