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

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