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

📄 admin_usertype.asp

📁 个人博客
💻 ASP
字号:
<!--#include file="conn.asp"-->
<!--#include file="Admin_Chkpass.asp"-->
<link href="Admin_STYLE.CSS" rel="stylesheet" type="text/css"> 
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0" class="bgcolor">
<%
dim action
action=request.QueryString("action")
select case action
	case "addclass"
		call addclass()
	case "del"
		call delclass()
	case "modify"
		call modifyclass()
	case "savemodi"
		call savemodify()
	case "order"
		call order()
	case else
		call main
end select

sub addclass()
	dim typename,rs,ordernum
	typename=Trim(Request.Form("typename"))
	If typename="" Then
		Response.Write("<script language=javascript>alert('名称不能为空!');window.location.replace('admin_usertype.asp')</script>")
		Response.End()
	End If	 
	if instr(typename,"'") or instr(typename,"select") or instr(typename,"in") or instr(typename,"from") or instr(typename,"len") or instr(typename,"where") or instr(typename,"or") or instr(typename,"and") then
    	Response.Write("<script language=javascript>alert('包含非法字符!');window.location.replace('admin_usertype.asp');</script>")
		Response.End
	end if
	set rs=conn.execute("select max(ordernum) from usertype")
	if not isnull(rs(0)) then
		ordernum=rs(0)+1
	else
		ordernum=1
	end if
	conn.execute("insert into [usertype] (typename,ordernum) values ('"&typename&"',"&ordernum&")")
	set rs=nothing
	call PutApplicationValue()
	call closeconn()
	Response.Write("<script language=javascript>alert('成功填加!');window.location.replace('admin_usertype.asp')</script>")
end sub

sub delclass
	dim id
	id=clng(request.QueryString("id"))
	'on error resume next
   conn.execute("delete from [usertype] where id="&id)
   conn.execute("update [user] set usertypeid=0 where usertypeid="&id)
   call uporder()
   call PutApplicationValue()
   call closeconn()
    response.Redirect "admin_usertype.asp"
end sub

sub savemodify()
	dim id,typename
	id=clng(request.QueryString("id"))
	typename=Trim(Request.Form("typename"))
	   If typename="" Then
    	  Response.Write("<script language=javascript>alert('名称不能为空!');history.back()</script>")
	      Response.End()
	   End If
   if instr(typename,"'") or instr(typename,"select") or instr(typename,"in") or instr(typename,"from") or instr(typename,"len") or instr(typename,"where") or instr(typename,"or") or instr(typename,"and") then
	   Response.Write("<script language=javascript>alert('包含非法字符!');history.back();</script>")
	   Response.End
   end if                     
   on error resume next
   conn.execute("update [usertype] set typename='"&typename&"' where id="&id)
   call PutApplicationValue()
   call closeconn()
	Response.Write("<script language=javascript>alert('修改成功!');window.location.replace('admin_usertype.asp')</script>")

end sub

sub order()
	dim ordernum,modi,rs
	ordernum=clng(request.QueryString("ordernum"))
	modi=request.QueryString("modi")
	select case modi
		case "up"
			if ordernum-1>0 then
				conn.execute("update [usertype] set ordernum=999999 where ordernum="&ordernum-1)
				conn.execute("update [usertype] set ordernum=ordernum-1 where ordernum="&ordernum)
				conn.execute("update [usertype] set ordernum="&ordernum&" where ordernum=999999")
			end if			
		case "down"
			set rs=conn.execute("select max(ordernum) from usertype")
			if ordernum<rs(0) then
				conn.execute("update [usertype] set ordernum=999999 where ordernum="&ordernum+1)
				conn.execute("update [usertype] set ordernum=ordernum+1 where ordernum="&ordernum)
				conn.execute("update [usertype] set ordernum="&ordernum&" where ordernum=999999")
			end if
			set rs=nothing
	end select
	call PutApplicationValue()
	call closeconn()
	response.Redirect "admin_usertype.asp"
end sub

sub uporder()
	dim rs,i,n
	n=0
	set rs=conn.execute("select count(id) from [usertype]")
	redim ordernum(rs(0))
	set rs=conn.execute("select id from [usertype] order by ordernum")
	while not rs.eof
		ordernum(n)=rs(0)
		n=n+1
		rs.movenext		
	wend
	i=1
	for n=0 to ubound(ordernum)
		conn.execute("update usertype set ordernum="&i&" where id="&clng(ordernum(n)))
		i=i+1		
	next
	set rs=nothing
end sub

sub main()
%>
<br>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
  <tr valign="middle"> 
    <td height="22" colspan="3" class="topbg"><div align="center"><strong>添加系统博客分类</strong></div></td>
  </tr>
   <tr class="tdbg"><form name="form1" method="post" action="admin_usertype.asp?action=addclass">
          <td height="20" colspan="3"><div align="center">系统博客分类名称:
			<input name="typename" type="text" id="typename" maxlength="20">
            <input type="submit" name="Submit" value="添加">			             
          </div></td></form>
  </tr>
</table>
		<br><br>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="border">
        <tr class="topbg" height="25">
          <td width="100" >        <div align="center">排序</div></td>
          <td width="200">        <div align="center">系统博客类别名</div></td>
          <td>          <div align="center">系统博客分类管理操作</div></td>
		  </tr>
<%
dim rs
set rs=conn.execute("select * from usertype order by ordernum")
while not rs.eof 
%>
  <tr class="tdbg" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#BFDFFF'"> 
  <td > <div align="center"><%=rs("ordernum")%></div></td>
    <td><div align="center"><%=rs("typename")%></div></td>
    <td><div align="center"><a href="admin_usertype.asp?action=modify&id=<%=rs("id")%>&oldname=<%=rs("typename")%>">修改</a> | <a href="admin_usertype.asp?action=del&id=<%=rs("id")%>" <%="onClick='return confirm(""确定要删除此分类吗(不可恢复)?"");'"%>>删除</a> |
    <a href="admin_usertype.asp?action=order&modi=up&ordernum=<%=rs("ordernum")%>">向上移动</a> | <a href="admin_usertype.asp?action=order&modi=down&ordernum=<%=rs("ordernum")%>">向下移动</a></div></td></tr>
<%
rs.movenext
wend 
set rs=nothing
call closeconn()
%>
</table>
<br>
<%
call copyright()
end sub

sub modifyclass()
dim id,oldname
id=request.QueryString("id")
oldname=request.QueryString("oldname")
%>
<br>
<table width="98%"  border="0" align="center" cellpadding="0" cellspacing="0" class="border">
  <tr>
    <td height="22" class="topbg"><div align="center"><strong>修改系统博客分类</strong></div></td>
  </tr>
  <tr><form name="form1" method="post" action="admin_usertype.asp?action=savemodi&id=<%=id%>">
    <td height="25"><div align="center">系统博客分类名称:
        <input name="typename" type="text" id="typename" maxlength="20" value="<%=oldname%>">
        <input type="submit" name="Submit" value="修改">
    </div></td></form>
  </tr>
</table>
<br>
<%
call copyright()
end sub%>
</body>

⌨️ 快捷键说明

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