www.pudn.com > zhaobiao.rar > ProjectManager.java


/** 
 *  
 */ 
package com.centralsoft.zhaobiao.qtdatachaxun; 
 
import java.sql.*; 
import java.util.*; 
 
import com.centralsoft.zhaobiao.qtdataguanli.Type; 
import com.centralsoft.zhaobiao.qtdatachaxun.Basic; 
import com.centralsoft.zhaobiao.qtdataguanli.Project; 
import com.centralsoft.zhaobiao.util.*; 
/** 
 * @author Administrator 
 * 
 */ 
public class ProjectManager { 
	public ProjectManager() {	 
	} 
	/** 
	 * 根据项目id获得该项目相关的所有类别列表 
	 * @param project_id 
	 * @return 
	 */ 
	public Vector getProjectTypeList(long project_id) { 
		Vector list = new Vector(); 
		ResultSet rs = null; 
		String sql = "select * from project_product where project_id ="+project_id; 
		dataBase db = new dataBase(); 
		rs = db.getResultSet(sql); 
		try { 
			while (rs.next()) { 
				Type type = new Type(); 
				long type_id; 
				type_id = rs.getLong("type_id"); 
				Basic basic = new Basic(); 
				type = basic.getType(type_id); 
				list.add(type); 
			} 
		} catch (Exception e) { 
			System.out.println(e.getMessage()); 
		} finally { 
			try { 
				if (rs != null) { 
					rs.close(); 
				} 
				db.closeConn(); 
			} catch (Exception e) { 
				System.out.println(e.getMessage()); 
			} 
		} 
		return list; 
	} 
	/** 
	 * 根据项目id和类别id获得满足两个条件的产品数量 
	 * @param project_id 
	 * @param type_id 
	 * @return 
	 */ 
	public long getPTProductListCount(long project_id,long type_id) { 
		long count = 0; 
		return count; 
	} 
	/** 
	 * 获得所有的项目集合的最大数量 
	 * @return 
	 */ 
	public long getProjectListCount() { 
		long count = 0; 
		dataBase db = new dataBase(); 
		ResultSet rs = null; 
		String sql = "select count(*) as countnub from project"; 
		rs = db.getResultSet(sql); 
		try { 
			while (rs.next()) { 
				count = rs.getLong("countnub"); 
			} 
		} catch (Exception e) { 
			System.out.println(e.getMessage()); 
		} finally { 
			try { 
				if (rs != null) { 
					rs.close(); 
				} 
				db.closeConn(); 
			} catch (Exception e) { 
				System.out.println(e.getMessage()); 
			} 
		} 
		return count; 
	} 
	/** 
	 * 获得某一页的所有的项目集合 
	 * @param page 
	 * @param pagemax 
	 * @return 
	 */ 
	public Vector getProjectList(long page,long pagemax) { 
		Vector list = new Vector(); 
		dataBase db = new dataBase(); 
		ResultSet rs = null; 
		page = page - 1; 
		String sql = "select * from project"; 
		rs = db.getResultSet(sql); 
		try { 
			int count = 1; 
			while (rs.next()) { 
				if (count>(page*pagemax)&&count<=(page*pagemax+pagemax)) { 
					Project pj = new Project(); 
					pj.setProject_id(rs.getLong("project_id")); 
					pj.setProject_name(rs.getString("project_name")); 
					pj.setProject_time(rs.getString("project_time")); 
					pj.setProject_company(rs.getString("project_company")); 
					pj.setProject_cost(rs.getString("project_cost")); 
					pj.setProject_content(rs.getString("project_content")); 
					list.add(pj); 
				} 
				count ++; 
			} 
		} catch (Exception e) { 
			System.out.println(e.getMessage()); 
		} finally { 
			try { 
				if (rs != null) { 
					rs.close(); 
				} 
				db.closeConn(); 
			} catch (Exception e) { 
				System.out.println(e.getMessage()); 
			} 
		} 
		return list; 
	} 
}