package Tgnet;
import java.sql.*;
import java.util.*;
public class ProductsDao {
// 管理员查找数据库中有的总数据
public static int getSupplierTotal() {
int ptotal = 0;
ResultSet rs = null;
String strSql = "select count(*) from Products";
try {
rs = baseDao.execSelectSql(strSql);
if (rs.next()) {
ptotal = rs.getInt(1);
}
} catch (Exception ex) {
System.out.print("getSupplierTotal:" + ex.getMessage());
}
return ptotal;
}
// 用户登陆后根据自己的ID查找数据库中有的总数据
public static int getSupplierTotal(int userID) {
int ptotal = 0;
ResultSet rs = null;
String strSql = "select count(*) from Products where=" + userID
+ "and StateValue<>3";
try {
rs = baseDao.execSelectSql(strSql);
if (rs.next()) {
ptotal = rs.getInt(1);
}
} catch (Exception ex) {
System.out.print("getSupplierTotal:" + ex.getMessage());
}
return ptotal;
}
// 用户
public static List getProductsList(int userID, int pPage, int pSize) {
List productsList = new ArrayList();
int p = (pPage - 1) * pSize;
String strSql = "select top pSize * from Products where ProductID not in (select top "
+ p
+ " ProductID from Products where UserID="
+ userID
+ "and StateValue<>3 order by ProductID )and UserID="
+ userID
+ " and StateValue<>3 order by ProductID";
ResultSet rs = null;
try {
rs = baseDao.execSelectSql(strSql);
while (rs.next()) {
Products product = new Products();
fillSupplier(product, rs);
productsList.add(product);
}
} catch (Exception ex) {
System.out.println("用户:" + ex.getMessage());
}
baseDao.closeAll(rs, null, null);
return productsList;
}
public static void fillSupplier(Products product, ResultSet rs)
throws SQLException {
product.setProductID(rs.getInt(1));
product.setProductName(rs.getString(2));
product.setSupplierID(rs.getInt(3));
product.setCategoryID(rs.getInt(4));
product.setUnitPrice(rs.getString(5));
product.setProductDes(rs.getString(6));
product.setUserID(rs.getInt(7));
product.setUpdatedDate(rs.getString(8));
product.setPicture(rs.getString(9));
product.setStateValue(rs.getInt(10));
}
// 管理员的
public static List getProductsList(int pPage, int pSize) {
List productsList = new ArrayList();
int p = (pPage - 1) * pSize;
String strSql = "select top " + pSize
+ " * from Products where ProductID not in (select top " + p
+ " ProductID from Products )";
ResultSet rs = null;
try {
rs = baseDao.execSelectSql(strSql);
while (rs.next()) {
Products product = new Products();
fillSupplier(product, rs);
productsList.add(product);
}
} catch (Exception ex) {
System.out.println("getSupplierList:" + ex.getMessage());
}
baseDao.closeAll(rs, null, null);
return productsList;
}
// 产品信息
public List listProducts(int CategoryID) {
List list = new ArrayList();
String strSql = "select * from Products where CategoryID=" + CategoryID;
// String mysql="select top "+pageSize+" * from messageInfo where id not
// in";
// mysql+="(select top "+(curpage-1)*pageSize+" id from messageInfo
// where receiveUname='"+uname+"' order by id )";
// mysql+=" and receiveUname='"+uname+"' order by id";
try {
ResultSet rs = baseDao.execSelectSql(strSql);
while (rs.next()) {
Products you = new Products();
you.setProductID(rs.getInt(1));
you.setProductName(rs.getString(2));
you.setSupplierID(rs.getInt(3));
you.setCategoryID(rs.getInt(4));
you.setUnitPrice(rs.getString(5));
you.setProductDes(rs.getString(6));
you.setUserID(rs.getInt(7));
you.setUpdatedDate(rs.getString(8));
you.setPicture(rs.getString(9));
you.setStateValue(rs.getInt(10));
list.add(you);
}
} catch (Exception ex) {
System.out.print("有异常》4》" + ex.getMessage());
}
return list;
}
public static int getMsgCount() {
int msgCount = 0;
String strSql = "select count(*) from Products";
try {
ResultSet rs = baseDao.execSelectSql(strSql);
while (rs.next()) {
msgCount = rs.getInt(1);
}
} catch (Exception ex) {
System.out.print("getMsgCount:" + ex.getMessage());
}
return msgCount;
}
public static List listProducts2(int pcurPage, int ppageSize) {
List list = new ArrayList();
int p = (pcurPage - 1) * ppageSize;
// String strSql="select * from Products";
String strSql = "select top " + ppageSize
+ " * from Products where ProductID not in";
strSql += "(select top "
+p
+ " ProductID from Products order by ProductID)order by ProductID";
try {
ResultSet rs = baseDao.execSelectSql(strSql);
while (rs.next()) {
Products you = new Products();
you.setProductID(rs.getInt(1));
you.setProductName(rs.getString(2));
you.setSupplierID(rs.getInt(3));
you.setCategoryID(rs.getInt(4));
you.setUnitPrice(rs.getString(5));
you.setProductDes(rs.getString(6));
you.setUserID(rs.getInt(7));
you.setUpdatedDate(rs.getString(8));
you.setPicture(rs.getString(9));
you.setStateValue(rs.getInt(10));
you.setHitCount(rs.getInt(11));
you.setScore(rs.getInt(12));
list.add(you);
}
} catch (Exception ex) {
System.out.print("有异常》中间》" + ex.getMessage());
}
return list;
}
public List listProducts2() {
List list = new ArrayList();
String strSql = "select * from Products";
// String strSql="select top "+pSize+" * from Products where id not in";
// strSql+="(select top "+(pPage-1)*pSize+" id from messageInfo)";
// mysql+=" and receiveUname='"+uname+"' order by id";
try {
ResultSet rs = baseDao.execSelectSql(strSql);
while (rs.next()) {
Products you = new Products();
you.setProductID(rs.getInt(1));
you.setProductName(rs.getString(2));
you.setSupplierID(rs.getInt(3));
you.setCategoryID(rs.getInt(4));
you.setUnitPrice(rs.getString(5));
you.setProductDes(rs.getString(6));
you.setUserID(rs.getInt(7));
you.setUpdatedDate(rs.getString(8));
you.setPicture(rs.getString(9));
you.setStateValue(rs.getInt(10));
you.setHitCount(rs.getInt(11));
you.setScore(rs.getInt(12));
list.add(you);
}
} catch (Exception ex) {
System.out.print("有异常》6》" + ex.getMessage());
}
return list;
}
// 电子数码显示
public static List getselect() {
List list = new ArrayList();
Connection con = null;
PreparedStatement psta = null;
ResultSet rs = null;
String str = "select * from products where CategoryID=4";
try {
con = baseDao.getCon();
psta = con.prepareStatement(str);
rs = psta.executeQuery();
while (rs.next()) {
Products tt = new Products();
tt.setProductName(rs.getString("productName"));
tt.setUnitPrice(rs.getString("UnitPrice"));
tt.setProductDes(rs.getString("ProductDes"));
tt.setUpdatedDate(rs.getString("UpdatedDate"));
list.add(tt);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
}
return list;
}
// 查询
public Products findsuppliers(int ProductID) {
Products ms = new Products();
String strSql = "select * from Products where ProductID=" + ProductID;
try {
ResultSet rs = baseDao.execSelectSql(strSql);
while (rs.next()) {
ms.setProductID(rs.getInt(1));
ms.setProductName(rs.getString(2));
ms.setSupplierID(rs.getInt(3));
ms.setCategoryID(rs.getInt(4));
ms.setUnitPrice(rs.getString(5));
ms.setProductDes(rs.getString(6));
ms.setUserID(rs.getInt(7));
ms.setUpdatedDate(rs.getString(8));
ms.setPicture(rs.getString(9));
ms.setStateValue(rs.getShort(10));
}
} catch (Exception ex) {
}
return ms;
}
// 修改更新
public int update(int ProductID, int statevalue) {
int q = 0;
String strSql = "update Products set St
没有合适的资源?快使用搜索试试~ 我知道了~
门户网站代码和数据库
共534个文件
gif:172个
jpg:166个
jsp:102个
需积分: 10 4 下载量 9 浏览量
2011-05-13
15:13:10
上传
评论
收藏 4.9MB RAR 举报
温馨提示
java开发的一购物网站,此功能别人可以借鉴的开发网站,初学者可以在此基础上进行学习,对初学者帮助是相当大的,
资源推荐
资源详情
资源评论
收起资源包目录
门户网站代码和数据库 (534个子文件)
UserBaseDao.class 10KB
ProductsDao.class 9KB
SuppliersDao.class 8KB
userInfDao.class 6KB
TgInfoDao.class 6KB
adInfoDao.class 3KB
lodgeDao.class 3KB
baseDao.class 3KB
TgUserInfoDao.class 3KB
Suppliers.class 3KB
BaseDao.class 3KB
Products.class 3KB
TgMessInfo.class 3KB
TgInfo.class 3KB
ProductsInfo.class 2KB
SuppliersInfo.class 2KB
adInfo.class 2KB
TgUserInfo.class 2KB
TgUserInfo.class 2KB
CategoriesDao.class 2KB
userInfo.class 2KB
LodgeInfo.class 2KB
userInfo.class 2KB
LodgeInfo.class 1KB
Categories.class 1KB
lodgeDao.class 878B
UploadFile.class 623B
.classpath 362B
style_leleju.css 17KB
style_leleju.css 17KB
style.css 7KB
home.css 2KB
CSS.css 2KB
css.css 1KB
css.css 1KB
css.css 1KB
css.css 1KB
css1.css 1KB
Css.css 829B
mibble.css 331B
Thumbs.db 181KB
Thumbs.db 171KB
Thumbs.db 130KB
Thumbs.db 93KB
Thumbs.db 82KB
Thumbs.db 60KB
Thumbs.db 51KB
Thumbs.db 44KB
Thumbs.db 43KB
Thumbs.db 40KB
Thumbs.db 35KB
Thumbs.db 35KB
Thumbs.db 11KB
Thumbs.db 7KB
6.gif 119KB
2007917164947.gif 58KB
index-ad1.gif 56KB
logolink.gif 55KB
logolink.gif 55KB
gt.gif 31KB
gt.gif 31KB
1.gif 29KB
Banner.gif 25KB
5.gif 25KB
index-ad3.gif 20KB
index-ad11.gif 18KB
index-5.gif 18KB
index-6.gif 18KB
index-ad10.gif 16KB
index-7.gif 15KB
4.gif 14KB
index-ad12.gif 12KB
index-ad2.gif 12KB
index-4.gif 11KB
2.gif 10KB
map.gif 10KB
map.gif 10KB
index-bg1.gif 8KB
p2.gif 7KB
p2.gif 7KB
adright.gif 7KB
logo.gif 7KB
index-ad6.gif 6KB
3.gif 6KB
3.gif 6KB
subbanner3.gif 6KB
subbanner3.gif 6KB
subbanner.gif 6KB
subbanner.gif 6KB
logo.gif 6KB
logo.gif 6KB
index-1.gif 5KB
index-ad7.gif 5KB
6.gif 5KB
index-ad4.gif 4KB
title-accp-about.gif 4KB
4.gif 4KB
topor.gif 4KB
lecture.gif 4KB
search_top.gif 4KB
共 534 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
yl273650380
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功