/**
 * 客户档案操作控制类
 * ClientAction.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.Client;
import com.zds.slms.service.IClientService;

/**
 * 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 ClientAction extends ActionSupport {
	// 客户档案业务处理接口
	private IClientService clientService;
	private Client client = new Client();
	// 查询结果集
	private List<Client> clients = new ArrayList<Client>();;
	// 操作结束后跳转的地址
	private String finish_Url;
	// 要删除的客户ID
	private String[] clientId;

	/**
	 * 客户档案查询
	 * 
	 * @return
	 */

	public String findClient() {
		clients = clientService.findClient(client);
		return "findClient";

	}

	/**
	 * 客户档案保存
	 * 
	 * @return
	 */
	public String saveClient() {
		clientService.saveClient(client);
		finish_Url = "clientAction!findClient.action";
		return "finish";
	}

	/**
	 * 客户档案删除
	 * 
	 * @return
	 */
	public String deleteClient() {
		clientService.deleteClient(clientId);
		finish_Url = "clientAction!findClient.action";
		return "finish";
	}

	/**
	 * 客户档案更新
	 * 
	 * @return
	 */
	public String updateClient() {
		clientService.updateClient(client);
		finish_Url = "clientAction!findClient.action";
		return "finish";
	}

	/**
	 * 客户档案更新前查询
	 * 
	 * @return
	 */
	public String preUpdateClient() {
		client = clientService.findClient(client).get(0);
		return "updateClient";
	}

	/**
	 * 客户档案查询
	 * 
	 * @param code
	 *            客户编码
	 * @return
	 */

	public int findClientByCode(String code) {
		client = new Client();
		client.setCode(code);
		clients = clientService.findClient(client);
		return clients.size();

	}

	/**
	 * @return the clientService
	 */
	public IClientService getClientService() {
		return clientService;
	}

	/**
	 * @param clientService
	 *            the clientService to set
	 */
	public void setClientService(IClientService clientService) {
		this.clientService = clientService;
	}

	/**
	 * @return the client
	 */
	public Client getClient() {
		return client;
	}

	/**
	 * @param client
	 *            the client to set
	 */
	public void setClient(Client client) {
		this.client = client;
	}

	/**
	 * @return the clients
	 */
	public List<Client> getClients() {
		return clients;
	}

	/**
	 * @param clients
	 *            the clients to set
	 */
	public void setClients(List<Client> clients) {
		this.clients = clients;
	}

	/**
	 * @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 clientId
	 */
	public String[] getClientId() {
		return clientId;
	}

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

}
