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