public List <FundStructureEntity> GetFundStructure(string connectionString) { List <FundStructureEntity> listfFundStructure = new List <FundStructureEntity>(); using (var context = new MISAEntity(connectionString)) { var categories = context.FundStructures.ToList(); foreach (var result in categories) { var fundStructure = new FundStructureEntity(); fundStructure.FundStructureId = result.FundStructureID.ToString(); fundStructure.FundStructureCode = result.FundStructureCode; fundStructure.FundStructureName = result.FundStructureName; fundStructure.BUCACodeId = result.MISACodeID; fundStructure.ParentId = result.ParentID.ToString(); fundStructure.Grade = result.Grade; fundStructure.IsParent = result.IsParent; fundStructure.Inactive = result.Inactive == true?false:true; fundStructure.IsSystem = result.IsSystem; fundStructure.InvestmentPeriod = result.InvestmentPeriod; listfFundStructure.Add(fundStructure); } } return(listfFundStructure); }
public FundStructureResponse UpdateFundStructure(FundStructureEntity fundStructure) { var response = new FundStructureResponse { Acknowledge = AcknowledgeType.Success }; try { if (!fundStructure.Validate()) { foreach (string error in fundStructure.ValidationErrors) { response.Message += error + Environment.NewLine; } response.Acknowledge = AcknowledgeType.Failure; return(response); } response.Message = FundStructureDao.UpdateFundStructure(fundStructure); if (!string.IsNullOrEmpty(response.Message)) { response.Acknowledge = AcknowledgeType.Failure; return(response); } response.FundStructureId = fundStructure.FundStructureId; return(response); } catch (Exception ex) { response.Message = ex.Message; return(response); } }
private object[] Take(FundStructureEntity fundStructureEntity) { return(new object[] { "@FundStructureID", fundStructureEntity.FundStructureId, "@FundStructureCode", fundStructureEntity.FundStructureCode, "@FundStructureName", fundStructureEntity.FundStructureName, "@BUCACodeID", fundStructureEntity.BUCACodeId, "@ParentID", fundStructureEntity.ParentId, "@Grade", fundStructureEntity.Grade, "@IsParent", fundStructureEntity.IsParent, "@Inactive", fundStructureEntity.Inactive, "@IsSystem", fundStructureEntity.IsSystem, "@InvestmentPeriod", fundStructureEntity.InvestmentPeriod, "@BudgetItemID", fundStructureEntity.BudgetItemId, "@CashWithdrawTypeID", fundStructureEntity.CashWithdrawTypeId, "@IsProjectExpense", fundStructureEntity.IsProjectExpense, "@IsAllocateExpense", fundStructureEntity.IsAllocateExpense, "@IsExpenseNoBuilding", fundStructureEntity.IsExpenseNoBuilding, }); }
public FundStructureResponse InsertFundStructureConvert(FundStructureEntity fundStructure) { var response = new FundStructureResponse { Acknowledge = AcknowledgeType.Success }; try { var fundStructureEntity = FundStructureDao.GetFundStructuresByFundStructureCode(fundStructure.FundStructureCode.Trim()).ToList(); if (fundStructureEntity.Count != 0) { response.Acknowledge = AcknowledgeType.Failure; response.Message = @"Mã khoản chi " + fundStructure.FundStructureCode.Trim() + @" đã tồn tại!"; return(response); } if (!fundStructure.Validate()) { foreach (string error in fundStructure.ValidationErrors) { response.Message += error + Environment.NewLine; } response.Acknowledge = AcknowledgeType.Failure; return(response); } response.Message = FundStructureDao.InsertFundStructure(fundStructure); if (!string.IsNullOrEmpty(response.Message)) { response.Acknowledge = AcknowledgeType.Failure; return(response); } response.FundStructureId = fundStructure.FundStructureId; return(response); } catch (Exception ex) { response.Message = ex.Message; return(response); } }
public string UpdateFundStructure(FundStructureEntity fundStructure) { const string sql = @"uspUpdate_FundStructure"; return(Db.Update(sql, true, Take(fundStructure))); }
public string InsertFundStructure(FundStructureEntity fundStructure) { const string sql = @"uspInsert_FundStructure"; return(Db.Insert(sql, true, Take(fundStructure))); }