LeaveWordAction.java~38~
资源名称:shihua.rar [点击查看]
上传用户:zghglow
上传日期:2022-08-09
资源大小:27227k
文件大小:9k
源码类别:
WEB源码(ASP,PHP,...)
开发平台:
JavaScript
- package com.chinacannel.xlchemical.struts.Action;
- import org.apache.struts.actions.DispatchAction;
- import com.chinacannel.xlchemical.service.LeaveWordService;
- import org.apache.struts.action.ActionForward;
- import javax.servlet.http.HttpServletRequest;
- import org.apache.struts.action.ActionMapping;
- import javax.servlet.http.HttpServletResponse;
- import org.apache.struts.action.ActionForm;
- import com.chinacannel.xlchemical.struts.ActionForm.LeaveWordActionForm;
- import com.chinacannel.entity.LeaveWord;
- import java.util.Date;
- import com.chinacannel.common.PageInfo;
- public class LeaveWordAction extends DispatchAction {
- private LeaveWordService ls = new LeaveWordService();
- public ActionForward AddLeaveWord(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- LeaveWordActionForm lwf = (LeaveWordActionForm) actionForm;
- LeaveWord lw = new LeaveWord();
- String Language = "CN";
- String Message = "";
- boolean b = false;
- try {
- if (servletRequest.getSession().getAttribute("Language") != null) {
- Language = servletRequest.getSession().getAttribute("Language").
- toString();
- }
- ls.beginTran();
- lw.setLea_Address(lwf.getAddress());
- lw.setLea_Content(lwf.getContent());
- lw.setLea_Email(lwf.getEmail());
- lw.setLea_Host(lwf.getHost());
- lw.setLea_Language(Language);
- lw.setLea_Name(lwf.getName());
- lw.setLea_QQ(lwf.getQq());
- lw.setLea_Sex(lwf.getSex());
- lw.setLea_Time(new Date());
- lw.setLea_IP(servletRequest.getRemoteAddr());
- b = ls.AddLeaveWord(lw);
- ls.commit();
- } catch (Exception ex) {
- log.error(ex.getMessage(), ex);
- try {
- ls.rollback();
- } catch (Exception ex2) {
- log.error(ex2.getMessage(), ex2);
- }
- }
- if (b == true) {
- if (Language.equals("CN")) {
- Message = "发表留言成功!";
- } else {
- Message = "发表留言成功!";
- }
- } else {
- Message = "发表留言失败!";
- }
- servletRequest.setAttribute("Url", "/Index.do?todo=ShowLeaveWord&fMenuID=" + servletRequest.getParameter("fMenuID"));
- servletRequest.setAttribute("Message", Message);
- return actionMapping.findForward("AddLeaveWord");
- }
- public ActionForward OpenLeaveWord(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- String Language = "CN";
- int pageNo = 0;
- PageInfo pageInfo = null;
- try {
- pageNo = Integer.parseInt(servletRequest.getParameter("pageNo"));
- } catch (Exception ex1) {}
- try {
- if (servletRequest.getSession().getAttribute("Language") != null) {
- Language = servletRequest.getSession().getAttribute("Language").
- toString();
- }
- ls.beginTran();
- pageInfo = ls.getPageInfo(Language, "2", pageNo);
- ls.commit();
- } catch (Exception ex) {
- log.error(ex.getMessage(), ex);
- try {
- ls.rollback();
- } catch (Exception ex2) {
- log.error(ex2.getMessage(), ex2);
- }
- }
- servletRequest.setAttribute("pageInfo", pageInfo);
- return actionMapping.findForward("OpenLeaveWord");
- }
- public ActionForward OpenLeaveWordInfo(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- LeaveWord lw = null;
- try {
- ls.beginTran();
- lw = ls.GetLeaveWordById
- (new Long(servletRequest.getParameter("LeaID")));
- ls.commit();
- } catch (Exception ex) {
- log.error(ex.getMessage(), ex);
- try {
- ls.rollback();
- } catch (Exception ex2) {
- log.error(ex2.getMessage(), ex2);
- }
- }
- servletRequest.setAttribute("lw", lw);
- return actionMapping.findForward("OpenLeaveWordInfo");
- }
- public ActionForward ShowLeaveWord(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- String Language = "CN";
- int pageNo = 0;
- PageInfo pageInfo = null;
- try {
- pageNo = Integer.parseInt(servletRequest.getParameter("pageNo"));
- } catch (Exception ex1) {}
- try {
- if (servletRequest.getSession().getAttribute("Language") != null) {
- Language = servletRequest.getSession().getAttribute("Language").
- toString();
- }
- ls.beginTran();
- pageInfo = ls.getPageInfo(Language, "1", pageNo);
- ls.commit();
- } catch (Exception ex) {
- log.error(ex.getMessage(), ex);
- try {
- ls.rollback();
- } catch (Exception ex2) {
- log.error(ex2.getMessage(), ex2);
- }
- }
- servletRequest.setAttribute("pageInfo", pageInfo);
- return actionMapping.findForward("ShowLeaveWord");
- }
- public ActionForward RevertLeaveWord(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- LeaveWord lw = null;
- LeaveWordActionForm laf = (LeaveWordActionForm)actionForm;
- boolean b = false;
- String Message = "";
- try {
- ls.beginTran();
- lw = ls.GetLeaveWordById
- (new Long(servletRequest.getParameter("LeaID")));
- lw.setLea_Revert(laf.getRevert());
- lw.setLea_RevertTime(new Date());
- b = ls.UpdateLeaveWord(lw);
- Message = "回复成功,请返回!";
- ls.commit();
- } catch (Exception ex) {
- log.error(ex.getMessage(), ex);
- try {
- ls.rollback();
- } catch (Exception ex2) {
- log.error(ex2.getMessage(), ex2);
- }
- }
- if (b == false) {
- Message = "回复失败,请返回!";
- }
- servletRequest.setAttribute("Url",
- "/Manage/LeaveWord.do?todo=OpenLeaveWord");
- servletRequest.setAttribute("Message", Message);
- return actionMapping.findForward("RevertLeaveWord");
- }
- public ActionForward DeleteLeaveWord(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- Long LeaID = new Long(0);
- LeaveWord lw = new LeaveWord();
- boolean b = false;
- String Message = "";
- try {
- if (servletRequest.getParameter("LeaID") != null) {
- LeaID = new Long(servletRequest.getParameter("LeaID"));
- }
- ls.beginTran();
- lw = ls.GetLeaveWordById(LeaID);
- b = ls.DeleteLeaveWord(lw);
- Message = "删除成功,请返回!";
- ls.commit();
- } catch (Exception ex) {
- log.error(ex.getMessage(), ex);
- try {
- ls.rollback();
- } catch (Exception ex2) {
- log.error(ex2.getMessage(), ex2);
- }
- }
- if (b == false) {
- Message = "删除失败,请返回!";
- }
- servletRequest.setAttribute("Message", Message);
- servletRequest.setAttribute
- ("Url", "/Manage/LeaveWord.do?todo=OpenLeaveWord");
- return actionMapping.findForward("DeleteLeaveWord");
- }
- }