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

📄 goodsdaoimpl.java

📁 很强大有很多购物网站的基础功能
💻 JAVA
字号:
package com.dao;

import com.model.Goods;
import com.tools.ChStr;
import com.tools.ConnDB;

public class GoodsDaoImpl implements GoodsDao {
	ConnDB conn = new ConnDB();
	ChStr chStr = new ChStr();

	public int insert(Goods g) {
		int ret = -1;
		try {
			String sql = "Insert into tb_goods (TypeID,GoodsName,Introduce,Price,nowPrice,picture,newgoods,sale) values("
					+ g.getTypeID()
					+ ",'"
					+ chStr.chStr(g.getGoodsName())
					+ "','"
					+ chStr.chStr(g.getIntroduce())
					+ "',"
					+ g.getPrice()
					+ ","
					+ g.getPrice()
					+ ",'"
					+ chStr.chStr(g.getPicture())
					+ "',"
					+ g.getNewGoods()
					+ "," + g.getSale() + ")";

			ret = conn.executeUpdate(sql);
		} catch (Exception e) {
			ret = 0;
		}
		conn.close();
		return ret;
	}

	public int update(Goods g) {
		int ret = -1;
		try {
			String sql = "update tb_Goods set TypeID=" + g.getTypeID()
					+ ",GoodsName='" + chStr.chStr(g.getGoodsName())
					+ "',introduce='" + chStr.chStr(g.getIntroduce())
					+ "',price=" + g.getPrice() + ",nowprice="
					+ g.getNowPrice() + ",picture='"
					+ chStr.chStr(g.getPicture()) + "',newgoods="
					+ g.getNewGoods() + ",sale=" + g.getSale() + " where ID="
					+ g.getID();
			ret = conn.executeUpdate(sql);
		} catch (Exception e) {
			ret = 0;
		}
		conn.close();
		return ret;
	}

	public int delete(Goods g) {
		int ret = -1;
		try {
			String sql = "Delete from tb_goods where ID=" + g.getID();
			ret = conn.executeUpdate(sql);
		} catch (Exception e) {
			ret = 0;
		}
		conn.close();
		return ret;

	}

}

⌨️ 快捷键说明

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