資源簡介
內(nèi)有詳細(xì)說明說,適合JAVA初學(xué)者,JAVA開發(fā)人員學(xué)習(xí)典藏

代碼片段和文件信息
package?com.dao;
import?java.sql.ResultSet;
import?java.sql.SQLException;
import?java.util.ArrayList;
import?java.util.HashMap;
import?java.util.List;
import?java.util.Map;
import?com.toolsbean.DB;
import?com.toolsbean.StringHandler;
import?com.valuebean.GoodsBean;
public?class?GoodsDao?extends?SuperDao{
private?DB?mydb=null;
public?GoodsDao(){
mydb=new?DB();
}
/**?@功能:分頁獲取所有商品?*/
public?List?getAllGoods(String?strcurrentPString?strcurrentGString?goWhich)?throws?SQLException{
String?sqlall=“select?*?from?tb_goods?order?by?goods_stocktime?desc“;
setDaoPage(sqlallnullstrcurrentP?strcurrentG?goWhich);
int?currentP=getDaoPage().getCurrentP();
int?top1=getDaoPage().getPerR();
int?top2=(currentP-1)*top1;
String?sqlsub=““;
if(currentP==1)
sqlsub=“select?top?“+top1+“?*?from?tb_goods?order?by?goods_stocktime?desc“;
else
sqlsub=“select?top?“+top1+“?*?from?tb_goods?where?(goods_stocktime?(select?min(goods_stocktime)?from?(select?top?“+top2+“?*?from?tb_goods?order?by?goods_stocktime?desc)?as?minv))?order?by?goods_stocktime?desc“;
List?alllist=getList(sqlsubnull);
List?goodslist=divide(alllisttop1);
return?goodslist;
}
/**?@功能:獲取某個商品的詳細(xì)信息?*/
public?GoodsBean?getSingleGoods(int?id)?throws?SQLException{
GoodsBean?single=null;
String?sql=“select?*?from?tb_goods?where?id=?“;
object[]?params={id};
List?list=getList(sqlparams);
if(list!=null&&list.size()!=0)
single=(GoodsBean)list.get(0);
return?single;
}
private?List?getList(String?sqlobject[]?params)?throws?SQLException{
List?list=null;
mydb.doPstm(sqlparams);
ResultSet?rs=mydb.getRs();
if(rs!=null){
list=new?ArrayList();
while(rs.next()){
GoodsBean?single=new?GoodsBean();
single.setId(rs.getInt(1));
single.setGoodsViewpic(rs.getString(2));
single.setGoodsName(rs.getString(3));
single.setGoodsPrice(rs.getFloat(4));
single.setGoodsStoreNum(rs.getInt(5));
single.setGoodsStocktime(StringHandler.timeTostr(rs.getTimestamp(6)));
single.setGoodsInfo(rs.getString(7));
single.setGoodsMaker(rs.getString(8));
list.add(single);
}
rs.close();
}
return?list;
}
private?List?divide(List?listint?perR){
List?goodslist=null;
if(list!=null){
goodslist=new?ArrayList();
/*?①首先補齊長度?*/
int?blank=perR-list.size(); //因為每頁顯示perR條記錄,所以list的長度只能等于perR或小于perR
if(blank>0){ //若list的長度小于perR,則向list中存放blank個null值,將list長度補齊到perR
for(int?i=0;i list.add(null);
}
/*?②然后進(jìn)行劃分?*/
for(int?i=0;i<3;i++){ //平均分成3份
List?temp=new?ArrayList();
for(int?j=0;j<4;j++){ //將每份中的元素存儲到temp中
temp.add(list.get(4*i+j));
}
goodslist.add(temp); //存儲temp到medialist中
}
}
return?goodslist;
}
/**?@功能:修改商品庫存量?*/
public?void?updateStoreNum(int?buynumint?id){
String?sql=“update?tb_goods?set?goods_storenum=goods_storenum-??where?id=?“;
object[]?pa
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????940544??2008-11-17?09:23??購物車模塊\程序使用說明.doc
?????文件????????940??2008-08-21?13:28??購物車模塊\sl\01\affirmOrderform.jsp
?????文件???????5702??2008-10-14?16:25??購物車模塊\sl\01\fillOrderform.jsp
?????文件?????????90??2008-08-15?16:30??購物車模塊\sl\01\index.jsp
?????文件???????1725??2008-09-14?09:34??購物車模塊\sl\01\listBrowseGoods.jsp
?????文件???????2209??2008-09-13?14:26??購物車模塊\sl\01\listGoods.jsp
?????文件???????1453??2008-10-15?14:01??購物車模塊\sl\01\listMain.jsp
?????文件???????1179??2008-09-13?16:07??購物車模塊\sl\01\login.jsp
?????文件????????320??2008-09-13?16:23??購物車模塊\sl\01\message.jsp
?????文件???????5956??2008-10-16?10:59??購物車模塊\sl\01\showOrderform.jsp
?????文件???????3897??2008-10-21?15:53??購物車模塊\sl\01\showShopcar.jsp
?????文件???????1616??2008-10-14?15:46??購物車模塊\sl\01\viewGoods.jsp
?????文件?????????36??2008-09-13?12:58??購物車模塊\sl\01\me
?????文件???????3024??2008-10-15?14:33??購物車模塊\sl\01\WEB-INF\web.xm
?????文件???????4847??2008-10-17?11:05??購物車模塊\sl\01\WEB-INF\classes\com\dao\GoodsDao.class
?????文件???????4674??2008-10-17?11:05??購物車模塊\sl\01\WEB-INF\classes\com\dao\OrderformDao.class
?????文件???????4267??2008-10-17?11:05??購物車模塊\sl\01\WEB-INF\classes\com\dao\ShopcarDao.class
?????文件???????2144??2008-10-17?11:05??購物車模塊\sl\01\WEB-INF\classes\com\dao\SuperDao.class
?????文件???????1633??2008-10-17?11:05??購物車模塊\sl\01\WEB-INF\classes\com\dao\TempDao.class
?????文件???????1508??2008-10-17?11:05??購物車模塊\sl\01\WEB-INF\classes\com\dao\UserDao.class
?????文件???????1325??2008-10-17?11:05??購物車模塊\sl\01\WEB-INF\classes\com\filter\CharacterEncodingFilter.class
?????文件???????2090??2008-10-17?11:05??購物車模塊\sl\01\WEB-INF\classes\com\filter\LoginFilter.class
?????文件???????2277??2008-10-17?11:05??購物車模塊\sl\01\WEB-INF\classes\com\filter\SubmitFilter.class
?????文件???????8565??2008-10-17?11:05??購物車模塊\sl\01\WEB-INF\classes\com\servlet\GoodsServlet.class
?????文件???????2308??2008-10-17?11:05??購物車模塊\sl\01\WEB-INF\classes\com\servlet\LogXServlet.class
?????文件??????12926??2008-10-17?11:05??購物車模塊\sl\01\WEB-INF\classes\com\servlet\ShopcarServlet.class
?????文件???????2852??2008-10-17?11:05??購物車模塊\sl\01\WEB-INF\classes\com\toolsbean\DB.class
?????文件???????4888??2008-10-17?11:05??購物車模塊\sl\01\WEB-INF\classes\com\toolsbean\PageBar.class
?????文件???????3390??2008-10-17?11:05??購物車模塊\sl\01\WEB-INF\classes\com\toolsbean\StringHandler.class
?????文件???????2325??2008-10-17?11:05??購物車模塊\sl\01\WEB-INF\classes\com\valuebean\GoodsBean.class
............此處省略90個文件信息
評論
共有 條評論