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

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

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

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.RetRentOrderIsExistsException();//归还明细单号已经存在
            }
        }
 public ActionResult Update(RetRentOrderDetail retRentOrderDetail)
 {
     return Json(retRentOrderDetailOper.Update(retRentOrderDetail,
         delegate(object sender, ISession session)
         {
             //判断是否存在归还明细单号
             IsExistsCode(session, retRentOrderDetail);
         }
         ));
 }
 public ActionResult Del(RetRentOrderDetail retRentOrderDetail)
 {
     return Json(retRentOrderDetailOper.Del(retRentOrderDetail));
 }