Ejemplo n.º 1
0
        /// <summary>
        /// Deletes the budget chapter.
        /// </summary>
        /// <param name="budgetChapter">The budget chapter.</param>
        /// <returns>System.String.</returns>
        public string DeleteBudgetChapter(BudgetChapterEntity budgetChapter)
        {
            const string sql = @"uspDelete_BudgetChapter";

            object[] parms = { "@BudgetChapterID", budgetChapter.BudgetChapterId };
            return(Db.Delete(sql, true, parms));
        }
 /// <summary>
 /// Takes the specified budget chapter.
 /// </summary>
 /// <param name="budgetChapter">The budget chapter.</param>
 /// <returns>System.Object[][].</returns>
 private object[] Take(BudgetChapterEntity budgetChapter)
 {
     return(new object[]
     {
         "@BudgetChapterID", budgetChapter.BudgetChapterId,
         "@BudgetChapterCode", budgetChapter.BudgetChapterCode,
         "@BudgetChapterName", budgetChapter.BudgetChapterName,
         "@IsActive", budgetChapter.IsActive,
     });
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Takes the specified budget chapter.
 /// </summary>
 /// <param name="budgetChapter">The budget chapter.</param>
 /// <returns>System.Object[][].</returns>
 private object[] Take(BudgetChapterEntity budgetChapter)
 {
     return(new object[]
     {
         "@BudgetChapterID", budgetChapter.BudgetChapterId,
         "@BudgetChapterCode", budgetChapter.BudgetChapterCode,
         "@BudgetChapterName", budgetChapter.BudgetChapterName,
         "@Description", budgetChapter.Description,
         "@IsSystem", budgetChapter.IsSystem,
         "@IsActive", budgetChapter.IsActive,
         "@ForeignName", budgetChapter.ForeignName
     });
 }
Ejemplo n.º 4
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);
            }
        }
        public List <BudgetChapterEntity> GetBudgetChapters(string connectionString)
        {
            List <BudgetChapterEntity> listBudgetChapter = new List <BudgetChapterEntity>();

            using (var context = new MISAEntity(connectionString))
            {
                var lstBudgetChapter = context.BudgetChapters.ToList();

                foreach (var result in lstBudgetChapter)
                {
                    var budgetChapter = new BudgetChapterEntity();
                    budgetChapter.BudgetChapterId   = result.BudgetChapterID.ToString();
                    budgetChapter.BudgetChapterCode = result.BudgetChapterCode;
                    budgetChapter.BudgetChapterName = result.BudgetChapterName;
                    budgetChapter.IsActive          = result.Active;
                    listBudgetChapter.Add(budgetChapter);
                }
            }
            return(listBudgetChapter);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Updates the budget chapter.
        /// </summary>
        /// <param name="budgetChapter">The budget chapter.</param>
        /// <returns>System.String.</returns>
        public string UpdateBudgetChapter(BudgetChapterEntity budgetChapter)
        {
            const string sql = "uspUpdate_BudgetChapter";

            return(Db.Update(sql, true, Take(budgetChapter)));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Inserts the budget chapter.
        /// </summary>
        /// <param name="budgetChapter">The budget chapter.</param>
        /// <returns>System.Int32.</returns>
        public int InsertBudgetChapter(BudgetChapterEntity budgetChapter)
        {
            const string sql = "uspInsert_BudgetChapter";

            return(Db.Insert(sql, true, Take(budgetChapter)));
        }
Ejemplo n.º 8
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);
            }
        }