VIPCard_add.jsp
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:8k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html; charset=utf-8" %>
  2. <%@ page import="java.util.*"%>
  3. <%@ page import="cn.js.fan.db.Conn"%>
  4. <%@ page import="cn.js.fan.util.*"%>
  5. <%@ page import="com.redmoon.forum.plugin.*"%>
  6. <%@ page import="com.redmoon.forum.plugin.entrance.*"%>
  7. <%@ page import="com.redmoon.forum.*"%>
  8. <%@ page import="com.redmoon.forum.person.*"%>
  9. <jsp:useBean id="StrUtil" scope="page" class="cn.js.fan.util.StrUtil"/>
  10. <html><head>
  11. <meta http-equiv="pragma" content="no-cache">
  12. <link rel="stylesheet" href="../../common.css">
  13. <LINK href="default.css" type=text/css rel=stylesheet>
  14. <meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>付费用户管理管理</title>
  17. <script>
  18. function findObj(theObj, theDoc)
  19. {
  20.   var p, i, foundObj;
  21.   
  22.   if(!theDoc) theDoc = document;
  23.   if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  24.   {
  25.     theDoc = parent.frames[theObj.substring(p+1)].document;
  26.     theObj = theObj.substring(0,p);
  27.   }
  28.   if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  29.   for (i=0; !foundObj && i < theDoc.forms.length; i++) 
  30.     foundObj = theDoc.forms[i][theObj];
  31.   for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
  32.     foundObj = findObj(theObj,theDoc.layers[i].document);
  33.   if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  34.   
  35.   return foundObj;
  36. }
  37. var GetDate=""; 
  38. function SelectDate(ObjName,FormatDate) {
  39. var PostAtt = new Array;
  40. PostAtt[0]= FormatDate;
  41. PostAtt[1]= findObj(ObjName);
  42. GetDate = showModalDialog("../../util/calendar/calendar.htm", PostAtt ,"dialogWidth:286px;dialogHeight:221px;status:no;help:no;");
  43. }
  44. function SetDate()
  45. findObj(ObjName).value = GetDate; 
  46. function openWinKinds() {
  47. var ret = showModalDialog('VIPCard_dir_sel_multi.jsp',window.self,'dialogWidth:480px;dialogHeight:320px;status:no;help:no;')
  48. if (ret==null)
  49. return;
  50. form1.kindNames.value = "";
  51. form1.kind.value = "";
  52. for (var i=0; i<ret.length; i++) {
  53. if (form1.kindNames.value=="") {
  54. form1.kind.value += ret[i][0];
  55. form1.kindNames.value += ret[i][1];
  56. }
  57. else {
  58. form1.kind.value += "," + ret[i][0];
  59. form1.kindNames.value += "," + ret[i][1];
  60. }
  61. }
  62. }
  63. function getLeaves() {
  64. return form1.kind.value;
  65. }
  66. function setFee(fee) {
  67. form1.fee.value = fee;
  68. }
  69. function getFee() {
  70. if (form1.fee.value=="")
  71. return 0.0;
  72. else
  73. return form1.fee.value;
  74. }
  75. </script>
  76. <body bgcolor="#FFFFFF" topmargin='0' leftmargin='0'>
  77. <jsp:useBean id="privilege" scope="page" class="cn.js.fan.module.pvg.Privilege"/>
  78. <table width='100%' cellpadding='0' cellspacing='0' >
  79.   <tr>
  80.     <td class="head">管理付费用户</td>
  81.   </tr>
  82. </table>
  83. <br>
  84. <table width="98%" height="227" border='0' align="center" cellpadding='0' cellspacing='0' class="frame_gray">
  85.   <tr> 
  86.     <td height=20 align="left" class="thead"> 添加付费用户 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="entranceVIPTeach.jsp">入口管理</a></td>
  87.   </tr>
  88.   <tr> 
  89.     <td valign="top">
  90. <%
  91. if (!privilege.isUserPrivValid(request, "forum.plugin"))
  92. {
  93. out.print(cn.js.fan.web.SkinUtil.makeErrMsg(request, cn.js.fan.web.SkinUtil.LoadString(request, "pvg_invalid")));
  94. return;
  95. }
  96. String op = ParamUtil.get(request, "op");
  97. VIPCardDb vtu = new VIPCardDb();
  98. if (op.equals("add")) {
  99. String userName = ParamUtil.get(request, "userName").trim();
  100. String errMsg = "";
  101. if (userName.equals("")) {
  102. // errMsg += "用户名不能为空!\r\n";
  103. }
  104. else {
  105. // 检查用户在论坛中是否存在
  106. UserDb ud = new UserDb();
  107. ud = ud.getUser(userName);
  108. if (!ud.isLoaded())
  109. errMsg += "用户不存在!\r\n";
  110. else if (!ud.isValid())
  111. errMsg += "该用户帐号已被禁止!\r\n";
  112. }
  113. String id = ParamUtil.get(request, "id");
  114. if (id.equals("") || !StrUtil.isNumeric(id))
  115. errMsg += "卡号不能为空且必须为数字!\r\n";
  116. String pwd = ParamUtil.get(request, "pwd").trim();
  117. if (pwd.equals(""))
  118. errMsg += "密码不能为空!\r\n";
  119. double fee = 0;
  120. String kind="",bDate,eDate;
  121. Date beginDate=null,endDate=null;
  122. boolean isValid = false;
  123. try {
  124. fee = ParamUtil.getDouble(request, "fee");
  125. String[] kindary = ParamUtil.getParameters(request, "kind");
  126. if (kindary==null)
  127. errMsg += "对不起,您必须选择至少一项类别!\r\n";
  128. else {
  129. int klen = kindary.length;
  130. for (int k=0; k<klen; k++) {
  131. if (kind.equals(""))
  132. kind = kindary[k];
  133. else
  134. kind += "|" + kindary[k];
  135. }
  136. }
  137. bDate = ParamUtil.get(request, "beginDate");
  138. eDate = ParamUtil.get(request, "endDate");
  139. beginDate = DateUtil.parse(bDate, "yyyy-MM-dd");
  140. endDate = DateUtil.parse(eDate, "yyyy-MM-dd");
  141. isValid = ParamUtil.getBoolean(request, "isValid", false);
  142. }
  143. catch (Exception e) {
  144. errMsg += e.getMessage() + "\r\n";
  145. }
  146. if (beginDate==null || endDate==null)
  147. errMsg += "开始和结束日期不能为空!";
  148. if (!errMsg.equals("")) {
  149. out.print(StrUtil.Alert(errMsg));
  150. }
  151. else {
  152. vtu.setUserName(userName);
  153. vtu.setFee(fee);
  154. vtu.setBeginDate(beginDate);
  155. vtu.setEndDate(endDate);
  156. vtu.setKind(kind);
  157. vtu.setId(id);
  158. vtu.setPwd(pwd);
  159. vtu.setValid(isValid);
  160. if (vtu.create())
  161. out.print(StrUtil.p_center("<BR>添加成功!您现在可以继续添加学习卡!"));
  162. else
  163. out.print(StrUtil.Alert("添加失败!"));
  164. }
  165. }
  166. %>
  167. <br>
  168.       <br>
  169.       <table width="38%"  border="0" align="center" cellpadding="5" class="tableframe_gray">
  170.         <form name="form1" method="post" action="?op=add">
  171.         <tr>
  172.           <td align="center">卡&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号</td>
  173.           <td align="left"><input name="id" type="hidden" id="id" value="<%=vtu.getNextID()%>"><%=vtu.getNextID()%></td>
  174.         </tr>
  175.         <tr>
  176.           <td align="center">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码</td>
  177.           <td align="left"><input name="pwd" type="text" id="pwd" value="<%=RandomSecquenceCreator.getId(8)%>"></td>
  178.         </tr>
  179.         <tr>
  180.           <td align="center">用&nbsp;&nbsp;户&nbsp;&nbsp;名</td>
  181.           <td align="left"><label>
  182.             <input name="userName" type="text" id="userName">
  183.           </label></td>
  184.         </tr>
  185.         <tr>
  186.           <td width="29%" align="center">开始时间</td>
  187.           <td width="71%" align="left"><input name="beginDate" size=10 readonly value="">
  188.             &nbsp;<img src="../../util/calendar/calendar.gif" align=absMiddle style="cursor:hand" onClick="SelectDate('beginDate','yyyy-mm-dd')"></td>
  189.         </tr>
  190.         <tr>
  191.           <td align="center">到期时间</td>
  192.           <td align="left"><input name="endDate" size=10 readonly>
  193.             &nbsp;<img src="../../util/calendar/calendar.gif" align=absMiddle style="cursor:hand" onClick="SelectDate('endDate','yyyy-mm-dd')"></td>
  194.         </tr>
  195.         
  196.         <tr>
  197.           <td align="center">费用共计</td>
  198.           <td align="left"><input name="fee" type="text" id="fee" size="10">
  199.             <label>
  200.             &nbsp;元&nbsp;&nbsp;&nbsp;</label></td>
  201.         </tr>
  202.         <tr>
  203.           <td align="center">目&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;录</td>
  204.           <td align="left"><label>
  205.           <input type="hidden" name="kind">
  206.           <textarea name="kindNames" cols="45" rows="3" readOnly wrap="yes" id="kindNames"></textarea>
  207.             <input class="SmallButton" title="添加部门" onClick="openWinKinds()" type="button" value="选择目录" name="button">
  208.             </label></td>
  209.         </tr>
  210.         <tr>
  211.           <td align="center">是否有效</td>
  212.           <td align="left"><input type=checkbox name="isValid" value="true"></td>
  213.         </tr>
  214.         <tr>
  215.           <td colspan="2" align="center"><input type="submit" name="Submit" value="确定">
  216. &nbsp;&nbsp;&nbsp;&nbsp;            &nbsp;
  217. <input type="reset" name="Submit2" value="重写"></td>
  218.         </tr>
  219.       </form>
  220.       </table>
  221.       <br></td>
  222.   </tr>
  223. </table>
  224. </td> </tr>             
  225.       </table>                                        
  226.        </td>                                        
  227.      </tr>                                        
  228.  </table>                                        
  229.                                
  230. </body>                                        
  231. </html>                            
  232.