日期:2010-02-26  浏览次数:21243 次

跟大家分享一下自己写的一个树型结构,参考了动力文章的无限极分类树形结构数据库,看演示吧http://asptree.guaishi.org/aspajax/

下面是核心类代码,注释是后来加的,可能有些写的不太正确
复制内容到剪贴板
代码:
<%
'数据库字段为类属性,添加、删除、修改、操作检查等函数为类的方法
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
  &nbs