⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin_cat.asp

📁 AspEase Auction System Ver2.0/动易拍卖系统 Ver2.0
💻 ASP
📖 第 1 页 / 共 3 页
字号:
	'更新该分类排序以及大于本需要和同在本分类下的分类排序序号
	conn.execute("update cat set orders=orders+1 where rootid="&rootid&" and orders>"&orders)
	conn.execute("update cat set orders="&orders&"+1 where catid="&Request.form("newcatid"))
else
	'当上级分类深度为0的时候只要更新上级拍卖分类数和该分类排序序号即可
	conn.execute("update cat set child=child+1 where catid="&request("class"))
	set rs=conn.execute("select max(orders) from cat where catid="&Request.form("newcatid"))
	conn.execute("update cat set orders="&rs(0)&"+1 where catid="&Request.form("newcatid"))
end if
end if
response.write "<p>分类添加成功!<br><B>该分类目前高级设置为默认选项,建议您返回分类管理中心重新设置该分类的高级选项</B><BR><br>"&str
set rs=nothing
call cache_cat()
end sub

'保存编辑分类信息
sub savedit()
if clng(request("editid"))=clng(request("class")) then
	response.write "所属分类不能指定自己"
	exit sub
end if
dim newcatid,maxrootid
dim parentid,catmaster,depth,child,ParentStr,rootid,iparentid,iParentStr
dim trs,brs,mrs
set rs = server.CreateObject ("adodb.recordset")
sql = "select * from cat where catid="&request("editid")
rs.Open sql,conn,1,3
newcatid=rs("catid")
parentid=rs("parentid")
iparentid=rs("parentid")
ParentStr=rs("ParentStr")
depth=rs("depth")
child=rs("child")
rootid=rs("rootid")
'判断所指定的分类是否其下属分类
if ParentID=0 then
	if clng(request("class"))<>0 then
	set trs=conn.execute("select rootid from cat where catid="&request("class"))
	if rootid=trs(0) then
		response.write "您不能指定该分类的下属分类作为所属分类1"
		exit sub
	end if
	end if
else
	set trs=conn.execute("select catid from cat where ParentStr like '%"&ParentStr&",%' and catid="&request("class"))
	if not (trs.eof and trs.bof) then		
		response.write "您不能指定该分类的下属分类作为所属分类2"
		response.end
	end if
end if
if parentid=0 then
	parentid=rs("catid")
	iparentid=0
end if
rs("catname") = Request.Form("catname")
rs.Update 
rs.Close
set rs=nothing

