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

📄 shouji_bean.java~14~

📁 模仿Taobao购物网
💻 JAVA~14~
字号:
package taobaoproject;

import java.sql.*;

public class ShouJI_Bean {
    private Connection conn;
    private PreparedStatement past;
    private ResultSet rst;
    private int goodsID;
    private String goodsName;
    private float memberPrice;
    private int buynum;
    private float marketPrice;

    public Connection getConn() {
        DB_Bean dbBean = new DB_Bean();
        conn = dbBean.getConn();
        return conn;
    }

    public void buy(int _goodsID,int _buynum) {
        getConn();
        //String sql = "select * from tb_GoodsInfo where GoodsID = " + _goodsID;
        try {
            past = conn.prepareStatement("select * from tb_GoodsInfo where GoodsID = ?");
            past.setInt(1,_goodsID);
            rst = past.executeQuery();
            rst.next();
            goodsID = _goodsID;
            goodsName = rst.getString("GoodsName");
            marketPrice = rst.getFloat("MarketPrice");
            memberPrice = rst.getFloat("MemberPrice");
            buynum = _buynum;
            //java.lang.System.out.println(sql);
        } catch (SQLException ex) {
            java.lang.System.out.println(ex);
        }
        try {
            rst.close();
            past.close();
            conn.close();
        } catch (SQLException ex1) {
            java.lang.System.out.println(ex1);
        }
    }

    public void setGoodsID(int goodsID) {
        this.goodsID = goodsID;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public void setMemberPrice(float memberPrice) {
        this.memberPrice = memberPrice;
    }

    public void setBuynum(int buynum) {
        this.buynum = buynum;
    }

    public void setMarketPrice(float marketPrice) {
        this.marketPrice = marketPrice;
    }

    public int getGoodsID() {
        return goodsID;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public float getMemberPrice() {
        return memberPrice;
    }

    public int getBuynum() {
        return buynum;
    }

    public float getMarketPrice() {
        return marketPrice;
    }
}

⌨️ 快捷键说明

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