首页>代码>Spring+Struts1+Hibernate三大框架开发企业人力资源管理系统源代码下载>/企业人力资源管理系统/PersonManager/src/com/wy/action/EmployeeAction.java
package com.wy.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.wy.dao.ObjectDao;
import com.wy.form.DepartmentForm;
import com.wy.form.EmployeeForm;
import com.wy.form.InviteJobForm;
import com.wy.form.ManagerForm;
import com.wy.tool.GetAutoNumber;

public class EmployeeAction extends DispatchAction {
	private ObjectDao objectDao;

	public ObjectDao getObjectDao() {
		return objectDao;
	}

	public void setObjectDao(ObjectDao objectDao) {
		this.objectDao = objectDao;
	}

	// 转向员工录用的页面
	
	public ActionForward forwardEmploye(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) {
		this.saveToken(request);
		
		String condition = "from EmployeeForm order by id desc";
		List list = objectDao.getObjectList(condition);
		String autoNumber = "1";
		if (list.size() != 0) {
			EmployeeForm employeeform = (EmployeeForm) list.get(0);
			Integer em_serialNumber = Integer.valueOf(employeeform.getId()) + 1;
			autoNumber = String.valueOf(em_serialNumber);
		}
		autoNumber = GetAutoNumber.getMaxNuber(autoNumber);
		request.setAttribute("departmentList", objectDao
				.getObjectList("from DepartmentForm"));
		EmployeeForm employeeForm =(EmployeeForm)form;		
		String id = request.getParameter("id");
		InviteJobForm inviteJobForm = (InviteJobForm) objectDao
					.getObjectForm("from InviteJobForm where id='" + id + "'");
			employeeForm.setEm_serialNumber(autoNumber);//将员工编号自动赋值
			employeeForm.setEm_name(inviteJobForm.getName());//将员工姓名赋值
			employeeForm.setEm_afterschool(inviteJobForm.getAfterSchool());//将员工的毕业学校自动赋值
			employeeForm.setEm_sex(inviteJobForm.getSex());//将员工的性别赋值
			employeeForm.setEm_born(inviteJobForm.getBorn());//将员工的出生日期赋值
			employeeForm.setEm_address(inviteJobForm.getAddress());//将员工地址赋值
			employeeForm.setEm_culture(inviteJobForm.getTeachSchool());//将员工的文化程度赋值
			employeeForm.setEm_tel(inviteJobForm.getTel());//将员工电话赋值
			employeeForm.setEm_speciality(inviteJobForm.getSpecialty());//将员工所学专业赋值
			request.setAttribute("employeeForm", employeeForm);
			request.setAttribute("id", id);
			return mapping.findForward("forwardEmploy");
	
	}
	//员工录用
	public ActionForward addEmployee(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		EmployeeForm employeeForm = (EmployeeForm) form;
	if (this.isTokenValid(request)) {
			this.resetToken(request);
			objectDao.insertObjectForm(employeeForm);
		} else {
		this.saveToken(request);
			request.setAttribute("result", "不能重复提交!!!");
		}
	
		request.setAttribute("id", request.getParameter("id"));
		return mapping.findForward("operationEmployee");
	}
	
	
	

	// 员工查看详细信息操作
	public ActionForward queryOneEmployee(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) {
		String em_serialNumber = request.getParameter("em_serialNumber");
		String condition = "from EmployeeForm where em_serialNumber='"
				+ em_serialNumber + "'";
		EmployeeForm employeeForm = (EmployeeForm) objectDao
				.getObjectForm(condition);
		request.setAttribute("employeeForm", employeeForm);
		request.setAttribute("departmentList", objectDao
				.getObjectList("from DepartmentForm"));
		return mapping.findForward("queryOneEmployee");
	}

	
	
	
	
	
	