set mrs=conn.execute("select max(rootid) from cat")
Maxrootid=mrs(0)+1
'假如更改了所属分类
'需要更新其原来所属分类信息,包括深度、父级ID、分类数、排序、继承版主等数据
'需要更新当前所属分类信息
dim k,nParentStr,mParentStr
dim ParentSql,catcount
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
		'更新当前分类数据
		conn.execute("update cat set depth=0,orders=0,rootid="&maxrootid&",parentid=0,parentstr='0' where catid="&newcatid)
		ParentStr=ParentStr & ","
		set rs=conn.execute("select count(*) from cat where ParentStr like '%"&ParentStr&"%'")
		catcount=rs(0)
		if isnull(catcount) then
		catcount=1
		else
		catcount=catcount+1
		end if
		'更新其原来所属拍卖分类数
		conn.execute("update cat set child=child-"&catcount&" where catid="&iparentid)
		'更新其原来所属分类数据,排序相当于剪枝而不需考虑
		for i=1 to depth
			'得到其父类的父类的分类ID
			set rs=conn.execute("select parentid from cat where catid="&iparentid)
			if not (rs.eof and rs.bof) then
				iparentid=rs(0)
				conn.execute("update cat set child=child-"&catcount&" where catid="&iparentid)
			end if
		next
		if child>0 then
		'更新其下属分类数据
		'有下属分类,排序不需考虑,更新下属分类深度和一级排序ID(rootid)数据
		'更新当前分类数据				
		i=0
		set rs=conn.execute("select * from cat where ParentStr like '%"&ParentStr&"%'")
		do while not rs.eof
		i=i+1
		mParentStr=replace(rs("ParentStr"),ParentStr,"")
		conn.execute("update cat set depth=depth-"&depth&",rootid="&maxrootid&",ParentStr='"&mParentStr&"' where catid="&rs("catid"))
		rs.movenext
		loop
		end if
	elseif iparentid>0 and cint(request("class"))>0 then
	'将一个分分类移动到其他分分类下
	'获得所指定的分类的相关信息
	set trs=conn.execute("select * from cat where catid="&request("class"))
	'得到其下属分类数
	ParentStr=ParentStr & ","
	set rs=conn.execute("select count(*) from cat where ParentStr like '%"&ParentStr & newcatid&"%'")
	catcount=rs(0)
	if isnull(catcount) then catcount=1
	'在获得移动过来的分类数后更新排序在指定分类之后的分类排序数据
	conn.execute("update cat set orders=orders + "&catCount&" + 1 where rootid="&trs("rootid")&" and orders>"&trs("orders")&"")
	'更新当前分类数据
	If trs("parentstr")="0" Then
	conn.execute("update cat set depth="&trs("depth")&"+1,orders="&trs("orders")&"+1,rootid="&trs("rootid")&",ParentID="&request("class")&",ParentStr='" & trs("catid") & "' where catid="&newcatid)
	Else
	conn.execute("update cat set depth="&trs("depth")&"+1,orders="&trs("orders")&"+1,rootid="&trs("rootid")&",ParentID="&request("class")&",ParentStr='" & trs("parentstr") & "," & trs("catid") & "' where catid="&newcatid)
	End If
	i=1
	'如果有则更新下属分类数据
	'深度为原有深度加上当前所属分类的深度
	set rs=conn.execute("select * from cat where ParentStr like '%"&ParentStr & newcatid&"%' order by orders")
	do while not rs.eof
	i=i+1
	If trs("parentstr")="0" Then
	iParentStr=trs("catid") & "," & replace(rs("parentstr"),ParentStr,"")
	Else
	iParentStr=trs("parentstr") & "," & trs("catid") & "," & replace(rs("parentstr"),ParentStr,"")
	End If
	conn.execute("update cat set depth=depth+"&trs("depth")&"-"&depth&"+1,orders="&trs("orders")&"+"&i&",rootid="&trs("rootid")&",ParentStr='"&iParentStr&"' where catid="&rs("catid"))
	rs.movenext
	loop
	ParentID=request("class")
	if rootid=trs("rootid") then
	'在同一分类下移动
	'更新所指向的上级拍卖分类数,i为本次移动过来的分类数
	'更新其父类分类数
	conn.execute("update cat set child=child+"&i&" where (not ParentID=0) and catid="&parentid)
	for k=1 to trs("depth")
		'得到其父类的父类的分类ID
		set rs=conn.execute("select parentid from cat where (not ParentID=0) and catid="&parentid)
		if not (rs.eof and rs.bof) then
			parentid=rs(0)
			'更新其父类的父类分类数
			conn.execute("update cat set child=child+"&i&" where (not ParentID=0) and  catid="&parentid)
		end if
	next
	'更新其原父类分类数
	conn.execute("update cat set child=child-"&i&" where (not ParentID=0) and catid="&iparentid)
	'更新其原来所属分类数据
	'response.write iparentid & "<br>"
	for k=1 to depth
		'得到其原父类的父类的分类ID
		set rs=conn.execute("select parentid from cat where (not ParentID=0) and catid="&iparentid)
		if not (rs.eof and rs.bof) then
			iparentid=rs(0)
			'response.write iparentid & "<br>"
			'更新其原父类的父类分类数
			conn.execute("update cat set child=child-"&i&" where (not ParentID=0) and  catid="&iparentid)
		end if
	next
	else
	'更新所指向的上级拍卖分类数,i为本次移动过来的分类数
	'更新其父类分类数
	conn.execute("update cat set child=child+"&i&" where catid="&parentid)
	for k=1 to trs("depth")
		'得到其父类的父类的分类ID
		set rs=conn.execute("select parentid from cat where catid="&parentid)
		if not (rs.eof and rs.bof) then
			parentid=rs(0)
			'更新其父类的父类分类数
			conn.execute("update cat set child=child+"&i&" where catid="&parentid)
		end if
	next
	'更新其原父类分类数
	conn.execute("update cat set child=child-"&i&" where catid="&iparentid)
	'更新其原来所属分类数据
	for k=1 to depth
		'得到其原父类的父类的分类ID
		set rs=conn.execute("select parentid from cat where catid="&iparentid)
		if not (rs.eof and rs.bof) then
			iparentid=rs(0)
			'更新其原父类的父类分类数
			conn.execute("update cat set child=child-"&i&" where catid="&iparentid)
		end if
	next
	end if 'end if rootid=trs("rootid") then
	else
	'如果原来是一级分类改成其他分类的下属分类
	'得到所指定的分类的相关信息
	set trs=conn.execute("select * from cat where catid="&request("class"))
	set rs=conn.execute("select count(*) from cat where rootid="&rootid)
	catcount=rs(0)
	'更新所指向的上级拍卖分类数,i为本次移动过来的分类数
	ParentID=request("class")
	'更新其父类分类数
	conn.execute("update cat set child=child+"&catcount&" where catid="&parentid)
	'response.write parentid & "-"&catcount&"<br>"
	for k=1 to trs("depth")
		'得到其父类的父类的分类ID
		set rs=conn.execute("select parentid from cat where catid="&parentid)
		if not (rs.eof and rs.bof) then
			parentid=rs(0)
			'更新其父类的父类分类数
			conn.execute("update cat set child=child+"&catcount&" where catid="&parentid)
		end if
	'response.write parentid & "-"&catcount&"<br>"
	next
	'在获得移动过来的分类数后更新排序在指定分类之后的分类排序数据
	conn.execute("update cat set orders=orders + "&catCount&" + 1 where rootid="&trs("rootid")&" and orders>"&trs("orders")&"")
	i=0
	set rs=conn.execute("select * from cat where 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("catid")
		else
		parentstr=trs("parentstr") & "," & trs("catid")
		end if
	conn.execute("update cat set depth=depth+"&trs("depth")&"+1,orders="&trs("orders")&"+"&i&",rootid="&trs("rootid")&",ParentStr='"&ParentStr&"',parentid="&request("class")&" where catid="&rs("catid"))
	else
		if trs("ParentStr")="0" then
		parentstr=trs("catid") & "," & rs("parentstr")
		else
		parentstr=trs("parentstr") & "," & trs("catid") & "," & rs("parentstr")
		end if
	conn.execute("update cat set depth=depth+"&trs("depth")&"+1,orders="&trs("orders")&"+"&i&",rootid="&trs("rootid")&",ParentStr='"&ParentStr&"' where catid="&rs("catid"))
	end if
	rs.movenext
	loop
	end if
end if
set rs=nothing
set mrs=nothing
set trs=nothing
response.write "<p>分类修改成功!<br><br>"&str
'cache分类数据
call cache_cat()
'end cache
end sub

'删除分类,删除分类数据,入口:分类ID
sub del()
'更新其上级拍卖分类数,如果该分类含有下级分类则不允许删除
set rs=conn.execute("select ParentStr,child,depth from cat where catid="&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
	conn.execute("update cat set child=child-1 where catid in ("&rs(0)&")")
end if
sql = "delete from cat where catid="&Request("editid")
conn.execute(sql)
end if
set rs=nothing
call cache_cat()
response.write "<p>分类删除成功!"
end sub

sub orders()
response.Write("<table width=""95%"" border=""0"" cellspacing=""1"" cellpadding=""3""  align=center class=""tableBorder"">")
response.Write("	<tr> ")
response.Write("	<th height=""22"">分类一级分类重新排序修改(请在相应拍卖分类的排序表单内输入相应的排列序号)")
response.Write("	</th>")
response.Write("	</tr>")
response.Write("	<tr><td class=""row"" colspan=""2"">")
	set rs = server.CreateObject ("Adodb.recordset")
	sql="select * from cat where ParentID=0 order by RootID"
	rs.open sql,conn,1,1
	if rs.eof and rs.bof then
		response.write "还没有相应的拍卖分类。"
	else		
		do while not rs.eof		
		response.Write("<table width=""100%""><form action=admin_cat.asp?action=updatorders method=post><tr><td width=""50%"">"&rs("catname")&"</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 value=修改></td></tr></form>"
		response.Write("</table>")
		rs.movenext
		loop				
	rs.close
	set rs=nothing	
	end if
response.Write("</td></tr>")
response.Write("<tr><td class=""row"" colspan=""2"">&nbsp;<font color=red>请注意,这里一定<B>不能填写相同的序号</B>,否则非常难修复!</font></td></tr>")
response.Write("</table>")
end sub
'=========================================================
'Copyright (C) 2003-2004 AspEase.Com. All rights reserved.
'Web: http://www.aspease.com
'Email: byhucn@126.com,lzz9812@163.com
'=========================================================
'
'FileName: admin_cat.asp
'Version:2.0
'UpdateTime: 2004-10-7 14:54:09
'Script Written by www.aspease.com 
'=========================================================
sub updateorders()
	dim cID,OrderID,ClassName	
	cID=replace(request.form("cID"),"'","")
	OrderID=replace(request.form("OrderID"),"'","")
	set rs=conn.execute("select catid from cat where rootid="&orderid)
	if rs.eof and rs.bof then
	response.write "设置成功,请返回。"
	conn.execute("update cat set rootid="&OrderID&" where rootid="&cID)
	else
	response.write "请不要和其他分类设置相同的序号"
	end if
	call cache_cat()
end sub


sub catorders()
response.Write("<table width=""95%"" border=""0"" cellspacing=""1"" cellpadding=""3""  align=center class=""tableBorder"">")
response.Write("	<form action=admin_cat.asp?action=updatcatorders method=post>")
response.Write("<tr> ")
response.Write("	<th height=""22"" colspan=""2"">分类N级分类重新排序修改(请在相应拍卖分类的排序表单内输入相应的排列序号)")
response.Write("	</th>")
response.Write("	</tr>")
response.Write("	")
dim trs,uporders,doorders
set rs = server.CreateObject ("Adodb.recordset")
sql="select * from cat order by RootID,orders"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
	response.write "<tr><td class=""row"" colspan=""2"">还没有相应的拍卖分类。</td></tr>"
else
	do while not rs.eof
	response.Write("	<tr><td width=""50%"" class=""row"">")
	if rs("depth")>0 then
	for i=1 to rs("depth")
		response.write "&nbsp;"
	next
	end if
	if rs("child")>0 then
		response.write "<img src=images/plus.gif>"
	else
		response.write "<img src=images/nofollow.gif>"

⌨️ 快捷键说明

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