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