/**
 * 商品档案操作控制类
 * MerchandiseAction.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.Merchandise;
import com.zds.slms.service.IMerchandiseService;

/**
 * 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 MerchandiseAction extends ActionSupport {
	// 商品档案业务处理接口
	private IMerchandiseService merchandiseService;
	private Merchandise merchandise = new Merchandise();
	// 查询结果集
	private List<Merchandise> merchandises = new ArrayList<Merchandise>();
	// 操作结束后跳转的地址
	private String finish_Url;
	// 要删除的商品ID
	private String[] merchandiseId;

	/**
	 * 商品档案查询
	 * 
	 * @return
	 */

	public String findMerchandise() {
		merchandises = merchandiseService.findMerchandise(merchandise);
		return "findMerchandise";

	}

	/**
	 * 商品档案保存
	 * 
	 * @return
	 */
	public String saveMerchandise() {
		merchandiseService.saveMerchandise(merchandise);
		finish_Url = "merchandiseAction!findMerchandise.action";
		return "finish";
	}

	/**
	 * 商品档案删除
	 * 
	 * @return
	 */
	public String deleteMerchandise() {
		merchandiseService.deleteMerchandise(merchandiseId);
		finish_Url = "merchandiseAction!findMerchandise.action";
		return "finish";
	}

	/**
	 * 商品档案更新
	 * 
	 * @return
	 */
	public String updateMerchandise() {
		merchandiseService.updateMerchandise(merchandise);
		finish_Url = "merchandiseAction!findMerchandise.action";
		return "finish";
	}

	/**
	 * 商品档案更新前查询
	 * 
	 * @return
	 */
	public String preUpdateMerchandise() {
		merchandise = merchandiseService.findMerchandise(merchandise).get(0);
		return "updateMerchandise";
	}

	/**
	 * 商品档案查询
	 * 
	 * @param code
	 *            商品编码
	 * @return
	 */

	public int findMerchandiseByCode(String code) {
		merchandise = new Merchandise();
		merchandise.setCode(code);
		merchandises = merchandiseService.findMerchandise(merchandise);
		return merchandises.size();

	}

	/**
	 * @return the merchandiseService
	 */
	public IMerchandiseService getMerchandiseService() {
		return merchandiseService;
	}

	/**
	 * @param merchandiseService
	 *            the merchandiseService to set
	 */
	public void setMerchandiseService(IMerchandiseService merchandiseService) {
		this.merchandiseService = merchandiseService;
	}

	/**
	 * @return the merchandise
	 */
	public Merchandise getMerchandise() {
		return merchandise;
	}

	/**
	 * @param merchandise
	 *            the merchandise to set
	 */
	public void setMerchandise(Merchandise merchandise) {
		this.merchandise = merchandise;
	}

	/**
	 * @return the merchandises
	 */
	public List<Merchandise> getMerchandises() {
		return merchandises;
	}

	/**
	 * @param merchandises
	 *            the merchandises to set
	 */
	public void setMerchandises(List<Merchandise> merchandises) {
		this.merchandises = merchandises;
	}

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

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

}
