JobsAction.java~4~
资源名称:shihua.rar [点击查看]
上传用户:zghglow
上传日期:2022-08-09
资源大小:27227k
文件大小:6k
源码类别:
WEB源码(ASP,PHP,...)
开发平台:
JavaScript
- package com.chinacannel.xlchemical.struts.Action;
- import org.apache.struts.actions.DispatchAction;
- 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.service.JobsService;
- import com.chinacannel.common.PageInfo;
- import com.chinacannel.xlchemical.struts.ActionForm.JobsActionForm;
- import com.chinacannel.entity.Jobs;
- import java.util.Date;
- public class JobsAction extends DispatchAction {
- private JobsService js = new JobsService();
- public ActionForward EditJobs(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- JobsActionForm jaf = (JobsActionForm) actionForm;
- Jobs jobs = new Jobs();
- String Language = "CN";
- boolean b = false;
- String Message = "";
- try {
- if (servletRequest.getSession().getAttribute("Language") != null) {
- Language = servletRequest.getSession().getAttribute("Language").
- toString();
- }
- js.beginTran();
- if (!jaf.getId().equals(new Long(0))) {
- jobs = js.GetJobsById(jaf.getId());
- }
- jobs.setJob_Address(jaf.getAddress());
- jobs.setJob_Branch(jaf.getBranch());
- jobs.setJob_Count(jaf.getCount());
- jobs.setJob_Desc(jaf.getDesc());
- jobs.setJob_EndTime(jaf.getEndTime());
- jobs.setJob_IssuanceTime(new Date());
- jobs.setJob_JobType(jaf.getJobType());
- jobs.setJob_Language(Language);
- jobs.setJob_Request(jaf.getRequest());
- jobs.setJob_Title(jaf.getTitle());
- jobs.setJob_Contact(jaf.getContact());
- jobs.setJob_Pay(jaf.getPay());
- if (!jaf.getId().equals(new Long(0))) {
- jobs.setJob_ID(jaf.getId());
- b = js.UpdateJobs(jobs);
- Message = "更新成功,请返回!";
- } else {
- jobs.setJob_Click(new Long(0));
- b = js.AddJobs(jobs);
- Message = "添加成功,请返回!";
- }
- js.commit();
- } catch (Exception ex) {
- log.error(ex.getMessage(), ex);
- try {
- js.rollback();
- } catch (Exception ex2) {
- log.error(ex2.getMessage(), ex2);
- }
- }
- if(b == false){
- Message = "操作失败,请返回!";
- }
- servletRequest.setAttribute("Message", Message);
- servletRequest.setAttribute("Url", "/Manage/Jobs.do?todo=OpenJobs");
- return actionMapping.findForward("EditJobs");
- }
- public ActionForward OpenJobs(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- int pageNo = 0;
- String Language = "CN";
- 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();
- }
- js.beginTran();
- pageInfo = js.getPageInfo(Language, pageNo);
- js.commit();
- } catch (Exception ex) {
- log.error(ex.getMessage(), ex);
- try {
- js.rollback();
- } catch (Exception ex2) {
- log.error(ex2.getMessage(), ex2);
- }
- }
- servletRequest.setAttribute("pageInfo", pageInfo);
- return actionMapping.findForward("OpenJobs");
- }
- public ActionForward OpenJobsInfo(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- Jobs jobs = null;
- try {
- js.beginTran();
- if (servletRequest.getParameter("jobID") != null) {
- jobs = js.GetJobsById(new Long(servletRequest.getParameter(
- "jobID")));
- }
- js.commit();
- } catch (Exception ex) {
- log.error(ex.getMessage(), ex);
- try {
- js.rollback();
- } catch (Exception ex2) {
- log.error(ex2.getMessage(), ex2);
- }
- }
- servletRequest.setAttribute("jobs", jobs);
- return actionMapping.findForward("OpenJobsInfo");
- }
- public ActionForward DeleteJobs(ActionMapping actionMapping,
- ActionForm actionForm,
- HttpServletRequest servletRequest,
- HttpServletResponse servletResponse) {
- Jobs jobs = null;
- boolean b = false;
- String Message = "";
- try {
- js.beginTran();
- jobs = js.GetJobsById(new Long(servletRequest.getParameter("jobID")));
- b = js.DeleteJobs(jobs);
- js.commit();
- Message = "删除成功,请返回!";
- } catch (Exception ex) {
- log.error(ex.getMessage(), ex);
- try {
- js.rollback();
- } catch (Exception ex2) {
- log.error(ex2.getMessage(), ex2);
- }
- }
- if (b == false) {
- Message = "删除失败,请返回!";
- }
- servletRequest.setAttribute("Message", Message);
- servletRequest.setAttribute("Url", "/Manage/Jobs.do?todo=OpenJobs");
- return actionMapping.findForward("DeleteJobs");
- }
- }