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

📄 admin_article_catalog.asp

📁 动感系统XP Access版,服务器需要安装Jmail 组件 配置SendMessages.asp 最后部分的参数
💻 ASP
📖 第 1 页 / 共 3 页
字号:
parentstr=rs(4)
rs.close
'Response.Write orders&"<br>"
neworders=orders
'算出正确的orders值
sql="select max(orders) from info_Catalog where ParentID="&request("class")
rs.open sql,conn,1,1
  if not (rs.eof and rs.bof) then
    neworders=rs(0)
  end if
  if isnull(neworders) then neworders=orders
rs.close
'Response.Write(sql)
conn.execute("update info_Catalog set orders=orders+1 where orders>"&cint(neworders)&"")

else
sql="select max(rootid) from info_Catalog"
rs.open sql,conn,1,1
maxrootid=rs(0)+1
if isnull(MaxRootID) then MaxRootID=1
rs.close
end if
sql="select CatalogID from info_Catalog where CatalogID="&request("newCatalogID")
rs.open sql,conn,1,1
if not (rs.eof and rs.bof) then
		msgtitle="添加新栏目"
		msginfo="<li>您不能指定和别的栏目一样的序号。</li>"
	exit sub
else
	CatalogID=request("newCatalogID")
end if
rs.close

sql = "select * from info_Catalog"
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 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("orders")=0
   rs("parentid")=0
   rs("parentstr")=0
end if
   rs("child")=0
   rs("CatalogID") = Request.form("newCatalogID")
   rs("CatalogName") = Request.Form("CatalogName")
   rs("readme") = Request.form("readme")
   rs("isUpdate")=0
rs.Update 
rs.Close

if request("class")<>"0" then
'当上级分类深度大于0的时候要更新其父类(或父类的父类)的版面数
if depth>0 then conn.execute("update info_Catalog set child=child+1 where CatalogID in ("&parentstr&")")
conn.execute("update info_Catalog set child=child+1 where CatalogID="&request("class"))
end if

msgtitle="添加新栏目"
msginfo="<p>栏目添加成功!<br><B>该栏目目前高级设置为默认选项,建议您返回栏目管理中心重新设置该栏目的高级选项</B><BR>"
call Sysmsg(msgtitle,msginfo)
set rs=nothing
end sub

'保存编辑栏目信息
sub savedit()
msgtitle="保存编辑栏目信息"
if clng(request("editid"))=clng(request("class")) then
	msginfo="<li>所属栏目不能指定自己</li>"
	call Sysmsg(msgtitle,msginfo,95)
	exit sub
end if
dim newCatalogID,maxrootid
dim parentid,depth,child,ParentStr,rootid,iparentid,iParentStr
dim trs,brs,mrs
set rs = server.CreateObject ("adodb.recordset")
sql = "select * from info_Catalog where CatalogID="&request("editid")
rs.Open sql,conn,1,3
newCatalogID=rs("CatalogID")
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 info_Catalog where CatalogID="&request("class"))
	if rootid=trs(0) then
		msginfo="<li>您不能指定该版面的下属栏目作为所属栏目</li>"
        call Sysmsg(msgtitle,msginfo)
		exit sub
	end if
	end if
else
	set trs=conn.execute("select CatalogID from info_Catalog where ParentStr like '%"&ParentStr&"%' and CatalogID="&request("class"))
	if not (trs.eof and trs.bof) then
		msginfo="<li>您不能指定该版面的下属栏目作为所属栏目</li>"
        call Sysmsg(msgtitle,msginfo,95)
		response.end
	end if
end if
if parentid=0 then
	parentid=rs("CatalogID")
	iparentid=0
end if
rs("CatalogName") = Request.Form("CatalogName")
'rs("parentid") = Request.Form("class")
rs("readme") = Request("readme")
rs.Update 
rs.Close
set rs=nothing

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

end sub

⌨️ 快捷键说明

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