SystemAction.java
上传用户:lm2018
上传日期:2015-12-12
资源大小:30449k
文件大小:6k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. //Created by MyEclipse Struts
  2. // XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.0/xslt/JavaClass.xsl
  3. package com.oa.module.system;
  4. import java.io.IOException;
  5. import java.io.PrintWriter;
  6. import java.util.List;
  7. import javax.servlet.http.HttpServletRequest;
  8. import javax.servlet.http.HttpServletResponse;
  9. import org.apache.struts.action.ActionForm;
  10. import org.apache.struts.action.ActionForward;
  11. import org.apache.struts.action.ActionMapping;
  12. import org.apache.struts.actions.DispatchAction;
  13. import com.oa.module.system.SystemForm;
  14. /** 
  15.  * MyEclipse Struts
  16.  * Creation date: 01-20-2008
  17.  * 
  18.  * XDoclet definition:
  19.  * @struts.action path="/system" name="systemForm" parameter="task" scope="request" validate="true"
  20.  */
  21. public class SystemAction extends DispatchAction {
  22. // --------------------------------------------------------- Instance Variables
  23. public SystemDAO systemdao;
  24. // --------------------------------------------------------- Methods
  25. public SystemDAO getSystemdao() {
  26. return systemdao;
  27. }
  28. public void setSystemdao(SystemDAO systemdao) {
  29. this.systemdao = systemdao;
  30. }
  31. /** 
  32.  * Method execute
  33.  * @param mapping
  34.  * @param form
  35.  * @param request
  36.  * @param response
  37.  * @return ActionForward
  38.  */
  39. //更新页面
  40. public ActionForward query(ActionMapping mapping, ActionForm form,
  41. HttpServletRequest request, HttpServletResponse response) {
  42. SystemForm systemForm = (SystemForm) form;
  43. List typelist = null;
  44. List paramlist = null;
  45. typelist = systemdao.gettype();
  46. paramlist = systemdao.getparam();
  47. request.setAttribute("typelist", typelist);
  48. request.setAttribute("paramlist", paramlist);
  49. return mapping.findForward("list");
  50. }
  51. //添加类别
  52. public ActionForward savetype(ActionMapping mapping, ActionForm form,
  53. HttpServletRequest request, HttpServletResponse response) {
  54. SystemForm systemForm = (SystemForm) form;
  55. String tname = systemForm.getTname();
  56. String tmemo = systemForm.getTmemo();
  57. //验证类别是否存在
  58. boolean check=systemdao.checktype(tname);
  59. if(check){
  60. request.setAttribute("msg","类别名已存在");
  61. return mapping.findForward("query");
  62. }else{
  63. boolean flag = systemdao.addtype(tname, tmemo);
  64. if (flag) {
  65. request.setAttribute("msg", "添加参数类别成功");
  66. return mapping.findForward("query");
  67. } else {
  68. request.setAttribute("msg", "添加参数类别失败");
  69. return mapping.findForward("query");
  70. }
  71. }
  72. }
  73. //添加参数
  74. public ActionForward saveparam(ActionMapping mapping, ActionForm form,
  75. HttpServletRequest request, HttpServletResponse response){
  76. SystemForm systemForm = (SystemForm) form;
  77. long tid = systemForm.getTid();
  78. System.out.println(systemForm.getTid());
  79. String pname = systemForm.getPname();
  80. String pmemo = systemForm.getPmemo();
  81. //验证参数是否存在
  82. boolean check=systemdao.checkparam(pname);
  83. if(check){
  84. request.setAttribute("msg","参数名已存在");
  85. return mapping.findForward("query");
  86. }else{
  87. boolean flag = systemdao.addparam(tid, pname, pmemo);
  88. if (flag) {
  89. request.setAttribute("msg", "添加参数成功");
  90. return mapping.findForward("query");
  91. } else {
  92. request.setAttribute("msg", "添加参数失败");
  93. return mapping.findForward("query");
  94. }
  95. }
  96. }
  97. //删除参数类别
  98. public ActionForward deltype(ActionMapping mapping, ActionForm form,
  99. HttpServletRequest request, HttpServletResponse response) {
  100. SystemForm systemForm = (SystemForm) form;
  101. long tid = systemForm.getTid();
  102. System.out.println(systemForm.getTid());
  103. boolean flag = systemdao.deltype(tid);
  104. if (flag) {
  105. request.setAttribute("msg", "删除参数类别成功");
  106. return mapping.findForward("query");
  107. } else {
  108. request.setAttribute("msg", "删除参数类别失败");
  109. return mapping.findForward("query");
  110. }
  111. }
  112. //删除参数
  113. public ActionForward delparam(ActionMapping mapping, ActionForm form,
  114. HttpServletRequest request, HttpServletResponse response) {
  115. SystemForm systemForm = (SystemForm) form;
  116. long pid = systemForm.getPid();
  117. boolean flag = systemdao.delparam(pid);
  118. if (flag) {
  119. request.setAttribute("msg", "删除参数成功");
  120. return mapping.findForward("query");
  121. } else {
  122. request.setAttribute("msg", "删除参数失败");
  123. return mapping.findForward("query");
  124. }
  125. }
  126. //修改参数类别
  127. public ActionForward edittype(ActionMapping mapping, ActionForm form,
  128. HttpServletRequest request, HttpServletResponse response) {
  129. SystemForm systemForm = (SystemForm) form;
  130. long tid=systemForm.getTid();
  131. System.out.println(tid);
  132. String tname=systemForm.getTname();
  133. System.out.println(tname);
  134. String tmemo=systemForm.getTmemo();
  135. System.out.println(tmemo);
  136. //验证类别是否存在
  137. boolean check=systemdao.checktype(tname);
  138. if(check){
  139. request.setAttribute("msg","类别名已存在");
  140. return mapping.findForward("query");
  141. }else{
  142. boolean flag =systemdao.edittype(tid,tname,tmemo);
  143. if (flag) {
  144. request.setAttribute("msg", "修改参数类别成功");
  145. return mapping.findForward("query");
  146. } else {
  147. request.setAttribute("msg", "修改参数类别失败");
  148. return mapping.findForward("query");
  149. }
  150. }
  151. }
  152. //修改参数
  153. public ActionForward editparam(ActionMapping mapping, ActionForm form,
  154. HttpServletRequest request, HttpServletResponse response) {
  155. SystemForm systemForm = (SystemForm) form;
  156. long tid=systemForm.getTid();
  157. long pid = systemForm.getPid();
  158. String pname=systemForm.getPname();
  159. String pmemo=systemForm.getPmemo();
  160. //验证参数是否存在
  161. boolean check=systemdao.checkparam(pname);
  162. if(check){
  163. request.setAttribute("msg","参数名已存在");
  164. return mapping.findForward("query");
  165. }else{
  166. boolean flag = systemdao.editparam(tid,pid,pname,pmemo);
  167. if (flag) {
  168. request.setAttribute("msg", "修改参数成功");
  169. return mapping.findForward("query");
  170. } else {
  171. request.setAttribute("msg", "修改参数失败");
  172. return mapping.findForward("query");
  173. }
  174. }
  175. }
  176. }