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

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

开发平台:

JavaScript

  1. package com.chinacannel.xlchemical.struts.Action;
  2. import org.apache.struts.actions.DispatchAction;
  3. import org.apache.struts.action.ActionForward;
  4. import javax.servlet.http.HttpServletRequest;
  5. import org.apache.struts.action.ActionMapping;
  6. import javax.servlet.http.HttpServletResponse;
  7. import org.apache.struts.action.ActionForm;
  8. import com.chinacannel.xlchemical.service.JobsService;
  9. import com.chinacannel.common.PageInfo;
  10. import com.chinacannel.xlchemical.struts.ActionForm.JobsActionForm;
  11. import com.chinacannel.entity.Jobs;
  12. import java.util.Date;
  13. public class JobsAction extends DispatchAction {
  14.     private JobsService js = new JobsService();
  15.     public ActionForward EditJobs(ActionMapping actionMapping,
  16.                                   ActionForm actionForm,
  17.                                   HttpServletRequest servletRequest,
  18.                                   HttpServletResponse servletResponse) {
  19.         JobsActionForm jaf = (JobsActionForm) actionForm;
  20.         Jobs jobs = new Jobs();
  21.         String Language = "CN";
  22.         boolean b = false;
  23.         String Message = "";
  24.         try {
  25.             if (servletRequest.getSession().getAttribute("Language") != null) {
  26.                 Language = servletRequest.getSession().getAttribute("Language").
  27.                            toString();
  28.             }
  29.             js.beginTran();
  30.             if (!jaf.getId().equals(new Long(0))) {
  31.                 jobs = js.GetJobsById(jaf.getId());
  32.             }
  33.             jobs.setJob_Address(jaf.getAddress());
  34.             jobs.setJob_Branch(jaf.getBranch());
  35.             jobs.setJob_Count(jaf.getCount());
  36.             jobs.setJob_Desc(jaf.getDesc());
  37.             jobs.setJob_EndTime(jaf.getEndTime());
  38.             jobs.setJob_IssuanceTime(new Date());
  39.             jobs.setJob_JobType(jaf.getJobType());
  40.             jobs.setJob_Language(Language);
  41.             jobs.setJob_Request(jaf.getRequest());
  42.             jobs.setJob_Title(jaf.getTitle());
  43.             jobs.setJob_Contact(jaf.getContact());
  44.             if (!jaf.getId().equals(new Long(0))) {
  45.                 jobs.setJob_ID(jaf.getId());
  46.                 b = js.UpdateJobs(jobs);
  47.                 Message = "更新成功,请返回!";
  48.             } else {
  49.                 jobs.setJob_Click(new Long(0));
  50.                 b = js.AddJobs(jobs);
  51.                 Message = "添加成功,请返回!";
  52.             }
  53.             js.commit();
  54.         } catch (Exception ex) {
  55.             log.error(ex.getMessage(), ex);
  56.             try {
  57.                 js.rollback();
  58.             } catch (Exception ex2) {
  59.                 log.error(ex2.getMessage(), ex2);
  60.             }
  61.         }
  62.         if(b == false){
  63.             Message = "操作失败,请返回!";
  64.         }
  65.         servletRequest.setAttribute("Message", Message);
  66.         servletRequest.setAttribute("Url", "/Manage/Jobs.do?todo=OpenJobs");
  67.         return actionMapping.findForward("EditJobs");
  68.     }
  69.     public ActionForward OpenJobs(ActionMapping actionMapping,
  70.                                   ActionForm actionForm,
  71.                                   HttpServletRequest servletRequest,
  72.                                   HttpServletResponse servletResponse) {
  73.         int pageNo = 0;
  74.         String Language = "CN";
  75.         PageInfo pageInfo = null;
  76.         try {
  77.             pageNo = Integer.parseInt(servletRequest.getParameter("pageNo"));
  78.         } catch (Exception ex1) {}
  79.         try {
  80.             if (servletRequest.getSession().getAttribute("Language") != null) {
  81.                 Language = servletRequest.getSession().getAttribute("Language").
  82.                            toString();
  83.             }
  84.             js.beginTran();
  85.             pageInfo = js.getPageInfo(Language, pageNo);
  86.             js.commit();
  87.         } catch (Exception ex) {
  88.             log.error(ex.getMessage(), ex);
  89.             try {
  90.                 js.rollback();
  91.             } catch (Exception ex2) {
  92.                 log.error(ex2.getMessage(), ex2);
  93.             }
  94.         }
  95.         servletRequest.setAttribute("pageInfo", pageInfo);
  96.         return actionMapping.findForward("OpenJobs");
  97.     }
  98.     public ActionForward OpenJobsInfo(ActionMapping actionMapping,
  99.                                       ActionForm actionForm,
  100.                                       HttpServletRequest servletRequest,
  101.                                       HttpServletResponse servletResponse) {
  102.         Jobs jobs = null;
  103.         try {
  104.             js.beginTran();
  105.             if (servletRequest.getParameter("jobID") != null) {
  106.                 jobs = js.GetJobsById(new Long(servletRequest.getParameter(
  107.                         "jobID")));
  108.             }
  109.             js.commit();
  110.         } catch (Exception ex) {
  111.             log.error(ex.getMessage(), ex);
  112.             try {
  113.                 js.rollback();
  114.             } catch (Exception ex2) {
  115.                 log.error(ex2.getMessage(), ex2);
  116.             }
  117.         }
  118.         servletRequest.setAttribute("jobs", jobs);
  119.         return actionMapping.findForward("OpenJobsInfo");
  120.     }
  121.     public ActionForward DeleteJobs(ActionMapping actionMapping,
  122.                                     ActionForm actionForm,
  123.                                     HttpServletRequest servletRequest,
  124.                                     HttpServletResponse servletResponse) {
  125.         Jobs jobs = null;
  126.         boolean b = false;
  127.         String Message = "";
  128.         try {
  129.             js.beginTran();
  130.             jobs = js.GetJobsById(new Long(servletRequest.getParameter("jobID")));
  131.             b = js.DeleteJobs(jobs);
  132.             js.commit();
  133.             Message = "删除成功,请返回!";
  134.         } catch (Exception ex) {
  135.             log.error(ex.getMessage(), ex);
  136.             try {
  137.                 js.rollback();
  138.             } catch (Exception ex2) {
  139.                 log.error(ex2.getMessage(), ex2);
  140.             }
  141.         }
  142.         if (b == false) {
  143.             Message = "删除失败,请返回!";
  144.         }
  145.         servletRequest.setAttribute("Message", Message);
  146.         servletRequest.setAttribute("Url", "/Manage/Jobs.do?todo=OpenJobs");
  147.         return actionMapping.findForward("DeleteJobs");
  148.     }
  149. }