📄 merchantbulletindao.java
字号:
/*
* 作者:茹振超
* 时间:2007年12月09日
* 功能:店铺管理 ->公告管理
*/
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.MerchantBulletinInfoBean;
public class MerchantBulletinDAO extends AbstractDAO {
private int pageSize;
// 获取页面信息
public int getBulletinPageInfo(String storeID, int pageSize) {
Connection conn = getConn();
int count = 0;
this.pageSize = pageSize;
String sql = "select count(*) from [MerchantBulletin] 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 MerchantBulletinInfoBean[] getBulletinInfoinThePage(String storeID,
int currentPage) {
String sql = "select top " + pageSize
+ " ID,CreateDate,Name from MerchantBulletin where StoreID='"
+ storeID + "' and ID not in(select top " + pageSize
* (currentPage - 1)
+ " ID from MerchantBulletin where StoreID='" + storeID + "')"
+ " order by ID";
ArrayList<Object[]> al = this.executeQuery(sql);
if (al == null)
return null;
MerchantBulletinInfoBean[] beanList = new MerchantBulletinInfoBean[al
.size()];
int i = 0;
Iterator<Object[]> it = al.iterator();
while (it.hasNext()) {
MerchantBulletinInfoBean bean = new MerchantBulletinInfoBean();
Object[] obj = it.next();
bean.setStoreID(storeID);
bean.setId(Integer.parseInt(obj[0].toString()));
bean.setCreateDate(obj[1].toString().substring(0, 10));
bean.setName(obj[2].toString());
beanList[i++] = bean;
}
return beanList;
}
// 获取详细信息
public MerchantBulletinInfoBean getDetailInfo(String ID) {
String sql = "select Content,CreateDate,StoreID,Name from MerchantBulletin where ID='"
+ ID + "'";
ArrayList<Object[]> al = this.executeQuery(sql);
MerchantBulletinInfoBean bean = new MerchantBulletinInfoBean();
Object[] obj = al.get(0);
bean.setId(Integer.parseInt(ID));
bean.setContent(obj[0].toString());
bean.setCreateDate(obj[1].toString().substring(0, 10));
bean.setStoreID(obj[2].toString());
bean.setName(obj[3].toString());
return bean;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -