/// <summary>
 /// 保存实体数据(新增、修改)
 /// <param name="keyValue">主键</param>
 /// <summary>
 /// <returns></returns>
 public void SaveEntity(string keyValue, XM_Facility_PayEntity entity)
 {
     try
     {
         if (!string.IsNullOrEmpty(keyValue))
         {
             entity.Modify(keyValue);
             this.BaseRepository().Update(entity);
         }
         else
         {
             entity.Create();
             this.BaseRepository().Insert(entity);
         }
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowServiceException(ex);
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// 保存实体数据(新增、修改)
 /// <param name="keyValue">主键</param>
 /// <summary>
 /// <returns></returns>
 public void SaveEntity(string keyValue, XM_Facility_PayEntity entity)
 {
     try
     {
         facilityPayService.SaveEntity(keyValue, entity);
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowBusinessException(ex);
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// 保存实体数据(新增、修改)
        /// <param name="keyValue">主键</param>
        /// <summary>
        /// <returns></returns>
        public void SaveEntityPurchase(string keyValue, XM_Pay_DatailsEntity entity, string items)
        {
            try
            {
                IRepository db = new RepositoryFactory().BaseRepository();
                if (!string.IsNullOrEmpty(keyValue))
                {
                    entity.Modify(keyValue);
                    db.Update(entity);
                }
                else
                {
                    entity.Create();
                    db.Insert(entity);
                }
                List <XM_Facility_BaseEntity> list      = Extensions.ToList <XM_Facility_BaseEntity>(items);
                List <XM_Facility_BaseEntity> list_item = items.ToList <XM_Facility_BaseEntity>();
                foreach (var item in list_item)
                {
                    XM_Facility_PayEntity tN_CP_FKMXEntity = new XM_Facility_PayEntity();
                    tN_CP_FKMXEntity.BindId           = entity.Id;
                    tN_CP_FKMXEntity.FacilityId       = item.Id;
                    tN_CP_FKMXEntity.FacilityCode     = item.Code;
                    tN_CP_FKMXEntity.FacilityName     = item.Name;
                    tN_CP_FKMXEntity.FacilityType     = item.Classify;
                    tN_CP_FKMXEntity.ProjectNo        = item.ProjectNo;
                    tN_CP_FKMXEntity.ProjectName      = item.ProjectName;
                    tN_CP_FKMXEntity.PactName         = item.PurchaseName;
                    tN_CP_FKMXEntity.PactCode         = item.PurchaseNo;
                    tN_CP_FKMXEntity.Price            = item.Price;
                    tN_CP_FKMXEntity.Quantity         = item.Quantity;
                    tN_CP_FKMXEntity.Unit             = item.Unit;
                    tN_CP_FKMXEntity.PaymentCompanyId = item.Package;
                    tN_CP_FKMXEntity.PaymentAmount    = item.TotalPrice;
                    tN_CP_FKMXEntity.PayDate          = entity.PayDate;
                    tN_CP_FKMXEntity.PayNo            = entity.PayNo;
                    tN_CP_FKMXEntity.VoucherNo        = entity.VoucherNo;
                    tN_CP_FKMXEntity.Create();
                    db.Insert(tN_CP_FKMXEntity);
                    XM_Facility_BaseEntity facilityEntity = new XM_Facility_BaseEntity();
                    facilityEntity.Id          = item.Id;
                    facilityEntity.PayQuantity = item.Quantity + item.PayQuantity;
                    db.Update(facilityEntity);
                }
                XM_Pact_PurchaseEntity PactEntity = pactPurchaseIBLL.GetXM_Pact_PurchaseEntity(entity.BindId);
                XM_Pact_PurchaseEntity PurEntity  = new XM_Pact_PurchaseEntity();

                //已付金额
                decimal?pAmount = PactEntity.PaidAmount + entity.PayAmount;
                //未付金额
                decimal?unpAmount = PactEntity.Amount - pAmount;
                PurEntity.PaidAmount   = pAmount;
                PurEntity.UnPaidAmount = unpAmount;
                PurEntity.Id           = entity.BindId;
                db.Update(PurEntity);
                //pactPurchaseIBLL.SaveEntity(entity.BindId, PurEntity);

                try
                {
                    db.Commit();
                }
                catch (Exception)
                {
                    db.Rollback();
                    throw;
                }
            }
            catch (Exception ex)
            {
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }