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

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.           if (Language.equals("CN")) {
  52.               Message = "发表留言成功!";
  53.           } else if (Language.equals("EN")){
  54.               Message = "Message delivered success!";
  55.           }
  56.         } else {
  57.             Message = "发表留言失败!";
  58.         }
  59.         servletRequest.setAttribute("Url", "/Index.do?todo=ShowLeaveWord&fMenuID=" + servletRequest.getParameter("fMenuID"));
  60.         servletRequest.setAttribute("Message", Message);
  61.         return actionMapping.findForward("AddLeaveWord");
  62.     }
  63.     public ActionForward OpenLeaveWord(ActionMapping actionMapping,
  64.                                        ActionForm actionForm,
  65.                                        HttpServletRequest servletRequest,
  66.                                        HttpServletResponse servletResponse) {
  67.         String Language = "CN";
  68.         int pageNo = 0;
  69.         PageInfo pageInfo = null;
  70.         try {
  71.             pageNo = Integer.parseInt(servletRequest.getParameter("pageNo"));
  72.         } catch (Exception ex1) {}
  73.         try {
  74.             if (servletRequest.getSession().getAttribute("Language") != null) {
  75.                 Language = servletRequest.getSession().getAttribute("Language").
  76.                            toString();
  77.             }
  78.             ls.beginTran();
  79.             pageInfo = ls.getPageInfo(Language, "2", pageNo);
  80.             ls.commit();
  81.         } catch (Exception ex) {
  82.             log.error(ex.getMessage(), ex);
  83.             try {
  84.                 ls.rollback();
  85.             } catch (Exception ex2) {
  86.                 log.error(ex2.getMessage(), ex2);
  87.             }
  88.         }
  89.         servletRequest.setAttribute("pageInfo", pageInfo);
  90.         return actionMapping.findForward("OpenLeaveWord");
  91.     }
  92.     public ActionForward OpenLeaveWordInfo(ActionMapping actionMapping,
  93.                                            ActionForm actionForm,
  94.                                            HttpServletRequest servletRequest,
  95.                                            HttpServletResponse servletResponse) {
  96.         LeaveWord lw = null;
  97.         try {
  98.             ls.beginTran();
  99.             lw = ls.GetLeaveWordById
  100.                  (new Long(servletRequest.getParameter("LeaID")));
  101.             ls.commit();
  102.         } catch (Exception ex) {
  103.             log.error(ex.getMessage(), ex);
  104.             try {
  105.                 ls.rollback();
  106.             } catch (Exception ex2) {
  107.                 log.error(ex2.getMessage(), ex2);
  108.             }
  109.         }
  110.         servletRequest.setAttribute("lw", lw);
  111.         return actionMapping.findForward("OpenLeaveWordInfo");
  112.     }
  113.     public ActionForward ShowLeaveWord(ActionMapping actionMapping,
  114.                                        ActionForm actionForm,
  115.                                        HttpServletRequest servletRequest,
  116.                                        HttpServletResponse servletResponse) {
  117.         String Language = "CN";
  118.         int pageNo = 0;
  119.         PageInfo pageInfo = null;
  120.         try {
  121.             pageNo = Integer.parseInt(servletRequest.getParameter("pageNo"));
  122.         } catch (Exception ex1) {}
  123.         try {
  124.             if (servletRequest.getSession().getAttribute("Language") != null) {
  125.                 Language = servletRequest.getSession().getAttribute("Language").
  126.                            toString();
  127.             }
  128.             ls.beginTran();
  129.             pageInfo = ls.getPageInfo(Language, "1", pageNo);
  130.             ls.commit();
  131.         } catch (Exception ex) {
  132.             log.error(ex.getMessage(), ex);
  133.             try {
  134.                 ls.rollback();
  135.             } catch (Exception ex2) {
  136.                 log.error(ex2.getMessage(), ex2);
  137.             }
  138.         }
  139.         servletRequest.setAttribute("pageInfo", pageInfo);
  140.         return actionMapping.findForward("ShowLeaveWord");
  141.     }
  142.     public ActionForward RevertLeaveWord(ActionMapping actionMapping,
  143.                                          ActionForm actionForm,
  144.                                          HttpServletRequest servletRequest,
  145.                                          HttpServletResponse servletResponse) {
  146.         LeaveWord lw = null;
  147.         LeaveWordActionForm laf = (LeaveWordActionForm)actionForm;
  148.         boolean b = false;
  149.         String Message = "";
  150.         try {
  151.             ls.beginTran();
  152.             lw = ls.GetLeaveWordById
  153.                  (new Long(servletRequest.getParameter("LeaID")));
  154.             lw.setLea_Revert(laf.getRevert());
  155.             lw.setLea_RevertTime(new Date());
  156.             b = ls.UpdateLeaveWord(lw);
  157.             Message = "回复成功,请返回!";
  158.             ls.commit();
  159.         } catch (Exception ex) {
  160.             log.error(ex.getMessage(), ex);
  161.             try {
  162.                 ls.rollback();
  163.             } catch (Exception ex2) {
  164.                 log.error(ex2.getMessage(), ex2);
  165.             }
  166.         }
  167.         if (b == false) {
  168.             Message = "回复失败,请返回!";
  169.         }
  170.         servletRequest.setAttribute("Url",
  171.                                     "/Manage/LeaveWord.do?todo=OpenLeaveWord");
  172.         servletRequest.setAttribute("Message", Message);
  173.         return actionMapping.findForward("RevertLeaveWord");
  174.     }
  175.     public ActionForward DeleteLeaveWord(ActionMapping actionMapping,
  176.                                          ActionForm actionForm,
  177.                                          HttpServletRequest servletRequest,
  178.                                          HttpServletResponse servletResponse) {
  179.         Long LeaID = new Long(0);
  180.         LeaveWord lw = new LeaveWord();
  181.         boolean b = false;
  182.         String Message = "";
  183.         try {
  184.             if (servletRequest.getParameter("LeaID") != null) {
  185.                 LeaID = new Long(servletRequest.getParameter("LeaID"));
  186.             }
  187.             ls.beginTran();
  188.             lw = ls.GetLeaveWordById(LeaID);
  189.             b = ls.DeleteLeaveWord(lw);
  190.             Message = "删除成功,请返回!";
  191.             ls.commit();
  192.         } catch (Exception ex) {
  193.             log.error(ex.getMessage(), ex);
  194.             try {
  195.                 ls.rollback();
  196.             } catch (Exception ex2) {
  197.                 log.error(ex2.getMessage(), ex2);
  198.             }
  199.         }
  200.         if (b == false) {
  201.             Message = "删除失败,请返回!";
  202.         }
  203.         servletRequest.setAttribute("Message", Message);
  204.         servletRequest.setAttribute
  205.                 ("Url", "/Manage/LeaveWord.do?todo=OpenLeaveWord");
  206.         return actionMapping.findForward("DeleteLeaveWord");
  207.     }
  208. }