Asp无限分类的实现,无限级别分类的实现方法

Sub savenew()
 Dim classid,rootid,ParentID,depth,orders
 Dim Maxrootid,ParentStr,ChildStr,neworders
 Dim Rs,SQL
 '保存添加分类信息
 CheckSave
 If Founderr = True Then Exit Sub
 If Request("class") <> "0" Then
  SQL = "SELECT rootid,classid,depth,orders,ParentStr,TurnLink,HtmlFileDir FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid=" & Request("class")
  Set Rs = NewAsp.Execute (SQL)
  rootid = Rs(0)
  ParentID = Rs(1)
  depth = Rs(2)
  orders = Rs(3)
  If depth 1 > 20 Then
   ErrMsg = "<li>本系统限制最多只能有20级子分类</li>"
   Founderr = True
   Exit Sub
  End If
  If Rs("TurnLink") = 1 Then
   ErrMsg = "<li>该分类是外部连接,您不能指定该分类作为所属分类</li>"
   Founderr = True
   Exit Sub
  End If
  ParentStr = Rs(4)
  HtmlFileDir = Rs("HtmlFileDir")
  Rs.Close
 Else
  SQL = "SELECT MAX(rootid) FROM NC_Classify WHERE ChannelID = "& ChannelID
  Set Rs = NewAsp.Execute (SQL)
  Maxrootid = Rs(0) 1
  If IsNull(Maxrootid) Then Maxrootid = 1
  Rs.Close
 End If
 SQL = "SELECT classid FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid=" & NewAsp.ChkNumeric(Request("newclassid"))
 Set Rs = NewAsp.Execute (SQL)
 If Not (Rs.EOF And Rs.BOF) Then
  ErrMsg = "<li>您不能指定和别的分类一样的序号。</li>"
  Founderr = True
  Exit Sub
 Else
  classid = Request("newclassid")
 End If
 Rs.Close
 Set Rs = NewAsp.CreateAXObject("adodb.recordset")
 SQL = "SELECT * FROM NC_Classify"
 Rs.Open SQL, Conn, 1, 3
 Rs.addnew
 If Request("class") <> "0" Then
  Rs("depth") = depth 1
  Rs("rootid") = rootid
  Rs("parentid") = Request.Form("class")
  HtmlFileDir = HtmlFileDir & strClassDir & "/"
  If ParentStr = "0" Then
   Rs("ParentStr") = Request.Form("class")
  Else
   Rs("ParentStr") = ParentStr & "," & Request.Form("class")
  End If
 Else
  Rs("depth") = 0
  Rs("rootid") = Maxrootid
  Rs("parentid") = 0
  Rs("ParentStr") = 0
  HtmlFileDir = strClassDir & "/"
 End If
 Rs("ChannelID") = ChannelID
 Rs("ColorModes") = Trim(Request.Form("ColorModes"))
 Rs("FontModes") = Trim(Request.Form("FontModes"))
 Rs("child") = 0
 Rs("ChildStr") = Trim(Request.Form("newclassid"))
 Rs("LinkTarget") = Trim(Request.Form("LinkTarget"))
 Rs("TurnLink") = Trim(Request.Form("TurnLink"))
 Rs("TurnLinkUrl") = Trim(Request.Form("TurnLinkUrl"))
 Rs("UserGroup") = Trim(Request.Form("UserGroup"))
 Rs("HtmlFileDir") = Trim(HtmlFileDir)
 Rs("ClassDir") = Trim(strClassDir)
 Rs("classid") = NewAsp.ChkNumeric(Request.Form("newclassid"))
 Rs("orders") = NewAsp.ChkNumeric(Request.Form("newclassid"))
 Rs("classname") = Trim(Request.Form("classname"))
 Rs("readme") = Trim(Request.Form("readme"))
 Rs("ShowCount") = 0
 Rs("isUpdate") = 1
 Rs("AdsCode") = "|||||||||||||||"
 Rs.Update
 Rs.Close
 If Request("class") <> "0" Then
  Dim nClassID
  ParentStr = ParentStr & "," & Request.Form("class")
  nClassID = Trim(Request.Form("newclassid"))
  SQL = "SELECT classid,ParentStr,ChildStr FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid in (" & ParentStr & ")"
  Set Rs = NewAsp.Execute (SQL)
  Do While Not Rs.EOF
   ChildStr = Rs("ChildStr") & "," & nClassID
   NewAsp.Execute ("UPDATE NC_Classify SET ChildStr='"&ChildStr&"' WHERE ChannelID = "& ChannelID &" And classid = " & Rs("classid"))
  Rs.movenext
  Loop
  Rs.Close
 End If
 Dim LocalPath
 If CInt(NewAsp.IsCreateHtml) <> 0 And CInt(Request.Form("TurnLink")) = 0 Then
  LocalPath = NewAsp.InstallDir & ChannelDir & HtmlFileDir
  'NewAsp.CreatPathEx(LocalPath)
 End If
 CheckAndFixClass 0,1
 Call RemoveCache
 SucMsg = "<li>恭喜您!分类添加成功。</li>"
 Set Rs = Nothing
 Succeed(SucMsg)
