JobsAction.java~5~
上传用户: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.             jobs.setJob_Pay(jaf.getPay());
  45.             if (!jaf.getId().equals(new Long(0))) {
  46.                 jobs.setJob_ID(jaf.getId());
  47.                 b = js.UpdateJobs(jobs);
  48.                 Message = "更新成功,请返回!";
  49.             } else {
  50.                 jobs.setJob_Click(new Long(0));
  51.                 b = js.AddJobs(jobs);
  52.                 Message = "添加成功,请返回!";
  53.             }
  54.             js.commit();
  55.         } catch (Exception ex) {
  56.             log.error(ex.getMessage(), ex);
  57.             try {
  58.                 js.rollback();
  59.             } catch (Exception ex2) {
  60.                 log.error(ex2.getMessage(), ex2);
  61.             }
  62.         }
  63.         if(b == false){
  64.             Message = "操作失败,请返回!";
  65.         }
  66.         servletRequest.setAttribute("Message", Message);
  67.         servletRequest.setAttribute("Url", "Manage/Jobs.do?todo=OpenJobs");
  68.         return actionMapping.findForward("EditJobs");
  69.     }
  70.     public ActionForward OpenJobs(ActionMapping actionMapping,
  71.                                   ActionForm actionForm,
  72.                                   HttpServletRequest servletRequest,
  73.                                   HttpServletResponse servletResponse) {
  74.         int pageNo = 0;
  75.         String Language = "CN";
  76.         PageInfo pageInfo = null;
  77.         try {
  78.             pageNo = Integer.parseInt(servletRequest.getParameter("pageNo"));
  79.         } catch (Exception ex1) {}
  80.         try {
  81.             if (servletRequest.getSession().getAttribute("Language") != null) {
  82.                 Language = servletRequest.getSession().getAttribute("Language").
  83.                            toString();
  84.             }
  85.             js.beginTran();
  86.             pageInfo = js.getPageInfo(Language, pageNo);
  87.             js.commit();
  88.         } catch (Exception ex) {
  89.             log.error(ex.getMessage(), ex);
  90.             try {
  91.                 js.rollback();
  92.             } catch (Exception ex2) {
  93.                 log.error(ex2.getMessage(), ex2);
  94.             }
  95.         }
  96.         servletRequest.setAttribute("pageInfo", pageInfo);
  97.         return actionMapping.findForward("OpenJobs");
  98.     }
  99.     public ActionForward OpenJobsInfo(ActionMapping actionMapping,
  100.                                       ActionForm actionForm,
  101.                                       HttpServletRequest servletRequest,
  102.                                       HttpServletResponse servletResponse) {
  103.         Jobs jobs = null;
  104.         try {
  105.             js.beginTran();
  106.             if (servletRequest.getParameter("jobID") != null) {
  107.                 jobs = js.GetJobsById(new Long(servletRequest.getParameter(
  108.                         "jobID")));
  109.             }
  110.             js.commit();
  111.         } catch (Exception ex) {
  112.             log.error(ex.getMessage(), ex);
  113.             try {
  114.                 js.rollback();
  115.             } catch (Exception ex2) {
  116.                 log.error(ex2.getMessage(), ex2);
  117.             }
  118.         }
  119.         servletRequest.setAttribute("jobs", jobs);
  120.         return actionMapping.findForward("OpenJobsInfo");
  121.     }
  122.     public ActionForward DeleteJobs(ActionMapping actionMapping,
  123.                                     ActionForm actionForm,
  124.                                     HttpServletRequest servletRequest,
  125.                                     HttpServletResponse servletResponse) {
  126.         Jobs jobs = null;
  127.         boolean b = false;
  128.         String Message = "";
  129.         try {
  130.             js.beginTran();
  131.             jobs = js.GetJobsById(new Long(servletRequest.getParameter("jobID")));
  132.             b = js.DeleteJobs(jobs);
  133.             js.commit();
  134.             Message = "删除成功,请返回!";
  135.         } catch (Exception ex) {
  136.             log.error(ex.getMessage(), ex);
  137.             try {
  138.                 js.rollback();
  139.             } catch (Exception ex2) {
  140.                 log.error(ex2.getMessage(), ex2);
  141.             }
  142.         }
  143.         if (b == false) {
  144.             Message = "删除失败,请返回!";
  145.         }
  146.         servletRequest.setAttribute("Message", Message);
  147.         servletRequest.setAttribute("Url", "Manage/Jobs.do?todo=OpenJobs");
  148.         return actionMapping.findForward("DeleteJobs");
  149.     }
  150. }