producttype.java

来自「在线拍卖系统」· Java 代码 · 共 81 行

JAVA
81
字号
package j2eebbs;

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

public class ProductType {

	protected int id;

	protected String Name;

	protected String introduce;

	public ProductType() {
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return Name;
	}

	public void setName(String name) {
		Name = name;
	}

	public String getIntroduce() {
		return introduce;
	}

	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}
	
	//增加产品类型
	public boolean insert(DB db) throws Exception {
		String strSql;
		strSql = "insert into producttype (name,introduce)values(" + Name + ",'" + introduce + "')";
		if (db.ExecSql(strSql) == 0) {
			return false;
		} else {
			return true;
		}
	}

	public static Vector search(DB db) throws Exception {
		Vector Types = new Vector();
		ResultSet rs;
		String strSql = null;

		strSql = "select * from producttype ";
		rs = db.OpenSql(strSql);

		while (rs.next()) {
			ProductType type = new ProductType();

			type.setId(rs.getInt("id"));
			type.setName(rs.getString("name"));
			type.setIntroduce(rs.getString("introduce"));

			Types.add(type);
		}
		return Types;
	}

	public static boolean delete(DB db, int id) throws Exception {
		String strSql;
		strSql = "delete from producttype where id=" + id;
		if (db.ExecSql(strSql) == 0) {
			return false;
		} else {
			return true;
		}
	}

}

⌨️ 快捷键说明

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