LeaveWordAction.java~34~
上传用户:zghglow
上传日期:2022-08-09
资源大小:27227k
文件大小:8k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

JavaScript

  1. package com.chinacannel.xlchemical.struts.Action;
  2. import org.apache.struts.actions.DispatchAction;
  3. import com.chinacannel.xlchemical.service.LeaveWordService;
  4. import org.apache.struts.action.ActionForward;
  5. import javax.servlet.http.HttpServletRequest;
  6. import org.apache.struts.action.ActionMapping;
  7. import javax.servlet.http.HttpServletResponse;
  8. import org.apache.struts.action.ActionForm;
  9. import com.chinacannel.xlchemical.struts.ActionForm.LeaveWordActionForm;
  10. import com.chinacannel.entity.LeaveWord;
  11. import java.util.Date;
  12. import com.chinacannel.common.PageInfo;
  13. public class LeaveWordAction extends DispatchAction {
  14.     private LeaveWordService ls = new LeaveWordService();
  15.     public ActionForward AddLeaveWord(ActionMapping actionMapping,
  16.                                       ActionForm actionForm,
  17.                                       HttpServletRequest servletRequest,
  18.                                       HttpServletResponse servletResponse) {
  19.         LeaveWordActionForm lwf = (LeaveWordActionForm) actionForm;
  20.         LeaveWord lw = new LeaveWord();
  21.         String Language = "CN";
  22.         String Message = "";
  23.         boolean b = false;
  24.         try {
  25.             if (servletRequest.getSession().getAttribute("Language") != null) {
  26.                 Language = servletRequest.getSession().getAttribute("Language").
  27.                            toString();
  28.             }
  29.             ls.beginTran();
  30.             lw.setLea_Address(lwf.getAddress());
  31.             lw.setLea_Content(lwf.getContent());
  32.             lw.setLea_Email(lwf.getEmail());
  33.             lw.setLea_Host(lwf.getHost());
  34.             lw.setLea_Language(Language);
  35.             lw.setLea_Name(lwf.getName());
  36.             lw.setLea_QQ(lwf.getQq());
  37.             lw.setLea_Sex(lwf.getSex());
  38.             lw.setLea_Time(new Date());
  39.             lw.setLea_IP(servletRequest.getRemoteAddr());
  40.             b = ls.AddLeaveWord(lw);
  41.             ls.commit();
  42.         } catch (Exception ex) {
  43.             log.error(ex.getMessage(), ex);
  44.             try {
  45.                 ls.rollback();
  46.             } catch (Exception ex2) {
  47.                 log.error(ex2.getMessage(), ex2);
  48.             }
  49.         }
  50.         if (b == true) {
  51.             Message = "发表留言成功!";
  52.         } else {
  53.             Message = "发表留言失败!";
  54.         }
  55.         servletRequest.setAttribute("Url", "/Index.do?todo=ShowLeaveWord&fMenuID=" + servletRequest.getParameter("fMenuID"));
  56.         servletRequest.setAttribute("Message", Message);
  57.         return actionMapping.findForward("AddLeaveWord");
  58.     }
  59.     public ActionForward OpenLeaveWord(ActionMapping actionMapping,
  60.                                        ActionForm actionForm,
  61.                                        HttpServletRequest servletRequest,
  62.                                        HttpServletResponse servletResponse) {
  63.         String Language = "CN";
  64.         int pageNo = 0;
  65.         PageInfo pageInfo = null;
  66.         try {
  67.             pageNo = Integer.parseInt(servletRequest.getParameter("pageNo"));
  68.         } catch (Exception ex1) {}
  69.         try {
  70.             if (servletRequest.getSession().getAttribute("Language") != null) {
  71.                 Language = servletRequest.getSession().getAttribute("Language").
  72.                            toString();
  73.             }
  74.             ls.beginTran();
  75.             pageInfo = ls.getPageInfo(Language, "2", pageNo);
  76.             ls.commit();
  77.         } catch (Exception ex) {
  78.             log.error(ex.getMessage(), ex);
  79.             try {
  80.                 ls.rollback();
  81.             } catch (Exception ex2) {
  82.                 log.error(ex2.getMessage(), ex2);
  83.             }
  84.         }
  85.         servletRequest.setAttribute("pageInfo", pageInfo);
  86.         return actionMapping.findForward("OpenLeaveWord");
  87.     }
  88.     public ActionForward OpenLeaveWordInfo(ActionMapping actionMapping,
  89.                                            ActionForm actionForm,
  90.                                            HttpServletRequest servletRequest,
  91.                                            HttpServletResponse servletResponse) {
  92.         LeaveWord lw = null;
  93.         try {
  94.             ls.beginTran();
  95.             lw = ls.GetLeaveWordById
  96.                  (new Long(servletRequest.getParameter("LeaID")));
  97.             ls.commit();
  98.         } catch (Exception ex) {
  99.             log.error(ex.getMessage(), ex);
  100.             try {
  101.                 ls.rollback();
  102.             } catch (Exception ex2) {
  103.                 log.error(ex2.getMessage(), ex2);
  104.             }
  105.         }
  106.         servletRequest.setAttribute("lw", lw);
  107.         return actionMapping.findForward("OpenLeaveWordInfo");
  108.     }
  109.     public ActionForward ShowLeaveWord(ActionMapping actionMapping,
  110.                                        ActionForm actionForm,
  111.                                        HttpServletRequest servletRequest,
  112.                                        HttpServletResponse servletResponse) {
  113.         String Language = "CN";
  114.         int pageNo = 0;
  115.         PageInfo pageInfo = null;
  116.         try {
  117.             pageNo = Integer.parseInt(servletRequest.getParameter("pageNo"));
  118.         } catch (Exception ex1) {}
  119.         try {
  120.             if (servletRequest.getSession().getAttribute("Language") != null) {
  121.                 Language = servletRequest.getSession().getAttribute("Language").
  122.                            toString();
  123.             }
  124.             ls.beginTran();
  125.             pageInfo = ls.getPageInfo(Language, "1", pageNo);
  126.             ls.commit();
  127.         } catch (Exception ex) {
  128.             log.error(ex.getMessage(), ex);
  129.             try {
  130.                 ls.rollback();
  131.             } catch (Exception ex2) {
  132.                 log.error(ex2.getMessage(), ex2);
  133.             }
  134.         }
  135.         servletRequest.setAttribute("pageInfo", pageInfo);
  136.         return actionMapping.findForward("ShowLeaveWord");
  137.     }
  138.     public ActionForward RevertLeaveWord(ActionMapping actionMapping,
  139.                                          ActionForm actionForm,
  140.                                          HttpServletRequest servletRequest,
  141.                                          HttpServletResponse servletResponse) {
  142.         LeaveWord lw = null;
  143.         LeaveWordActionForm laf = (LeaveWordActionForm)actionForm;
  144.         boolean b = false;
  145.         String Message = "";
  146.         try {
  147.             ls.beginTran();
  148.             lw = ls.GetLeaveWordById
  149.                  (new Long(servletRequest.getParameter("LeaID")));
  150.             lw.setLea_Revert(laf.getRevert());
  151.             lw.setLea_RevertTime(new Date());
  152.             b = ls.UpdateLeaveWord(lw);
  153.             Message = "回复成功,请返回!";
  154.             ls.commit();
  155.         } catch (Exception ex) {
  156.             log.error(ex.getMessage(), ex);
  157.             try {
  158.                 ls.rollback();
  159.             } catch (Exception ex2) {
  160.                 log.error(ex2.getMessage(), ex2);
  161.             }
  162.         }
  163.         if (b == false) {
  164.             Message = "回复失败,请返回!";
  165.         }
  166.         servletRequest.setAttribute("Url",
  167.                                     "/Manage/LeaveWord.do?todo=OpenLeaveWord");
  168.         servletRequest.setAttribute("Message", Message);
  169.         return actionMapping.findForward("RevertLeaveWord");
  170.     }
  171.     public ActionForward DeleteLeaveWord(ActionMapping actionMapping,
  172.                                          ActionForm actionForm,
  173.                                          HttpServletRequest servletRequest,
  174.                                          HttpServletResponse servletResponse) {
  175.         Long LeaID = new Long(0);
  176.         LeaveWord lw = new LeaveWord();
  177.         boolean b = false;
  178.         String Message = "";
  179.         try {
  180.             if (servletRequest.getParameter("LeaID") != null) {
  181.                 LeaID = new Long(servletRequest.getParameter("LeaID"));
  182.             }
  183.             ls.beginTran();
  184.             lw = ls.GetLeaveWordById(LeaID);
  185.             b = ls.DeleteLeaveWord(lw);
  186.             Message = "删除成功,请返回!";
  187.             ls.commit();
  188.         } catch (Exception ex) {
  189.             log.error(ex.getMessage(), ex);
  190.             try {
  191.                 ls.rollback();
  192.             } catch (Exception ex2) {
  193.                 log.error(ex2.getMessage(), ex2);
  194.             }
  195.         }
  196.         if (b == false) {
  197.             Message = "删除失败,请返回!";
  198.         }
  199.         servletRequest.setAttribute("Message", Message);
  200.         servletRequest.setAttribute
  201.                 ("Url", "/Manage/LeaveWord.do?todo=OpenLeaveWord");
  202.         return actionMapping.findForward("DeleteLeaveWord");
  203.     }
  204. }