首页>代码>java jsp开发的电子商务系统代码下载>/java电子商务系统-毕业论文和项目/commerce/src/com/wgh/dao/GoodsDaoImpl.java
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,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;

  }

}
最近下载更多
lawyer12321  LV1 3月21日
moyune1  LV2 2024年12月27日
84126415  LV2 2024年12月10日
yuanyuan927  LV1 2024年11月22日
微信网友_7222576034680832  LV2 2024年10月23日
colecole  LV3 2024年10月8日
hlFDGd  LV1 2024年6月11日
微信网友_7026079165190144  LV1 2024年6月6日
1234567tian  LV2 2024年6月1日
Qolmen  LV12 2024年5月11日
最近浏览更多
lawyer12321  LV1 3月21日
moyune1  LV2 2024年12月27日
ma406805131  LV19 2024年12月18日
WenMeng  LV9 2024年12月16日
565236523 2024年12月10日
暂无贡献等级
9632148963  LV1 2024年12月10日
84126415  LV2 2024年12月10日
yuanyuan927  LV1 2024年11月22日
dongandmin  LV8 2024年11月13日
3312djdad  LV2 2024年11月8日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友