?? merchantgoodstypedao.java
字號:
/*
* 作者:管磊
* 時間:2007年12月06日
* 功能:庫存銷售管理->商品管理->商品類型管理。
*/
package com.mole.struts.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Iterator;
import com.mole.struts.bean.MerchantGoodsTypeBean;
public class MerchantGoodsTypeDAO extends AbstractDAO {
private int pageSize;
public MerchantGoodsTypeDAO() {
}
// 獲取頁數信息
public int getPageInfo(String storeID, int pageSize) {
Connection conn = getConn();
int count = 0;
this.pageSize = pageSize;
String sql = "SELECT COUNT(*) FROM [GoodsType] where StoreID=?";
try {
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, storeID);
ResultSet rs = ps.executeQuery();
if (rs.next())
count = rs.getInt(1);
} catch (Exception e) {
e.printStackTrace();
}
return count;
}
// 獲取所有的商品類型信息
public MerchantGoodsTypeBean[] getAllGoodsType(String storeID,
int currentPage) {
String sql = "select top " + pageSize
+ "[ID],[Name],[Description] from [GoodsType] where storeID='"
+ storeID + "' and [ID] not in (select top " + pageSize
* (currentPage - 1) + "[ID] from [GoodsType] where storeID='"
+ storeID + "' ) order by ID";
ArrayList<Object[]> al = this.executeQuery(sql);
MerchantGoodsTypeBean[] beanlist = new MerchantGoodsTypeBean[al.size()];
Iterator<Object[]> it = al.iterator();
int i = 0;
while (it.hasNext()) {
MerchantGoodsTypeBean bean = new MerchantGoodsTypeBean();
Object[] obj = it.next();
String tempString = (String) obj[2];
if (tempString != null && tempString.length() > 15) {
tempString = tempString.substring(0, 12) + "...";
}
bean.setName(obj[1].toString());
bean.setDescription(tempString);
bean.setId(obj[0].toString());
beanlist[i++] = bean;
}
return beanlist;
}
// 獲取該商品詳細信息
public MerchantGoodsTypeBean getDetailGoodsTypeInfo(String ID) {
String sql = "select id,name,storeid,description from goodstype where id='"
+ ID + "'";
ArrayList<Object[]> al = this.executeQuery(sql);
MerchantGoodsTypeBean bean = new MerchantGoodsTypeBean();
Object[] obj = al.get(0);
bean.setId(obj[0].toString());
bean.setName(obj[1].toString());
bean.setStoreId(obj[2].toString());
bean.setDescription((String) obj[3]);
return bean;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -