📄 admin_newsclass.asp
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<%
if request.cookies("admin_OK")="" then
response.redirect("admin_login.html")
end if
%>
<%
dim db
db=0
%>
<!--#include file="../config/db.asp"-->
<!--#include file="../config/function.inc.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>新闻分类后台管理</title>
<link href="../css/mycss.css" rel="stylesheet" type="text/css" />
</head>
<body>
<%
dim rst,sql,rst1,sql1,myErrors
set rst=server.createobject("adodb.recordset")
set rst1=server.CreateObject("adodb.recordset")
%>
<%'----------------------添加新闻分类--------------------
if request.querystring("act")="class" then
sql="shop_newsclass"
rst.open sql,conn,1,3
rst.addnew
rst("nc_name")=request.form("nc_name")
rst("nc_upid")=request.form("upid")
rst.update
rst.close
set myErrors=conn.errors
if myErrors.count=0 then
msgboxU "添加成功!"
'---------返回新闻管理--------
response.Redirect("admin_news_show.asp")
else
msgboxU "添加失败!原因:"&myErrors.item(0).description
end if
'返回本页,去掉参数
response.redirect "admin_newsclass.asp"
end if
%>
<%'---------------------修改新闻分类名------------------------
if request.querystring("act")="update" then
if not isnumeric(request.querystring("id")) or isempty(request.querystring("id")) then
msgboxU "非法参数!"
else
sql="select * from shop_newsclass where nc_id=" & request.querystring("id")
rst.open sql,conn,1,3
if rst("nc_upid")=0 then
rst("nc_name")=request.form("modify")
else
rst("nc_name")=request.form("modify")
rst("nc_upid")=request.form("upid")
end if
rst.update
rst.close
set myErrors=conn.errors
if myErrors.count=0 then
msgboxU "修改成功!"
'---------返回新闻管理--------
response.Redirect("admin_news_show.asp")
else
msgboxU "修改失败!原因:"&myErrors.item(0).description
end if
end if
'返回本页,去掉参数
response.redirect "admin_newsclass.asp"
end if
%>
<%'----------------------删除分类-----------------------------
if request.querystring("act")="del" then
if not isnumeric(request.querystring("id")) or isempty(request.querystring("id")) then
msgboxU "非法参数!"
else
sql="select * from shop_newsclass where nc_id=" & request.querystring("id")
rst.open sql,conn,1,1
if rst("nc_upid") = 0 then'判定为一级分类
sql="select count(*) as num from shop_newsclass where nc_upid=" & request.querystring("id")
rst.close
rst1.open sql,conn,1,1
if rst1("num")>0 then
msgboxU "此分类下有内容,您不能删除此分类"
else
sql1="delete from shop_newsclass where nc_id=" & request.querystring("id")
conn.execute sql1
set myErrors=conn.errors
if myErrors.count=0 then
msgboxU "删除成功!"
'---------返回新闻管理--------
response.Redirect("admin_news_show.asp")
else
msgboxU "删除失败!原因:"&myErrors.item(0).description
end if
end if
rst1.close
else'判定为二级分类
sql="select count(*) as num from shop_news where n_ncid=" & request.querystring("id")
rst.close
rst1.open sql,conn,1,1
if rst1("num")>0 then
msgboxU "此分类下游新闻内容,您不能删除此分类"
else
sql1="delete from shop_newsclass where nc_id=" & request.querystring("id")
conn.execute sql1
set myErrors=conn.errors
if myErrors.count=0 then
msgboxU "删除成功!"
'---------返回新闻管理--------
response.Redirect("admin_news_show.asp")
else
msgboxU "删除失败!原因:"&myErrors.item(0).description
end if
end if
rst1.close
end if
end if
'返回本页,去掉参数
response.redirect "admin_newsclass.asp"
end if
%>
<%'---------------------修改新闻分类排序------------------------
if request.querystring("act")="sort" then
if not isnumeric(request.querystring("id")) or isempty(request.querystring("id")) then
msgboxU "非法参数!"
else
sql="select * from shop_newsclass where nc_id=" & request.querystring("id")
rst.open sql,conn,1,3
rst("nc_sort")=request.form("sort")
rst.update
rst.close
set myErrors=conn.errors
if myErrors.count=0 then
msgboxU "修改分类排序成功!"
'---------返回新闻管理--------
response.Redirect("admin_news_show.asp")
else
msgboxU "修改分类排序失败!原因:"&myErrors.item(0).description
end if
end if
'返回本页,去掉参数
response.redirect "admin_newsclass.asp"
end if
%>
<div align="center">新闻分类后台管理</div>
<p>新闻分类管理:<a href="admin_newsclass.asp?act=add">填加新闻分类</a></p>
<table width="754" height="73" border="1" cellpadding="0" cellspacing="0" bordercolor="#333333">
<tr>
<td width="181"><div align="center">分类名称</div></td>
<td width="185"><div align="center">子分类名</div></td>
<td width="172"><div align="center">管理</div></td>
<td width="216"><div align="center">排序</div></td>
</tr>
<%
sql="select * from shop_newsclass where nc_upid=0 order by nc_sort asc"
rst.open sql,conn,1,1
do while not rst.eof
%>
<tr>
<td>
<%=rst("nc_name")%>
</td>
<td>-----------</td>
<td><div align="center"><a href="admin_newsclass.asp?act=modify&id=<%=rst("nc_id")%>">修改</a> <a href="admin_newsclass.asp?act=del&id=<%=rst("nc_id")%>" onclick="javascript:return confirm('你确定要删除次新闻分类吗?');">删除</a></div></td>
<td align="center" valign="bottom"> <form id="form3" name="form3" method="post" action="admin_newsclass.asp?act=sort&id=<%=rst("nc_id")%>">
<div align="center">
<input name="sort" type="text" id="sort" value="<%=rst("nc_sort")%>" size="10" />
<input type="submit" name="Submit2" value="提交" />
</div>
</form></td>
</tr>
<%
sql1="select * from shop_newsclass where nc_upid=" & rst("nc_id") & " order by nc_sort asc"
rst1.open sql1,conn,1,1
do while not rst1.eof
%>
<tr>
<td>-------------></td>
<td><%=rst1("nc_name")%></td>
<td><div align="center"><a href="admin_newsclass.asp?act=modify&id=<%=rst1("nc_id")%>">修改</a> <a href="admin_newsclass.asp?act=del&id=<%=rst1("nc_id")%>" onclick="javascript:return confirm('你确定要删除次新闻分类吗?');">删除</a></div></td>
<td align="center" valign="middle"><form id="form4" name="form4" method="post" action="admin_newsclass.asp?act=sort&id=<%=rst1("nc_id")%>">
<div align="center">
<input name="sort" type="text" id="sort" value="<%=rst1("nc_sort")%>" size="10" />
<input type="submit" name="Submit22" value="提交" />
</div>
</form> </td>
</tr>
<%
rst1.movenext
loop
rst1.close
rst.movenext
loop
rst.close
%>
</table>
<%
%>
<%'--------------------------显示修改新闻分类----------------------
if request.querystring("act")="modify" then
sql="select * from shop_newsclass where nc_id=" & request.querystring("id")
rst.open sql,conn,1,1
%>
<form id="form1" name="form1" method="post" action="admin_newsclass.asp?act=update&id=<%=request.querystring("id")%>">
<p>
<%
if rst("nc_upid")=0 then
%>
修改分类名:
<input name="modify" type="text" id="modify" value="<%=rst("nc_name")%>" />
<br />
</p>
<%
rst.close
else
%>
<p>修改2级分类的顶级分类
<select name="upid" size="1" id="upid">
<option value="<%=rst("nc_upid")%>" selected="selected">请选择上级分类</option>
<%
sql="select * from shop_newsclass where nc_upid=0"
rst1.open sql,conn,1,1
do while not rst1.eof
%>
<option value="<%=rst1("nc_id")%>"><%=rst1("nc_name")%></option>
<%
rst1.movenext
loop
%>
</select>
修改分类名:
<input name="modify" type="text" id="modify2" value="<%=rst("nc_name")%>" />
</p>
<%
rst1.close
rst.close
end if
%>
<p>
<input type="submit" name="Submit" value="提交" />
</p>
</form>
<%
end if
%>
<%'-------------------------添加新闻分类----------------------
if request.QueryString("act")<>"modify" then
%>
<p>添加新闻分类</p>
<form id="form2" name="form2" method="post" action="admin_newsclass.asp?act=class">
<p>提示:如果没有选择上级分类,新增分类将作为顶级分类; 如果选择上级分类,将作为子分类。</p>
<p>选择上级分类
<select name="upid" size="1" id="upid">
<option value="0" selected="selected">请选择上级分类</option>
<%
sql="select * from shop_newsclass where nc_upid=0"
rst.open sql,conn,1,1
do while not rst.eof
%>
<option value="<%=rst("nc_id")%>"><%=rst("nc_name")%></option>
<%
rst.movenext
loop
rst.close
%>
</select>
分类名
<input name="nc_name" type="text" id="nc_name" />
</p>
<p>
<input type="submit" name="Submit3" value="提交" />
</p>
</form>
<p> </p>
<%
end if
%>
<%
set rst1=nothing
set rst=nothing
conn.close
set conn=nothing
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -