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

📄 admin_userclass.asp

📁 本息统基于中国网站技术人员最熟悉WindowsNT环境和Asp语言
💻 ASP
📖 第 1 页 / 共 4 页
字号:
<% 
	rsClass.close 
	set rsClass=nothing 
end sub 

sub OrderN() 
	dim sqlClass,rsClass,i,iCount,trs,UpMoveNum,DownMoveNum 
	sqlClass="select * From oblog_userclass order by RootID,OrderID" 
	set rsClass=server.CreateObject("adodb.recordset") 
	rsClass.open sqlClass,conn,1,1 
%>
<table cellpadding="0" cellspacing="1" border="0" width="98%" class="border" align=center>
	<tr>
	  <td colspan="4" align="center" class="title"><strong>N 级 分 类 排 序</strong></td> 
  </tr> 
  <% 
do while not rsClass.eof 
%> 
  <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#cccccc'" style="padding: 0px 2px;"> 
      <td width="300"> 
	  <% 
	for i=1 to rsClass("Depth") 
	  	response.write "&nbsp;&nbsp;&nbsp;" 
	next 
	if rsClass("Child")>0 then 
		response.write "<img src='Images/tree_folder4.gif' width='15' height='15' valign='abvmiddle'>" 
	else 
	  	response.write "<img src='Images/tree_folder3.gif' width='15' height='15' valign='abvmiddle'>" 
	end if 
	if rsClass("ParentID")=0 then 
		response.write "<b>" 
	end if 
	response.write rsClass("classname") 
	if rsClass("Child")>0 then 
		response.write "(" & rsClass("Child") & ")" 
	end if 
	%></td> 
<% 
	if rsClass("ParentID")>0 then   '如果不是一级分类,则算出相同深度的分类数目,得到该分类在相同深度的分类中所处位置(之上或者之下的分类数) 
		'所能提升最大幅度应为For i=1 to 该版之上的版面数 
		set trs=conn.execute("select count(id) From oblog_userclass where ParentID="&rsClass("ParentID")&" and OrderID<"&rsClass("OrderID")&"") 
		UpMoveNum=trs(0) 
		if isnull(UpMoveNum) then UpMoveNum=0 
		if UpMoveNum>0 then 
  			response.write "<form action='admin_userclass.asp?Action=UpOrderN' method='post'><td width='150'>" 
			response.write "<select name=MoveNum size=1><option value=0>向上移动</option>" 
			for i=1 to UpMoveNum 
				response.write "<option value="&i&">"&i&"</option>" 
			next 
			response.write "</select>" 
			response.write "<input type=hidden name=id value="&rsClass("id")&">&nbsp;<input type=submit name=Submit value=修&nbsp;改 style='cursor: hand;background-color: #cccccc;'>" 
			response.write "</td></form>" 
		else 
			response.write "<td width='150'>&nbsp;</td>" 
		end if 
		trs.close 
		'所能降低最大幅度应为For i=1 to 该版之下的版面数 
		set trs=conn.execute("select count(id) From oblog_userclass where ParentID="&rsClass("ParentID")&" and orderID>"&rsClass("orderID")&"") 
		DownMoveNum=trs(0) 
		if isnull(DownMoveNum) then DownMoveNum=0 
		if DownMoveNum>0 then 
  			response.write "<form action='admin_userclass.asp?Action=DownOrderN' method='post'><td width='150'>" 
			response.write "<select name=MoveNum size=1><option value=0>向下移动</option>" 
			for i=1 to DownMoveNum 
				response.write "<option value="&i&">"&i&"</option>" 
			next 
			response.write "</select>" 
			response.write "<input type=hidden name=id value="&rsClass("id")&">&nbsp;<input type=submit name=Submit value=修&nbsp;改 style='cursor: hand;background-color: #cccccc;'>" 
			response.write "</td></form>" 
		else 
			response.write "<td width='150'>&nbsp;</td>" 
		end if 
		trs.close 
	else 
		response.write "<td colspan=2>&nbsp;</td>" 
	end if 
%> 
      <td>&nbsp;</td>
  </tr> 
  <% 
	UpMoveNum=0 
	DownMoveNum=0 
	rsClass.movenext 
loop 
%> 
</table> 
<% 
	rsClass.close 
	set rsClass=nothing 
end sub 

sub Reset() 
%>
<table cellpadding="0" cellspacing="1" border="0" width="98%" class="border" align=center>
  <form name="form1" method="post" action="admin_userclass.asp?Action=SaveReset"> 
	<tr>
	  <td colspan="3" align="center" class="title"><strong>复 位 所 有 分 类</strong></td> 
  </tr> 
    <tr class="tdbg">  
    <td align="center">  
        <table width="80%" border="0" cellspacing="1" cellpadding="1"> 
          <tr class="tdbg">  
            <td height="150"><span class="style1"><strong>注意:</strong></span><br> 
            &nbsp;&nbsp;&nbsp;&nbsp;如果选择复位所有分类,则所有分类都将作为一级分类,这时您需要重新对各个分类进行归属的基本设置。不要轻易使用该功能,仅在做出了错误的设置而无法复原分类之间的关系和排序的时候使用。          
		    </td> 
          </tr> 
        </table> 
	 <tr class="tdbg">  
    <td align="center">  
        <input type="submit" name="Submit" value="&nbsp;复位所有分类&nbsp;" style="cursor: hand;background-color: #cccccc;"> &nbsp;&nbsp;&nbsp; 
		<input name="Cancel" type="button" id="Cancel" value=" 取&nbsp;&nbsp;消 " onClick="window.location.href='admin_userclass.asp'" style="cursor: hand;background-color: #cccccc;">
      </td>
    </tr>
	</form>
</table>
<%
end sub

sub Unite()
%>
<table cellpadding="0" cellspacing="1" border="0" width="98%" class="border" align=center>
<form name="myform" method="post" action="admin_userclass.asp" onSubmit="return ConfirmUnite();">
	<tr>
	  <td colspan="3" align="center" class="title"><strong>分 类 合 并</strong></td>
  </tr>
  <tr class="tdbg"> 
    <td align="center">
        &nbsp;&nbsp;将分类 
        <select name="id" id="id">
        <%call Admin_ShowClass_Option(1,0)%>
        </select>
        合并到
        <select name="Targetid" id="Targetid">
        <%call Admin_ShowClass_Option(4,0)%>
        </select>
		</td>
		</tr>
  <tr class="tdbg"> 
    <td align="center">
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
        <input name="Action" type="hidden" id="Action" value="SaveUnite">
        <input type="submit" name="Submit" value=" &nbsp;合并分类&nbsp; " style="cursor: hand;background-color: #cccccc;">
        &nbsp;&nbsp; 
        <input name="Cancel" type="button" id="Cancel" value=" 取&nbsp;&nbsp;消 " onClick="window.location.href='admin_userclass.asp'" style="cursor: hand;background-color: #cccccc;">

	</td>
  </tr>
  <tr class="tdbg"> 
    <td height="60"><span class="style1"><strong>注意事项:</strong></span><br>
      &nbsp;&nbsp;&nbsp;&nbsp;所有操作不可逆,请慎重操作!!!<br>
      &nbsp;&nbsp;&nbsp;&nbsp;不能在同一个分类内进行操作,不能将一个分类合并到其下属分类中。目标分类中不能含有子分类。<br>
        &nbsp;&nbsp;&nbsp;&nbsp;合并后您所指定的分类(或者包括其下属分类)将被删除,所有用户将转移到目标分类中。</td>
  </tr>
 </form>
</table> 
<script language="JavaScript" type="text/JavaScript">
function ConfirmUnite()
{
  if (document.myform.id.value==document.myform.Targetid.value)
  {
    alert("请不要在相同分类内进行操作!");
	document.myform.Targetid.focus();
	return false;
  }
  if (document.myform.Targetid.value=="")
  {
    alert("目标分类不能指定为含有子分类的分类!");
	document.myform.Targetid.focus();
	return false;
  }
}
</script>
<% 
end sub 
%> 
</body> 
</html> 
<% 

sub SaveAdd()
	dim id,classname,Readme,PrevOrderID
	dim sql,rs,trs
	dim RootID,ParentDepth,ParentPath,ParentStr,ParentName,Maxid,MaxRootID
	dim PrevID,NextID,Child

	classname=trim(request("classname"))
	Readme=trim(request("Readme"))
	if classname="" then
		response.Write "<br><li>分类名称不能为空!</li>"
		response.End()
	end if
	set rs = conn.execute("select Max(id) From oblog_userclass")
	Maxid=rs(0)
	if isnull(Maxid) then
		Maxid=0
	end if
	rs.close
	id=Maxid+1
	set rs=conn.execute("select max(rootid) From oblog_userclass")
	MaxRootID=rs(0)
	if isnull(MaxRootID) then
		MaxRootID=0
	end if
	rs.close
	RootID=MaxRootID+1
	
	if ParentID>0 then
		sql="select * From oblog_userclass where id=" & ParentID & ""
		rs.open sql,conn,1,1
		if rs.bof and rs.eof then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>所属分类已经被删除!</li>"
		end if
		if FoundErr=True then
			rs.close
			set rs=nothing
			exit sub
		else	
			RootID=rs("RootID")
			ParentName=rs("classname")
			ParentDepth=rs("Depth")
			ParentPath=rs("ParentPath")
			Child=rs("Child")
			ParentPath=ParentPath & "," & ParentID     '得到此分类的父级分类路径
			PrevOrderID=rs("OrderID")
			if Child>0 then		
				dim rsPrevOrderID
				'得到与本分类同级的最后一个分类的OrderID
				set rsPrevOrderID=conn.execute("select Max(OrderID) From oblog_userclass where ParentID=" & ParentID)
				PrevOrderID=rsPrevOrderID(0)
				set trs=conn.execute("select id From oblog_userclass where ParentID=" & ParentID & " and OrderID=" & PrevOrderID)
				PrevID=trs(0)
				
				'得到同一父分类但比本分类级数大的子分类的最大OrderID,如果比前一个值大,则改用这个值。
				set rsPrevOrderID=conn.execute("select Max(OrderID) From oblog_userclass where ParentPath like '" & ParentPath & ",%'")
				if (not(rsPrevOrderID.bof and rsPrevOrderID.eof)) then
					if not IsNull(rsPrevOrderID(0))  then
				 		if rsPrevOrderID(0)>PrevOrderID then
							PrevOrderID=rsPrevOrderID(0)
						end if
					end if
				end if
			else
				PrevID=0
			end if

		end if
		rs.close
	else
		if MaxRootID>0 then
			set trs=conn.execute("select id From oblog_userclass where RootID=" & MaxRootID & " and Depth=0")
			PrevID=trs(0)
			trs.close
		else
			PrevID=0
		end if
		PrevOrderID=0
		ParentPath="0"
	end if

	sql="Select * From oblog_userclass Where ParentID=" & ParentID & " AND classname='" & classname & "'"
	set rs=server.CreateObject("adodb.recordset")
	rs.open sql,conn,1,1
	if not(rs.bof and rs.eof) then
		FoundErr=True
		if ParentID=0 then
			ErrMsg=ErrMsg & "<br><li>已经存在一级分类:" & classname & "</li>"
		else
			ErrMsg=ErrMsg & "<br><li>“" & ParentName & "”中已经存在子分类“" & classname & "”!</li>"
		end if
		rs.close
		set rs=nothing
		exit sub
	end if
	rs.close
	
	sql="Select top 1 * From oblog_userclass"
	rs.open sql,conn,2,2
    rs.addnew
	rs("id")=id
   	rs("classname")=classname
	rs("RootID")=RootID
	rs("ParentID")=ParentID
	if ParentID>0 then
		rs("Depth")=ParentDepth+1
	else
		rs("Depth")=0
	end if
	rs("ParentPath")=ParentPath
	rs("OrderID")=PrevOrderID
	rs("Child")=0
	rs("Readme")=Readme
	rs("PrevID")=PrevID
	rs("NextID")=0
	rs.update
	rs.Close
    set rs=Nothing
	
	'更新与本分类同一父分类的上一个分类的“NextID”字段值
	if PrevID>0 then
		conn.execute("update oblog_userclass set NextID=" & id & " where id=" & PrevID)
	end if
	
	if ParentID>0 then
		'更新其父类的子分类数
		conn.execute("update oblog_userclass set child=child+1 where id="&ParentID)
		
		'更新该分类排序以及大于本需要和同在本分类下的分类排序序号
		conn.execute("update oblog_userclass set OrderID=OrderID+1 where rootid=" & rootid & " and OrderID>" & PrevOrderID)
		conn.execute("update oblog_userclass set OrderID=" & PrevOrderID & "+1 where id=" & id)
	end if
	
    'call CloseConn()
	Response.Redirect "admin_userclass.asp"  
