📄 admin_goods_class.asp
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<% Option Explicit %>
<!-- 后台商品分类管理 -->
<!-- #include file="../config/db.asp" -->
<!-- #include file="../config/function.inc.asp" -->
<%
dim sql,rst,myErrors
on error resume next
set rst=server.CreateObject("adodb.recordset")
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>FIF VIP ASP教程后台管理--商品分类管理</title>
<link href="../config/global.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
'处理参数
select case request.QueryString("act")
case "add":'添加分类
if request.Form("f_name")<>"" then
sql="insert into tbl_goodsclass (gc_name) values ('" & request.Form("f_name") & "')"
conn.execute sql
set myErrors=conn.errors
if myErrors.count=0 then
msgboxU "添加成功!"
else
msgboxU "添加失败!原因:"&myErrors.item(0).description
end if
else
msgboxU "没有输入分类名"
end if
case "update":'更新分类
if request.QueryString("id")="" or request.form("f_name")="" then
msgboxU "错误的参数,或未输入分类名"
else
sql="update tbl_goodsclass set gc_name='" & request.Form("f_name") & "' where gc_id=" & request.QueryString("id")
conn.execute sql
end if
set myErrors=conn.errors
if myErrors.count=0 then
msgboxU "修改成功!"
else
msgboxU "修改失败!原因:"&myErrors.item(0).description
end if
case "del":'删除分类
if request.QueryString("id")="" then
msgboxU "错误的参数"
else
sql="select count(*) as num from tbl_goods where gds_gcid=" & request.QueryString("id")
rst.open sql,conn,1,1
if rst("num")>0 then
msgboxU "此分类下有商品,您不能删除此分类"
else
sql="delete from tbl_goodsclass where gc_id=" & request.querystring("id")
conn.execute sql
set myErrors=conn.errors
if myErrors.count=0 then
msgboxU "删除成功!"
else
msgboxU "删除失败!原因:"&myErrors.item(0).description
end if
end if
rst.close
end if
end select
%>
<p>商品分类列表: </p>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr align="center">
<td width="74">ID</td>
<td width="456">商品分类名</td>
<td width="237">操作</td>
</tr>
<%
sql="select * from tbl_goodsclass"
rst.open sql,conn,1,1
do while not rst.eof
%>
<tr>
<td align="right"><%=rst("gc_id")%></td>
<td><%=rst("gc_name")%></td>
<td align="center"><a href="admin_goods_class.asp?act=modify&id=<%=rst("gc_id")%>">修改</a> <a href="admin_goods_class.asp?act=del&id=<%=rst("gc_id")%>" onclick="javascript:return confirm('您确定要删除此商品分类吗?');">删除</a> </td>
</tr>
<%
rst.movenext
loop
rst.close
%>
</table><br>
<br>
<form action="<%
if request.querystring("act")="modify" then
response.write "admin_goods_class.asp?act=update&id=" & request.querystring("id")
else
response.write "admin_goods_class.asp?act=add"
end if
%>" method="post" name="frm">
<table width="400" height="69" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="33" align="center"><%
if request.querystring("act")="modify" then
response.write "修改商品分类名"
sql="select * from tbl_goodsclass where gc_id=" & request.QueryString("id")
rst.open sql,conn,1,1
else
response.write "新增商品分类"
end if
%></td>
</tr>
<tr>
<td>商品分类名:
<input name="f_name" type="text" id="f_name" value="<% if request.QueryString("act")="modify" then response.Write(rst("gc_name")) %>">
<input type="submit" name="Submit" value="<%
if request.QueryString("act")="modify" then
response.Write "修改商品分类"
rst.close
else
response.Write "新增商品分类"
end if
%>"></td>
</tr>
</table>
</form>
<%
set rst=nothing
conn.close
set conn=nothing
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -