addpro.asp
上传用户:syzzy1975
上传日期:2022-07-17
资源大小:670k
文件大小:13k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
  2. <%
  3. %><!--#include file="inc/config.asp"-->
  4. <!--#include file="inc/conn.asp"--> 
  5. <!--#include file="inc/chk.asp"--> 
  6. <%
  7. if session("rank")>2 then
  8. call Msgbox("对不起,您的权限不够!","Back","None")
  9. response.End
  10. end if
  11. %>
  12. <%
  13. '添加产品
  14. If NOT IsEmpty (request("AddProSubmit")) then
  15. dim productdate,discount
  16. discount=round(request("price2")/request("price1"),2)
  17. if request("productdateyear")<>"" then
  18. productdate=trim(request("productdateyear"))&"年"&trim(request("productdatemonth"))&"月"
  19. else
  20. productdate=""
  21. end if
  22. set rs=server.CreateObject("adodb.recordset")
  23. rs.Open "select * from product",conn,1,3
  24. rs.AddNew
  25. rs("productdate")=productdate 
  26. rs("discount")=discount 
  27. rs("name")=trim(request("name")) 
  28. rs("format")=request("format")
  29. if request("pagenum")<>"" then
  30. rs("pagenum")=int(request("pagenum"))
  31. else
  32. rs("pagenum")=0
  33. end if
  34. if request("printed")<>"" then
  35. rs("printed")=int(request("printed"))
  36. else
  37. rs("printed")=0
  38. end if
  39. rs("author")=trim(request("author"))
  40. rs("mark")=trim(request("mark"))
  41. rs("introduce")=trim(request("introduce")) 
  42. rs("price1")=trim(request("price1"))  
  43. rs("price2")=trim(request("price2"))  
  44. rs("vipprice")=trim(request("vipprice"))  
  45. rs("pic")=trim(request("pic")) 
  46. rs("categoryid")=int(request("categoryid"))
  47. rs("sortsid")=int(request("sortsid")) 
  48. rs("score")=request("score") 
  49. rs("type")=trim(request("type"))
  50. rs("solded")=0 
  51. rs("viewnum")=0 
  52. rs("adddate")=now() 
  53. rs("rank")=0  
  54. rs("ranknum")=0
  55. if request("detail")<>"" then
  56. rs("detail")=htmlencode2(request("detail"))
  57. end if
  58. if request("content")<>"" then
  59. rs("content")=htmlencode2(request("content"))
  60. end if
  61. if request("detail")<>"" then
  62. rs("desc")=htmlencode2(strvalue(request("detail") ,100))
  63. end if
  64. '是否推荐产品
  65. if request("recommend")=1 then  
  66. rs("recommend")=1
  67. else
  68. rs("recommend")=0
  69. end if
  70. rs.Update
  71. rs.Close
  72. set rs=nothing
  73. call MsgBox("添加成功!","GoUrl","addpro.asp")
  74. response.End
  75. end if
  76. %>
  77. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  78. <html>
  79. <head>
  80. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  81. <title>406网络书店</title>
  82. <link href="../style.css" rel="stylesheet" type="text/css">
  83. </head>
  84. <body>
  85. <!--#include file="head.htm"-->
  86. <table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  87.   <tr>
  88.     <td width="219" align="left" valign="top"><br>
  89.       <!--#include file="menu.htm"-->
  90.         <br></td><td width="561" align="left" valign="top">      <script language = "JavaScript">
  91. var onecount;
  92. onecount=0;
  93. subcat = new Array();
  94. <%
  95. '读取分类字段赋给JS数组
  96. dim count
  97. set rs=server.createobject("adodb.recordset")
  98. rs.open "select * from sorts order by sortsorder ",conn,1,1
  99. count = 0
  100. do while not rs.eof 
  101. %>
  102. subcat[<%=count%>] = new Array("<%= trim(rs("sorts"))%>","<%= rs("categoryid")%>","<%= rs("sortsid")%>");
  103. <%
  104.         count = count + 1
  105.         rs.movenext
  106.         loop
  107.         rs.close
  108. %>
  109. onecount=<%=count%>;
  110. function changelocation(locationid)
  111.     {
  112.     document.myform.sortsid.length = 0; 
  113.     var locationid=locationid;
  114.     var i;
  115.     for (i=0;i < onecount; i++)
  116.         {
  117.             if (subcat[i][1] == locationid)
  118.             { 
  119.              document.myform.sortsid.options[document.myform.sortsid.length] = new Option(subcat[i][0], subcat[i][2]);
  120.             }        
  121.         }
  122.         
  123.     }    
  124.       </script>      <br>      <table border="0" cellpadding="0" cellspacing="0">
  125.         <tr>
  126.           <td width="18"><img src="../images/w.gif" width="18" height="18"></td>
  127.           <td width="66" style="color:#415373">添加商品</td>
  128.         </tr>
  129.       </table>      <br>      <form action="" method="post" name="myform" id="myform">
  130.         <table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
  131.           <tr>
  132.             <td> <span class="redfont">*</span>选择分类:</td>
  133.             <td colspan="2">
  134. <%
  135. rs.open "select * from category order by categoryorder",conn,1,1
  136. if rs.eof and rs.bof then
  137. call MsgBox("请先添加分类!","Back","None")
  138. response.end
  139. else
  140. %>
  141.               <select name="categoryid" size="1" id="select2" onChange="changelocation(document.myform.categoryid.options[document.myform.categoryid.selectedIndex].value)">
  142.                 <option selected value="<%=rs("categoryid")%>"><%=trim(rs("category"))%></option>
  143. <%      
  144.  dim selclass
  145.  selclass=rs("categoryid")
  146.  rs.movenext
  147.  do while not rs.eof
  148. %>
  149.                 <option value="<%=rs("categoryid")%>"><%=trim(rs("category"))%></option>
  150.                 <%
  151.  rs.movenext
  152.  loop
  153. end if
  154. rs.close
  155. %>
  156.               </select>
  157.       小类:
  158.       <select name="sortsid">
  159. <%
  160. rs.open "select * from sorts where categoryid="&selclass ,conn,1,1
  161. if not(rs.eof and rs.bof) then
  162. %>
  163.         <option value="<%=rs("sortsid")%>" selected><%=rs("sorts")%></option>
  164.         <% rs.movenext
  165. do while not rs.eof
  166. %>
  167.         <option value="<%=rs("sortsid")%>"><%=rs("sorts")%></option>
  168. <%
  169. rs.movenext
  170. loop
  171. end if
  172.         rs.close
  173.         set rs = nothing
  174.         conn.Close
  175.         set conn = nothing
  176. %>
  177.       </select>
  178.             </td>
  179.           </tr>
  180.           <tr>
  181.             <td><span class="redfont">*</span>书名:</td>
  182.             <td colspan="2">
  183.               <input name="name" type="text" id="name" size="30">
  184.             </td>
  185.           </tr>
  186.           <tr>
  187.             <td><span class="redfont">*</span>作者:</td>
  188.             <td colspan="2"><input name="author" type="text" id="author" size="20"></td>
  189.           </tr>
  190.           <tr>
  191.             <td><span class="redfont">*</span>出 版 社:              </td>
  192.             <td colspan="2">
  193.               <input name="mark" type="text" id="mark" size="30" ></td>
  194.           </tr>
  195.           <tr>
  196.             <td>装帧:</td>
  197.             <td colspan="2">
  198.               <input name="introduce" type="text" id="introduce" size="30" ></td>
  199.           </tr>
  200.           <tr>
  201.             <td><span class="redfont">*</span>出版日期:</td>
  202.             <td colspan="2">
  203.               <select name="productdateyear" id="productdateyear">
  204.                 <%dim i
  205. for i=year(now) to 1900 step -1
  206. response.write "<option value="&i&">"&i&"</option>"
  207. next
  208. %>
  209.               </select>
  210.               年
  211.               <select name="productdatemonth" id="productdatemonth">
  212.                 <%for i=1 to 12
  213. response.write "<option value="&i&">"&i&"</option>"
  214. next%>
  215.               </select>
  216.       月</td>
  217.           </tr>
  218.           <tr>
  219.             <td><span class="redfont">*</span>价格:              </td>
  220.             <td colspan="2">市场价:
  221.                 <input name="price1" type="text" id="price1" onKeyPress = "return regInput(this, /^d*.?d{0,2}$/, String.fromCharCode(event.keyCode))" VALUE="0" size="6" 
  222. onpaste = "return regInput(this, /^d*.?d{0,2}$/, window.clipboardData.getData('Text'))"
  223. ondrop = "return regInput(this, /^d*.?d{0,2}$/, event.dataTransfer.getData('Text'))">
  224.                 元, 会员价:
  225.                 <input name="price2" type="text" id="price2" onKeyPress = "return regInput(this, /^d*.?d{0,2}$/, String.fromCharCode(event.keyCode))" value="0" size="6" 
  226. onpaste = "return regInput(this, /^d*.?d{0,2}$/, window.clipboardData.getData('Text'))"
  227. ondrop = "return regInput(this, /^d*.?d{0,2}$/, event.dataTransfer.getData('Text'))">
  228.                 元, VIP价:
  229.                 <INPUT NAME="vipprice" TYPE="text" ID="vipprice" ONKEYPRESS = "return regInput(this, /^d*.?d{0,2}$/, String.fromCharCode(event.keyCode))" value="0" SIZE="6" 
  230. ONPASTE = "return regInput(this, /^d*.?d{0,2}$/, window.clipboardData.getData('Text'))"
  231. ONDROP = "return regInput(this, /^d*.?d{0,2}$/, event.dataTransfer.getData('Text'))">
  232.                 元<br> 
  233.               赠送积分:
  234.               <INPUT NAME="score" VALUE="0" SIZE="4" TYPE="text" ONKEYPRESS = "return regInput(this, /^[0-9]*$/, String.fromCharCode(event.keyCode))"
  235. ONPASTE = "return regInput(this, /^[0-9]*$/, window.clipboardData.getData('Text'))"
  236. ONDROP = "return regInput(this, /^[0-9]*$/, event.dataTransfer.getData('Text'))">
  237.                 分</td>
  238.           </tr>
  239.           
  240.           <tr>
  241.             <td>开本:</td>
  242.             <td colspan="2"><input name="format" type="text" id="format" size="10"></td>
  243.           </tr>
  244.           <tr>
  245.             <td>版次:</td>
  246.             <td colspan="2">            <input name="printed" type="text" id="printed" onKeyPress = "return regInput(this, /^d*.?d{0,2}$/, String.fromCharCode(event.keyCode))" size="6" 
  247. onpaste = "return regInput(this, /^d*.?d{0,2}$/, window.clipboardData.getData('Text'))"
  248. ondrop = "return regInput(this, /^d*.?d{0,2}$/, event.dataTransfer.getData('Text'))"></td>
  249.           </tr>
  250.           <tr>
  251.             <td>页数:              </td>
  252.             <td colspan="2">
  253.               <input name="pagenum" type="text" id="pagenum" onKeyPress = "return regInput(this, /^d*.?d{0,2}$/, String.fromCharCode(event.keyCode))" size="10" 
  254. onpaste = "return regInput(this, /^d*.?d{0,2}$/, window.clipboardData.getData('Text'))"
  255. ondrop = "return regInput(this, /^d*.?d{0,2}$/, event.dataTransfer.getData('Text'))"></td>
  256.           </tr>
  257.           <tr>
  258.             <td><span class="redfont">*</span>ISBN:</td>
  259.             <td colspan="2"><input name="type" type="text" id="type2" size="30"></td>
  260.           </tr>
  261.           <tr>
  262.             <td><span class="redfont">*</span>商品图片:              </td>
  263.             <td colspan="2">
  264.               <input name="pic" type="text" id="pic" size="30" VALUE="bookimages/emptybook.gif">
  265. &nbsp;
  266.       <input type="button" name="Submit2" value="上 传" onClick="javascript:window.open('upfile.asp','','width=580,height=160,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=no');return false;"></td>
  267.           </tr>
  268.           <tr>
  269.             <td>详细说明:</td>
  270.             <td colspan="2">
  271.               <textarea name="detail" cols="46" rows="8" id="detail"></textarea>
  272.             </td>
  273.           </tr>
  274.           <tr>
  275.             <td valign="top">目录:</td>
  276.             <td colspan="2"><TEXTAREA NAME="content" COLS="46" ROWS="8" ID="content"></TEXTAREA>
  277.             </td>
  278.           </tr>
  279.           <tr align="center">
  280.             <td colspan="3">
  281.                 <input name="recommend" type="checkbox" id="recommend" value="1">
  282.         推荐此商品
  283.         <input name="AddProSubmit" type="submit" id="AddProSubmit" onClick="return checkpro();" value="添加">
  284. <script language="JavaScript">
  285. <!--
  286. function checkpro()
  287. {
  288.     if(checkspace(document.myform.name.value)) {
  289. document.myform.name.focus();
  290.     alert("请输入书名!");
  291. return false;
  292.   }
  293. if(checkspace(document.myform.author.value)) {
  294. document.myform.author.focus();
  295.     alert("请输入作者!");
  296. return false;
  297.   }
  298. if(checkspace(document.myform.mark.value)) {
  299. document.myform.mark.focus();
  300.     alert("请输入出版社!");
  301. return false;
  302.   }
  303. if(checkspace(document.myform.type.value)) {
  304. document.myform.type.focus();
  305.     alert("请输入ISBN!");
  306. return false;
  307.   }
  308.     if(checkspace(document.myform.price1.value)||document.myform.price1.value==0) {
  309. document.myform.price1.focus();
  310.     alert("请输入市场价!");
  311. return false;
  312.   }
  313.     if(checkspace(document.myform.price2.value)||document.myform.price2.value==0) {
  314. document.myform.price2.focus();
  315.     alert("请输入会员价!");
  316. return false;
  317.   }
  318.     if(checkspace(document.myform.vipprice.value)||document.myform.vipprice.value==0) {
  319. document.myform.vipprice.focus();
  320.     alert("请输入VIP价!");
  321. return false;
  322.   }
  323.      if(checkspace(document.myform.price1.value)) {
  324. document.myform.price1.focus();
  325.     alert("请输入商品市场价格!");
  326. return false;
  327.   }
  328.      if(checkspace(document.myform.price2.value)) {
  329. document.myform.price2.focus();
  330.     alert("请输入商品会员价格!");
  331. return false;
  332.   }
  333.       if(checkspace(document.myform.vipprice.value)) {
  334. document.myform.vipprice.focus();
  335.     alert("请输入VIP月会员商品价格!");
  336. return false;
  337.   }
  338.  
  339. }
  340. function checkspace(checkstr) {
  341.   var str = '';
  342.   for(i = 0; i < checkstr.length; i++) {
  343.     str = str + ' ';
  344.   }
  345.   return (str == checkstr);
  346. }
  347. function regInput(obj, reg, inputStr)
  348. {
  349. var docSel = document.selection.createRange()
  350. if (docSel.parentElement().tagName != "INPUT") return false
  351. oSel = docSel.duplicate()
  352. oSel.text = ""
  353. var srcRange = obj.createTextRange()
  354. oSel.setEndPoint("StartToStart", srcRange)
  355. var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
  356. return reg.test(str)
  357. }
  358. //-->
  359.                           
  360. </script></td>
  361.           </tr>
  362.         </table>
  363.       </form></td>
  364.   </tr>
  365. </table>
  366. <!--#include file="foot.htm"-->
  367. </body>
  368. </html>