/**
 * 员工档案操作控制类
 * EmployeeAction.java
 * Copyright (C) 2010 SLMS
 * Simple Logistics Management System
 * 
 */
package com.zds.slms.action;

import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.zds.slms.domain.Employee;
import com.zds.slms.service.IEmployeeService;

/**
 * Copyright (C) 2010:SLMS<br/>
 * Project:SLMS<br/>
 * Module ID:<br/>
 * Comments:Simple Logistics Management System<br/>
 * JDK version used:JDK1.6<br/>
 * Package:com.zds.slms.action<br/>
 * Author:chenyongzheng<br/>
 * Create Date:2010-12-3<br/>
 * Modified By:<br/>
 * Modified Date:<br/>
 * Why & What is modified:<br/>
 * Version:0.1<br/>
 */
@SuppressWarnings("serial")
public class EmployeeAction extends ActionSupport {
	// 员工档案业务处理接口
	private IEmployeeService employeeService;
	private Employee employee = new Employee();
	// 查询结果集
	private List<Employee> employees = new ArrayList<Employee>();
	// 操作结束后跳转的地址
	private String finish_Url;
	// 要删除的员工ID
	private String[] employeeId;

	/**
	 * 员工档案查询
	 * 
	 * @return
	 */

	public String findEmployee() {
		employees = employeeService.findEmployee(employee);
		return "findEmployee";

	}

	/**
	 * 员工档案保存
	 * 
	 * @return
	 */
	public String saveEmployee() {
		employeeService.saveEmployee(employee);
		finish_Url = "employeeAction!findEmployee.action";
		return "finish";
	}

	/**
	 * 员工档案删除
	 * 
	 * @return
	 */
	public String deleteEmployee() {
		employeeService.deleteEmployee(employeeId);
		finish_Url = "employeeAction!findEmployee.action";
		return "finish";
	}

	/**
	 * 员工档案更新
	 * 
	 * @return
	 */
	public String updateEmployee() {
		employeeService.updateEmployee(employee);
		finish_Url = "employeeAction!findEmployee.action";
		return "finish";
	}

	/**
	 * 员工档案更新前查询
	 * 
	 * @return
	 */
	public String preUpdateEmployee() {
		employee = employeeService.findEmployee(employee).get(0);
		return "updateEmployee";
	}

	/**
	 * 员工档案查询
	 * 
	 * @param code
	 *            员工编码
	 * @return
	 */

	public int findEmployeeByCode(String code) {
		employee = new Employee();
		employee.setCode(code);
		employees = employeeService.findEmployee(employee);
		return employees.size();

	}

	/**
	 * @return the employeeService
	 */
	public IEmployeeService getEmployeeService() {
		return employeeService;
	}

	/**
	 * @param employeeService
	 *            the employeeService to set
	 */
	public void setEmployeeService(IEmployeeService employeeService) {
		this.employeeService = employeeService;
	}

	/**
	 * @return the employee
	 */
	public Employee getEmployee() {
		return employee;
	}

	/**
	 * @param employee
	 *            the employee to set
	 */
	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	/**
	 * @return the employees
	 */
	public List<Employee> getEmployees() {
		return employees;
	}

	/**
	 * @param employees
	 *            the employees to set
	 */
	public void setEmployees(List<Employee> employees) {
		this.employees = employees;
	}

	/**
	 * @return the finish_Url
	 */
	public String getFinish_Url() {
		return finish_Url;
	}

	/**
	 * @param finish_Url
	 *            the finish_Url to set
	 */
	public void setFinish_Url(String finish_Url) {
		this.finish_Url = finish_Url;
	}

	/**
	 * @return the employeeId
	 */
	public String[] getEmployeeId() {
		return employeeId;
	}

	/**
	 * @param employeeId
	 *            the employeeId to set
	 */
	public void setEmployeeId(String[] employeeId) {
		this.employeeId = employeeId;
	}

}
