package colbean;
/**
* 手机详细信息表业务操作的 Bean
* @author 唐昕、王高国
* 检验人:王欢、毛小叶、张兵
*/
import java.sql.*;
import java.util.*;
import db.*;
import showbean.*;
public class ColTelType {
/**
* 缺货商品信息
* @return ArrayList list
*/
public List searchLittleTel(){
List list=null;
DBConn db = DBConn.getInstance();
ResultSet rs=null;
try {
rs=db.executesql("select * from teltype where telcount=0");
if(rs!=null){
list=new ArrayList();
while(rs.next()){
TelType t=new TelType();
t.setDate(rs.getString("prodate"));
t.setCount(rs.getInt("telcount"));
t.setDvid(rs.getInt("camera"));
t.setGuiseid(rs.getInt("guise"));
t.setId(rs.getInt(1));
t.setInterid(rs.getInt("intertypeid"));
t.setOsid(rs.getInt("telos"));
t.setPath(rs.getString("picture"));
t.setPrice(rs.getDouble("price"));
t.setRingid(rs.getInt("ring"));
t.setScreenid(rs.getInt("screencolor"));
t.setTelid(rs.getInt("telid"));
t.setTypename(rs.getString(2));
t.setUserprice(rs.getDouble("userprice"));
t.setBuycount(rs.getInt("buycount"));
list.add(t);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return list;
}
/**
* 更新手机记录
* @param tt
* @return boolean 值
*/
public boolean updateTel(TelType tt){
boolean b=false;
DBConn db = DBConn.getInstance();
String sql="update teltype set typename='"+tt.getTypename()
+"',telid="+tt.getTelid()+",price="+tt.getPrice()+
",userprice="+tt.getUserprice()
+",intertypeid="+tt.getInterid()+",prodate='"+tt.getDate()
+"',picture='"+tt.getPath()+"',telcount="+tt.getCount()
+",screencolor="+tt.getScreenid()+",telos="+tt.getOsid()
+",camera="+tt.getDvid()+",guise="+tt.getGuiseid()
+",ring="+tt.getRingid()+" where typeid="+tt.getId();
System.out.println("updatesql="+sql);
b=db.execute(sql);
return b;
}
/**
* 获得所有特价商品信息
* @return ArrayList list
*/
public List<TelType> getCheapShopping(){
List<TelType> list=null;
DBConn db = DBConn.getInstance();
ResultSet rs=null;
try {
rs=db.executesql("select * from teltype where userprice<=1000");
if(rs!=null){
list=new ArrayList<TelType>();
while(rs.next()){
TelType t=new TelType();
t.setDate(rs.getString("prodate"));
t.setCount(rs.getInt("telcount"));
t.setDvid(rs.getInt("camera"));
t.setGuiseid(rs.getInt("guise"));
t.setId(rs.getInt(1));
t.setInterid(rs.getInt("intertypeid"));
t.setOsid(rs.getInt("telos"));
t.setPath(rs.getString("picture"));
t.setPrice(rs.getDouble("price"));
t.setRingid(rs.getInt("ring"));
t.setScreenid(rs.getInt("screencolor"));
t.setTelid(rs.getInt("telid"));
t.setTypename(rs.getString(2));
t.setUserprice(rs.getDouble("userprice"));
t.setBuycount(rs.getInt("buycount"));
list.add(t);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return list;
}
/**
* 最新商品信息
* @return ArrayList list
*/
public List<TelType> getNewShopping(){
List<TelType> list=null;
DBConn db = DBConn.getInstance();
GregorianCalendar calendar=new GregorianCalendar();
int year=calendar.get(Calendar.YEAR);
String sql="select * from TelType where prodate>='"+year+"'";
System.out.println("sql++++++"+sql);
ResultSet rs=db.executesql(sql);
try {
if(rs!=null){
list=new ArrayList<TelType>();
while(rs.next()){
TelType t=new TelType();
t.setDate(rs.getString("prodate"));
t.setCount(rs.getInt("telcount"));
t.setDvid(rs.getInt("camera"));
t.setGuiseid(rs.getInt("guise"));
t.setId(rs.getInt(1));
t.setInterid(rs.getInt("intertypeid"));
t.setOsid(rs.getInt("telos"));
t.setPath(rs.getString("picture"));
t.setPrice(rs.getDouble("price"));
t.setRingid(rs.getInt("ring"));
t.setScreenid(rs.getInt("screencolor"));
t.setTelid(rs.getInt("telid"));
t.setTypename(rs.getString(2));
t.setUserprice(rs.getDouble("userprice"));
t.setBuycount(rs.getInt("buycount"));
list.add(t);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return list;
}
/**
* 获得热销商品信息
* @return ArrayList list
*/
public List<TelType> getGrade(){
List<TelType> list=null;
DBConn db = DBConn.getInstance();
ResultSet rs=db.executesql("select * from teltype where buycount!=0 order by buycount desc ");
try{
if (rs != null) {
list=new ArrayList<TelType>();
while (rs.next()) {
TelType t=new TelType();
t.setDate(rs.getString("prodate"));
t.setCount(rs.getInt("telcount"));
t.setDvid(rs.getInt("camera"));
t.setGuiseid(rs.getInt("guise"));
t.setId(rs.getInt(1));
t.setInterid(rs.getInt("intertypeid"));
t.setOsid(rs.getInt("telos"));
t.setPath(rs.getString("picture"));
t.setPrice(rs.getDouble("price"));
t.setRingid(rs.getInt("ring"));
t.setScreenid(rs.getInt("screencolor"));
t.setTelid(rs.getInt("telid"));
t.setTypename(rs.getString(2));
t.setUserprice(rs.getDouble("userprice"));
t.setBuycount(rs.getInt("buycount"));
list.add(t);
}
}
}catch(Exception e){
e.printStackTrace();
}
return list;
}
/**
* 高级搜索商品信息
* @param tt
* @param dvfrom
* @param yto
* @param page
* @return ArrayList list
*/
public List advanceSearch(TelType tt, int dvfrom, int yto, int page) {
List<TelType> list = null;
DBConn db = DBConn.getInstance();
String sql = "select top 4 * from teltype where typename like '%" +
tt.getTypename() +
"%' and prodate >='" + tt.getDate() + "' and prodate <= '" +
yto + "' and userprice >= " + tt.getPrice()
+ " and userprice <=" + tt.getUserprice() +
" and intertypeid =" + tt.getInterid()
+ " and camera >=" + tt.getDvid() + " and camera <=" +
dvfrom;
ResultSet rs = null;
if (tt.getGuisei
- 1
- 2
- 3
前往页