📄 admin_classify.asp
字号:
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=" & 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=" & 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") & "," & 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") & "," & 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") & "," & 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=" & 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=" & 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=" & 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
Sub DelClass()
Dim ChildStr,nChildStr
Dim Rss,Rsc
On Error Resume Next
Set Rs = Newasp.Execute("select ParentStr,child,depth,parentid,HtmlFileDir,UseHtml from NC_Classify where ChannelID = "& ChannelID &" And classid=" & Request("editid"))
If Not (Rs.EOF And Rs.bof) Then
If Rs(1) > 0 Then
ErrMsg = "<li>该分类含有下属分类,请删除其下属分类后再进行删除本分类的操作</li>"
Founderr = True
Exit Sub
End If
HtmlFileDir = Rs(4)
UseHtml = Rs(5)
If Rs(3) > 0 Then
ChildStr = "," & Request("editid")
SQL = "select classid,ParentStr from NC_Classify where ChannelID = "& ChannelID &" And classid=" & Request("editid")
Set Rss = Newasp.Execute (SQL)
SQL = "select classid,ChildStr from NC_Classify where ChannelID = "& ChannelID &" And classid in (" & Rss("ParentStr") & ")"
Set Rsc = Newasp.Execute (SQL)
Do While Not Rsc.EOF
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 Rss = Nothing
End If
If Rs(2) > 0 Then
Newasp.Execute ("update NC_Classify set child=child-1 where ChannelID = "& ChannelID &" And classid in (" & Rs(0) & ")")
End If
SQL = "delete from NC_Classify where ChannelID = "& ChannelID &" And classid=" & Request("editid")
Newasp.Execute (SQL)
Call DelRelated
End If
Set Rs = Nothing
Newasp.Execute("UPDATE NC_Classify SET child=0 WHERE ChannelID="& ChannelID &" And child<0")
CheckAndFixClass 0,1
Call RemoveCache
Succeed ("恭喜您!分类删除成功。")
End Sub
Sub ResumeClass()
CheckAndFixClass 0,1
Response.Redirect Request.ServerVariables("HTTP_REFERER")
End Sub
Sub CheckAndFixClass(ParentID,orders)
Dim Rs,Child,ParentStr
If ParentID=0 Then
Newasp.Execute("UPDATE NC_Classify SET Depth=0,ParentStr='0' WHERE ChannelID="& ChannelID &" And ParentID=0")
End If
Set Rs=Newasp.Execute("SELECT classid,rootid,ParentStr,Depth FROM NC_Classify WHERE ChannelID="& ChannelID &" And ParentID="&ParentID&" ORDER BY rootid,orders")
Do while Not Rs.EOF
If Rs(2)<>"0" Then
ParentStr=Rs(2)&","&Rs(0)
Else
ParentStr=Rs(0)
End If
Conn.Execute "UPDATE NC_Classify SET Depth="&Rs(3)+1&",ParentStr='"&ParentStr&"',rootid="&rs(1)&" WHERE ChannelID="& ChannelID &" And ParentID="&Rs(0)&"",Child
Newasp.Execute("UPDATE NC_Classify SET Child="&Child&",orders="&orders&" WHERE ChannelID="& ChannelID &" And classid="&Rs(0)&"")
orders=orders+1
CheckAndFixClass Rs(0),orders
Rs.MoveNext
Loop
Set Rs=Nothing
End Sub
Sub DelRelated()
On Error Resume Next
Select Case moduleid
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -