www.pudn.com > shop.rar > GoodsDTO.java
package com.soft136.shop.model;
import java.sql.SQLException;
import java.util.ArrayList;
import oracle.jdbc.rowset.OracleCachedRowSet;
import com.soft136.shop.DAO.GoodsDAO;
public class GoodsDTO {
public void addGoods(int goods_id, String goods_name, int type_id,
double goods_price, double goods_dicount, String goods_desc,
String supplier, int qty, int ispreferred, String pic_url)
throws SQLException, ClassNotFoundException {
new GoodsDAO().addGoods(goods_id, goods_name, type_id, goods_price,
goods_dicount, goods_desc, supplier, qty, ispreferred, pic_url);
}
public ArrayList getGoods() throws SQLException,
ClassNotFoundException {
OracleCachedRowSet crs = new GoodsDAO().getAllGoods();
if (crs != null) {
ArrayList list = new ArrayList();
while (crs.next()) {
list.add(new GoodsBean(crs.getInt(1), crs.getString(2), crs
.getInt(3), crs.getDouble(4), crs.getDouble(5), crs
.getString(6), crs.getString(7), crs.getInt(8), crs
.getInt(9), crs.getString(10)));
}
return list;
} else {
return null;
}
}
public ArrayList getSelectGoods(int id) throws SQLException,
ClassNotFoundException {
OracleCachedRowSet crs = new GoodsDAO().getGoods(id);
if (crs != null) {
ArrayList list = new ArrayList();
while (crs.next()) {
list.add(new GoodsBean(crs.getInt(1), crs.getString(2), crs
.getInt(3), crs.getDouble(4), crs.getDouble(5), crs
.getString(6), crs.getString(7), crs.getInt(8), crs
.getInt(9), crs.getString(10)));
}
return list;
} else {
return null;
}
}
public ArrayList getcloth() throws SQLException,
ClassNotFoundException {
OracleCachedRowSet crs = new GoodsDAO().getcloth();
if (crs != null) {
ArrayList list = new ArrayList();
while (crs.next()) {
list.add(new GoodsBean(crs.getInt(1), crs.getString(2), crs
.getInt(3), crs.getDouble(4), crs.getDouble(5), crs
.getString(6), crs.getString(7), crs.getInt(8), crs
.getInt(9), crs.getString(10)));
}
return list;
} else {
return null;
}
}
public ArrayList getshoes() throws SQLException,
ClassNotFoundException {
OracleCachedRowSet crs = new GoodsDAO().getshoes();
if (crs != null) {
ArrayList list = new ArrayList();
while (crs.next()) {
list.add(new GoodsBean(crs.getInt(1), crs.getString(2), crs
.getInt(3), crs.getDouble(4), crs.getDouble(5), crs
.getString(6), crs.getString(7), crs.getInt(8), crs
.getInt(9), crs.getString(10)));
}
return list;
} else {
return null;
}
}
public ArrayList getcomputer() throws SQLException,
ClassNotFoundException {
OracleCachedRowSet crs = new GoodsDAO().getcomputer();
if (crs != null) {
ArrayList list = new ArrayList();
while (crs.next()) {
list.add(new GoodsBean(crs.getInt(1), crs.getString(2), crs
.getInt(3), crs.getDouble(4), crs.getDouble(5), crs
.getString(6), crs.getString(7), crs.getInt(8), crs
.getInt(9), crs.getString(10)));
}
return list;
} else {
return null;
}
}
}