⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 productmanager.java

📁 自己做的一个企业招标系统,B/S结构。开发工具Eclipse
💻 JAVA
字号:
/**
 * 
 */
package com.centralsoft.zhaobiao.qtdatachaxun;

import java.sql.*;
import java.util.*;

import com.centralsoft.zhaobiao.qtdataguanli.Type;
import com.centralsoft.zhaobiao.qtdataguanli.Project;
import com.centralsoft.zhaobiao.qtdataguanli.Product;
import com.centralsoft.zhaobiao.util.dataBase;
import com.centralsoft.zhaobiao.qtdatachaxun.Basic;
/**
 * @author Administrator
 *<p>Title: 产品信息管理类</p>
 *<p>Description: 有关产品的浏览操作</p>
 */
public class ProductManager {
	public ProductManager() {		
	}
	/**
	 * 获得所有的类别集合
	 * @return
	 */
	public Vector getTypeList() {
		Vector list = new Vector();
		ResultSet rs = null;
		dataBase db = new dataBase();
		String sql = "select * from type";
		rs = db.getResultSet(sql);
		try {
			while (rs.next()) {
				Type type = new Type();
				type.setType_id(rs.getLong("type_id"));
				type.setType_name(rs.getString("type_name"));
				type.setType_content(rs.getString("type_content"));
				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获得PPM表中的项目集合数量(去掉PPM表中重复的project_id)
	 * @param product_id
	 * @return
	 */
	public long getProjectListCount(long product_id) {
		long count = 0;
		Set set1 = new TreeSet();
		Basic basic = new Basic();
		dataBase db = new dataBase();
		String sql = "select * from ppm where product_id ="+product_id;
		ResultSet rs = null;
		rs = db.getResultSet(sql);
		try {
			while (rs.next()) {
				long project_id;
				Project pj = new Project();
				project_id = rs.getLong("project_id");
				pj = basic.getProject(project_id);
				if (set1.add(pj)) {//将指定的元素添加到se里t
					count++;
				}
			}
		} catch (Exception e) {
			System.out.println(e.getMessage());
		} finally {
			try {
				if (rs != null) {
					rs.close();
				}
			} catch (Exception e) {
				System.out.println(e.getMessage());
			}
		}
		System.out.println("根据该产品id获得PPM表中的项目集合数量:"+count);
		return count;
	}
	/**
	 * 根据类别id,获得类别下的所有产品集合的数目
	 * @param type_id
	 * @return
	 */
	public long getProductListCount(long type_id) {
		long count = 0;
		dataBase db = new dataBase();
		ResultSet rs = null;
		String sql = "select * from product where type_id = "+type_id;
		rs = db.getResultSet(sql);
		try {
			while (rs.next()) {
				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 count;
	}
	/**
	 * 根据类别id,获得某一页类别下的所有产品集合
	 * @param page
	 * @param pagemax
	 * @param type_id
	 * @return
	 */
	public Vector getProductList(long page,long pagemax,long type_id) {
		Vector list = new Vector();
		dataBase db = new dataBase();
		ResultSet rs = null;
		page = page - 1;
		String sql = "select * from product where type_id ="+type_id;
		rs = db.getResultSet(sql);
		try {
			int count = 1;
			while (rs.next()) {
				if (count > (page * pagemax) && count <= (page*pagemax + pagemax)) {
					Product pd = new Product();
					pd.setProduct_id(rs.getLong("product_id"));
					pd.setProduct_name(rs.getString("product_name"));
					pd.setMaker_id(rs.getLong("maker_id"));
					pd.setType_id(rs.getLong("type_id"));
					pd.setProduct_content(rs.getString("product_content"));
					list.add(pd);
				}
				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;
	}
	/**
	 * 根据该产品id获得某一页PPM表中的项目集合
	 * @param page
	 * @param pagemax
	 * @param product_id
	 * @return
	 */
	public Set getProjectList(long page,long pagemax,long product_id) {
		Set set1 = new TreeSet();
		Set set2 = new TreeSet();
		dataBase db = new dataBase();
		Basic basic = new Basic();
		ResultSet rs = null;
		String sql = "select * from ppm where product_id ="+product_id;
		page = page - 1;
		rs = db.getResultSet(sql);
		try {
			int count = 1;
			while (rs.next()) {
				long project_id;
				project_id = rs.getLong("project_id");
				Project pj = new Project();
				pj = basic.getProject(project_id);
				if (set1.add(pj)) {
					if (count > (page * pagemax) && count <= (page * pagemax + pagemax)) {
						set2.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());
			}
		}
		System.out.println("set2==="+set2.size());
		return set2;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -