admin_sorting.asp

来自「多用户管理分权限发布、管理软件信息;  自由选择系统默认为静态HTML或动态A」· ASP 代码 · 共 1,046 行 · 第 1/3 页

ASP
1,046
字号
		End If
		strParent = Rs(4)
		Rs.Close
		neworders = orders
		SQL = "select max(orders) from NC_SoftSort where ParentID=" & Request("class")
		Rs.Open SQL, Conn, 1, 1
		If Not (Rs.bof And Rs.EOF) Then
			neworders = Rs(0)
		End If
		If IsNull(neworders) Then neworders = orders
		Rs.Close
		Newasp.Execute ("update NC_SoftSort set orders=orders+1 where orders>" & CInt(neworders) & "")
	Else
		SQL = "select max(rootid) from NC_SoftSort"
		Rs.Open SQL, Conn, 1, 1
		Maxrootid = Rs(0) + 1
		If IsNull(Maxrootid) Then Maxrootid = 1
		Rs.Close
	End If
	SQL = "select sortid from NC_SoftSort where sortid=" & Request("newsortid")
	Rs.Open SQL, Conn, 1, 1
	If Not (Rs.EOF And Rs.bof) Then
		ErrMsg = "<li>您不能指定和别的分类一样的序号。</li>"
		Founderr = True
		Exit Sub
	Else
		sortid = Request("newsortid")
	End If
	Rs.Close
	SQL = "select * from NC_SoftSort"
	Rs.Open SQL, Conn, 1, 3
	Rs.addnew
	If Request("class") <> "0" Then
		Rs("depth") = depth + 1
		Rs("rootid") = rootid
		Rs("orders") = neworders + 1
		Rs("parentid") = Request.Form("class")
		If strParent = "0" Then
			Rs("strparent") = Request.Form("class")
		Else
			Rs("strparent") = strParent & "," & Request.Form("class")
		End If
	Else
		Rs("depth") = 0
		Rs("rootid") = Maxrootid
		Rs("orders") = 0
		Rs("parentid") = 0
		Rs("strparent") = 0
	End If
	Rs("child") = 0
	Rs("sortid") = Request.Form("newsortid")
	Rs("sortname") = Newasp.HTMLEncodes(Request.Form("sortname"))
	Rs("readme") = Request.Form("readme")
	Rs("skinid") = Request.Form("skinid")
	Rs("isUpdate") = 1
	Rs.Update
	Rs.Close
	If Request("class") <> "0" Then
		If depth > 0 Then Newasp.Execute ("update NC_SoftSort set child=child+1 where sortid in (" & strParent & ")")
		Newasp.Execute ("update NC_SoftSort set child=child+1 where sortid=" & Request("class"))
	End If
	CreateNewFolder CLng(Request.Form("newsortid")), CLng(Request.Form("class"))
	Set Rs = Newasp.Execute("select ID from NC_Template")
	Do While Not Rs.EOF
		Newasp.DelCahe ("SortingList" & Rs(0))
		Newasp.DelCahe ("SortingMenu" & Rs(0))
		Rs.movenext
	Loop
	Newasp.DelCahe "SortingJumpMenu"
	Newasp.DelCahe "SortingJumpList"
	SucMsg = "<li>分类添加成功!</li>"
	NC_Admin.Succeed_Msg (SucMsg)
	Set Rs = Nothing
End Sub

