/*
 * 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_SHDJClientForm;
import com.yuntong.business.vo.Y_ClientInfoVO;
import com.yuntong.business.vo.Y_FreightStyleVO;
import com.yuntong.service.Y_IGoodsManagerService;

/** 
 * MyEclipse Struts
 * Creation date: 04-01-2007
 * 
 * XDoclet definition:
 * @struts.action path="/y_SHDJClientAction" name="y_SHDJClientForm" input="/yuntong/SHGL/Y_shgl_2.jsp" scope="request" validate="true"
 */
public class Y_SHDJClientActionAction extends Action {
	/*
	 * Generated Methods
	 */
	private Y_IGoodsManagerService service;
	/** 
	 * Method execute
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		Y_SHDJClientForm cForm = (Y_SHDJClientForm) form;
		
		//得到提交的客户信息
		String myid=cForm.getMycid();
		int clientID=Integer.parseInt(myid);
		
		Y_ClientInfoVO vo=new Y_ClientInfoVO();
		vo.setClientID(clientID);
		//新客户
		if(myid.equals("9")){
			vo.setClientAddress(cForm.getCaddress());
			vo.setClientCompany(cForm.getCname());
			vo.setClientEmail(cForm.getCemail());
			vo.setClientMarketID(Integer.parseInt(cForm.getMarketvalue()));
			vo.setClientPhone(cForm.getCphone());
			vo.setClientPostID(cForm.getCpostid());
			vo.setClientName(cForm.getCman());
		}
		//保存到session中
		HttpSession session=request.getSession();
		session.setAttribute("Y_khdj", vo);
		
		//初始化结算方式信息（收讫，提付）		
		List flist=service.findAllFreight();
		//初始化货款计算方式（重货，轻货）
		List plist=service.findAllPaymentInfo();
		//保存结算方式信息
		session.setAttribute("Y_finfo", flist);
		//保存货款计算方式信息
		session.setAttribute("Y_pinfo", plist);
		return mapping.findForward("go3");
	}
	public Y_IGoodsManagerService getService() {
		return service;
	}
	public void setService(Y_IGoodsManagerService service) {
		this.service = service;
	}
}