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