日期:2014-05-17 浏览次数:20830 次
<% request.setCharacterEncoding("GBK"); int categoryId = -1; String strCategoryId = request.getParameter("categoryId"); if(strCategoryId != null && !strCategoryId.trim().equals("")) { categoryId = Integer.parseInt(strCategoryId); } String action = request.getParameter("action"); if(action != null && action.trim().equals("add")) { String name = request.getParameter("name"); double normalPrice = Double.parseDouble(request.getParameter("normalPrice")); double memberPrice = Double.parseDouble(request.getParameter("memberPrice")); String descr = request.getParameter("descr"); Product p = new Product(); p.setName(name); p.setNormalPrice(normalPrice); p.setMemberPrice(memberPrice); p.setDescr(descr); p.setCategoryId(categoryId); p.setPdate(new Date()); ProductMgr.getInstance().add(p); %> <script type="text/javascript"> parent.main.location.reload(); //--> </script> <% } %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>添加产品</title> </head> <center> 产品添加 </center> <body> <form action="ProductAdd.jsp" name="productadd" method="post"> <table border="1" align="center"> <input type="hidden" name="action" value="add" /> <tr> <td> 产品名称: </td> <td> <input name="name" size="25" maxlength="25" type="text"> </tr> <tr> <td> 市场价格: </td> <td> <input name="normalPrice" size="25" type="text"> </td> </tr> <tr> <td> 会员价格: </td> <td> <input name="memberPrice" size="25" type="text"> </td> </tr> <tr> <td> 所属类别 </td> <td> <select name="categoryId"> <% List<Category> categories = CategoryService.getInstance().getCategories(); for (Iterator<Category> it = categories.iterator(); it.hasNext();) { Category c = it.next(); String selected = ""; if (c.getId() == categoryId) selected = "selected"; String preStr = ""; for (int i = 1; i < c.getGrade(); i++) preStr += "--"; %> <option value="<%=c.getId()%>|<%=c.getGrade()%>" <%=selected%>><%=preStr + c.getName()%></option> <% }