End Sub
Sub savedit()
 Dim newclassid,Maxrootid,ParentID,depth,Child
 Dim ParentStr,rootid,iparentid,iParentStr
 Dim trs,brs,mrs,Rsc,Rss,k
 Dim nParentStr,mParentStr,ParentSql,ChildStr,nChildStr
 Dim ArrChildStr,ii,ClassCount
 Dim Rs,SQL,i
 '保存编辑分类信息
 If CLng(Request("editid")) = CLng(Request("class")) Then
  ErrMsg = "<li>所属分类不能指定自己</li>"
  Founderr = True
  Exit Sub
 End If
 CheckSave
 If Founderr = True Then Exit Sub
 If CLng(Request("class")) <> 0 Then
  HtmlFileDir = NewAsp.Execute("SELECT HtmlFileDir FROM [NC_Classify] WHERE ChannelID = "& ChannelID &" And classid=" & Request("class"))(0)
  HtmlFileDir = HtmlFileDir & strClassDir & "/"
 End If
 Set Rs = NewAsp.CreateAXObject("adodb.recordset")
 SQL = "SELECT * FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid=" & Request("editid")
 Rs.Open SQL, Conn, 1, 3
 newclassid = Rs("classid")
 ParentID = Rs("parentid")
 iparentid = Rs("parentid")
 ParentStr = Rs("ParentStr")
 ChildStr = Rs("ChildStr")
 ClassDir = Rs("ClassDir")
 depth = Rs("depth")
 Child = Rs("child")
 rootid = Rs("rootid")
 If CLng(Request("class")) = 0 Then
  HtmlFileDir = strClassDir & "/"
 End If
 If Child <> 0 And LCase(ClassDir) <> LCase(strClassDir) Then
  ErrMsg = "<li>对不起!该分类中有下属分类不能修改分类目录!</li>"
  Founderr = True
  Exit Sub
 End If
 If Child <> 0 And ParentID <> Clng(Request("class")) Then
  ErrMsg = "<li>对不起!该分类中有下属分类不能移动,请先移动其下属分类。</li>"
  Founderr = True
  Exit Sub
 End If
 If ParentID = 0 Then
  If CLng(Request("class")) <> 0 Then
   Set trs = NewAsp.Execute("SELECT rootid,TurnLink FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid=" & Request("class"))
   If rootid = trs(0) Then
    ErrMsg = "<li>您不能指定该分类的下属分类作为所属分类</li>"
    Founderr = True
    Exit Sub
   End If
   If trs(1) = 1 Then
    ErrMsg = "<li>该分类是外部连接,您不能指定该分类作为所属分类</li>"
    Founderr = True
    Exit Sub
   End If
  End If
 Else
  Set trs = NewAsp.Execute("SELECT classid FROM NC_Classify WHERE ChannelID = "& ChannelID &" And ParentStr like '%" & ParentStr & "%' and classid=" & Request("class"))
  If Not (tRs.EOF And tRs.BOF) Then
   ErrMsg = "<li>您不能指定该分类的下属分类作为所属分类</li>"
   Founderr = True
   Exit Sub
  End If
 End If
 If ParentID = 0 Then
  ParentID = Rs("classid")
  iparentid = 0
 End If
 Rs("classname") = Trim(Request.Form("classname"))
 Rs("readme") = Trim(Request.Form("readme"))
 Rs("ColorModes") = Trim(Request.Form("ColorModes"))
 Rs("FontModes") = Trim(Request.Form("FontModes"))
 Rs("LinkTarget") = Trim(Request.Form("LinkTarget"))
 Rs("TurnLink") = Trim(Request.Form("TurnLink"))
 Rs("TurnLinkUrl") = Trim(Request.Form("TurnLinkUrl"))
 Rs("UserGroup") = Trim(Request.Form("UserGroup"))
 Rs("ClassDir") = Trim(strClassDir)
 Rs("HtmlFileDir") = Trim(HtmlFileDir)
 Rs("isUpdate") = 1
 Rs.Update
 Rs.Close
 Set Rs = Nothing
 Set mrs = NewAsp.Execute("SELECT MAX(rootid) FROM NC_Classify WHERE ChannelID="& ChannelID)
 Maxrootid = mrs(0) 1
 '假如更改了所属分类
 '需要更新其原来所属分类信息,包括深度、父级ID、分类数、排序
 '需要更新当前所属分类信息
 If CLng(ParentID) <> CLng(Request("class")) And Not (iparentid = 0 And CInt(Request("class")) = 0) Then
  '如果原来不是一级分类改成一级分类
  If iparentid > 0 And CInt(Request("class")) = 0 Then
   '如果不是一级分类改成一级分类,更新子分类数据
   '开始更新子分类
   'ChildStr = "," & ChildStr
   Set Rsc = NewAsp.Execute ("SELECT classid,ChildStr FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid in (" & ParentStr & ")")
   Do While Not Rsc.EOF
    ArrChildStr = Split(Rsc("ChildStr"), ",")
    nChildStr = ""
    For ii = 0 to Ubound(ArrChildStr)
     If ArrChildStr(ii) <> ChildStr Then
      nChildStr = nChildStr & ArrChildStr(ii) & Chr(32)
     End If
    Next
    nChildStr = Replace(Trim(nChildStr), Chr(32), ",")
    'nChildStr = Replace(Rsc("ChildStr"), ChildStr, "")
    NewAsp.Execute ("UPDATE NC_Classify SET ChildStr='" & nChildStr & "' WHERE ChannelID = "& ChannelID &" And classid = " & Rsc("classid"))
   Rsc.movenext
   Loop
   Rsc.Close
   Set Rsc = Nothing
   '更新子分类结束
   '---------------------------------------------------
   '更新当前分类数据
   NewAsp.Execute ("UPDATE NC_Classify set depth=0,orders=0,rootid=" & Maxrootid & ",parentid=0,ParentStr='0' WHERE classid=" & newclassid)
   ParentStr = ParentStr & ","
   Set Rs = NewAsp.Execute("SELECT COUNT(ClassID) FROM NC_Classify WHERE ChannelID = "& ChannelID &" And ParentStr like '%" & ParentStr & "%'")
   ClassCount = Rs(0)
   If IsNull(ClassCount) Then
    ClassCount = 1
   Else
    ClassCount = ClassCount 1
   End If
   '更新其原来所属分类数
   NewAsp.Execute ("UPDATE NC_Classify SET child=child-" & ClassCount & " WHERE ChannelID = "& ChannelID &" And classid=" & iparentid)
   '更新其原来所属分类数据,排序相当于剪枝而不需考虑
   For i = 1 To depth
    '得到其父类的父类的ID
    Set Rs = NewAsp.Execute("SELECT parentid FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid=" & iparentid)
    If Not (Rs.EOF And Rs.BOF) Then
     iparentid = Rs(0)
     NewAsp.Execute ("UPDATE NC_Classify SET child=child-" & ClassCount & " WHERE ChannelID = "& ChannelID &" And classid=" & iparentid)
    End If
   Next
   If Child > 0 Then
    '更新其下属分类数据
    '有下属分类,排序不需考虑,更新下属分类深度和一级排序ID(rootid)数据
    '更新当前分类数据
    i = 0
    Set Rs = NewAsp.Execute("SELECT * FROM NC_Classify WHERE ChannelID = "& ChannelID &" And ParentStr LIKE '%" & ParentStr & "%'")
    Do While Not Rs.EOF
     i = i 1
     mParentStr = Replace(Rs("ParentStr"), ParentStr, "")
     NewAsp.Execute ("UPDATE NC_Classify SET depth=depth-" & depth & ",rootid=" & Maxrootid & ",ParentStr='" & mParentStr & "' WHERE ChannelID = "& ChannelID &" And classid=" & Rs("classid"))
     Rs.movenext
    Loop
   End If
   '------------------------------------------------------
  ElseIf iparentid > 0 And CInt(Request("class")) > 0 Then
   '将一个分类移动到其他分类下
   '开始更新子分类
   'ChildStr = "," & ChildStr
   Set Rsc = NewAsp.Execute ("SELECT classid,ChildStr FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid in (" & ParentStr & ")")
   Do While Not Rsc.EOF
    ArrChildStr = Split(Rsc("ChildStr"), ",")
    nChildStr = ""
    For ii = 0 to Ubound(ArrChildStr)
     If ArrChildStr(ii) <> ChildStr Then
      nChildStr = nChildStr & ArrChildStr(ii) & Chr(32)
     End If
    Next
    nChildStr = Replace(Trim(nChildStr), Chr(32), ",")
    'nChildStr = Replace(Rsc("ChildStr"), ChildStr, "")
    NewAsp.Execute ("UPDATE NC_Classify SET ChildStr='" & nChildStr & "' WHERE ChannelID = "& ChannelID &" And classid = " & Rsc("classid"))
   Rsc.movenext
   Loop
   Rsc.Close
   Set Rsc = Nothing
   '更新子分类结束
   '-----------------------------------------------------------
   '获得所指定的分类的相关信息
   Set trs = NewAsp.Execute("SELECT * FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid=" & NewAsp.ChkNumeric(Request("class")))
   '得到其下属分类数
   ParentStr = ParentStr & ","
   Set Rs = NewAsp.Execute("SELECT COUNT(ClassID) FROM NC_Classify WHERE ChannelID = "& ChannelID &" And ParentStr like '%" & ParentStr & "%'")
   ClassCount = Rs(0)
   If IsNull(ClassCount) Then ClassCount = 1
   '在获得移动过来的分类数后更新排序在指定分类之后的分类排序数据
   NewAsp.Execute ("UPDATE NC_Classify SET orders=orders " & ClassCount & " 1 WHERE rootid=" & trs("rootid") & " and orders>" & trs("orders") & "")
   '更新当前分类数据
   NewAsp.Execute ("UPDATE NC_Classify SET depth=" & trs("depth") & " 1,orders=" & trs("orders") & " 1,rootid=" & trs("rootid") & ",ParentID=" & NewAsp.ChkNumeric(Request("class")) & ",ParentStr='" & trs("ParentStr") & "," & trs("classid") & "' WHERE ChannelID = "& ChannelID &" And classid=" & newclassid)
   i = 1
   '如果有则更新下属分类数据
   '深度为原有深度加上当前所属分类的深度
   Set Rs = NewAsp.Execute("SELECT * FROM NC_Classify WHERE ChannelID = "& ChannelID &" And ParentStr like '%" & ParentStr & "%' ORDER BY orders")
   Do While Not Rs.EOF
    i = i 1
    iParentStr = trs("ParentStr") & "," & trs("classid") & "," & Replace(Rs("ParentStr"), ParentStr, "")
    NewAsp.Execute ("UPDATE NC_Classify SET depth=depth " & trs("depth") & "-" & depth & " 1,orders=" & trs("orders") & " " & i & ",rootid=" & trs("rootid") & ",ParentStr='" & iParentStr & "' WHERE ChannelID = "& ChannelID &" And classid=" & Rs("classid"))
    Rs.movenext
   Loop
   ParentID = Request("class")
   If rootid = trs("rootid") Then
    '在同一分类下移动
    '更新所指向的上级分类数,i为本次移动过来的分类数
    '更新其父类分类数
    NewAsp.Execute ("UPDATE NC_Classify SET child=child " & i & " WHERE ChannelID = "& ChannelID &" And (not ParentID=0) and classid=" & ParentID)
    For k = 1 To trs("depth")
     '得到其父类的父类的分类ID
     Set Rs = NewAsp.Execute("SELECT parentid FROM NC_Classify WHERE ChannelID = "& ChannelID &" And (not ParentID=0) and classid=" & ParentID)
     If Not (Rs.EOF And Rs.BOF) Then
      ParentID = Rs(0)
      '更新其父类的父类分类数
      NewAsp.Execute ("UPDATE NC_Classify SET child=child " & i & " WHERE ChannelID = "& ChannelID &" And (not ParentID=0) and  classid=" & ParentID)
     End If
    Next
    '更新其原父类分类数
    NewAsp.Execute ("UPDATE NC_Classify SET child=child-" & i & " WHERE ChannelID = "& ChannelID &" And (not ParentID=0) and classid=" & iparentid)
    '更新其原来所属分类数据
    For k = 1 To depth
     '得到其原父类的父类的分类ID
     Set Rs = NewAsp.Execute("SELECT parentid FROM NC_Classify WHERE ChannelID = "& ChannelID &" And (not ParentID=0) and classid=" & iparentid)
     If Not (Rs.EOF And Rs.BOF) Then
      iparentid = Rs(0)
      '更新其原父类的父类分类数
      NewAsp.Execute ("UPDATE NC_Classify SET child=child-" & i & " WHERE ChannelID = "& ChannelID &" And (not ParentID=0) and  classid=" & iparentid)
     End If
    Next
   Else
    '更新所指向的上级分类数,i为本次移动过来的分类数
    '更新其父类分类数
    NewAsp.Execute ("UPDATE NC_Classify SET child=child " & i & " WHERE ChannelID = "& ChannelID &" And classid=" & ParentID)
    For k = 1 To trs("depth")
     '得到其父类的父类的分类ID
     Set Rs = NewAsp.Execute("SELECT parentid FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid=" & ParentID)
     If Not (Rs.EOF And Rs.BOF) Then
      ParentID = Rs(0)
      '更新其父类的父类分类数
      NewAsp.Execute ("UPDATE NC_Classify SET child=child " & i & " WHERE ChannelID = "& ChannelID &" And classid=" & ParentID)
     End If
    Next
    '更新其原父类分类数
    NewAsp.Execute ("UPDATE NC_Classify SET child=child-" & i & " WHERE ChannelID = "& ChannelID &" And classid=" & iparentid)
    For k = 1 To depth
     '得到其原父类的父类的分类ID
     Set Rs = NewAsp.Execute("SELECT parentid FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid=" & iparentid)
     If Not (Rs.EOF And Rs.BOF) Then
      iparentid = Rs(0)
      '更新其原父类的父类分类数
      NewAsp.Execute ("UPDATE NC_Classify SET child=child-" & i & " WHERE ChannelID = "& ChannelID &" And classid=" & iparentid)
     End If
    Next
   End If
   '-----------------------------------------------
   '开始更新子分类
   SQL = "SELECT classid,parentid,ParentStr,ChildStr FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid=" & Request("class")
   Set Rss = NewAsp.Execute (SQL)
   If Rss("parentid") <> 0 Then
    '如果是一级分类移动到其它一级分类的子分类
    nChildStr = Rss("ChildStr") & "," & NewAsp.ChkNumeric(Request("editid"))
    NewAsp.Execute ("UPDATE NC_Classify SET ChildStr='"&nChildStr&"' WHERE ChannelID = "& ChannelID &" And classid = " & Rss("classid"))
    SQL = "SELECT classid,ParentStr,ChildStr FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid in (" & Rss("ParentStr") & ")"
    Set Rsc = NewAsp.Execute (SQL)
    Do While Not Rsc.EOF
     nChildStr = Rsc("ChildStr") & "," & NewAsp.ChkNumeric(Request("editid"))
     NewAsp.Execute ("UPDATE NC_Classify SET ChildStr='"&nChildStr&"' WHERE ChannelID = "& ChannelID &" And classid = " & Rsc("classid"))
    Rsc.movenext
    Loop
    Rsc.Close
    Set Rsc = Nothing
   Else
    '如果是一级分类移动到其它一级分类,执行以下更新
    nChildStr = Rss("ChildStr") & "," & NewAsp.ChkNumeric(Request("editid"))
    NewAsp.Execute ("UPDATE NC_Classify SET ChildStr='"&nChildStr&"' WHERE ChannelID = "& ChannelID &" And classid = " & Rss("classid"))
   End If
   Rss.Close
   Set Rss = Nothing
   '更新子分类结束
  Else
   '如果原来是一级分类改成其他分类的下属分类
   '更新一级分类的子分类
   '开始更新子分类
   SQL = "SELECT classid,parentid,ParentStr,ChildStr FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid=" & CLng(Request("class"))
   Set Rss = NewAsp.Execute (SQL)
   If Rss("parentid") <> 0 Then
    '如果是一级分类移动到其它一级分类的子分类
    nChildStr = Rss("ChildStr") & "," & ChildStr
    NewAsp.Execute ("UPDATE NC_Classify SET ChildStr='"&nChildStr&"' WHERE ChannelID = "& ChannelID &" And classid = " & Rss("classid"))
    SQL = "SELECT classid,ParentStr,ChildStr FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid in (" & Rss("ParentStr") & ")"
    Set Rsc = NewAsp.Execute (SQL)
    Do While Not Rsc.EOF
     nChildStr = Rsc("ChildStr") & "," & ChildStr
     NewAsp.Execute ("UPDATE NC_Classify SET ChildStr='"&nChildStr&"' WHERE ChannelID = "& ChannelID &" And classid = " & Rsc("classid"))
    Rsc.movenext
    Loop
    Rsc.Close
    Set Rsc = Nothing
   Else
    '如果是一级分类移动到其它一级分类,执行以下更新
    nChildStr = Rss("ChildStr") & "," & ChildStr
    NewAsp.Execute ("UPDATE NC_Classify SET ChildStr='"&nChildStr&"' WHERE ChannelID = "& ChannelID &" And classid = " & Rss("classid"))
   End If
   Rss.Close
   Set Rss = Nothing
   '更新子分类结束
   '---------------------------------------------------
   '得到所指定的分类的相关信息
   Set trs = NewAsp.Execute("SELECT * FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid=" & CLng(Request("class")))
   Set Rs = NewAsp.Execute("SELECT COUNT(ClassID) FROM NC_Classify WHERE ChannelID = "& ChannelID &" And rootid=" & rootid)
   ClassCount = Rs(0)
   Rs.Close
   '更新所指向的上级分类数,i为本次移动过来的分类数
   ParentID = Request("class")
   '更新其父类分类数
   NewAsp.Execute ("UPDATE NC_Classify SET child=child " & ClassCount & " WHERE ChannelID = "& ChannelID &" And classid=" & ParentID)
   For k = 1 To trs("depth")
    '得到其父类的父类的分类ID
    Set Rs = NewAsp.Execute("SELECT parentid FROM NC_Classify WHERE ChannelID = "& ChannelID &" And classid=" & ParentID)
    If Not (Rs.EOF And Rs.BOF) Then
     ParentID = Rs(0)
     '更新其父类的父类分类数
     NewAsp.Execute ("UPDATE NC_Classify SET child=child " & ClassCount & " WHERE ChannelID = "& ChannelID &" And classid=" & ParentID)
    End If
   Next
   '在获得移动过来的分类数后更新排序在指定分类之后的分类排序数据
   NewAsp.Execute ("UPDATE NC_Classify SET orders=orders " & ClassCount & " 1 WHERE ChannelID = "& ChannelID &" And rootid=" & trs("rootid") & " and orders>" & trs("orders") & "")
   i = 0
   Set Rs = NewAsp.Execute("SELECT * FROM NC_Classify WHERE ChannelID = "& ChannelID &" And rootid=" & rootid & " ORDER BY orders")
   Do While Not Rs.EOF
    i = i 1
    If Rs("parentid") = 0 Then
     If trs("ParentStr") = "0" Then
      ParentStr = trs("classid")
     Else
      ParentStr = trs("ParentStr") & "," & trs("classid")
     End If
     NewAsp.Execute ("UPDATE NC_Classify SET depth=depth " & trs("depth") & " 1,orders=" & trs("orders") & " " & i & ",rootid=" & trs("rootid") & ",ParentStr='" & ParentStr & "',parentid=" & CLng(Request("class")) & " WHERE ChannelID = "& ChannelID &" And classid=" & Rs("classid"))
    Else
     If trs("ParentStr") = "0" Then
      ParentStr = trs("classid") & "," & Rs("ParentStr")
     Else
      ParentStr = trs("ParentStr") & "," & trs("classid") & "," & Rs("ParentStr")
     End If
     NewAsp.Execute ("UPDATE NC_Classify SET depth=depth " & trs("depth") & " 1,orders=" & trs("orders") & " " & i & ",rootid=" & trs("rootid") & ",ParentStr='" & ParentStr & "' WHERE ChannelID = "& ChannelID &" And classid=" & Rs("classid"))
    End If
    Rs.movenext
   Loop
   '------------------------------------
  End If
 End If
 Set Rs = Nothing
 Set mrs = Nothing
 Set trs = Nothing
 Dim LocalPath
 If CInt(NewAsp.IsCreateHtml) > 0 And CInt(Request.Form("TurnLink")) = 0 Then
  LocalPath = NewAsp.InstallDir & ChannelDir & HtmlFileDir
  'NewAsp.CreatPathEx(LocalPath)
 End If
 CheckAndFixClass 0,1
 Call RemoveCache
 SucMsg = "<li>恭喜您!分类修改成功。</li>"
 Succeed(SucMsg)
End Sub

有话要说