package models;
import java.sql.*;
import java.util.*;
import utils.connectionFactory;
public class goodsManager {
private Connection conn = null;
private Statement stmtg = null;
private Statement stmts = null;
private Statement stmtin = null;
private Statement stmtout=null;
private Statement stmtprice=null;
private ResultSet rsg = null;
private ResultSet rss = null;
private ResultSet rsin = null;
private ResultSet rsout = null;
private ResultSet rsprice = null;
private List <Goods> goodses = new ArrayList<Goods>();
public List<Goods> getGoodsList() throws Exception {
conn = connectionFactory.getConnection();
stmtg = conn.createStatement();
stmts = conn.createStatement();
stmtin = conn.createStatement();
stmtout = conn.createStatement();
stmtprice = conn.createStatement();
rsg = stmtg.executeQuery("use WHAT select * from Goods");
while(rsg.next()){
Goods goods = new Goods();
goods.setId(rsg.getString(1));
goods.setName(rsg.getString(2));
int amount,ams,amin,amout;
rss = stmts.executeQuery("use WHAT select * from Tack_Stock where id="+goods.getId());
boolean f = rss.next();
System.out.println(f);
if(!f){
ams = 0;
}else{
ams = rss.getInt(2);
}
amin = 0;
rsin = stmtin.executeQuery("use WHAT select * from InBill where goodsId="+goods.getId());
while(rsin.next()){
amin+=rsin.getInt(3);
}
amout = 0;
rsout = stmtout.executeQuery("use WHAT select * from OutBill where goodsId="+goods.getId());
while(rsout.next()){
amout+=rsout.getInt(3);
}
amount=ams+amin-amout;
goods.setAmount(amount);
goods.setUnit(rsg.getString(4));
rsprice = stmtprice.executeQuery("use WHAT select * from GoodsPrice where id='"+goods.getId()+"'and Ending_Date is NULL");
f=rsprice.next();
if(!f){
throw new Exception(goods.getName()+"价格设定错误!货物编号:"+goods.getId());
}
goods.setPrice(rsprice.getDouble(4));
goods.setSC(rsg.getInt(5));
goods.setZC(rsg.getInt(6));
goodses.add(goods);
}
if(rsg!=null)rsg.close();
if(rss!=null)rss.close();
if(rsin!=null)rsin.close();
if(rsout!=null)rsout.close();
if(rsprice!=null)rsprice.close();
if(stmtg!=null)stmtg.close();
if(stmts!=null)stmts.close();
if(stmtin!=null)stmtin.close();
if(stmtout!=null)stmtout.close();
if(stmtprice!=null)stmtprice.close();
if(conn!=null)conn.close();
return goodses;
}
public List<Goods> getGoodsList(Goods g) throws Exception {
boolean f;
conn = connectionFactory.getConnection();
stmtg = conn.createStatement();
stmts = conn.createStatement();
stmtin = conn.createStatement();
stmtout = conn.createStatement();
stmtprice = conn.createStatement();
System.out.println("g.getId输出:"+g.getId()+"g.getSC输出:"+g.getSC());
if(g.getId()!=null&&g.getId().equals("")){
g.setId(null);
}
if(g.getSC()==0){
rsg = stmtg.executeQuery("use WHAT select * from Goods where id='"+g.getId()+"'");
}
if(g.getId()==null){
rsg = stmtg.executeQuery("use WHAT select * from Goods where SC='"+g.getSC()+"'");
}
if(g.getSC()!=0&&g.getId()!=null){
rsg = stmtg.executeQuery("use WHAT select * from Goods where id='"+g.getId()+"'and SC='"+g.getSC()+"'");
}
while(rsg.next()){
Goods goods = new Goods();
goods.setId(rsg.getString(1));
goods.setName(rsg.getString(2));
int amount,ams,amin,amout;
rss = stmts.executeQuery("use WHAT select * from Tack_Stock where id="+goods.getId());
f=rss.next();
if(!f){
ams = 0;
}else{
ams = rss.getInt(2);
}
amin = 0;
rsin = stmtin.executeQuery("use WHAT select * from InBill where goodsId="+goods.getId());
while(rsin.next()){
amin+=rsin.getInt(3);
}
amout = 0;
rsout = stmtout.executeQuery("use WHAT select * from OutBill where goodsId="+goods.getId());
while(rsout.next()){
amout+=rsout.getInt(3);
}
amount=ams+amin-amout;
goods.setAmount(amount);
goods.setUnit(rsg.getString(4));
rsprice = stmtprice.executeQuery("use WHAT select * from GoodsPrice where id='"+goods.getId()+"'and Ending_Date is NULL");
f=rsprice.next();
if(!f){
throw new Exception("价格设定错误!");
}
goods.setPrice(rsprice.getDouble(4));
goods.setSC(rsg.getInt(5));
goods.setZC(rsg.getInt(6));
goodses.add(goods);
}
if(rsg!=null)rsg.close();
if(rss!=null)rss.close();
if(rsin!=null)rsin.close();
if(rsout!=null)rsout.close();
if(rsprice!=null)rsprice.close();
if(stmtg!=null)stmtg.close();
if(stmts!=null)stmts.close();
if(stmtin!=null)stmtin.close();
if(stmtout!=null)stmtout.close();
if(stmtprice!=null)stmtprice.close();
if(conn!=null)conn.close();
return goodses;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
WarehouseAdministrator.rar (70个子文件)
WarehouseAdministrator
.project 1KB
.settings
.jsdtscope 500B
org.eclipse.jdt.core.prefs 330B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.name 6B
.mymetadata 339B
WebRoot
mainframe.jsp 474B
alert.jsp 1KB
define.jsp 2KB
WEB-INF
web.xml 653B
lib
commons-fileupload.jar 57KB
commons-io.jar 87KB
sqljdbc.jar 247KB
ognl-2.6.11.jar 164KB
struts2-core-2.0.11.1.jar 2.22MB
commons-logging-1.0.4.jar 37KB
freemarker-2.3.8.jar 784KB
xwork-2.0.4.jar 445KB
classes
utils
connectionFactory.class 1KB
actions
warehouseAction.class 2KB
listAction.class 1KB
alertAction.class 922B
pstAction.class 2KB
gdfAction.class 2KB
log4j.properties 636B
models
warehouseManager.class 2KB
GoodsDef.class 1KB
Price.class 2KB
Goods.class 2KB
leastManager.class 3KB
gdfManager.class 4KB
goodsManager.class 5KB
Least.class 2KB
Warehouse.class 1KB
priceManager.class 4KB
struts.xml 2KB
3.jpg 63KB
index.jsp 1014B
META-INF
warehouseAdministrator.jsp 909B
MANIFEST.MF 36B
测试.html 469B
list.jsp 3KB
top.jsp 1KB
price_define.jsp 2KB
img
3.jpg 63KB
left.jsp 1KB
alter_define.jsp 1KB
price_alter.jsp 1KB
warehouseAdministrator.jsp 910B
bg.jpg 2.92MB
warehouse_planning_chart.jsp 2KB
.myeclipse
src
utils
connectionFactory.java 592B
actions
pstAction.java 2KB
gdfAction.java 2KB
listAction.java 956B
warehouseAction.java 1KB
alertAction.java 412B
log4j.properties 636B
models
Goods.java 1KB
leastManager.java 2KB
warehouseManager.java 4KB
GoodsDef.java 793B
Warehouse.java 669B
goodsManager.java 5KB
Price.java 1KB
Least.java 935B
priceManager.java 4KB
gdfManager.java 4KB
struts.xml 2KB
.classpath 981B
共 70 条
- 1
资源评论
- hwjwt12013-05-10哎。。。都是些没数据库的。。给个数据库设计也许啊。。
happiers
- 粉丝: 13
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功