ProductAdd.jsp
上传用户:lsj999sz
上传日期:2022-06-15
资源大小:4717k
文件大小:5k
源码类别:

ICQ/即时通讯

开发平台:

Java

  1. <%@ page language="java" import="com.bjsxt.shopping.product.*" pageEncoding="GBK"%>
  2. <%@ page import="com.bjsxt.shopping.category.*" %>
  3. <%@ page import="java.util.*"%>
  4. <%
  5. request.setCharacterEncoding("GBK");
  6. int categoryId = -1;
  7. String strCategoryId = request.getParameter("categoryId");
  8. if(strCategoryId != null && !strCategoryId.trim().equals("")) {
  9. categoryId = Integer.parseInt(strCategoryId);
  10. }
  11. String action = request.getParameter("action");
  12. if(action != null && action.trim().equals("add")) {
  13. String name = request.getParameter("name");
  14. double normalPrice = Double.parseDouble(request.getParameter("normalPrice"));
  15. double memberPrice = Double.parseDouble(request.getParameter("memberPrice"));
  16. String descr = request.getParameter("descr");
  17. Product p = new Product();
  18. p.setName(name);
  19. p.setNormalPrice(normalPrice);
  20. p.setMemberPrice(memberPrice);
  21. p.setDescr(descr);
  22. p.setCategoryId(categoryId);
  23. p.setPdate(new Date());
  24. ProductMgr.getInstance().add(p);
  25. %>
  26. <script type="text/javascript">
  27. <!--
  28. parent.main.location.reload();
  29. //-->
  30. </script>
  31. <%
  32. }
  33.  %>
  34. <html><head><title>金尚商城产品添加</title>
  35. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  36. <meta name="keywords" content="Discuz!,Board,Comsenz,forums,bulletin board,">
  37. <meta name="description" content="醒客论坛专区  - Discuz! Board">
  38. <meta name="generator" content="Discuz! 4.0.0RC4 with Templates 4.0.0">
  39. <meta name="MSSmartTagsPreventParsing" content="TRUE">
  40. <meta http-equiv="MSThemeCompatible" content="Yes">
  41. <style type="text/css"><!--
  42. a { text-decoration: none; color: #000000 }
  43. a:hover { text-decoration: underline }
  44. body { scrollbar-base-color: #F3F6FA; scrollbar-arrow-color: #4D76B3; font-size: 12px; background-color: #ffffff }
  45. table { font: 12px Verdana,Tahoma; color: #000000 }
  46. input,select,textarea { font: 11px Verdana,Tahoma; color: #000000; font-weight: normal; background-color: #F3F6FA }
  47. select { font: 11px Verdana,Tahoma; color: #000000; font-weight: normal; background-color: #F3F6FA }
  48. .nav { font: 12px Verdana,Tahoma; color: #000000; font-weight: bold }
  49. .nav a { color: #000000 }
  50. .header { font: 11px Verdana,Tahoma; color: #FFFFFF; font-weight: bold; background-image: url("images/green/bg01.gif") }
  51. .header a { color: #FFFFFF }
  52. .category { font: 11px Verdana,Tahoma; color: #000000; background-color: #EFEFEF }
  53. .tableborder { background: #4D76B3; border: 0px solid #4D76B3 } 
  54. .singleborder { font-size: 0px; line-height: 0px; padding: 0px; background-color: #F3F6FA }
  55. .smalltxt { font: 11px Verdana,Tahoma }
  56. .outertxt { font: 12px Verdana,Tahoma; color: #000000 }
  57. .outertxt a { color: #000000 }
  58. .bold { font-weight: bold }
  59. .altbg1 { background: #F3F6FA }
  60. .altbg2 { background: #FFFFFF }
  61. --></style>
  62. <script language="JavaScript" src="images/common.js"></script>
  63. <style type="text/css" id="defaultPopStyle">.cPopText { font-family: Tahoma, Verdana; background-color: #FFFFCC; border: 1px #000000 solid; font-size: 12px; padding-right: 4px; padding-left: 4px; height: 20px; padding-top: 2px; padding-bottom: 2px; visibility: hidden; filter: Alpha(Opacity=80)}</style></head><body leftmargin="0" rightmargin="0" topmargin="0" onkeydown="if(event.keyCode==27) return false;"><div id="popLayer" style="position: absolute; z-index: 1000;" class="cPopText"></div>
  64. <script type="text/javascript">
  65. function check() {
  66. var selectedCategory = document.formAdd.categoryId.options[document.formAdd.categoryId.selectedIndex];
  67. var selectedValue = selectedCategory.value;
  68. if(selectedValue.split("|")[1] == "1") {
  69. alert("请选择第二级分类!");
  70. document.formAdd.categoryId.focus();
  71. return false;
  72. } else {
  73. selectedCategory.value = selectedValue.split("|")[0];
  74. }
  75. return true;
  76. }
  77. </script>
  78. <br>
  79. <form method="post" name="formAdd" action="ProductAdd.jsp" onsubmit="return check()">
  80. <input type="hidden" name="action" value="add"/>
  81. <table class="tableborder" align="center" cellpadding="4" cellspacing="1" width="97%">
  82. <tbody><tr>
  83. <td colspan="2" class="header">产品添加 - 必填内容</td>
  84. </tr>
  85. <tr>
  86. <td class="altbg1" width="21%">产品名称:</td>
  87. <td class="altbg2"><input name="name" size="25" maxlength="25" type="text"> 
  88. </tr>
  89. <tr>
  90. <td class="altbg1">市场价格:</td>
  91. <td class="altbg2"><input name="normalPrice" size="25" type="text"></td>
  92. </tr><tr>
  93. <td class="altbg1">会员价格:</td>
  94. <td class="altbg2"><input name="memberPrice" size="25" type="text"></td>
  95. </tr>
  96. <tr>
  97. <td class="altbg1">所属类别</td>
  98. <td class="altbg2">
  99. <select name="categoryId">
  100. <%
  101. List<Category> categories = CategoryService.getInstance().getCategories();
  102. for(Iterator<Category> it = categories.iterator(); it.hasNext(); ) {
  103. Category c = it.next();
  104. String selected = "";
  105. if(c.getId() == categoryId) selected = "selected";
  106. String preStr = "";
  107. for(int i=1; i<c.getGrade(); i++) preStr += "--";
  108. %>
  109. <option value="<%=c.getId()%>|<%=c.getGrade()%>" <%=selected%>><%=preStr + c.getName()%></option>
  110. <%
  111. }
  112.  %>
  113. </select>
  114. </td>
  115. </tr>
  116. <tr>
  117. <td class="altbg1" valign="top">产品描述:</td>
  118. <td class="altbg2"><textarea name="descr" cols="60" rows="5" id="descr"></textarea></td>
  119. </tr>
  120. </tbody></table>
  121. <br>
  122. <center><input name="regsubmit" value="提 &nbsp; 交" type="submit"></center>
  123. </form>
  124. <script language="JavaScript">
  125. //document.register.username.focus();
  126. </script>
  127. </body></html>