private void SaveStatus(string keyValue, LR_ERP_PurchaseWarehousingEntity entity)
        {
            var db = this.BaseRepository().BeginTrans();

            try
            {
                entity.F_ModifyDate     = DateTime.Now;
                entity.F_ModifyUserName = Learun.Util.LoginUserInfo.Get().realName;
                entity.F_Id             = Guid.NewGuid().ToString();
                entity.F_Status         = keyValue;
                db.Insert(entity);
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }
        /// <summary>
        /// 保存实体数据(新增、修改)
        /// <param name="keyValue">主键</param>
        /// <summary>
        /// <returns></returns>
        public void SaveEntity(string keyValue, LR_ERP_PurchaseWarehousingEntity entity, List <LR_ERP_PurchaseWarehousingDetailEntity> lR_ERP_PurchaseWarehousingDetailList)
        {
            var db = this.BaseRepository().BeginTrans();
            LR_ERP_PurchaseWarehousingEntity lR_ERP_PurchaseWarehousingEntityTmp = new LR_ERP_PurchaseWarehousingEntity();

            try
            {
                if (!string.IsNullOrEmpty(keyValue))
                {
                    lR_ERP_PurchaseWarehousingEntityTmp = GetLR_ERP_PurchaseWarehousingEntity(keyValue);
                    entity.F_ModifyDate     = DateTime.Now;
                    entity.F_ModifyUserName = Learun.Util.LoginUserInfo.Get().realName;
                    entity.Modify(keyValue);
                    db.Update(entity);
                    db.Delete <LR_ERP_PurchaseWarehousingDetailEntity>(t => t.F_PWID == lR_ERP_PurchaseWarehousingEntityTmp.F_Id);
                    foreach (LR_ERP_PurchaseWarehousingDetailEntity item in lR_ERP_PurchaseWarehousingDetailList)
                    {
                        item.Create();
                        item.F_PWID = lR_ERP_PurchaseWarehousingEntityTmp.F_Id;
                        db.Insert(item);
                    }
                }
                else
                {
                    entity.Create();
                    db.Insert(entity);
                    foreach (LR_ERP_PurchaseWarehousingDetailEntity item in lR_ERP_PurchaseWarehousingDetailList)
                    {
                        item.Create();
                        item.F_PWID = entity.F_Id;
                        db.Insert(item);
                    }
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
            if (!string.IsNullOrEmpty(lR_ERP_PurchaseWarehousingEntityTmp.F_PurchaseNo) && !string.IsNullOrEmpty(keyValue))
            {
                SaveStatus(keyValue, lR_ERP_PurchaseWarehousingEntityTmp);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 保存实体数据(新增、修改)
 /// <param name="keyValue">主键</param>
 /// <summary>
 /// <returns></returns>
 public void SaveEntity(string keyValue, LR_ERP_PurchaseWarehousingEntity entity, List <LR_ERP_PurchaseWarehousingDetailEntity> lR_ERP_PurchaseWarehousingDetailList)
 {
     try
     {
         purchaseWarehousingService.SaveEntity(keyValue, entity, lR_ERP_PurchaseWarehousingDetailList);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }
 public void UpdatePurchase(string purchaseId)
 {
     try
     {
         LR_ERP_PurchaseWarehousingEntity entity = GetLR_ERP_PurchaseWarehousingEntity(purchaseId);
         entity.F_Status = String.Empty;
         this.BaseRepository().Update(entity);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowServiceException(ex);
         }
     }
 }
 public void UpdatePurchaseInfo(string purchaseInfoId, string purchaseId)
 {
     try
     {
         LR_ERP_PurchaseWarehousingEntity purchaseRequisitionEntity = GetLR_ERP_PurchaseWarehousingEntity(purchaseInfoId);
         purchaseRequisitionEntity.F_Status = purchaseId;
         this.BaseRepository().Update(purchaseRequisitionEntity);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowServiceException(ex);
         }
     }
 }