/*
 * 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.service.Y_IAreaFreightInfoService;

/** 
 * MyEclipse Struts
 * Creation date: 04-22-2007
 * 运时运费的分野
 * XDoclet definition:
 * @struts.action validate="true"
 */
public class Y_spysyfAction extends Action {
	private Y_IAreaFreightInfoService areaFreightInfoService;
	public Y_IAreaFreightInfoService getAreaFreightInfoService() {
		return areaFreightInfoService;
	}
	public void setAreaFreightInfoService(
			Y_IAreaFreightInfoService areaFreightInfoService) {
		this.areaFreightInfoService = areaFreightInfoService;
	}
	
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		HttpSession session=request.getSession();
		//得到提交信息
		String p=request.getParameter("p");
		//得到分野信息
		//当前页
		int cur=Integer.parseInt(session.getAttribute("Y_ysyfc")+"");
		//查询信息
		int cx1=Integer.parseInt(session.getAttribute("Y_ysyf1")+"");
		int cx2=Integer.parseInt(session.getAttribute("Y_ysyf2")+"");
//		得到总页数
		int pageNum=areaFreightInfoService.getPageNum(12, cx1, cx2);
		if (pageNum==0){
			return mapping.findForward("go");			
		}
		if(p.equals("a")){
			cur=1;
		}
		if(p.equals("b")){
			if(cur-1<1){
				cur=1;
			}else{
				cur=cur-1;
			}
		}
		if(p.equals("c")){
			if(cur+1>pageNum){
				cur=pageNum;
			}else{
				cur=cur+1;
			}
		}
		if(p.equals("d")){
			cur=pageNum;
		}
		if(p.equals("e")){
			cur=Integer.parseInt(request.getParameter("mp"));
			if(cur>pageNum){
				cur=pageNum;
			}
			if(cur<1){
				cur=1;
			}
		}
						
		//得到页信息
		List clist=areaFreightInfoService.findSplitRegister(12, cur, cx1, cx2);
		//保存当前页信息
		session.setAttribute("Y_ysyfinfo", clist);
		//保存分页信息
		//当前页
		session.setAttribute("Y_ysyfc", cur);
		//总页数
		session.setAttribute("Y_ysyfs", pageNum);
		
		
		return mapping.findForward("go");
	}
}