📄 goodsinfo_bean.java
字号:
package taobaoproject;
import java.sql.*;
import java.util.*;
import java.io.*;
public class GoodsInfo_Bean {
private Connection conn;
private PreparedStatement past;
private ResultSet rst;
private ArrayList class_List;
private ArrayList goods_List;
public Connection getConn() {
DB_Bean dbBean = new DB_Bean();
conn = dbBean.getConn();
return conn;
}
public PreparedStatement getPast() {
return past;
}
public ResultSet getRst() {
return rst;
}
public ArrayList getGoods_List(int count, int goodsID,int classID,String iserfinement,String isHot,String isDiscount, String likestr) {
String sql = "select";
if(count != -1)
sql += " top " +count;
sql += " * from tb_GoodsInfo where 1 = 1";
if(goodsID != -1)
sql += " and GoodsID = " +goodsID;
if(classID != -1)
sql += " and ClassID = " +classID;
if(!iserfinement.equals(""))
sql += " and Iserfinement = " + "'" + iserfinement + "'";
if(!isHot.equals(""))
sql += " and IsHot = " + "'" +isHot + "'";
if(!isDiscount.equals(""))
sql += " and IsDiscount = " + "'" +isDiscount + "'";
if(likestr != "")
sql += " and GoodsName like '%" +likestr + "%'";
sql += " order by AddDate desc";
getConn();
goods_List = new ArrayList();
java.lang.System.out.println(sql);
try {
past = conn.prepareStatement(sql);
rst = past.executeQuery();
while(rst.next())
{
GoodsBean goodBean = new GoodsBean();
goodBean.setGoodsID(rst.getInt("GoodsID"));
goodBean.setClassID(rst.getInt("ClassID"));
goodBean.setGoodsName(rst.getString("GoodsName"));
goodBean.setGoodsIntroduce(rst.getString("GoodsIntroduce"));
goodBean.setGoodsBrand(rst.getString("GoodsBrand"));
goodBean.setGoodsUrl(rst.getString("GoodsUrl"));
goodBean.setMarketPrice(rst.getFloat("MarketPrice"));
goodBean.setMemberPrice(rst.getFloat("MemberPrice"));
goodBean.setIserfinement(rst.getString("Iserfinement"));
goodBean.setIsHot(rst.getString("IsHot"));
goodBean.setAddDate(rst.getString("AddDate"));
goodBean.setIsDiscount(rst.getString("IsDiscount"));
goods_List.add(goodBean);
}
} catch (SQLException ex) {
java.lang.System.out.print(ex);
}
try {
rst.close();
past.close();
conn.close();
} catch (SQLException ex1) {
}
return goods_List;
}
public ArrayList getClass_List(String id) {
String sql = "select * from tb_Class where ";
if(id != "") {
sql =sql + "ClassID=" + id;
}
else {
sql += "1=1";
}
getConn();
class_List = new ArrayList();
try {
past = conn.prepareStatement(sql);
rst = past.executeQuery();
while(rst.next())
{
GoodsBean goodBean = new GoodsBean();
goodBean.setClassID(rst.getInt("ClassID"));
goodBean.setClassName(rst.getString("ClassName"));
class_List.add(goodBean);
}
} catch (SQLException ex) {
java.lang.System.out.print(ex);
}
try {
rst.close();
past.close();
conn.close();
} catch (SQLException ex1) {
}
return class_List;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -