/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.yuntong.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.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.yuntong.action.actionform.Y_SHDJFactoryForm;
import com.yuntong.business.vo.Y_AreaInfoVO;
import com.yuntong.business.vo.Y_FactoryInfoVO;
import com.yuntong.service.Y_IAreaManagerService;
import com.yuntong.service.Y_IMarketManagerService;

/** 
 * MyEclipse Struts
 * Creation date: 03-26-2007
 * 
 * XDoclet definition:
 * @struts.action path="/y_SHGLFactroy" name="y_SHDJFactoryForm" scope="request" validate="true"
 * @struts.action-forward name="go2" path="/Y_shgl_2.jsp"
 */
public class Y_SHGLFactroyAction extends Action {
	private Y_IAreaManagerService service;
	private Y_IMarketManagerService service2;
	/*
	 * Generated Methods
	 */

	public Y_IAreaManagerService getService() {
		return service;
	}

	public void setService(Y_IAreaManagerService service) {
		this.service = service;
	}


	/** 收货登记1----2action
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		//得到提交的厂商信息
		Y_SHDJFactoryForm y_SHDJFactoryForm = (Y_SHDJFactoryForm) form;
		Y_FactoryInfoVO factoryInfoVO=new Y_FactoryInfoVO();
		factoryInfoVO.setFactoryID(Integer.parseInt(y_SHDJFactoryForm.getFactoryID()));		
		//新客户时
		if(y_SHDJFactoryForm.getFactoryID().equals("9999")){
			factoryInfoVO.setFactoryAddress(y_SHDJFactoryForm.getFactoryAddress());				
			factoryInfoVO.setFactoryAreaID(Integer.parseInt(y_SHDJFactoryForm.getFactoryArea()));
			factoryInfoVO.setFactoryEmail(y_SHDJFactoryForm.getFactoryEmail());
			factoryInfoVO.setFactoryFax(y_SHDJFactoryForm.getFactoryFax());		
			factoryInfoVO.setFactoryName(y_SHDJFactoryForm.getFactoryName());
			factoryInfoVO.setFactoryLinkMan(y_SHDJFactoryForm.getFactoryLinkman());
			factoryInfoVO.setFactoryPhone(y_SHDJFactoryForm.getFactoryPhone());
			factoryInfoVO.setFactoryPostID(y_SHDJFactoryForm.getFactoryPostID());
			factoryInfoVO.setFactoryRemark(y_SHDJFactoryForm.getFactoryInfo());						
		}
		//保存信息到session中				
		HttpSession session=request.getSession();
		session.setAttribute("Y_csdj", factoryInfoVO);
		//初始化地区下拉列表
		List list=service.findAllAreaInfo();		
		session.setAttribute("areainfo", list);
		if(list.size()>0){
			//初始化市场下拉列表(根据地区编号)			
			List list2=service2.findMarketInfoByAreaID(((Y_AreaInfoVO)(list.get(0))).getAreaID());
			session.setAttribute("marketinfo", list2);
		}
		
		return mapping.findForward("go2");
	}

	public Y_IMarketManagerService getService2() {
		return service2;
	}

	public void setService2(Y_IMarketManagerService service2) {
		this.service2 = service2;
	}
}