purchase.jsp
上传用户:yatiankong
上传日期:2014-05-16
资源大小:5604k
文件大小:3k
源码类别:

Applet

开发平台:

Java

  1. <%@ page contentType="text/html; charset=gb2312" %>
  2. <%@ page session="true" %>
  3. <%@ page import="MyFly.Book.Books" %>
  4. <jsp:useBean id="book" scope="page" class="MyFly.Book.bookmn" />
  5. <jsp:useBean id="shop" scope="page" class="MyFly.Book.Purchase"/>
  6. <%
  7. String mesg = "";
  8. String submits = request.getParameter("Submit");
  9. String Id="";
  10. if (submits!=null && !submits.equals("")){
  11. if (shop.addnew(request)){
  12. mesg = "你要的图书已经放入你的购物车中!谢谢";
  13. } else if (shop.getIsEmpty()){
  14. mesg = "库存图书数量不足!只剩"+shop.getLeaveBook()+"本";//查看书的数目
  15. } else {
  16. mesg = "暂时不能购买!";
  17. }
  18. }else {
  19. if (request.getParameter("bookid")==null || request.getParameter("bookid").equals("")) {
  20. mesg = "你要购买的图书不存在!";
  21. } else {
  22. try {
  23.  Id = request.getParameter("bookid");
  24. if (!book.getOnebook(Id)){
  25. mesg = "你要购买的图书不存在!";
  26. }
  27. }
  28.  catch (Exception e){
  29. mesg = "你要购买的图书不存在!";
  30. }
  31. }
  32. }
  33. %>
  34. <html>
  35. <head>
  36. <title>电子书店 购买图书</title>
  37. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  38. <script language="javascript">
  39. function openScript(url,name, width, height){
  40. var Win = window.open(url,name,'width=' + width + ',height=' + height + ',resizable=0,scrollbars=no,menubar=no,status=no' );
  41. }
  42. function check()
  43. {
  44. if (document.form1.amount.value<1){
  45. alert("你的购买数量有问题");
  46. document.form1.amount.focus();
  47. //document.form1.amount.
  48. return false;
  49. }
  50. return true;
  51. }
  52. </script>
  53. <link rel="stylesheet" href="books.css" type="text/css">
  54. </head>
  55. <body bgcolor="#FFCC99" text="#000000" onload="javascript:window.focus();">
  56. <div align="center">
  57.   <% if(!mesg.equals("")){
  58. out.println(mesg);
  59.   } else {
  60. Books bk = (Books) book.getBooklist().elementAt(0);   
  61. %>
  62.   <table width="90%" border="0" cellspacing="2" cellpadding="1">
  63.     <form name="form1" method="post" action="purchase.jsp">
  64.       <tr> 
  65.         <td align="center">图书名:<%= bk.getProductName() %></td>
  66.       </tr>
  67.       <tr align="center"> 
  68.         <td>你想要的数量: 
  69.           <input name="amount" type="text" value="1" size="3"> 
  70.           本</td>
  71.       </tr>
  72.       <tr align="center"> 
  73.         <td>
  74.   <input type="hidden" name="bookid" value="<%=Id %>">
  75.           <input type="submit" name="Submit" value="购 买" onclick="return(check());">
  76.           <input type="reset" name="Reset" value="取 消">
  77.         </td>
  78.       </tr>
  79.    <tr align="center"> 
  80.         <td>&nbsp;</td>
  81.       </tr>
  82.     </form>
  83.   </table>
  84. <% } %>
  85.   <br>
  86.   <p><a href="javascript:window.close()">关闭窗口</a></p>
  87.   <table width="100%" border="0" cellspacing="2" cellpadding="2">
  88.     <tr>
  89.       <td align="center">星海公司开发<br>
  90.         CopyRight@2003 <br>
  91.         Email:<a href="mailto:pz990@163.net">pz990@163.net</a></td>
  92.     </tr>
  93.   </table>
  94. </div>
  95. </body>
  96. </html>