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


package com.easyjf.asp.action; 
 
import java.util.ArrayList; 
import java.util.Collection; 
import java.util.Date; 
 
import com.easyjf.asp.business.ActiveUser; 
import com.easyjf.asp.business.Material; 
import com.easyjf.util.CommUtil; 
import com.easyjf.web.Module; 
import com.easyjf.web.WebForm; 
import com.easyjf.web.tools.DbPageList; 
import com.easyjf.web.tools.IPageList; 
 
public class MaterialAction extends BaseAction { 
 
	public void doInit(WebForm form, Module module) {	 
		super.doInit(form, module); 
	} 
	 
	public IPageList doQuery(WebForm form, int currentPage, int pageSize) { 
		ActiveUser u=(ActiveUser)this.getCurrentUser(form);		 
		String scope="belongDept=?"; 
		Collection paras=new ArrayList(); 
		paras.add(u.getDept());  
		String orderType=CommUtil.null2String(form.get("orderType")); 
		String orderField=CommUtil.null2String(form.get("orderField"));		 
		String title=CommUtil.null2String(form.get("queryTitle")); 
		String source=CommUtil.null2String(form.get("querySource")); 
		String provider=CommUtil.null2String(form.get("queryProvider"));		 
		if(!title.equals("")) 
		{ 
			scope+=" and title like ?"; 
			paras.add("%"+title+"%"); 
		} 
		if(!source.equals("")) 
		{ 
			scope+=" and source=?"; 
			paras.add(source); 
		} 
		if(!provider.equals("")) 
		{ 
			scope+=" and provider=?"; 
			paras.add(provider); 
		} 
		if(orderField.equals("")) 
		{ 
		orderField="inputTime"; 
		orderType="desc";				 
		}	 
		if(!orderField.equals("")) 
		{ 
		scope +=" order by "+orderField; 
		if(!orderType.equals(""))scope+=" "+orderType; 
		} 
		DbPageList pList=new DbPageList(Material.class,scope,paras); 
		pList.doList(currentPage,pageSize); 
		return pList; 
		} 
 
	public Object form2Obj(WebForm form) { 
		String cid=CommUtil.null2String(form.get("cid")); 
		Material obj=null; 
		if(cid.equals("")) 
		{ 
			obj=(Material)form.toPo(Material.class); 
			obj.setInputTime(new Date()); 
			obj.setInputUser(this.getCurrentUser(form).getUserName()); 
			obj.setStatus(new Integer(0)); 
		} 
		else 
		{ 
			obj=Material.read(cid); 
			form.toPo(obj); 
		}		 
		if(obj!=null)obj.setBelongDept(((ActiveUser)this.getCurrentUser(form)).getDept());			 
		return obj; 
	} 
}