Exemple #1
0
        private void IsExists(ISession session, Stock stock)
        {
            ICriteria criteria = session.CreateCriteria(typeof(Stock));

            ICriterion criterion = null;
            if (stock.Id != Guid.Empty)
            {
                criterion = Restrictions.Not(Restrictions.IdEq(stock.Id));
                criteria.Add(criterion);
            }

            criterion = Restrictions.Eq("Storehouse", stock.Storehouse);
            criteria.Add(criterion);

            criterion = Restrictions.Eq("Goods", stock.Goods);
            criteria.Add(criterion);
            //统计
            criteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.Count("Id"))
                );

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.StockIsExistsException();//库存表存在
            }
        }
Exemple #2
0
 public ActionResult Update(Stock stock)
 {
     return Json(stockOper.Update(stock,
         delegate(object sender, ISession session)
         {
             //判断是否存在库存数据
             IsExists(session, stock);
         }
         ));
 }
Exemple #3
0
 public ActionResult Del(Stock stock)
 {
     return Json(stockOper.Del(stock));
 }