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
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【项目实战案例】java物资管理系统项目(web端) 物资管理系统使用说明书 配置源程序 附加SQL Server 2005数据库 (1)将MR\07\WebRoot\Database文件夹中的扩展名为db_Material_Data.MDF和db_Material_Log.LDF的两个文件拷贝到本地机器的MyEclipse工作空间以外的任何位置。 (2)打开SQL Server 2005的“SQL Server Management Studio”,并登录,然后展开本地服务器,在“数据库”节点上单击鼠标右键,在弹出的快捷菜单中选择“附加”子节点。 (3)将弹出“附加数据库”对话框,在该对话框中单击“添加”按钮,选择所要附加数据库的db_Material_Data.MDF文件,单击【确定】按钮,即可完成数据库的附加操作。 将程序导入到MyEclipse中,并发布运行 (1)将“MR\07\”文件夹拷贝到MyEclipse的工作空间中。 (2)启动MyEclipse,在左侧的“包资源管理器”中,单击鼠标右键,选择“Import”菜单项,在弹出的对话框中,展开General节点,并选择“E
资源推荐
资源详情
资源评论
收起资源包目录
【项目实战案例】java物资管理系统项目(web端) (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
程序使用说明.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
资源评论
西攻城狮北
- 粉丝: 8379
- 资源: 434
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 阀门检测49-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、TFRecord、VOC数据集合集.rar
- 非常好的SqlServer大量源代码和教程资料100%好用.zip
- 基于Vue的社区拼购商城(毕业设计).zip
- springboot儿童安全知识教育系统
- (解压密码1234)HTML打包EXE 2.0.0 含Webview2内核
- zheshiyige rocketde bao
- 《人工智能及其应用》蔡自兴最新版课后习题参考答案2021
- 基于Vue、Node.js(Express)、MongoDB搭建的个人博客博客&后台管理系统admin,承接毕业设计系统+解决疑难杂症,联系微信zonemeen.zip
- 洗衣店全球市场报告:2023年洗衣机零售额高达934亿元,潜力无限
- springboot儿童安全知识教育系统
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功