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

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

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

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.RetOrderIsExistsException();//退货明细单号已经存在
            }
        }
 public ActionResult Update(RetOrderDetail retOrderDetail)
 {
     return Json(retOrderDetailOper.Update(retOrderDetail,
         delegate(object sender, ISession session)
         {
             //判断是否存在退货明细单号
             IsExistsCode(session, retOrderDetail);
         }
         ));
 }
 public ActionResult Del(RetOrderDetail retOrderDetail)
 {
     return Json(retOrderDetailOper.Del(retOrderDetail));
 }