Private Sub savedit()
	Dim newsortid
	Dim Maxrootid
	Dim ParentID
	Dim depth
	Dim Child
	Dim strParent
	Dim rootid
	Dim iparentid
	Dim istrparent
	Dim trs
	Dim brs
	Dim mrs
	Dim k
	Dim nstrparent
	Dim mstrparent
	Dim ParentSql
	Dim boardcount
	If CLng(Request("editid")) = CLng(Request("class")) Then
		ErrMsg = "<li>所属分类不能指定自己</li>"
		Founderr = True
		Exit Sub
	End If
	Set Rs = CreateObject("adodb.recordset")
	SQL = "select * from NC_SoftSort where sortid=" & Request("editid")
	Rs.Open SQL, Conn, 1, 3
	newsortid = Rs("sortid")
	ParentID = Rs("parentid")
	iparentid = Rs("parentid")
	strParent = Rs("strparent")
	depth = Rs("depth")
	Child = Rs("child")
	rootid = Rs("rootid")

	If ParentID = 0 Then
		If CLng(Request("class")) <> 0 Then
			Set trs = Newasp.Execute("select rootid from NC_SoftSort where sortid=" & Request("class"))
			If rootid = trs(0) Then
				ErrMsg = "<li>您不能指定该分类的下属分类作为所属分类</li>"
				Founderr = True
				Exit Sub
				Response.End
			End If
		End If
	Else
		Set trs = Newasp.Execute("select sortid from NC_SoftSort where strparent like '%" & strParent & "%' and sortid=" & Request("class"))
		If Not (trs.EOF And trs.bof) Then
			ErrMsg = "<li>您不能指定该分类的下属分类作为所属分类</li>"
			Founderr = True
			Exit Sub
			Response.End
		End If
	End If
	If ParentID = 0 Then
		ParentID = Rs("sortid")
		iparentid = 0
	End If
	Rs("sortname") = Newasp.HTMLEncodes(Request.Form("sortname"))

	Rs("readme") = Request("readme")
	Rs("skinid") = Request.Form("skinid")
	Rs("isUpdate") = 1
	Rs.Update
	Rs.Close
	Set Rs = Nothing
	Set mrs = Newasp.Execute("select max(rootid) from NC_SoftSort")
	Maxrootid = mrs(0) + 1

	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
			Newasp.Execute ("update NC_SoftSort set depth=0,orders=0,rootid=" & Maxrootid & ",parentid=0,strparent='0' where sortid=" & newsortid)
			strParent = strParent & ","
			Set Rs = Newasp.Execute("select count(*) from NC_SoftSort where strparent like '%" & strParent & "%'")
			boardcount = Rs(0)
			If IsNull(boardcount) Then
				boardcount = 1
			Else
				boardcount = boardcount + 1
			End If
			Newasp.Execute ("update NC_SoftSort set child=child-" & boardcount & " where sortid=" & iparentid)
			For i = 1 To depth
				Set Rs = Newasp.Execute("select parentid from NC_SoftSort where sortid=" & iparentid)
				If Not (Rs.EOF And Rs.bof) Then
					iparentid = Rs(0)
					Newasp.Execute ("update NC_SoftSort set child=child-" & boardcount & " where sortid=" & iparentid)
				End If
			Next
			If Child > 0 Then
				i = 0
				Set Rs = Newasp.Execute("select * from NC_SoftSort where strparent like '%" & strParent & "%'")
				Do While Not Rs.EOF
					i = i + 1
					mstrparent = Replace(Rs("strparent"), strParent, "")
					Newasp.Execute ("update NC_SoftSort set depth=depth-" & depth & ",rootid=" & Maxrootid & ",strparent='" & mstrparent & "' where sortid=" & Rs("sortid"))
					Rs.movenext
				Loop
			End If
		ElseIf iparentid > 0 And CInt(Request("class")) > 0 Then
			Set trs = Newasp.Execute("select * from NC_SoftSort where sortid=" & Request("class"))
			strParent = strParent & ","
			Set Rs = Newasp.Execute("select count(*) from NC_SoftSort where strparent like '%" & strParent & "%'")
			boardcount = Rs(0)
			If IsNull(boardcount) Then boardcount = 1
			Newasp.Execute ("update NC_SoftSort set orders=orders + " & boardcount & " + 1 where rootid=" & trs("rootid") & " and orders>" & trs("orders") & "")
			Newasp.Execute ("update NC_SoftSort set depth=" & trs("depth") & "+1,orders=" & trs("orders") & "+1,rootid=" & trs("rootid") & ",ParentID=" & Request("class") & ",strparent='" & trs("strparent") & "," & trs("sortid") & "' where sortid=" & newsortid)
			i = 1
			Set Rs = Newasp.Execute("select * from NC_SoftSort where strparent like '%" & strParent & "%' order by orders")
			Do While Not Rs.EOF
				i = i + 1
				istrparent = trs("strparent") & "," & trs("sortid") & "," & Replace(Rs("strparent"), strParent, "")
				Newasp.Execute ("update NC_SoftSort set depth=depth+" & trs("depth") & "-" & depth & "+1,orders=" & trs("orders") & "+" & i & ",rootid=" & trs("rootid") & ",strparent='" & istrparent & "' where sortid=" & Rs("sortid"))
				Rs.movenext
			Loop
			ParentID = Request("class")
			If rootid = trs("rootid") Then

				Newasp.Execute ("update NC_SoftSort set child=child+" & i & " where (not ParentID=0) and sortid=" & ParentID)
				For k = 1 To trs("depth")
					Set Rs = Newasp.Execute("select parentid from NC_SoftSort where (not ParentID=0) and sortid=" & ParentID)
					If Not (Rs.EOF And Rs.bof) Then
						ParentID = Rs(0)
						Newasp.Execute ("update NC_SoftSort set child=child+" & i & " where (not ParentID=0) and  sortid=" & ParentID)
					End If
				Next
				Newasp.Execute ("update NC_SoftSort set child=child-" & i & " where (not ParentID=0) and sortid=" & iparentid)
				For k = 1 To depth
					Set Rs = Newasp.Execute("select parentid from NC_SoftSort where (not ParentID=0) and sortid=" & iparentid)
					If Not (Rs.EOF And Rs.bof) Then
						iparentid = Rs(0)
						Newasp.Execute ("update NC_SoftSort set child=child-" & i & " where (not ParentID=0) and  sortid=" & iparentid)
					End If
				Next
			Else
				Newasp.Execute ("update NC_SoftSort set child=child+" & i & " where sortid=" & ParentID)
				For k = 1 To trs("depth")
					Set Rs = Newasp.Execute("select parentid from NC_SoftSort where sortid=" & ParentID)
					If Not (Rs.EOF And Rs.bof) Then
						ParentID = Rs(0)
						Newasp.Execute ("update NC_SoftSort set child=child+" & i & " where sortid=" & ParentID)
					End If
				Next
				Newasp.Execute ("update NC_SoftSort set child=child-" & i & " where sortid=" & iparentid)
				For k = 1 To depth
					Set Rs = Newasp.Execute("select parentid from NC_SoftSort where sortid=" & iparentid)
					If Not (Rs.EOF And Rs.bof) Then
						iparentid = Rs(0)
						Newasp.Execute ("update NC_SoftSort set child=child-" & i & " where sortid=" & iparentid)
					End If
				Next
			End If
		Else

			Set trs = Newasp.Execute("select * from NC_SoftSort where sortid=" & Request("class"))
			Set Rs = Newasp.Execute("select count(*) from NC_SoftSort where rootid=" & rootid)
			boardcount = Rs(0)
			ParentID = Request("class")
			Newasp.Execute ("update NC_SoftSort set child=child+" & boardcount & " where sortid=" & ParentID)
			For k = 1 To trs("depth")
				Set Rs = Newasp.Execute("select parentid from NC_SoftSort where sortid=" & ParentID)
				If Not (Rs.EOF And Rs.bof) Then
					ParentID = Rs(0)
					Newasp.Execute ("update NC_SoftSort set child=child+" & boardcount & " where sortid=" & ParentID)
				End If
			Next
			Newasp.Execute ("update NC_SoftSort set orders=orders + " & boardcount & " + 1 where rootid=" & trs("rootid") & " and orders>" & trs("orders") & "")
			i = 0
			Set Rs = Newasp.Execute("select * from NC_SoftSort where rootid=" & rootid & " order by orders")
			Do While Not Rs.EOF
				i = i + 1
				If Rs("parentid") = 0 Then
					If trs("strparent") = "0" Then
						strParent = trs("sortid")
					Else
						strParent = trs("strparent") & "," & trs("sortid")
					End If
					Newasp.Execute ("update NC_SoftSort set depth=depth+" & trs("depth") & "+1,orders=" & trs("orders") & "+" & i & ",rootid=" & trs("rootid") & ",strparent='" & strParent & "',parentid=" & Request("class") & " where sortid=" & Rs("sortid"))
				Else
					If trs("strparent") = "0" Then
						strParent = trs("sortid") & "," & Rs("strparent")
					Else
						strParent = trs("strparent") & "," & trs("sortid") & "," & Rs("strparent")
					End If
					Newasp.Execute ("update NC_SoftSort set depth=depth+" & trs("depth") & "+1,orders=" & trs("orders") & "+" & i & ",rootid=" & trs("rootid") & ",strparent='" & strParent & "' where sortid=" & Rs("sortid"))
				End If
				Rs.movenext
			Loop
		End If
	End If
	CreateNewFolder CLng(Request.Form("editid")), CLng(Request.Form("class"))
	Set Rs = Newasp.Execute("select ID from NC_Template")
	Do While Not Rs.EOF
		Newasp.DelCahe ("SortingList" & Rs(0))
		Newasp.DelCahe ("SortingMenu" & Rs(0))
		Rs.movenext
	Loop
	Newasp.DelCahe "SortingJumpMenu"
	Newasp.DelCahe "SortingJumpList"
	SucMsg = "<li>分类修改成功!</li>"
	NC_Admin.Succeed_Msg (SucMsg)
	Set Rs = Nothing
	Set mrs = Nothing
	Set trs = Nothing
