package com.tianyuan.CWMM.action;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.hibernate.Session;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.tianyuan.CWMM.model.Material;
import com.tianyuan.CWMM.model.MaterialCategory;
import com.tianyuan.CWMM.service.MaterialOperation;
import com.tianyuan.CWMM.service.impl.MaerialOperationImpl;
import com.tianyuan.CWMM.util.HibernateSessionFactory;
import com.tianyuan.CWMM.vo.MaterialVO;
public class MaterialAction extends ActionSupport {
private int id, price, quantity, category_id, flag;
private String name, categoryName;
List<MaterialVO> materialList = null;
List<MaterialCategory> materialCategoryList = null;
public int getFlag() {
return flag;
}
public void setFlag(int flag) {
this.flag = flag;
}
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public List<MaterialCategory> getMaterialCategoryList() {
return materialCategoryList;
}
public void setMaterialCategoryList(
List<MaterialCategory> materialCategoryList) {
this.materialCategoryList = materialCategoryList;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getCategory_id() {
return category_id;
}
public void setCategory_id(int category_id) {
this.category_id = category_id;
}
public List<MaterialVO> getMaterialList() {
return materialList;
}
public void setMaterialList(List<MaterialVO> materialList) {
this.materialList = materialList;
}
public String queryMaterial() throws Exception
{
String materialCategory = null;
materialList = new ArrayList<MaterialVO>();
//MaterialVO tempMaterialVO = new MaterialVO();
Session session = new HibernateSessionFactory().getSessionFactory()
.openSession();
session.beginTransaction();
List<Material> tempList = session.createQuery("from Material").list();
for(Iterator<Material> tempIterator = tempList.iterator() ; tempIterator.hasNext() ; )
{
MaterialVO tempMaterialVO = new MaterialVO();
Material tempMaterial = tempIterator.next();
int materialId = tempMaterial.getId();
int id = (int) session
.createQuery(
"select category_id from Material m where m.id= :id")
.setInteger("id", materialId).list().get(0);
materialCategory = (String) session
.createQuery(
"select categoryName from MaterialCategory mc where mc.id= :id")
.setInteger("id", id).list().get(0);
tempMaterialVO.setId(materialId);
tempMaterialVO.setCategory(materialCategory);
tempMaterialVO.setName(tempMaterial.getName());
tempMaterialVO.setPrice(tempMaterial.getPrice());
tempMaterialVO.setQuantity(tempMaterial.getQuantity());
tempMaterialVO.setCategoryId(id);
materialList.add(tempMaterialVO);
}
queryMaterialCategory();
return "queryMaterial";
}
public String updateMaterialInfo() {
Material m = new Material();
MaterialOperation materialOperation = new MaerialOperationImpl();
m.setCategory_id(category_id);
m.setId(id);
m.setName(name);
m.setPrice(price);
m.setQuantity(quantity);
materialOperation.updateMaterialInfo(m);
return "updateMaterialInfo";
}
public String queryMaterialCategory() {
Session session = new HibernateSessionFactory().getSessionFactory()
.openSession();
session.beginTransaction();
materialCategoryList = session.createQuery("from MaterialCategory")
.list();
session.getTransaction().commit();
session.close();
if(flag == 1)
{
return "queryMaterialCategory1";
}
return "queryMaterialCategory2";
}
public String deleteMaterial() {
Session session = new HibernateSessionFactory().getSessionFactory()
.openSession();
session.beginTransaction();
session.delete(session.load(Material.class, id));
session.getTransaction().commit();
session.close();
return "deleteMaterial";
}
public String addMaterial() {
Material m = new Material();
MaterialOperation materialOperation = new MaerialOperationImpl();
m.setCategory_id(category_id);
m.setId(id);
m.setName(name);
m.setPrice(price);
m.setQuantity(quantity);
materialOperation.addMaterial(m);
return "addMaterial";
}
public String updateMaterialCategory() {
MaterialCategory materialCategory = new MaterialCategory();
materialCategory.setId(id);
materialCategory.setCategoryName(categoryName);
Session session = new HibernateSessionFactory().getSessionFactory()
.openSession();
session.beginTransaction();
session.update(materialCategory);
session.getTransaction().commit();
session.close();
return "updateMaterialCategory";
}
public String addMaterialCategory() {
MaterialCategory materialCategory = new MaterialCategory();
materialCategory.setCategoryName(categoryName);
Session session = new HibernateSessionFactory().getSessionFactory()
.openSession();
session.beginTransaction();
session.save(materialCategory);
session.getTransaction().commit();
session.close();
return "addMaterialCategory";
}
public String deleteMaterialCategory() {
Session session = new HibernateSessionFactory().getSessionFactory()
.openSession();
session.beginTransaction();
session.delete(session.load(MaterialCategory.class, id));
session.getTransaction().commit();
session.close();
return "deleteMaterialCategory";
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
SSH2+mysql写的物资管理系统 (181个子文件)
MaterialAction.class 7KB
BorrowAction.class 5KB
BorrowOperationImpl.class 4KB
UserOperationImpl.class 3KB
AddUser.class 2KB
PasswordManagementImpl.class 2KB
QueryUser.class 2KB
UpdateUser.class 2KB
ChangePassword.class 2KB
UserAction.class 2KB
User.class 2KB
Material.class 1KB
MaterialVO.class 1KB
DeleteUser.class 1KB
MaerialOperationImpl.class 1KB
Borrow.class 1KB
BorrowVO.class 1KB
HibernateSessionFactory.class 1KB
MaterialCategory.class 1001B
BorrowOperation.class 438B
UserOperation.class 296B
PasswordManagement.class 294B
MaterialOperation.class 232B
.classpath 771B
org.eclipse.wst.common.component 530B
org.eclipse.wst.jsdt.ui.superType.container 49B
common.css 3KB
style.css 2KB
Thumbs.db 89KB
login_04.gif 22KB
login_11.gif 9KB
main_01.gif 8KB
login_06.gif 5KB
login_10.gif 4KB
login_03.gif 4KB
main_07.gif 3KB
login_07.gif 3KB
login_08.gif 2KB
login_09.gif 2KB
main_11.gif 2KB
main_05.gif 1KB
main_34.gif 1KB
main_19.gif 1KB
main_06.gif 953B
main_03.gif 871B
dl.gif 813B
cz.gif 796B
main_29.gif 785B
main_13.gif 633B
main_17.gif 596B
user.gif 596B
main_15.gif 594B
main_21.gif 591B
main_10.gif 549B
pass.gif 500B
quit.gif 426B
tab_bg.gif 376B
tb.gif 368B
main_32.gif 212B
main_71.gif 134B
main_30.gif 116B
del.gif 96B
main_69.gif 96B
add.gif 91B
edit.gif 91B
main_74.gif 85B
main_31.gif 83B
sj.gif 58B
main_72.gif 58B
main_35.gif 54B
main_43.gif 54B
main_28.gif 54B
right.html 12KB
top.html 5KB
left.html 4KB
index.html 2KB
down.html 960B
center.html 951B
main.html 716B
user_info_update_success.html 332B
loginFail.html 328B
fail_changePassword.html 285B
success_changePassword.html 279B
success.html 240B
success.html 232B
welcome.html 185B
hibernate-core-4.1.10.Final.jar 4.32MB
struts2-dojo-plugin-2.3.8.jar 1.65MB
freemarker-2.3.19.jar 909KB
spring-core-3.2.1.RELEASE.jar 843KB
spring-context-3.2.1.RELEASE.jar 838KB
mysql-connector-java-5.1.22-bin.jar 813KB
struts2-core-2.3.8.jar 775KB
javassist-3.15.0-GA.jar 633KB
spring-web-3.2.1.RELEASE.jar 610KB
xwork-core-2.3.8.jar 604KB
javassist-3.11.0.GA.jar 600KB
spring-beans-3.2.1.RELEASE.jar 593KB
antlr-2.7.7.jar 435KB
commons-lang3-3.1.jar 308KB
共 181 条
- 1
- 2
天--元
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- IMG_20240425_190941.jpg
- 基于stm32的pid控制算法附带串口控制台
- 实验项目一:线性表(模板 ).docx
- 基于LM317A设计交流220V输入可调5V-12V直流输出稳压电源电路multisim10仿真源文件.zip
- Screenshot_2024-04-25-17-04-18-55_2332cb9b27b851b548ba47a91682926c.jpg
- -基于AVR单片机的LNG加液机控制器设计.pdf
- ThePowerOfNow-EckhartTolle.mobi
- BLOCK_TYPE_HEARTBEAT_D70A3465D4EE4E9_046141_dump_1st.dmp
- 项目方法测试调用接口工具
- studyupdate
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页