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; } }
最近下载更多
woshixiaomu LV2
1月9日
1234dwaz11123a LV1
2023年12月13日
hxh666 LV2
2023年12月11日
syhsyhzxhzxh LV3
2023年10月23日
寒江雪2017 LV9
2023年8月2日
laureline LV1
2023年6月21日
alone2 LV2
2023年5月30日
The way LV1
2023年5月30日
自知则知之1 LV2
2023年5月26日
www111111111 LV2
2023年5月22日
最近浏览更多
攻城狮aoao LV3
4月12日
苏青梧
3月25日
暂无贡献等级
烟橙沐雨 LV1
3月21日
wjh007 LV4
3月15日
Liang朝伟 LV1
1月5日
woshixiaomu LV2
1月2日
asddwh LV12
2023年12月29日
iiiiiiixiiiiii LV1
2023年12月28日
pangzhihui LV12
2023年12月27日
小小白银110 LV1
2023年12月26日