src/com/jiudai/dao/BuyDAO.java

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

package com.jiudai.dao;

 
import java.util.List;

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

import com.jiudai.Utils.HibernateUtil;
import com.jiudai.domain.BuyInfo;

public class BuyDAO { 
	
	private final int PAGE_SIZE = 8;
	
	/*保存汽车采购信息*/
	public void  AddBuyInfo(BuyInfo buyInfo) {
		Session s = null;
		Transaction tx = null;
		try {
			s = HibernateUtil.getSession();
			tx = s.beginTransaction();
			s.save(buyInfo);
			/*登记采购信息时需要同时更新汽车的库存*/
			StockDAO stockDAO = new StockDAO();
			String carname = buyInfo.getCarname();
			int count = buyInfo.getNumber();
			stockDAO.UpdateStockCount(carname, count); 
			tx.commit(); 
		} catch (HibernateException e) {
			if(tx != null)
				tx.rollback(); 
			throw e;
		} finally {
			HibernateUtil.closeSession();
		} 
	}

	public int CalculateTotalPage(String keyword, String startdate, String enddate) {
		Session s = null;
		try {
			s = HibernateUtil.getSession();
			String hql = "select new Map" +
			"(b.buyId as buyId," +
			"b.carname as carname," +
			"b.dateString as dateString," +
			"b.day as day," +
			"b.model as model," +
			"b.month as month," +
			"b.number as number," + 
			"b.price as price," + 
			"b.supplyer as supplyer," + 
			"b.totalMoney as totalMoney," +
			"b.year as year," +
			"em.name as name) from BuyInfo b,Employee em " +
			"where b.employeeId = em.id ";
			if(!keyword.equals("")) {
				hql += " and b.carname like '%" + keyword + "%'";
后面还有 54 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。