public BudgetComponentDefinitionGridViewController( DataGridView targetGridView, IEnumerable <TBudgetComponentDefinition> definitions, ICityBudgetConfiguration cityBudgetConfiguration, string costsLabel, Func <TBudgetComponentDefinition, ISet <PersistedCityStatisticsWithFinancialData>, decimal> getCostsFunc) { foreach (var name in new[] { Sector, costsLabel, Rate }) { targetGridView.Columns.Add(new DataGridViewTextBoxColumn() { Name = name, HeaderText = name, AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill }); } _taxDefinitionControlSets = definitions .Select(x => new BudgetComponentDefinitionControlSet(targetGridView, x, cityBudgetConfiguration, costsLabel, getCostsFunc)) .ToList(); _dataGridView = targetGridView; _totalRowIndex = targetGridView.Rows.Add(_totalDataGridViewRow); _totalDataGridViewRow.Cells[costsLabel] = new DataGridViewTextBoxCell(); }
public BudgetComponentDefinitionControlSet( DataGridView dataGridView, TBudgetComponentDefinition budgetComponentDefinition, ICityBudgetConfiguration cityBudgetConfiguration, string costsLabel, Func <TBudgetComponentDefinition, ISet <PersistedCityStatisticsWithFinancialData>, decimal> getCostsFunc) { _budgetComponentDefinition = budgetComponentDefinition; _getCostsFunc = getCostsFunc; var dataGridViewRow = new DataGridViewRow(); var index = dataGridView.Rows.Add(dataGridViewRow); dataGridView[Sector, index].Value = budgetComponentDefinition.Name; dataGridView[Sector, index].ReadOnly = true; var combobox = new DataGridViewComboBoxCell(); _projectedCostsCell = dataGridView[costsLabel, index]; dataGridView[Rate, index] = combobox; combobox.DataSource = _budgetComponentDefinition .GetSelectableRatePercentages() .Select(x => new { Value = x, Label = x.ToString("P") }) .OrderByDescending(x => x.Value) .ToList(); combobox.DisplayMember = "Label"; combobox.ValueMember = "Value"; combobox.Value = budgetComponentDefinition.CurrentRate(cityBudgetConfiguration); dataGridView.CellValueChanged += (s, e) => { if (combobox == dataGridView[e.ColumnIndex, e.RowIndex]) { budgetComponentDefinition.SetCurrentRate(cityBudgetConfiguration, Convert.ToDecimal(combobox.Value)); } }; }
public PersistedCityStatisticsWithFinancialData( PersistedCityStatistics persistedCityStatistics, int currentAmountOfFunds, int currentProjectedAmountOfFunds, ICityBudgetConfiguration cityBudgetConfiguration) { PersistedCityStatistics = persistedCityStatistics; CurrentAmountOfFunds = currentAmountOfFunds; CurrentProjectedAmountOfFunds = currentProjectedAmountOfFunds; ResidentialTaxIncome = Convert.ToInt32(persistedCityStatistics.ResidentialZonePopulationStatistics.Sum * cityBudgetConfiguration.ResidentialTaxRate); CommercialTaxIncome = Convert.ToInt32(persistedCityStatistics.CommercialZonePopulationStatistics.Sum * cityBudgetConfiguration.CommercialTaxRate); IndustrialTaxIncome = Convert.ToInt32(persistedCityStatistics.IndustrialZonePopulationStatistics.Sum * cityBudgetConfiguration.IndustrialTaxRate); PoliceServiceExpenses = Convert.ToInt32((persistedCityStatistics.NumberOfPoliceStations * 10) * cityBudgetConfiguration.PoliceServiceRate); FireServiceExpenses = Convert.ToInt32((persistedCityStatistics.NumberOfFireStations * 10) * cityBudgetConfiguration.FireDepartmentServiceRate); RoadInfrastructureExpenses = Convert.ToInt32((persistedCityStatistics.NumberOfRoadZones) * cityBudgetConfiguration.RoadInfrastructureServiceRate); RailroadInfrastructureExpenses = Convert.ToInt32((persistedCityStatistics.NumberOfRailRoadZones) * cityBudgetConfiguration.RailroadInfrastructureServiceRate) + Convert.ToInt32((persistedCityStatistics.NumberOfTrainStations * 10) * cityBudgetConfiguration.RailroadInfrastructureServiceRate); }
public LandValueCalculator(ICityBudgetConfiguration cityBudgetConfiguration) { _cityBudgetConfiguration = cityBudgetConfiguration; }
public void SetCurrentRate(ICityBudgetConfiguration cityBudgetConfiguration, decimal rate) { _setCurrentRate(cityBudgetConfiguration, rate); }
public decimal CurrentRate(ICityBudgetConfiguration cityBudgetConfiguration) { return(_getCurrentRate(cityBudgetConfiguration)); }
public PersistedCityStatisticsWithFinancialData ProcessFinances(PersistedCityStatistics persistedCityStatistics, ICityBudgetConfiguration cityBudgetConfiguration) { var financialData = new PersistedCityStatisticsWithFinancialData( persistedCityStatistics: persistedCityStatistics, currentAmountOfFunds: CurrentAmount, currentProjectedAmountOfFunds: ProjectedIncome, cityBudgetConfiguration: cityBudgetConfiguration ); AddProjectedIncome(financialData.GetTotal()); return(financialData); }