Example #1
0
        private void IsExistsBarCode(ISession session, GoodsInfo goods)
        {
            ICriteria criteria = session.CreateCriteria(typeof(GoodsInfo));

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

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

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.GoodsInfoBarCodeIsExistsException();//商品资料Code已经存在
            }
        }
Example #2
0
 public ActionResult Add(GoodsInfo goodsInfo)
 {
     return Json(goodsInfoOper.Add(goodsInfo,
         delegate(object sender, ISession session)
         {
             //判断是否存在商品资料Code
             IsExistsCode(session, goodsInfo);
             //判断是否存在商品资料BarCode
             IsExistsBarCode(session, goodsInfo);
         }
         ));
 }
Example #3
0
 public ActionResult Del(GoodsInfo goodsInfo)
 {
     return Json(goodsInfoOper.Del(goodsInfo));
 }