Ejemplo n.º 1
0
        /// <summary>
        /// Inserts the account category.
        /// </summary>
        /// <param name="budgetChapterEntity">The account category entity.</param>
        /// <returns>BudgetChapterResponse.</returns>
        public BudgetChapterResponse InsertBudgetChapter(BudgetChapterEntity budgetChapterEntity)
        {
            var response = new BudgetChapterResponse {
                Acknowledge = AcknowledgeType.Success
            };

            try
            {
                if (!budgetChapterEntity.Validate())
                {
                    foreach (string error in budgetChapterEntity.ValidationErrors)
                    {
                        response.Message += error + Environment.NewLine;
                    }
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
                budgetChapterEntity.BudgetChapterId = Guid.NewGuid().ToString();
                //check ma trung
                var budgetChapterEntityExited = BudgetChapterDao.GetBudgetChaptersByBudgetChapterCode(budgetChapterEntity.BudgetChapterCode);
                if (budgetChapterEntityExited != null)
                {
                    response.Acknowledge = AcknowledgeType.Failure;
                    response.Message     = string.Format(@"Mã chương {0} đã tồn tại trong hệ thống. Vui lòng nhập mã khác", budgetChapterEntityExited.BudgetChapterCode);
                    return(response);
                }

                response.Message = BudgetChapterDao.InsertBudgetChapter(budgetChapterEntity);
                if (!string.IsNullOrEmpty(response.Message))
                {
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
                response.BudgetChapterId = budgetChapterEntity.BudgetChapterId;
                return(response);
            }
            catch (Exception ex)
            {
                response.Acknowledge = AcknowledgeType.Failure;
                response.Message     = ex.Message;
                return(response);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the account category.
        /// </summary>
        /// <param name="budgetChapterEntity">The account category entity.</param>
        /// <returns>BudgetChapterResponse.</returns>
        public BudgetChapterResponse UpdateBudgetChapter(BudgetChapterEntity budgetChapterEntity)
        {
            var response = new BudgetChapterResponse {
                Acknowledge = AcknowledgeType.Success
            };

            try
            {
                if (!budgetChapterEntity.Validate())
                {
                    foreach (string error in budgetChapterEntity.ValidationErrors)
                    {
                        response.Message += error + Environment.NewLine;
                    }
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
                //check ma trung
                var budgetChapterEntityExited = BudgetChapterDao.GetBudgetChaptersByBudgetChapterCode(budgetChapterEntity.BudgetChapterCode);
                if (budgetChapterEntityExited != null && budgetChapterEntity.BudgetChapterCode != budgetChapterEntityExited.BudgetChapterCode)
                {
                    response.Acknowledge = AcknowledgeType.Failure;
                    response.Message     = string.Format(@"Mã chương {0} đã tồn tại trong hệ thống. Vui lòng nhập mã khác", budgetChapterEntityExited.BudgetChapterCode);
                    return(response);
                }
                response.Message = BudgetChapterDao.UpdateBudgetChapter(budgetChapterEntity);
                if (!string.IsNullOrEmpty(response.Message))
                {
                    if (response.Message.Contains("FK_AccountingObject_BudgetChapter") ||
                        response.Message.Contains("FK_BABankTransferDetailParallel_BudgetChapter") ||
                        response.Message.Contains("FK_BADepositDetail_BudgetChapter") ||
                        response.Message.Contains("FK_BADepositDetailFixedAsset_BudgetChapter") ||
                        response.Message.Contains("FK_BADepositDetailParallel_BudgetChapter") ||
                        response.Message.Contains("FK_BADepositDetailSale_BudgetChapter") ||
                        response.Message.Contains("FK_BAWithDrawDetail_BudgetChapter") ||
                        response.Message.Contains("FK_BAWithDrawDetailFixedAsset_BudgetChapter") ||
                        response.Message.Contains("FK_BAWithDrawDetailParallel_BudgetChapter") ||
                        response.Message.Contains("FK_BAWithDrawDetailPurchase_BudgetChapter") ||
                        response.Message.Contains("FK_BUBudgetReserve_BudgetChapter") ||
                        response.Message.Contains("FK_BUCommitmentAdjustmentDetail_BudgetChapter") ||
                        response.Message.Contains("FK_BUCommitmentRequestDetail_BudgetChapter") ||
                        response.Message.Contains("FK_BUPlanAdjustmentDetail_BudgetChapter") ||
                        response.Message.Contains("FK_BUPlanWithdrawDetail_BudgetChapter") ||
                        response.Message.Contains("FK_BUTransferDetail_BudgetChapter") ||
                        response.Message.Contains("FK_BUTransferDetailFixedAsset_BudgetChapter") ||
                        response.Message.Contains("FK_BUTransferDetailParallel_BudgetChapter") ||
                        response.Message.Contains("FK_BUTransferDetailPurchase_BudgetChapter") ||
                        response.Message.Contains("FK_BUVoucherListDetailParallel_BudgetChapter") ||
                        response.Message.Contains("FK_BUVoucherListDetailTransfer_BudgetChapter") ||
                        response.Message.Contains("FK_CAPaymentDetail_BudgetChapter") ||
                        response.Message.Contains("FK_CAPaymentDetailFixedAsset_BudgetChapter") ||
                        response.Message.Contains("FK_CAPaymentDetailParallel_BudgetChapter") ||
                        response.Message.Contains("FK_CAPaymentDetailPurchase_BudgetChapter") ||
                        response.Message.Contains("FK_CAReceiptDetail_BudgetChapter") ||
                        response.Message.Contains("FK_CAReceiptDetailFixedAsset_BudgetChapter") ||
                        response.Message.Contains("FK_CAReceiptDetailParallel_BudgetChapter") ||
                        response.Message.Contains("FK_FAAdjustmentDetail_BudgetChapter") ||
                        response.Message.Contains("FK_FAIncrementDecrementDetail_BudgetChapter") ||
                        response.Message.Contains("FK_FixedAsset_BudgetChapter_BudgetChapterCode") ||
                        response.Message.Contains("FK_GLVoucherDetail_BudgetChapter") ||
                        response.Message.Contains("FK_GLVoucherDetailParallel_BudgetChapter") ||
                        response.Message.Contains("FK_INInwardOutwardDetail_BudgetChapter") ||
                        response.Message.Contains("FK_OpeningAccountEntry_BudgetChapter") ||
                        response.Message.Contains("FK_OpeningFixedAssetEntry_BudgetChapter") ||
                        response.Message.Contains("FK_OpeningInventoryEntry_BudgetChapter") ||
                        response.Message.Contains("FK_PUInvoiceDetailFixedAsset_BudgetChapter"))
                    {
                        response.Message = @"Chương " + budgetChapterEntity.BudgetChapterCode + " đã phát sinh tại các nghiệp vụ liên quan không thể sửa mã!";
                    }
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
                if (!string.IsNullOrEmpty(response.Message))
                {
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }
                response.BudgetChapterId = budgetChapterEntity.BudgetChapterId;
                return(response);
            }
            catch (Exception ex)
            {
                response.Acknowledge = AcknowledgeType.Failure;
                response.Message     = ex.Message;
                return(response);
            }
        }