package com.dao;
import org.hibernate.Session;
import com.core.MySession;
import com.actionForm.StockGoodsForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.LinkedList;
import com.actionForm.StockMainForm;
import org.hibernate.Transaction;
import java.text.NumberFormat;
import com.actionForm.StockDetailForm;
import java.util.Set;
import java.util.HashSet;
import com.actionForm.IfForm;
import org.hibernate.Query;
import com.actionForm.StockMainViewForm;
import java.util.Date;
import com.actionForm.GoodsForm;
import com.actionForm.InStorageForm;
import com.actionForm.StorageForm;
import com.actionForm.CheckForm;
import com.actionForm.LoanForm;
public class InstorageDAO {
private Session session = null;
// session=MySession.openSession(); //打开Session
// MySession.closeSession(session); //关闭Session
public void cart_add(StockGoodsForm goodsForm, HttpServletRequest request) {
HttpSession httpsession = request.getSession();
System.out.println("******************:" +
httpsession.getAttribute("stockgoods") +
"**********");
if (httpsession.getAttribute("stockgoods") != null &&
!httpsession.getAttribute("stockgoods").equals("")) {
List list = (List) httpsession.getAttribute("stockgoods");
boolean flag = true;
for (int i = 0; i < list.size(); i++) { //判断是否已经添加了该记录
StockGoodsForm goodsF = (StockGoodsForm) list.get(i);
if (goodsF.getId() == goodsForm.getId()) { //已经采购
goodsF.setNumber(goodsF.getNumber() + goodsForm.getNumber());
list.set(i, goodsF); //重新设定指定位置i处的元素
flag = false;
break;
}
}
if (flag) {
list.add(goodsForm);
}
httpsession.setAttribute("stockgoods", list);
} else {
System.out.println("goodsForm:" + goodsForm);
List list = new LinkedList();
list.add(goodsForm);
httpsession.setAttribute("stockgoods", list);
}
}
public void cart_remove(int id, HttpServletRequest request) {
HttpSession httpsession = request.getSession();
List list = (List) httpsession.getAttribute("stockgoods");
if (list.size() > 1) {
list.remove(id); //移去指定的物资信息
httpsession.setAttribute("stockgoods", list);
} else {
httpsession.removeAttribute("stockgoods");
}
}
//清空保存物资信息的Session
public void cart_clear(HttpServletRequest request) {
HttpSession httpsession = request.getSession();
httpsession.removeAttribute("stockgoods");
}
//添加采购单信息
public int stockadd(StockMainForm stockMainForm, HttpServletRequest request) {
int rtn = 1;
HttpSession httpsession = request.getSession();
List list = (List) httpsession.getAttribute("stockgoods");
Transaction tx = null;
if (list.size() <= 0) {
rtn = 0;
} else {
session = MySession.openSession(); //打开Session
try {
tx = session.beginTransaction();
System.out.println("供应商ID:" + stockMainForm.getProviderid());
for (int i = 0; i < list.size(); i++) {
StockDetailForm stockDetailForm = new StockDetailForm();
StockGoodsForm stockGoods = (StockGoodsForm) list.get(i);
stockMainForm.setCreateTime(new Date());
int goodsid = stockGoods.getId();
GoodsForm goodsForm = (GoodsForm) session.get(GoodsForm.class,
goodsid);
stockDetailForm.setGoods(goodsForm);
// System.out.println("GOODSID:"+goodsForm.getId());
// stockDetailForm.setGoodsid(stockGoods.getId());
stockDetailForm.setNumber(stockGoods.getNumber());
stockDetailForm.setPrice(stockGoods.getPrice());
stockMainForm.getStockDetail().add(stockDetailForm);
stockDetailForm.setStockMain(stockMainForm);
System.out.println("goods.getId:" + stockGoods.getId() +
"**********" +
stockDetailForm.getGoodsid());
}
session.save(stockMainForm);
/*********生成采购单号*******************/
NumberFormat formater = NumberFormat.getNumberInstance();
int id = stockMainForm.getId();
formater.setMinimumIntegerDigits(5);
java.util.Date createTime = stockMainForm.getCreateTime();
java.sql.Date date = new java.sql.Date(createTime.getTime());
String sNo = "CG" + date +
formater.format(id).toString().replace(",", ""); //组合采购单号
/**************************************/
//插入采购单号
StockMainForm stockmaniF = (StockMainForm) session.get(
StockMainForm.class, id);
stockmaniF.setSno(sNo);
session.update(stockmaniF);
tx.commit();
httpsession.removeAttribute("stockgoods");
rtn=1;
} catch (Exception e) {
if (tx != null) {
tx.rollback();
}
rtn=0;
e.printStackTrace();
System.out.println("保存采购信息时的错误提示:" + e.getMessage());
} finally {
MySession.closeSession(session); //关闭Session
}
}
return rtn;
}
//添加审核入库信息
public int eligibleAdd(int id, HttpServletRequest request) {
int rtn = 1;
session = MySession.openSession(); //打开session
Transaction tx = null;
try {
tx = session.beginTransaction();
InStorageForm inStorageForm = new InStorageForm();
inStorageForm.setStockid(id);
inStorageForm.setCreateTime(new Date());
HttpSession httpsession = request.getSession();
inStorageForm.setUsername((String) httpsession.getAttribute(
"username")); //设置操作员
session.save(inStorageForm); //保存审核入库信息
/********生成审核入库单信息***********/
NumberFormat formater = NumberFormat.getNumberInstance();
int iid = inStorageForm.getId();
formater.setMinimumIntegerDigits(5);
java.util.Date inTime = inStorageForm.getCreateTime();
java.sql.Date date = new java.sql.Date(inTime.getTime());
String ino = "RK" + date +
formater.format(iid).toString().replace(",", ""); //组合入库单号
/**********************************/
//插入入库单号
InStorageForm inStorageF = (InStorageForm) session.get(
InStorageForm.class, iid);
inStorageF.setIno(ino);
session.update(inStorageF);
//修改采购单状态为已入库
StockMainForm stockMainForm = (StockMainForm) session.get(
StockMainForm.class, id);
stockMainForm.setState(1);
session.update(stockMainForm);
//修改库存信息表
String hql = "FROM StockDetailForm WHERE stockid=" + id + "";
System.out.println("HQL:" + hql);
List list = null;
Query query = session.cr
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
功能说明 (1)系统管理/用户管理 (2)系统管理/系统初始化 (3)修改密码 (4)基础信息/供应商管理 (5)基础信息/物资管理 (6)基础信息/部门管理 (7)物资入库/采购登记 (8)物资入库/审核入库 (9)物资出库/部门领用 (10)物资出库/物资借出 (11)物资出库/物资审核 (12)物资入库/借出归还 (13)物资处理/库存盘点 (14)物资处理/部门报损 (15)查询统计/采购单查询 (16)查询统计/入库查询 (17)查询统计/部门领用查询 (18)查询统计/部门领用汇总 (19)查询统计/部门报损查询 (20)查询统计/部门报损汇总 (21)查询统计/借出查询 (22)查询统计/部门汇总
资源推荐
资源详情
资源评论
收起资源包目录
基于javaWeb+JSP+SQL server实现的物资管理系统【源码+数据库+运行指导文档】 (211个子文件)
InstorageDAO.class 9KB
QueryDAO.class 9KB
OutStorageDAO.class 8KB
UserDAO.class 5KB
IfDeal.class 5KB
User.class 4KB
GoodsDAO.class 4KB
Instorage.class 4KB
ProviderDAO.class 4KB
LoanForm.class 4KB
Loan.class 4KB
Goods.class 3KB
Provider.class 3KB
BranchDAO.class 3KB
GoodsForm.class 3KB
Cart.class 3KB
Branch.class 3KB
GetUseForm.class 2KB
DamageForm.class 2KB
GetUse.class 2KB
Damage.class 2KB
UserForm.class 2KB
StockMainViewForm.class 2KB
StockDetailForm.class 2KB
ProviderForm.class 2KB
StockMainForm.class 2KB
SysDAO.class 2KB
BranchForm.class 2KB
IfForm.class 2KB
MySession.class 1KB
InStorageForm.class 1KB
GetTime.class 1KB
CheckForm.class 1008B
StockGoodsForm.class 899B
SelfRequestProcessor.class 899B
StorageForm.class 860B
.classpath 2KB
org.eclipse.wst.jsdt.ui.superType.container 49B
style.css 3KB
wend.doc 98KB
login.gif 173KB
sysinitialize.gif 28KB
item_over.gif 2KB
item_out.gif 2KB
error_b.gif 2KB
search.gif 1KB
noel.gif 576B
enforce.gif 567B
compart.gif 181B
bg.gif 65B
left.gif 51B
hibernate3.jar 3.9MB
jbosscache-core-3.2.1.GA.jar 1.11MB
infinispan-core-4.2.0.ALPHA1.jar 994KB
javassist-3.12.0.GA.jar 618KB
c3p0-0.9.1.jar 594KB
sqljdbc.jar 570KB
commons-collections-3.1.jar 546KB
struts.jar 537KB
proxool-0.8.3.jar 465KB
antlr.jar 350KB
dom4j-1.6.1.jar 307KB
cglib-2.2.jar 272KB
ehcache-1.5.0.jar 258KB
commons-beanutils.jar 184KB
commons-digester.jar 164KB
oscache-2.1.jar 112KB
hibernate-jpa-2.0-api-1.0.0.Final.jar 99KB
commons-validator.jar 82KB
jakarta-oro.jar 64KB
commons-logging.jar 37KB
swarmcache-1.0RC2.jar 30KB
slf4j-api-1.6.1.jar 25KB
commons-fileupload.jar 22KB
jta-1.1.jar 11KB
InstorageDAO.java 13KB
QueryDAO.java 12KB
OutStorageDAO.java 10KB
IfDeal.java 9KB
User.java 6KB
UserDAO.java 5KB
GoodsDAO.java 4KB
Loan.java 4KB
Provider.java 4KB
Goods.java 4KB
Instorage.java 4KB
ProviderDAO.java 4KB
LoanForm.java 3KB
Branch.java 3KB
BranchDAO.java 3KB
Damage.java 3KB
GetUse.java 3KB
Cart.java 2KB
GoodsForm.java 2KB
SysDAO.java 2KB
DamageForm.java 2KB
GetUseForm.java 2KB
UserForm.java 2KB
StockMainForm.java 2KB
StockMainViewForm.java 2KB
共 211 条
- 1
- 2
- 3
资源评论
程序猿小D
- 粉丝: 4298
- 资源: 1045
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功