📄 product.asp
字号:
<!--#include file="menkan.asp"-->
<!--#include file="conn.asp"-->
<!--#include file="page.asp"-->
<%
action=request.QueryString("action")
productclassid=request.QueryString("productclassid")
edit=request.QueryString("edit")
productid=request.QueryString("productid")
pedit=request.QueryString("pedit")
where=request.QueryString("where")
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="Image/Main.css" rel="stylesheet" type="text/css" />
<title>产品管理</title>
</head>
<body>
<!--#include file="top.asp"-->
<%if action="classlist" then%>
<table width="760" border="1"align="center" cellpadding="3" cellspacing="1" bordercolor="#CCCCCC" style="border-collapse: collapse">
<tr>
<td colspan="3">【<a href="?action=classlist">品牌列表</a>】【<a href="?action=class">添加品牌</a>】【<a href="?action=list">产品列表</a>】【<a href="?action=product">添加产品</a>】</td>
</tr>
<tr>
<td colspan="3" align="center" bgcolor="#eeeeee">手机品牌列表</td>
</tr>
<tr>
<td width="5%" align="center">ID</td>
<td width="45%" align="center">手机品牌</td>
<td width="45%" align="center">管理操作</td>
</tr>
<%
Set mypage=new xdownpage
mypage.getconn=conn
mypage.getsql="select * from productclass order by productclassid asc"
mypage.pagesize=16
set rspage=mypage.getrs()
Response.Write("<br/>")
for i=1 to mypage.pagesize
if not rspage.eof then
%>
<tr>
<td align="center"><%=rspage("productclassid")%></td>
<td align="left"><%=rspage("productclassname")%></td>
<td align="center">
<a href="?action=class&edit=true&productclassid=<%=rspage("productclassid")%>">编辑</a>|
<a href="#" onClick="if(confirm('确定删除吗?这将删除此品牌下所有产品'))location.href='?action=delclass&productclassid=<%=rspage("productclassid")%>';else return;">删除</a></td>
</tr>
<%
rspage.movenext
else
exit for
end if
next
%>
<tr>
<td colspan="3" align="right"><%mypage.showpage()%></td>
</tr>
</table>
<%
Set mypage=nothing
end if
%>
<%
if action="class" then
if edit="true" then
set rs=server.CreateObject("adodb.recordset")
sql="select * from productclass where productclassid="&productclassid&""
rs.open sql,conn,1,1
productclassname=rs("productclassname")
rs.close
set rs=nothing
end if
%>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="14"></td>
</tr>
</table>
<table width="760" border="1"align="center" cellpadding="3" cellspacing="1" bordercolor="#CCCCCC" style="border-collapse: collapse">
<form method="post" name="class" <%if edit<>"true" then%> action="?action=saveclass"<%else%>action="?action=saveclass&edit=true&productclassid=<%=productclassid%>"<%end if%>>
<tr>
<td colspan="2">【<a href="?action=classlist">品牌列表</a>】【<a href="?action=class">添加品牌</a>】【<a href="?action=list">产品列表</a>】【<a href="?action=product">添加产品</a>】</td>
</tr>
<tr>
<td colspan="2" align="center" bgcolor="#eeeeee">
<%
if edit="true" then
response.Write("编辑品牌")
else
response.Write("添加品牌")
end if
%> </td>
</tr>
<tr>
<td width="20%" align="center">品牌名称</td>
<td>
<%if edit="true" then%>
<input type="text" name="productclassname" value="<%=productclassname%>">
<%else%>
<input type="text" name="productclassname">
<%end if%> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="提交">
<input type="reset" name="Submit2" value="重置"></td>
</tr>
</form>
</table>
<%end if%>
<%
if action="saveclass" then
if request.Form("productclassname")="" or len(request.Form("productclassname"))<2 or len(request.Form("productclassname"))>10 then
response.write "<SCRIPT language=JavaScript>alert('请输入栏目名称不得小于2大于10个字!');"
response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
set rs=server.CreateObject("adodb.recordset")
if edit="true" then
sql="select * from productclass where productclassid="&productclassid&""
rs.open sql,conn,1,3
else
sql="select * from productclass"
rs.open sql,conn,1,3
Rs.AddNew
end if
rs("productclassname")=request.Form("productclassname")
rs.update
rs.close
set rs=nothing
response.Redirect "?action=classlist"
end if
if action="delclass" then
conn.execute("delete * from product where productclassid in ("&productclassid&")")
conn.execute("delete * from productclass where productclassid in ("&productclassid&")")
response.Redirect "?action=classlist"
end if
%>
<%if action="list" then%>
<table width="760" border="1"align="center" cellpadding="3" cellspacing="1" bordercolor="#CCCCCC" style="border-collapse: collapse">
<tr>
<td colspan="5">【<a href="?action=classlist">品牌列表</a>】【<a href="?action=class">添加品牌</a>】【<a href="?action=list">产品列表</a>】【<a href="?action=product">添加产品</a>】</td>
</tr>
<tr>
<td colspan="5" align="center" bgcolor="#eeeeee">
手机产品列表</td>
</tr>
<tr>
<td width="5%" align="center">ID</td>
<td width="25%" align="center">手机型号</td>
<td width="25%" align="center">手机品牌</td>
<td width="20%" align="center">库存数量</td>
<td width="20%" align="center">管理操作</td>
</tr>
<%
Set mypage=new xdownpage
mypage.getconn=conn
if where<>""then
mypage.getsql="select * from product where productclassid="&where&" order by productid desc"
else
mypage.getsql="select * from product order by productid desc"
end if
mypage.pagesize=16
set rspage=mypage.getrs()
Response.Write("<br/>")
for i=1 to mypage.pagesize
if not rspage.eof then
%>
<tr>
<td align="center"><%=rspage("productid")%></td>
<td align="left"><a href="showproduct.asp?action=show&productid=<%=rspage("productid")%>" target="_blank"><%=rspage("productname")%></a></td>
<td align="center">
<%
set rs=server.CreateObject("adodb.recordset")
sql="select * from productclass where productclassid="&rspage("productclassid")
rs.open sql,conn,1,1
response.Write rs("productclassname")
rs.close
set rs=nothing
%> </td>
<td align="center"><%=rspage("productkucun")%></td>
<td align="center">
<a href="?action=product&pedit=true&productid=<%=rspage("productid")%>">编辑</a>|
<a href="#" onClick="if(confirm('确定删除吗?'))location.href='?action=del&productid=<%=rspage("productid")%>';else return;">删除</a></td>
</tr>
<%
rspage.movenext
else
exit for
end if
next
%>
<tr>
<td colspan="5" align="right"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><select name='where' onChange='javascript:location=this.options[this.selectedIndex].value;'>
<%Set TiaoRs=Server.CreateObject("AdoDb.RecordSet")
TiaoRs.Open "Select * From productclass",Conn,1,1
response.Write "<option ><-请选择类别!-></option>"
Do While Not TiaoRs.eof
response.Write "<option value=?action=list"
response.Write "&where="
response.Write TiaoRs(0)
response.Write ">"
response.Write TiaoRs(1)
response.Write "</option>"
tiaors.movenext
Loop
TiaoRs.Close
Set TiaoRs=Nothing%>
</select></td>
<td align="right"><%mypage.showpage()%></td>
</tr>
</table> </td>
</tr>
</table>
<%
Set mypage=nothing
end if
%>
<%
if action="product" then
if pedit="true" then
set rs=server.CreateObject("adodb.recordset")
sql="select * from product where productid="&productid&""
rs.open sql,conn,1,1
productclassid=rs("productclassid")
productname=rs("productname")
productpicture=rs("productpicture")
productkucun=rs("productkucun")
productcontent=rs("productcontent")
productprice=rs("productprice")
rs.close
set rs=nothing
end if
%>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="14"></td>
</tr>
</table>
<table width="760" border="1"align="center" cellpadding="3" cellspacing="1" bordercolor="#CCCCCC" style="border-collapse: collapse">
<form method="post" name="product" <%if pedit<>"true" then%> action="?action=save"<%else%>action="?action=save&pedit=true&productid=<%=productid%>"<%end if%>>
<tr>
<td colspan="2">【<a href="?action=classlist">品牌列表</a>】【<a href="?action=class">添加品牌</a>】【<a href="?action=list">产品列表</a>】【<a href="?action=product">添加产品</a>】</td>
</tr>
<tr>
<td colspan="2" align="center" bgcolor="#eeeeee">
<%
if pedit="true" then
response.Write("编辑产品")
else
response.Write("添加产品")
end if
%> </td>
</tr>
<tr>
<td align="center">手机品牌</td>
<td>
<select name="productclassid" id="productclassid">
<option value="0"><-请选择手机品牌-></option>
<%
set rs=server.CreateObject("adodb.recordset")
sql="select * from productclass order by productclassid asc"
rs.open sql,conn,1,1
do while not rs.eof
%>
<option value="<%=rs("productclassid")%>"<%if pedit="true" then%><%if rs("productclassid")=productclassid then%>selected="selected"<%end if%><%end if%>><%=rs("productclassname")%> </option>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
</select> </td>
</tr>
<tr>
<td width="20%" align="center">手机型号</td>
<td>
<%if pedit="true" then%>
<input type="text" name="productname" value="<%=productname%>">
<%else%>
<input type="text" name="productname">
<%end if%> </td>
</tr>
<tr>
<td align="center">手机图片</td>
<td>
<%if pedit="true" then%>
<img src="<%=productpicture%>" width="100" height="100"><br>
<input name="productpicture" type="text" id="productpicture" size="30" value="<%=productpicture%>"/>
<input class="button" type="button" name="Submit3121" value="上传图片" onClick="window.open('UploadPic.asp?formname=product&editname=productpicture&uppath=upload/product&filelx=jpg','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')" />
<%else%>
<input name="productpicture" type="text" id="productpicture" size="30"/>
<input class="button" type="button" name="Submit3121" value="上传图片" onClick="window.open('UploadPic.asp?formname=product&editname=productpicture&uppath=upload/product&filelx=jpg','','status=no,scrollbars=no,top=20,left=110,width=420,height=165')" />
<%end if%> </td>
</tr>
<tr>
<td align="center">库存数量</td>
<td>
<%if pedit="true" then%>
<input type="text" name="productkucun" value="<%=productkucun%>">台
<%else%>
<input type="text" name="productkucun">台
<%end if%> </td>
</tr>
<tr>
<td align="center">手机售价</td>
<td><input name="productprice" type="text" id="productprice" <%if pedit="true" then%> value="<%=productprice%>"<%end if%>>
元/台</td>
</tr>
<tr>
<td align="center">手机介绍</td>
<td>
<%if pedit="true" then%>
<textarea name="productcontent" cols="60" rows="8"><%=productcontent%></textarea>
<%else%>
<textarea name="productcontent" cols="60" rows="8"></textarea>
<%end if%> </td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" name="Submit" value="提交">
<input type="reset" name="Submit2" value="重置"></td>
</tr>
</form>
</table>
<%end if%>
<%
if action="save" then
if request.Form("productclassid")="" or request.Form("productclassid")="0" then
response.write "<SCRIPT language=JavaScript>alert('请选择手机品牌!');"
response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
if request.Form("productname")="" or len(request.Form("productname"))<2 or len(request.Form("productname"))>25 then
response.write "<SCRIPT language=JavaScript>alert('请输入手机型号不得小于2大于25个字!');"
response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
if request.Form("productkucun")="" or IsNumeric(request.Form("productkucun"))=false then
response.write "<SCRIPT language=JavaScript>alert('请输入手机库存数量,且只能是数字!');"
response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
if request.Form("productprice")="" or IsNumeric(request.Form("productprice"))=false then
response.write "<SCRIPT language=JavaScript>alert('请输入手机售价,且只能是数字!');"
response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
if request.Form("productpicture")="" then
response.write "<SCRIPT language=JavaScript>alert('请上传手机图片!');"
response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
if request.Form("productcontent")="" then
response.write "<SCRIPT language=JavaScript>alert('请输入手机介绍!');"
response.Write"this.location.href='vbscript:history.back()';</SCRIPT>"
Response.End
end if
set rs=server.CreateObject("adodb.recordset")
if pedit="true" then
sql="select * from product where productid="&productid&""
rs.open sql,conn,1,3
else
sql="select * from product"
rs.open sql,conn,1,3
Rs.AddNew
end if
rs("productclassid")=request.Form("productclassid")
rs("productname")=request.Form("productname")
rs("productkucun")=request.Form("productkucun")
rs("productprice")=request.Form("productprice")
rs("productpicture")=request.Form("productpicture")
rs("productcontent")=request.Form("productcontent")
rs.update
rs.close
set rs=nothing
response.Redirect "?action=list"
end if
if action="del" then
conn.execute("delete * from product where productid in ("&productid&")")
response.Redirect "?action=list"
end if
%>
<!--#include file="foot.asp"-->
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -