コード例 #1
0
        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();//库存表存在
            }
        }
コード例 #2
0
 public ActionResult Update(StockInit stockInit)
 {
     return(Json(stockInitOper.Update(stockInit,
                                      delegate(object sender, ISession session)
     {
         //判断是否存在库存数据
         IsExists(session, stockInit);
     }
                                      )));
 }
コード例 #3
0
 public ActionResult Del(StockInit stockInit)
 {
     return(Json(stockInitOper.Del(stockInit)));
 }
コード例 #4
0
 private void btnInitStock_Click(object sender, EventArgs e)
 {
     StockInit.InitAsync();
 }