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

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.meet.struts.action;
  4. import java.io.IOException;
  5. import java.io.PrintWriter;
  6. import java.lang.reflect.InvocationTargetException;
  7. import java.util.List;
  8. import javax.servlet.http.HttpServletRequest;
  9. import javax.servlet.http.HttpServletResponse;
  10. import org.apache.commons.beanutils.BeanUtils;
  11. import org.apache.struts.action.ActionErrors;
  12. import org.apache.struts.action.ActionForm;
  13. import org.apache.struts.action.ActionForward;
  14. import org.apache.struts.action.ActionMapping;
  15. import org.apache.struts.action.ActionMessage;
  16. import org.apache.struts.actions.DispatchAction;
  17. import com.oa.module.meet.hibernate.Tmeetroom;
  18. import com.oa.module.meet.meetroomdao.MeetRoomInterfer;
  19. import com.oa.module.meet.struts.form.MeetroomForm;
  20. import com.oa.module.pub.ectomere.XPage;
  21. /**
  22.  * MyEclipse Struts Creation date: 01-19-2008
  23.  * 
  24.  * XDoclet definition:
  25.  * 
  26.  * @struts.action path="/meetroom" name="meetroomForm" parameter="task"
  27.  *                scope="request" validate="true"
  28.  */
  29. public class MeetroomAction extends DispatchAction {
  30. // --------------------------------------------------------- Instance
  31. // Variables
  32. private MeetRoomInterfer meetroominter;
  33. // --------------------------------------------------------- Methods
  34. /**
  35.  * Method execute
  36.  * 
  37.  * @param mapping
  38.  * @param form
  39.  * @param request
  40.  * @param response
  41.  * @return ActionForward
  42.  */
  43. public ActionForward query(ActionMapping mapping, ActionForm form,
  44. HttpServletRequest request, HttpServletResponse response) {
  45. MeetroomForm meetroomForm = (MeetroomForm) form;
  46. int currentPage = 1;
  47. try {
  48. currentPage = Integer.parseInt(request.getParameter("currentPage"));
  49. } catch (Exception e) {
  50. currentPage = 1;
  51. }
  52. int count = 5;
  53. Tmeetroom info = new Tmeetroom();
  54. // 拷贝查询参数
  55. try {
  56. BeanUtils.copyProperties(info, meetroomForm);
  57. } catch (IllegalAccessException e) {
  58. // TODO Auto-generated catch block
  59. e.printStackTrace();
  60. } catch (InvocationTargetException e) {
  61. // TODO Auto-generated catch block
  62. e.printStackTrace();
  63. }
  64. XPage meetroompage = meetroominter.getItemlist(currentPage, count, info);
  65. request.setAttribute("meetroomtpage", meetroompage);
  66. return mapping.findForward("roomlist");
  67. }
  68. public ActionForward addlist(ActionMapping mapping, ActionForm form,
  69. HttpServletRequest request, HttpServletResponse response) {
  70. MeetroomForm meetroomForm = (MeetroomForm) form;
  71. List addrlist = meetroominter.addrlist();
  72. request.setAttribute("addrlist",addrlist);
  73. meetroomForm.setTask("add");
  74. return mapping.getInputForward();
  75. }
  76. public ActionForward add(ActionMapping mapping, ActionForm form,
  77. HttpServletRequest request, HttpServletResponse response) {
  78. MeetroomForm meetroomForm = (MeetroomForm) form;
  79. Tmeetroom room = new Tmeetroom();
  80. try {
  81. BeanUtils.copyProperties(room,meetroomForm);
  82. } catch (IllegalAccessException e) {
  83. // TODO 自动生成 catch 块
  84. e.printStackTrace();
  85. } catch (InvocationTargetException e) {
  86. // TODO 自动生成 catch 块
  87. e.printStackTrace();
  88. }
  89. boolean flag = meetroominter.great(room);
  90. if (flag) {
  91. request.setAttribute("msg", "添加成功");
  92. return new ActionForward("/meetroom.do?task=query", true);
  93. } else {
  94. request.setAttribute("msg", "添加失败");
  95. return mapping.getInputForward();
  96. }
  97. }
  98. public ActionForward init(ActionMapping mapping, ActionForm form,
  99. HttpServletRequest request, HttpServletResponse response) {
  100. MeetroomForm meetroomForm = (MeetroomForm) form;
  101. Tmeetroom room = meetroominter.getlistroom(meetroomForm.getRmid());
  102. try {
  103. BeanUtils.copyProperties(meetroomForm,room);
  104. } catch (IllegalAccessException e) {
  105. // TODO 自动生成 catch 块
  106. e.printStackTrace();
  107. } catch (InvocationTargetException e) {
  108. // TODO 自动生成 catch 块
  109. e.printStackTrace();
  110. }
  111. List addrlist = meetroominter.addrlist();
  112. request.setAttribute("addrlist",addrlist);
  113. meetroomForm.setTask("edit");
  114. return mapping.getInputForward();
  115. }
  116. public ActionForward edit(ActionMapping mapping, ActionForm form,
  117. HttpServletRequest request, HttpServletResponse response) {
  118. MeetroomForm meetroomForm = (MeetroomForm) form;
  119. Tmeetroom room = new Tmeetroom();
  120. try {
  121. BeanUtils.copyProperties(room,meetroomForm);
  122. } catch (IllegalAccessException e) {
  123. // TODO 自动生成 catch 块
  124. e.printStackTrace();
  125. } catch (InvocationTargetException e) {
  126. // TODO 自动生成 catch 块
  127. e.printStackTrace();
  128. }
  129. boolean flag = meetroominter.update(room);
  130. if (flag) {
  131. request.setAttribute("msg", "修改成功");
  132. return new ActionForward("/meetroom.do?task=query", true);
  133. } else {
  134. request.setAttribute("msg", "修改失败");
  135. return mapping.getInputForward();
  136. }
  137. }
  138. /**
  139.  * 冻结会议室
  140.  * @param mapping
  141.  * @param form
  142.  * @param request
  143.  * @param response
  144.  * @return
  145.  */
  146. public ActionForward support(ActionMapping mapping, ActionForm form,
  147. HttpServletRequest request, HttpServletResponse response) {
  148. MeetroomForm meetroomForm = (MeetroomForm) form;
  149. meetroomForm.setRstate(2);
  150. Tmeetroom room = new Tmeetroom();
  151. room.setRmid(meetroomForm.getRmid());
  152. room.setRaddress(meetroomForm.getRaddress());
  153. room.setRmemo(meetroomForm.getRmemo());
  154. room.setRname(meetroomForm.getRname());
  155. room.setRnumber(meetroomForm.getRnumber());
  156. try {
  157. BeanUtils.copyProperties(room,meetroomForm);
  158. } catch (IllegalAccessException e) {
  159. // TODO 自动生成 catch 块
  160. e.printStackTrace();
  161. } catch (InvocationTargetException e) {
  162. // TODO 自动生成 catch 块
  163. e.printStackTrace();
  164. }
  165. boolean flag = meetroominter.updatestats(room);
  166. if (flag) {
  167. request.setAttribute("msg", "冻结成功");
  168. return new ActionForward("/meetroom.do?task=query", true);
  169. } else {
  170. return null;
  171. }
  172. }
  173. /**
  174.  * 激活会议室
  175.  * @param mapping
  176.  * @param form
  177.  * @param request
  178.  * @param response
  179.  * @return
  180.  */
  181. public ActionForward life(ActionMapping mapping, ActionForm form,
  182. HttpServletRequest request, HttpServletResponse response) {
  183. MeetroomForm meetroomForm = (MeetroomForm) form;
  184. meetroomForm.setRstate(0);
  185. Tmeetroom room = new Tmeetroom();
  186. room.setRmid(meetroomForm.getRmid());
  187. boolean flag = meetroominter.updatestats2(room);
  188. if (flag) {
  189. request.setAttribute("msg", "激活成功");
  190. return new ActionForward("/meetroom.do?task=query", true);
  191. } else {
  192. return null;
  193. }
  194. }
  195. public ActionForward checkname(ActionMapping mapping, ActionForm form,
  196. HttpServletRequest request, HttpServletResponse response) {
  197. MeetroomForm meetroomForm = (MeetroomForm) form;
  198. String name = request.getParameter("name");
  199. PrintWriter out=null;
  200. try {
  201. out=response.getWriter();
  202. } catch (IOException e) {
  203. e.printStackTrace();
  204. }
  205. boolean flag=meetroominter.selectname(name);
  206. if(flag){
  207. out.print("这个会议名称已存在...");
  208. }
  209. return null;
  210. }
  211. public MeetRoomInterfer getMeetroominter() {
  212. return meetroominter;
  213. }
  214. public void setMeetroominter(MeetRoomInterfer meetroominter) {
  215. this.meetroominter = meetroominter;
  216. }
  217. }