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

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

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

            int count = (int)criteria.UniqueResult();
            if (count > 0)
            {
                throw new EasyJob.Tools.Exceptions.SellOrderIsExistsException();//销售明细单号已经存在
            }
        }
 public ActionResult Update(SellOrderDetail sellOrderDetail)
 {
     return Json(sellOrderDetailOper.Update(sellOrderDetail,
         delegate(object sender, ISession session)
         {
             //判断是否存在销售明细单号
             IsExistsCode(session, sellOrderDetail);
         }
         ));
 }
 public ActionResult Del(SellOrderDetail sellOrderDetail)
 {
     return Json(sellOrderDetailOper.Del(sellOrderDetail));
 }