end sub

sub SaveModify()
	dim classname,Readme,IsElite,ShowOnTop,Setting,ClassMaster,ClassPicUrl,LinkUrl,SkinID,LayoutID,BrowsePurview,AddPurview
	dim trs,rs
	dim id,sql,rsClass,i
	dim SkinCount,LayoutCount
	id=trim(request("id"))
	if id="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>参数不足!</li>"
	else
		id=CLng(id)
	end if
	classname=trim(request("classname"))
	Readme=trim(request("Readme"))
	if classname="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>分类名称不能为空!</li>"
	end if
	
	if FoundErr=True then
		exit sub
	end if	
	sql="select * From oblog_userclass where id=" & id
	set rsClass=server.CreateObject ("Adodb.recordset")
	rsClass.open sql,conn,1,3
	if rsClass.bof and rsClass.eof then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>找不到指定的分类!</li>"
		rsClass.close
		set rsClass=nothing
		exit sub
	end if

	if FoundErr=True then
		rsClass.close
		set rsClass=nothing
		exit sub
	end if
	
   	rsClass("classname")=classname
	rsClass("Readme")=Readme
	rsClass.update
	rsClass.close
	set rsClass=nothing
	
	set rs=nothing
	set trs=nothing	
    'call CloseConn()
	Response.Redirect "admin_userclass.asp"  
end sub


sub DeleteClass()
	dim sql,rs,PrevID,NextID,id
	id=trim(Request("id"))
	if id="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>参数不足!</li>"
		exit sub
	else
		id=CLng(id)
	end if
	
	sql="select id,RootID,Depth,ParentID,Child,PrevID,NextID From oblog_userclass where id="&id
	set rs=server.CreateObject ("Adodb.recordset")
	rs.open sql,conn,1,3
	if rs.bof and rs.eof then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>分类不存在,或者已经被删除</li>"
	else
		if rs("Child")>0 then
			FoundErr=True
			ErrMsg=ErrMsg & "<br><li>该分类含有子分类,请删除其子分类后再进行删除本分类的操作</li>"
		end if
	end if
	if FoundErr=True then
		rs.close
		set rs=nothing
		exit sub
	end if
	PrevID=rs("PrevID")
	NextID=rs("NextID")
	if rs("Depth")>0 then
		conn.execute("update oblog_userclass set child=child-1 where id=" & rs("ParentID"))
	end if
	rs.delete
	rs.update
	rs.close
	set rs=nothing
	'修改上一分类的NextID和下一分类的PrevID
	if PrevID>0 then
		conn.execute "update oblog_userclass set NextID=" & NextID & " where id=" & PrevID
	end if
	if NextID>0 then
		conn.execute "update oblog_userclass set PrevID=" & PrevID & " where id=" & NextID
	end if
	'call CloseConn()
	response.redirect "admin_userclass.asp"
		
end sub


sub SaveMove()
	dim id,sql,rsClass,i
	dim rParentID
	dim trs,rs
	dim ParentID,RootID,Depth,Child,ParentPath,ParentName,iParentID,iParentPath,PrevOrderID,PrevID,NextID
	id=trim(request("id"))
	if id="" then
		FoundErr=True
		ErrMsg=ErrMsg & "<br><li>参数不足!</li>"

⌨️ 快捷键说明

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