private void IsExistsCode(ISession session, CheckStockDetail checkStockDetail) { ICriteria criteria = session.CreateCriteria(typeof(CheckStockDetail)); ICriterion criterion = null; if (checkStockDetail.Id != Guid.Empty) { criterion = Restrictions.Not(Restrictions.IdEq(checkStockDetail.Id)); criteria.Add(criterion); } criterion = Restrictions.Eq("CheckStockID", checkStockDetail.CheckStock); criteria.Add(criterion); //统计 criteria.SetProjection( Projections.ProjectionList() .Add(Projections.Count("Id")) ); int count = (int)criteria.UniqueResult(); if (count > 0) { throw new EasyJob.Tools.Exceptions.CheckStockIsExistsException();//盘点明细单号已经存在 } }
public ActionResult Update(CheckStockDetail checkStockDetail) { return(Json(checkStockDetailOper.Update(checkStockDetail, delegate(object sender, ISession session) { //判断是否存在盘点明细单号 IsExistsCode(session, checkStockDetail); } ))); }
public ActionResult Del(CheckStockDetail checkStockDetail) { return(Json(checkStockDetailOper.Del(checkStockDetail))); }