End Sub

Private Sub del()
	Set Rs = Newasp.Execute("select strparent,child,depth from NC_SoftSort where sortid=" & Request("editid"))
	If Not (Rs.EOF And Rs.bof) Then
		If Rs(1) > 0 Then
			Response.Write "该分类含有下属分类,请删除其下属分类后再进行删除本分类的操作"
			Exit Sub
		End If
		If Rs(2) > 0 Then
			Newasp.Execute ("update NC_SoftSort set child=child-1 where sortid in (" & Rs(0) & ")")
		End If
		SQL = "delete from NC_SoftSort where sortid=" & Request("editid")
		Newasp.Execute (SQL)
		Newasp.Execute ("delete from NC_SoftInfo where sortid=" & Request("editid"))
		Newasp.Execute ("delete from NC_SoftSite where sortid=" & Request("editid"))
		DelFolder (Request("editid"))
	End If
	Set Rs = Newasp.Execute("select ID from NC_Template")
	Do While Not Rs.EOF
		Newasp.DelCahe ("SortingList" & Rs(0))
		Newasp.DelCahe ("SortingMenu" & Rs(0))
		Rs.movenext
	Loop
	Set Rs = Nothing
	Newasp.DelCahe "SortingJumpMenu"
	Newasp.DelCahe "SortingJumpList"
	NC_Admin.Succeed_Msg ("分类删除成功!")

