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

📄 admin_goods_class.asp

📁 商业网站/图片管理系统/投票系统/新闻管理系统/
💻 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"-->
<%dim rst,sql,rst1,sql1,myErrors,rid
set rst=server.createobject("adodb.recordset")
set rst1=server.createobject("adodb.recordset")
rid=request.querystring("id")
%>
<%'-------------添加商品分类---------------------
if request.querystring("act")="add" then
	sql="select * from shop_goodsclass"
	rst.open sql,conn,1,3
	rst.addnew
	if request.form("gc_big")="" then
		rst("gc_name")=request.form("gc_samll")
	else
		rst("gc_name")=request.form("gc_small")
		rst("gc_upid")=request.Form("gc_big")
	end if
	rst.update
	rst.close
	set myErrors=conn.errors
	if myErrors.count=0 then
		msgboxU "添加分类成功!"
	else
		msgboxU "添加分类失败!原因:"&myErrors.item(0).description
	end if
	'返回本页,去掉参数
	response.redirect "admin_goods_class.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_goodsclass where gc_id="&rid
		rst.open sql,conn,1,1
		'商品大小类判定
		if rst("gc_upid") = 0 then'判定为大类	
			'是否有小类判定
			sql1="select count(*) as num from shop_goodsclass where gc_upid="&rst("gc_id")
			rst.close
			rst1.open sql1,conn,1,1
			if rst1("num")>0 then
				msgboxU "此商品大类有二级商品分类,您不能删除!"
			else
				sql="delete from shop_goodsclass where gc_id="&rid
				conn.execute sql
				set myErrors=conn.errors
				if myErrors.count=0 then
					msgboxU "删除商品大类成功!"
				else
					msgboxU "删除商品大类失败!原因:"&myErrors.item(0).description
				end if
			end if
			rst1.close
		else'判定为小类
			'是否有产品判定
			sql1="select count(*) as num from shop_goods where gds_gcid="&rst("gc_id")
			rst.close
			rst1.open sql1,conn,1,1
			if rst1("num")>0 then
				msgboxU "此二级商品分类有商品,您不能删除!"
			else
				sql="delete from shop_goodsclass where gc_id="&rid
				conn.execute sql
				set myErrors=conn.errors
				if myErrors.count=0 then
					msgboxU "删除二级商品分类成功!"
				else
					msgboxU "删除二级商品分类失败!原因:"&myErrors.item(0).description
				end if
			end if
			rst1.close
		end if	
	end if
	'返回本页,去掉参数
	response.redirect "admin_goods_class.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_goodsclass where gc_id="&rid
			rst.open sql,conn,1,3
			if rst("gc_upid")=0 then'判断为大类更新
				rst("gc_name")=request.form("gc_big_display")
			else'判断为小类更新
				rst("gc_name")=request.form("gc_small_display")
				rst("gc_upid")=request.form("gc_big_liebiao_display")
			end if
			rst.update
			rst.close
			
			set myErrors=conn.errors
			if myErrors.count=0 then
				msgboxU "修改成功!"
			else
				msgboxU "修改失败!原因:"&myErrors.item(0).description
			end if
	end if
	'返回本页,去掉参数
	response.redirect "admin_goods_class.asp"
end if
%>
<!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>
</head>

<body>
<p align="center">商品分类后台管理</p>
<p>商品分类列表:</p>
<table width="780" border="1" cellspacing="0" cellpadding="0">
	<tr>
		<td width="97" height="19">ID</td>
		<td width="186">大类名</td>
		<td width="266">小类名</td>
		<td width="164">操作</td>
		<td width="55">操作</td>
	</tr>
<%
sql="select * from shop_goodsclass where gc_upid=0"
rst.open sql,conn,1,1
do while not rst.eof
%>
	<tr>
		<td><%=rst("gc_id")%></td>
		<td><%=rst("gc_name")%></td>
		<td>---------</td>
		<td><a href="admin_goods_class.asp?act=modify&id=<%=rst("gc_id")%>">编辑</a></td>
		<td><a href="admin_goods_class.asp?act=del&id=<%=rst("gc_id")%>">删除</a></td>
	</tr>
	<%
		sql1="select * from shop_goodsclass where gc_upid="&rst("gc_id")&" order by gc_id desc"
		rst1.open sql1,conn,1,1
		do while not rst1.eof
		%>
		<tr>
			<td><%=rst1("gc_id")%></td>
			<td>--------&gt;</td>
			<td><%=rst1("gc_name")%></td>
			<td><a href="admin_goods_class.asp?act=modify&id=<%=rst1("gc_id")%>">编辑</a></td>
			<td><a href="admin_goods_class.asp?act=del&id=<%=rst1("gc_id")%>">删除</a></td>
		</tr>
<%
			rst1.movenext
		loop
		rst1.close
	rst.movenext
loop
rst.close
%>
</table>


<%'--------------显示添加商品分类--------------------
if request.querystring("act")<>"modify" then
%>
添加商品分类:
<form id="form1" name="form1" method="post" action="admin_goods_class.asp?act=add">
	<p>提示:如果没有选择上级分类,新增分类将作为顶级分类; 如果选择上级分类,将作为子分类。</p>
	<p>商品分类大类
		<select name="gc_big" size="1" id="gc_big">
			<option value="0" selected="selected">选择商品大分类</option>
		<%
		sql="select * from shop_goodsclass where gc_upid=0"
		rst.open sql,conn,1,1
		do while not rst.eof
		%>
			<option value="<%=rst("gc_id")%>"><%=rst("gc_name")%></option>
		<%
			rst.movenext
		loop
		rst.close
		%>
		</select>
&nbsp;&nbsp;商品分类小类
<input name="gc_small" type="text" id="gc_small" />
	</p>
	<p>
		<input type="submit" name="Submit" value="提交" />
</p>
</form>
<%
end if
%>


<%'-------------------显示修改商品分类-------------------
if request.querystring("act")="modify" then 
	sql="select * from shop_goodsclass where gc_id="&rid
	rst.open sql,conn,1,1
%>
<p>修改商品分类:</p>
<form id="form2" name="form2" method="post" action="admin_goods_class.asp?act=update&amp;id=<%=request.querystring("id")%>">
	<%'----------判断要修改的项目属于大类还是小类------------
	if rst("gc_upid")=0 then'属于大类
	
	%>
			<p>商品大类原名:<%=rst("gc_name")%></p>
			<p>修改商品分类名:
				<input name="gc_big_display" type="text" id="gc_big_display" value="<%=rst("gc_name")%>" />
			</p>
	<%
	else'属于小类
	%>
			<p>商品小类原名:<%=rst("gc_name")%></p>
			<p>修改此小类的所属大类:	
				<select name="gc_big_liebiao_display" size="1" id="gc_big_liebiao_display">
					<option value="<%=rst("gc_upid")%>" selected="selected">请选择商品大类</option>
					<%
					sql1="select * from shop_goodsclass where gc_upid=0"
					rst1.open sql1,conn,1,1
					do while not rst1.eof
					%>
					<option value="<%=rst1("gc_id")%>"><%=rst1("gc_name")%></option>
					<%
						rst1.movenext
					loop
					rst1.close
					%>
				</select>
			修改小分类名:
			<input name="gc_small_display" type="text" id="gc_small_display" value="<%=rst("gc_name")%>" />
			</p>
			<p>
				<%
	end if
	%>
</p>
			<p>
				<input type="submit" name="Submit2" value="提交" />
</p>
</form>
<%
	rst.close
end if
%>

<%
set rst=nothing
set rst1=nothing
conn.close
set conn=nothing

%>
</body>

</html>

⌨️ 快捷键说明

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