Beispiel #1
0
        /// <summary>
        /// Deletes the fixed asset category.
        /// </summary>
        /// <param name="fixedAssetCategory">The fixed asset category.</param>
        /// <returns></returns>
        public string DeleteFixedAssetCategory(FixedAssetCategoryEntity fixedAssetCategory)
        {
            const string sql = @"uspDelete_FixedAssetCategory";

            object[] parms = { "@FixedAssetCategoryID", fixedAssetCategory.FixedAssetCategoryId };
            return(Db.Delete(sql, true, parms));
        }
Beispiel #2
0
        public FixedAssetCategoryResponse UpdateFixedAssetCategory(FixedAssetCategoryEntity fixedAssetCategoryEntity)
        {
            var response = new FixedAssetCategoryResponse {
                Acknowledge = AcknowledgeType.Success
            };

            try
            {
                if (!fixedAssetCategoryEntity.Validate())
                {
                    foreach (string error in fixedAssetCategoryEntity.ValidationErrors)
                    {
                        response.Message += error + Environment.NewLine;
                    }
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }

                if (!string.IsNullOrEmpty(response.Message))
                {
                    response.Acknowledge = AcknowledgeType.Failure;
                    return(response);
                }

                var fixedAssetCategoryCheck = FixedAssetCategoryDao.GetFixedAssetCategorybyCode(fixedAssetCategoryEntity.FixedAssetCategoryCode);
                if (fixedAssetCategoryCheck != null)
                {
                    if (fixedAssetCategoryCheck.FixedAssetCategoryId !=
                        fixedAssetCategoryEntity.FixedAssetCategoryId)
                    {
                        response.Acknowledge = AcknowledgeType.Failure;
                        response.Message     = @"Mã nhóm " + fixedAssetCategoryEntity.FixedAssetCategoryCode + " đã tồn tại";
                        return(response);
                    }
                }

                response.Message = FixedAssetCategoryDao.UpdateFixedAssetCategory(fixedAssetCategoryEntity);
                response.fixedAssetCategoryId = fixedAssetCategoryEntity.FixedAssetCategoryId;
                return(response);
            }
            catch (Exception ex)
            {
                response.Acknowledge = AcknowledgeType.Failure;
                response.Message     = ex.Message;
                return(response);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Takes the specified fixedAssetCategory.
 /// </summary>
 /// <param name="fixedAssetCategory">The fixedAssetCategory.</param>
 /// <returns></returns>
 private object[] Take(FixedAssetCategoryEntity fixedAssetCategory)
 {
     return(new object[]
     {
         "@FixedAssetCategoryID", fixedAssetCategory.FixedAssetCategoryId,
         "@ParentID", fixedAssetCategory.ParentId,
         "@FixedAssetCategoryCode", fixedAssetCategory.FixedAssetCategoryCode,
         "@FixedAssetCategoryName", fixedAssetCategory.FixedAssetCategoryName,
         "@FixedAssetCategoryForeignName", fixedAssetCategory.FixedAssetCategoryForeignName,
         "@DepreciationRate", fixedAssetCategory.DepreciationRate,
         "@LifeTime", fixedAssetCategory.LifeTime,
         "@Grade", fixedAssetCategory.Grade,
         "@IsParent", fixedAssetCategory.IsParent,
         "@OrgPriceAccountCode", fixedAssetCategory.OrgPriceAccountCode,
         "@DepreciationAccountCode", fixedAssetCategory.DepreciationAccountCode,
         "@CapitalAccountCode", fixedAssetCategory.CapitalAccountCode,
         "@BudgetChapterCode", fixedAssetCategory.BudgetChapterCode,
         "@BudgetCategoryCode", fixedAssetCategory.BudgetCategoryCode,
         "@BudgetGroupCode", fixedAssetCategory.BudgetGroupCode,
         "@BudgetItemCode", fixedAssetCategory.BudgetItemCode,
         "@IsActive", fixedAssetCategory.IsActive,
         "@Unit", fixedAssetCategory.Unit
     });
 }
        public List <FixedAssetCategoryEntity> GetFixedAssetCategory(string connectionString)
        {
            List <FixedAssetCategoryEntity> listFixedAssetCategory = new List <FixedAssetCategoryEntity>();

            using (var context = new MISAEntity(connectionString))
            {
                var categories = context.FixedAssetCategories.ToList().OrderBy(x => x.Grade);
                foreach (var result in categories)
                {
                    var fixedAssetCategory = new FixedAssetCategoryEntity();
                    fixedAssetCategory.FixedAssetCategoryId   = result.FixedAssetCategoryID.ToString();
                    fixedAssetCategory.FixedAssetCategoryCode = result.FixedAssetCategoryCode;
                    fixedAssetCategory.FixedAssetCategoryName = result.FixedAssetCategoryName;
                    fixedAssetCategory.Description            = result.Description;
                    fixedAssetCategory.ParentId              = result.ParentID.ToString();
                    fixedAssetCategory.Grade                 = result.Grade;
                    fixedAssetCategory.IsParent              = result.IsParent;
                    fixedAssetCategory.LifeTime              = result.LifeTime ?? 0;
                    fixedAssetCategory.DepreciationRate      = result.DepreciationRate ?? 0;
                    fixedAssetCategory.OrgPriceAccount       = result.OrgPriceAccount;
                    fixedAssetCategory.DepreciationAccount   = result.DepreciationAccount;
                    fixedAssetCategory.CapitalAccount        = result.CapitalAccount;
                    fixedAssetCategory.BudgetChapterCode     = result.BudgetChapterCode;
                    fixedAssetCategory.BudgetKindItemCode    = result.BudgetKindItemCode;
                    fixedAssetCategory.BudgetSubKindItemCode = result.BudgetSubKindItemCode;
                    fixedAssetCategory.BudgetItemCode        = result.BudgetItemCode;
                    fixedAssetCategory.BudgetSubItemCode     = result.BudgetSubItemCode;
                    fixedAssetCategory.IsActive              = true;


                    listFixedAssetCategory.Add(fixedAssetCategory);
                }
            }

            return(listFixedAssetCategory);
        }
Beispiel #5
0
 private object[] Take(FixedAssetCategoryEntity fixedAssetCategory)
 {
     return(new object[]
     {
         "@FixedAssetCategoryID", fixedAssetCategory.FixedAssetCategoryId,
         "@FixedAssetCategoryCode", fixedAssetCategory.FixedAssetCategoryCode,
         "@FixedAssetCategoryName", fixedAssetCategory.FixedAssetCategoryName,
         "@Description", fixedAssetCategory.Description,
         "@ParentID", fixedAssetCategory.ParentId,
         "@Grade", fixedAssetCategory.Grade,
         "@IsParent", fixedAssetCategory.IsParent,
         "@LifeTime", fixedAssetCategory.LifeTime,
         "@DepreciationRate", fixedAssetCategory.DepreciationRate,
         "@OrgPriceAccount", fixedAssetCategory.OrgPriceAccount,
         "@DepreciationAccount", fixedAssetCategory.DepreciationAccount,
         "@CapitalAccount", fixedAssetCategory.CapitalAccount,
         "@BudgetChapterCode", fixedAssetCategory.BudgetChapterCode,
         "@BudgetKindItemCode", fixedAssetCategory.BudgetKindItemCode,
         "@BudgetSubKindItemCode", fixedAssetCategory.BudgetSubKindItemCode,
         "@BudgetItemCode", fixedAssetCategory.BudgetItemCode,
         "@BudgetSubItemCode", fixedAssetCategory.BudgetSubItemCode,
         "@IsActive", fixedAssetCategory.IsActive
     });
 }
Beispiel #6
0
        /// <summary>
        /// Inserts the fixed asset category.
        /// </summary>
        /// <param name="fixedAssetCategory">The fixed asset category.</param>
        /// <returns></returns>
        public int InsertFixedAssetCategory(FixedAssetCategoryEntity fixedAssetCategory)
        {
            const string sql = "uspInsert_FixedAssetCategory";

            return(Db.Insert(sql, true, Take(fixedAssetCategory)));
        }
Beispiel #7
0
        /// <summary>
        /// Updates the fixed asset category.
        /// </summary>
        /// <param name="fixedAssetCategory">The fixed asset category.</param>
        /// <returns></returns>
        public string UpdateFixedAssetCategory(FixedAssetCategoryEntity fixedAssetCategory)
        {
            const string sql = "uspUpdate_FixedAssetCategory";

            return(Db.Update(sql, true, Take(fixedAssetCategory)));
        }
Beispiel #8
0
 internal static FixedAssetCategoryModel FromDataTransferObject(FixedAssetCategoryEntity entity)
 {
     return(entity == null ? null : AutoMapper.Mapper.Map <FixedAssetCategoryEntity, FixedAssetCategoryModel>(entity));
 }