src/com/jiudai/dao/SellDAO.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.SellInfo;
public class SellDAO {
private final int PAGE_SIZE = 8;
/*登记销售 信息*/
public void AddSellInfo(SellInfo sellInfo) throws Exception {
/*首先查询该汽车库存*/
String carname = sellInfo.getCarname();
StockDAO stockDAO = new StockDAO();
int stockCount = stockDAO.GetStockCount(carname);
/*如果库存不足就抛出异常,action能捕获该异常信息*/
if(sellInfo.getNumber() > stockCount) {
throw new Exception("汽车库存不足!无法操作!");
}
Session s = null;
Transaction tx = null;
try {
stockDAO.UpdateStockCount(carname, 0-sellInfo.getNumber());
s = HibernateUtil.getSession();
tx = s.beginTransaction();
s.save(sellInfo);
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" +
"(s.sellId as sellId," +
"s.carname as carname," +
"s.dateString as dateString," +
"s.day as day," +
"s.model as model," +
"s.month as month," +
"s.number as number," +
"s.price as price," +
"s.supplyer as supplyer," +
"s.totalMoney as totalMoney," +
"s.year as year," +
后面还有 61 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
