📄 admin_product.asp
字号:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<% Option Explicit %>
<!-- #include file="conn_CompMarket.asp" -->
<!-- #include file="adovbs.inc" -->
<%
Dim Product_ID '保存被操作的产品编号
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>清北DIY俱乐部每日报价</title>
<link href="priceEdit.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body>
<%
'删除商品-开始
If request.querystring("command")="delete" then
If request.form("Submit")="删除" then
'产品编号通过“hidden”属性的“input”表单元素来传递
Product_ID=request.form("Product_ID")
'设置当前查询所要操作的表和相应的SQL语句
rsSource="Hardware"
rsSQL="delete "&rsSource&" where [分类]+[品牌]+[型号]='"&Product_ID&"'"
'建立记录集对象,开始查询
'删除被选中的产品
set rsCompMarket=Server.CreateObject("ADODB.Recordset")
rsCompMarket.Open rsSQL,dcnCompMarket,1,2,1
If rsCompMarket.State=adStateOpen Then rsCompMarket.Close
set rsCompMarket=Nothing
End If
%>
<%
'设置当前查询所要操作的表和相应的SQL语句
rsSource="Hardware"
rsSQL="select * from "&rsSource&" order by 分类,品牌,型号,零售价"
'建立记录集对象,开始查询
set rsCompMarket=Server.CreateObject("ADODB.Recordset")
With rsCompMarket
.Source=rsSource
.ActiveConnection=dcnCompMarket
.CursorType=adOpenDynamic
.LockType=adLockOptimistic
.Open rsSQL
End With
%>
<table width="800" border="0" bgcolor="#999999">
<tr><td>
<table border="1" width="100%" cellpadding="1">
<tr><td width="80" align="center"><b>分类</b></td>
<td align="center"><b>型号</b></td>
<td align="center"><b>零售价</b></td>
<td align="center"><b>说明</b></td>
<td align="center"><b>操作</b></td>
</tr>
<%
'给出商品列表,给出“删除”按钮
Do While NOT rsCompMarket.EOF
Response.Write("<form Method=""post"" Action=""admin_product.asp?command=delete"">")
'通过“hidden”属性的“input”表单元素来传递“产品编号”
'不使用"querystring”方法的原因是:产品编号中的特殊字符例如“+”无法正确接收,倒是传输过程数据缺失
Response.Write("<input type=""hidden"" name=""Product_ID"" value=""" & _
rsCompMarket.Fields("分类") & rsCompMarket.Fields("品牌") &rsCompMarket.Fields("型号") & """>")
Response.Write("<tr><td align=center>" & rsCompMarket.Fields("分类") & "</td>" & _
"<td>" & rsCompMarket.Fields("品牌") & " " & rsCompMarket.Fields("型号") & "</td>" & _
"<td align=""right"">" & rsCompMarket.Fields("零售价") & " </td>" & _
"<td>" & rsCompMarket.Fields("说明") & " </td>" & _
"<td align=""center""><input type=""submit"" name=""Submit"" value=""删除""></td></tr>")
Response.Write("</form>")
rsCompMarket.MoveNext
Loop
'使用完毕后关闭数据库连接
rsCompMarket.Close
set rsCompMarket=Nothing
%>
</table>
</td></tr>
</table>
<%
'删除商品-结束
End If
%>
<%
'修改报价-开始
If request.querystring("command")="modify" then
If request.form("Submit")="修改" then
'产品编号通过“hidden”属性的“input”表单元素来传递
Product_ID=request.form("Product_ID")
'修改后的“零售价”、“柜台价”和“说明”
Dim Price_OUT '储存零售价
Dim Price_IN '储存柜台价
Dim Detail '储存商品说明
Price_OUT=request.form("Price_OUT")
Price_IN=request.form("Price_IN")
Detail=request.form("Detail")
if Price_OUT="" then Price_OUT="0"
if Price_IN="" then Price_IN="0"
if Detail="" then Detail=" "
'设置当前查询所要操作的表和相应的SQL语句
rsSource="Hardware"
rsSQL="update "&rsSource&_
" set [零售价]="&Price_OUT&_
",[柜台价]="&Price_IN&_
",[说明]='"&Detail&"'"&_
" where [分类]+[品牌]+[型号]='"&Product_ID&"'"
'建立记录集对象,开始查询
'修改被选中的产品
set rsCompMarket=Server.CreateObject("ADODB.Recordset")
rsCompMarket.Open rsSQL,dcnCompMarket,1,2,1
If rsCompMarket.State=adStateOpen Then rsCompMarket.Close
set rsCompMarket=Nothing
End If
%>
<%
'设置当前查询所要操作的表和相应的SQL语句
rsSource="Hardware"
rsSQL="select * from "&rsSource&" order by 分类,品牌,型号,零售价"
'建立记录集对象,开始查询
set rsCompMarket=Server.CreateObject("ADODB.Recordset")
With rsCompMarket
.Source=rsSource
.ActiveConnection=dcnCompMarket
.CursorType=adOpenDynamic
.LockType=adLockOptimistic
.Open rsSQL
End With
%>
<table width="800" border="0" bgcolor="#999999">
<tr><td>
<table border="1" width="100%" cellpadding="1">
<tr><td width="80" align="center"><b>分类</b></td>
<td align="center"><b>型号</b></td>
<td align="center"><b>零售价</b></td>
<td align="center"><b>柜台价</b></td>
<td align="center"><b>说明</b></td>
<td align="center"><b>操作</b></td>
</tr>
<%
'给出商品列表,给出“修改”按钮
Do While NOT rsCompMarket.EOF
Response.Write("<form Method=""post"" Action=""admin_product.asp?command=modify"">")
'通过“hidden”属性的“input”表单元素来传递“产品编号”
'不使用"querystring”方法的原因是:产品编号中的特殊字符例如“+”无法正确接收,倒是传输过程数据缺失
Response.Write("<input type=""hidden"" name=""Product_ID"" value=""" & _
rsCompMarket.Fields("分类") & rsCompMarket.Fields("品牌") &rsCompMarket.Fields("型号") & """>")
Response.Write("<tr><td align=center>" & rsCompMarket.Fields("分类") & "</td>" & _
"<td>" & rsCompMarket.Fields("品牌") & " " & rsCompMarket.Fields("型号") & "</td>" & _
"<td>" & _
"<input type=""text"" size=""4"" name=""Price_OUT"" value=""" & rsCompMarket.Fields("零售价") & """>"&_
"</td>" & _
"<td>" & _
"<input type=""text"" size=""4"" name=""Price_IN"" value=""" & rsCompMarket.Fields("柜台价") & """>"&_
"</td>" & _
"<td>" & _
"<input type=""text"" size=""50"" name=""Detail"" value=""" & rsCompMarket.Fields("说明") & """>"&_
"</td>" & _
"<td align=""center""><input type=""submit"" name=""Submit"" value=""修改""></td></tr>")
Response.Write("</form>")
rsCompMarket.MoveNext
Loop
'使用完毕后关闭数据库连接
rsCompMarket.Close
set rsCompMarket=Nothing
%>
</table>
</td></tr>
</table>
<%
'修改报价-结束
End If
%>
<%
'添加商品-开始
If request.querystring("command")="add" Then
'选中所有分类
'设置当前查询所要操作的表和相应的SQL语句
rsSource="HardwareType"
rsSQL="select [分类] from "&rsSource
'建立记录集对象,开始查询
Dim rsHardwareType '储存商品分类
Set rsHardwareType=Server.CreateObject("ADODB.Recordset")
rsHardwareType.Open rsSQL,dcnCompMarket,1,2,1
'欲添加的商品的分类
Dim productType '储存商品分类
Dim selectedType '储存被选中的商品分类
If not request.querystring("Type")="" Then
productType=request.querystring("Type")
selectedType=productType
Else
productType=rsHardwareType("分类")
selectedType=""
End If
'设置当前查询所要操作的表和相应的SQL语句
rsSource="HardwareBrand"
rsSQL="select [品牌] from "&rsSource&" where [分类]='"&productType&"'"
'建立记录集对象,开始查询
Dim rsHardwareBrand '储存商品品牌
'选中此分类下的品牌
Set rsHardwareBrand=Server.CreateObject("ADODB.Recordset")
rsHardwareBrand.Open rsSQL,dcnCompMarket,1,2,1
'是否添加商品
If request.form("Submit")="添加商品" Then
'添加一个商品所需的信息
Dim tempType '分类
Dim tempBrand '品牌
Dim tempName '型号
Dim tempPriceOut '零售价
Dim tempPriceIn '柜台价
Dim tempDetail '说明
tempType=selectedType
tempBrand=request.form("selectBrand")
tempName=request.form("addName")
tempPriceOut=request.form("addPriceOut")
tempPriceIn=request.form("addPriceIn")
tempDetail=request.form("addDetail")
'判断添加商品所需信息是否完整
If tempType="" or tempBrand="" or tempName="" Then
response.redirect("admin_product.asp?command=add")
End If
If tempPriceOut="" Then tempPriceOut="0"
If tempPriceIn="" Then tempPriceIn="0"
If tempDetail="" Then tempDetail=" "
'设置当前查询所要操作的表和相应的SQL语句
rsSource="Hardware"
rsSQL="insert into "&rsSource&" (分类,品牌,型号,零售价,柜台价,说明) "&_
"values ("&_
"'"&tempType&"'," & "'"&tempBrand&"'," &_
"'"&tempName&"'," &_
tempPriceOut&"," & tempPriceIn&"," &_
"'"&tempDetail&"'"&")"
Response.Write rsSQL
'建立记录集对象,开始查询
'修改被选中的产品
set rsCompMarket=Server.CreateObject("ADODB.Recordset")
rsCompMarket.Open rsSQL,dcnCompMarket,1,2,1
If rsCompMarket.State=adStateOpen Then rsCompMarket.Close
set rsCompMarket=Nothing
End If
%>
<table width="800" border="0" cellpadding="5" bgcolor="#999999">
<tr><td><form name="addProduct" method="post" action="admin_product.asp?command=add&Type=<% =selectedType %>">
<table border="1" align="center" cellpadding="3">
<tr>
<td>分类</td>
<td colspan="3">
<select name="selectType" onChange="MM_jumpMenu('self',this,0)">
<option>请选择分类...</option>
<%
Do While not rsHardwareType.EOF
If rsHardwareType("分类")=selectedType Then
Response.Write("<option selected "&_
"value=""admin_product.asp?command=add&Type="&rsHardwareType("分类")&""">"&_
rsHardwareType.Fields("分类")&"</option>")
Else
Response.Write("<option "&_
"value=""admin_product.asp?command=add&Type="&rsHardwareType("分类")&""">"&_
rsHardwareType.Fields("分类")&"</option>")
End If
rsHardwareType.MoveNext
Loop
If rsHardwareType.State=adStateOpen Then rsHardwareType.Close
set rsHardwareType=Nothing
%>
</select>
</td>
</tr>
<tr>
<td>品牌</td>
<td colspan="3">
<select name="selectBrand">
<Option>请选择品牌...</Option>
<%
Do While not rsHardwareBrand.EOF
Response.Write("<option value="""&rsHardwareBrand.Fields("品牌")&""">"&_
rsHardwareBrand.Fields("品牌")&"</option>")
rsHardwareBrand.MoveNext
Loop
If rsHardwareBrand.State=adStateOpen Then rsHardwareBrand.Close
set rsHardwareBrand=Nothing
%>
</select>
</td>
</tr>
<tr>
<td>型号</td>
<td colspan="3"><input name="addName" type="text" id="addName" size="50"></td>
</tr>
<tr>
<td>零售价</td>
<td><input name="addPriceOut" type="text" id="addPriceOut" size="4"></td>
<td>柜台价</td>
<td><input name="addPriceIn" type="text" id="addPriceIn" size="4"></td>
</tr>
<tr>
<td>说明</td>
<td colspan="3"><textarea name="addDetail" cols="50" rows="4" id="addDetail"></textarea></td>
</tr>
<tr>
<td colspan="4"><div align="center">
<input type="submit" name="Submit" value="添加商品">
<input type="reset" name="Reset" value="重新输入">
</div></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<%
'添加商品-结束
End If
%>
<%
'使用完毕后关闭数据库连接
If dcnCompMarket.State=adStateOpen Then
dcnCompMarket.Close
End If
Set dcnCompMarket=Nothing
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -