コード例 #1
0
        private void IsExistsCode(ISession session, Storehouse sh)
        {
            ICriteria criteria = session.CreateCriteria(typeof(Storehouse));

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

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

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.StorehouseCodeIsExistsException();//库存Code已经存在
            }
        }
コード例 #2
0
 public ActionResult Add(Storehouse storehouse)
 {
     //根据地址码获取地址
     storehouse.Addr = PojoUtil.GetAddrForCode(HibernateOper, storehouse.AddrCode);
     LocationUtil.Location loc = LocationUtil.GetLocation(storehouse.Addr + storehouse.Location);
     if (loc != null)
     {
         storehouse.Lat = loc.lat;
         storehouse.Lng = loc.lng;
     }
     return Json(storehouseOper.Add(storehouse,
         delegate(object sender, ISession session)
         {
             //判断是否存在库存Code
             IsExistsCode(session, storehouse);
         }
         ));
 }
コード例 #3
0
 public ActionResult Del(Storehouse storehouse)
 {
     return Json(storehouseOper.Del(storehouse));
 }