private void IsExistsCode(ISession session, PurOrderDetail retDetail)
        {
            ICriteria criteria = session.CreateCriteria(typeof(PurOrderDetail));

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

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

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.PurOrderIsExistsException();//采购明细单号已经存在
            }
        }
 public ActionResult Update(PurOrderDetail purOrderDetail)
 {
     return Json(purOrderDetailOper.Update(purOrderDetail,
         delegate(object sender, ISession session)
         {
             //判断是否存在采购明细单号
             IsExistsCode(session, purOrderDetail);
         }
         ));
 }
 public ActionResult Del(PurOrderDetail purOrderDetail)
 {
     return Json(purOrderDetailOper.Del(purOrderDetail));
 }