	// 员工查看操作
	public ActionForward queryEmployee(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		List list = null;
		String condition = "from EmployeeForm order by id desc";
		if (request.getParameter("departmentId") != null) {
			String em_departmentId = request.getParameter("departmentId");
			condition = "from EmployeeForm where em_departmentId='"
					+ em_departmentId + "' order by id desc";
			request.setAttribute("departmentId", em_departmentId);
		}
		list = objectDao.getObjectList(condition);
		request.setAttribute("list", list);
		request.setAttribute("departmentList", objectDao
				.getObjectList("from DepartmentForm"));
		return mapping.findForward("queryEmployee");
	}

	// 转向添加员工的页面
	public ActionForward forwardInsertEmployee(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) {
		this.saveToken(request);
		
		String condition = "from EmployeeForm order by id desc";
		List list = objectDao.getObjectList(condition);
		String autoNumber = "1";
		if (list.size() != 0) {
			EmployeeForm employeeform = (EmployeeForm) list.get(0);
			Integer em_serialNumber = Integer.valueOf(employeeform.getId()) + 1;
			autoNumber = String.valueOf(em_serialNumber);
		}
		autoNumber = GetAutoNumber.getMaxNuber(autoNumber);
		request.setAttribute("autoNumber", autoNumber);
		request.setAttribute("departmentList", objectDao
				.getObjectList("from DepartmentForm"));


		return mapping.findForward("forwardInsertEmployee");
	}
	
	

	// 添加员工
	public ActionForward saveEmployee(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		EmployeeForm employeeForm = (EmployeeForm) form;
		if (this.isTokenValid(request)) {
			this.resetToken(request);
			objectDao.insertObjectForm(employeeForm);
		} else {
			this.saveToken(request);
			request.setAttribute("result", "不能重复提交!!!");
		}
		return queryEmployee(mapping, form, request, response);
	}

	// 转向修改员工的页面
	public ActionForward forwardUpdateEmployee(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) {
		this.saveToken(request);
		String em_serialNumber = request.getParameter("em_serialNumber");
		String condition = "from EmployeeForm where em_serialNumber='"
				+ em_serialNumber + "'";

		EmployeeForm employeeForm = (EmployeeForm) objectDao
				.getObjectForm(condition);
		System.out.println("3213=" + employeeForm.getEm_sex());

		request.setAttribute("employeeForm", employeeForm);
		request.setAttribute("departmentList", objectDao
				.getObjectList("from DepartmentForm"));
		return mapping.findForward("forwardUpdateEmployee");
	}

	// 修改员工
	public ActionForward updateEmployee(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		EmployeeForm employeeForm = (EmployeeForm) form;
		if (this.isTokenValid(request)) {
			this.resetToken(request);
			objectDao.updateObjectForm(employeeForm);
		} else {
			this.saveToken(request);
			request.setAttribute("result", "不能重复提交!!!");
		}
		return queryEmployee(mapping, form, request, response);
	}

	// 删除员工信息
	public ActionForward deleteEmployee(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		String em_serialNumber = request.getParameter("em_serialNumber");
		String condition = "from EmployeeForm where em_serialNumber='"
				+ em_serialNumber + "'";
		EmployeeForm employeeForm = (EmployeeForm) objectDao
				.getObjectForm(condition);
		if (!objectDao.deleteObjectForm(employeeForm)) {
			request.setAttribute("result", "删除员工信息失败,可能还存在其他的信息");
		}
		return mapping.findForward("operationEmployee");
	}

}
最近下载更多
qq2901732871  LV9 2023年6月2日
duoer12  LV5 2022年12月30日
wanglinddad  LV55 2022年8月20日
1973356987  LV13 2021年6月17日
Crush  LV3 2021年5月19日
tbq111  LV2 2021年5月1日
没钱穷快活  LV1 2021年4月19日
judy0971  LV12 2021年3月29日
zhangbo112154  LV1 2020年11月14日
小帅时代  LV7 2020年9月30日
最近浏览更多
yzh_falcon  LV3 6月23日
WBelong  LV8 3月5日
暂无贡献等级
185838390  LV1 2月16日
123456wadff  LV3 1月15日
zhangjilu  LV18 1月7日
王王王229  LV1 2023年9月3日
白云龙  LV2 2023年8月21日
RMJ-YYY  LV3 2023年7月3日
qq2901732871  LV9 2023年6月2日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友