www.pudn.com > erp0.1.zip > SystemRegionAction.java


package com.easyjf.asp.action; 
 
import java.util.ArrayList; 
import java.util.Collection; 
import java.util.Date; 
import com.easyjf.asp.business.SystemRegion; 
import com.easyjf.util.CommUtil; 
import com.easyjf.web.WebForm; 
import com.easyjf.web.tools.DbPageList; 
import com.easyjf.web.tools.IPageList; 
 
public class SystemRegionAction extends BaseAction { 
	public IPageList doQuery(WebForm form, int currentPage, int pageSize) {						 
		String scope="1=1"; 
		Collection paras=new ArrayList();		 
		String orderType=CommUtil.null2String(form.get("orderType")); 
		String orderField=CommUtil.null2String(form.get("orderField"));		 
		String parentSn=CommUtil.null2String(form.get("parentSn")); 
		if(parentSn.equals(""))parentSn="0000000"; 
		SystemRegion region=SystemRegion.readBySn(parentSn); 
		if(region!=null)form.addResult("parentTitle",region.getTitle()); 
		String querySn=CommUtil.null2String(form.get("querySn")); 
		String queryTitle=CommUtil.null2String(form.get("queryTitle"));		 
		if(!parentSn.equals("")) 
		{ 
			scope+=" and parentSn = ?"; 
			paras.add(parentSn); 
		} 
		if(!querySn.equals("")) 
		{ 
			scope+=" and sn=?"; 
			paras.add(querySn); 
		} 
		if(!queryTitle.equals("")) 
		{ 
			scope+=" and title like ?"; 
			paras.add("%"+queryTitle+"%"); 
		}		 
		if(orderField.equals("")) 
		{ 
		orderField="inputTime"; 
		orderType="desc";				 
		}	 
		if(!orderField.equals("")) 
		{ 
		scope +=" order by "+orderField; 
		if(!orderType.equals(""))scope+=" "+orderType; 
		} 
		DbPageList pList=new DbPageList(SystemRegion.class,scope,paras); 
		pList.doList(currentPage,pageSize); 
		return pList; 
		} 
	 
	public Object form2Obj(WebForm form) { 
		String cid=CommUtil.null2String(form.get("cid")); 
		SystemRegion obj=null; 
		if(cid.equals("")) 
		{ 
			obj=(SystemRegion)form.toPo(SystemRegion.class); 
			obj.setInputTime(new Date()); 
			obj.setInputUser(this.getCurrentUser(form).getUserName()); 
		} 
		else 
		{ 
			obj=SystemRegion.read(cid); 
			form.toPo(obj); 
		}		 
		return obj; 
	} 
}