yuexiaoshouzhangdanserviceimpl.java

来自「自己写的一个java购销系统」· Java 代码 · 共 125 行

JAVA
125
字号
package com.yuanjin.mtgx.service.impl;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.yuanjin.mtgx.dao.YueXiaoShouZhangDanDAO;
import com.yuanjin.mtgx.dao.impl.YueXiaoShouZhangDanDAOImpl;
import com.yuanjin.mtgx.entity.YueXiaoShouZhangDan;
import com.yuanjin.mtgx.service.YueXiaoShouZhangDanService;
import com.yuanjin.mtgx.util.HbnUtil;

public class YueXiaoShouZhangDanServiceImpl implements YueXiaoShouZhangDanService {
	
	private YueXiaoShouZhangDanDAO dao=new YueXiaoShouZhangDanDAOImpl();

	public boolean addYueXiaoShouZhangDan(YueXiaoShouZhangDan yxszd) {
		// TODO Auto-generated method stub
		Session session=null;
		Transaction tran=null;
		boolean success=false;
		try {
			session=HbnUtil.getCurrentSession();
			tran=session.beginTransaction();
			dao.save(yxszd);
			tran.commit();
			success=true;
		} catch (HibernateException e) {
			tran.rollback();
			e.printStackTrace();
		}
		return success;
	}

	public boolean deleteYueXiaoShouZhangDan(YueXiaoShouZhangDan yxszd) {
		// TODO Auto-generated method stub
		Session session=null;
		Transaction tran=null;
		boolean success=false;
		try {
			session=HbnUtil.getCurrentSession();
			tran=session.beginTransaction();
			dao.delete(yxszd);
			tran.commit();
			success=true;
		} catch (HibernateException e) {
			tran.rollback();
			e.printStackTrace();
		}
		return success;
	}

	public List findAllYueXiaoShouZhangDan() {
		// TODO Auto-generated method stub
		Session session=null;
		Transaction tran=null;
		List list=null;
		try {
			session=HbnUtil.getCurrentSession();
			tran=session.beginTransaction();
			list=dao.findALL();
			tran.commit();
		} catch (HibernateException e) {
			tran.rollback();
			e.printStackTrace();
		}
		return list;
	}

	public YueXiaoShouZhangDan findYueXiaoShouZhangDanByNo(String zdbh) {
		// TODO Auto-generated method stub
		Session session=null;
		Transaction tran=null;
		YueXiaoShouZhangDan yxszd=null;
		try {
			session=HbnUtil.getCurrentSession();
			tran=session.beginTransaction();
			yxszd=dao.findByNo(zdbh);
			tran.commit();
		} catch (HibernateException e) {
			tran.rollback();
			e.printStackTrace();
		}
		return yxszd;
	}

	public boolean modifyYueXiaoShouZhangDan(YueXiaoShouZhangDan yxszd) {
		// TODO Auto-generated method stub
		Session session=null;
		Transaction tran=null;
		boolean success=false;
		try {
			session=HbnUtil.getCurrentSession();
			tran=session.beginTransaction();
			dao.update(yxszd);
			tran.commit();
			success=true;
		} catch (HibernateException e) {
			tran.rollback();
			e.printStackTrace();
		}
		return success;
	}

	public YueXiaoShouZhangDan findYueXiaoShouZhangDanByMonth(String month) {
		// TODO Auto-generated method stub
		Session session=null;
		Transaction tran=null;
		YueXiaoShouZhangDan yxszd=null;
		try {
			session=HbnUtil.getCurrentSession();
			tran=session.beginTransaction();
			yxszd=dao.findByMonth(month);
			tran.commit();
		} catch (HibernateException e) {
			tran.rollback();
			e.printStackTrace();
		}
		return yxszd;
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?