End Sub

Private Sub orders()
	Response.Write " <table width=""96%"" border=""0"" cellspacing=""1"" cellpadding=""3"" align=center class=""tableBorder"">"
	Response.Write " <tr>"
	Response.Write " <th>分类一级分类重新排序修改(请在相应软件分类的排序表单内输入相应的排列序号) </th>"
	Response.Write " </tr>"
	Response.Write " <tr>"
	Response.Write " <td class=forumrow>"
	Response.Write "<table width=""50%"">"
	Set Rs = CreateObject("Adodb.recordset")
	SQL = "select * from NC_SoftSort where ParentID=0 order by RootID"
	Rs.Open SQL, Conn, 1, 1
	If Rs.bof And Rs.EOF Then
		Response.Write "还没有相应的软件分类。"
	Else
		Do While Not Rs.EOF
			Response.Write "<form action=admin_sorting.asp?action=updatorders method=post><tr><td width=""50%"">" & Rs("sortname") & "</td>"
			Response.Write "<td width=""50%""><input type=text name=""OrderID"" size=4 value=""" & Rs("rootid") & """><input type=hidden name=""cID"" value=""" & Rs("rootid") & """>&nbsp;&nbsp;<input type=submit name=Submit class=button value='修 改'></td></tr></form>"
			Rs.movenext
		Loop
		Response.Write "</table>"
		Response.Write "<BR>&nbsp;<font color=red>请注意,这里一定<B>不能填写相同的序号</B>,否则非常难修复!</font>"
	End If
	Rs.Close
	Set Rs = Nothing
	Response.Write " </td>"
	Response.Write " </tr>"
	Response.Write "</table>"
End Sub

Private Sub updateorders()
	Dim cID
	Dim OrderID
	Dim ClassName
	cID = Replace(Request.Form("cID"), "'", "")
	OrderID = Replace(Request.Form("OrderID"), "'", "")
	Set Rs = Newasp.Execute("select sortid from NC_SoftSort where rootid=" & OrderID)
	If Rs.bof And Rs.EOF Then
		NC_Admin.Succeed_Msg ("设置成功,请返回。")
		Newasp.Execute ("update NC_SoftSort set rootid=" & OrderID & " where rootid=" & cID)
		Newasp.Execute ("update NC_SoftInfo set rootid=" & OrderID & " where rootid=" & cID)
	Else

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?