private void IsExists(ISession session, StorageAlarm storageAlarm) { ICriteria criteria = session.CreateCriteria(typeof(StorageAlarm)); ICriterion criterion = null; if (storageAlarm.Id != Guid.Empty) { criterion = Restrictions.Not(Restrictions.IdEq(storageAlarm.Id)); criteria.Add(criterion); } criterion = Restrictions.Eq("Storehouse", storageAlarm.Storehouse); criteria.Add(criterion); criterion = Restrictions.Eq("Goods", storageAlarm.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.StorageAlarmIsExistsException();//库存报警表存在 } }
public ActionResult Update(StorageAlarm storageAlarm) { return Json(storageAlarmOper.Update(storageAlarm, delegate(object sender, ISession session) { //判断是否存在库存数据 IsExists(session, storageAlarm); } )); }
public ActionResult Del(StorageAlarm storageAlarm) { return Json(storageAlarmOper.Del(storageAlarm)); }