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

📄 goodsdaoimpl.java~8~

📁 电子商务系统 系统主要分为前台和后台。前台包括产品的展示及会员购物等模块
💻 JAVA~8~
字号:
package com.wgh.dao;

import commerce.goods;
import com.wgh.DB.chStr;
import com.wgh.DB.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,Pirce,nowPirce,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 + -