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