Example #1
0
        private YearsData AddYearsData(DataRow simulationRow, ReportProjectCost projectCostEntry, int year, BudgetsPerBRKey budgetPerBrKey)
        {
            var yearsData = new YearsData
            {
                Deck   = simulationRow["DECK_SEEDED_" + year].ToString(),
                Super  = simulationRow["SUP_SEEDED_" + year].ToString(),
                Sub    = simulationRow["SUB_SEEDED_" + year].ToString(),
                Culv   = simulationRow["CULV_SEEDED_" + year].ToString(),
                DeckD  = simulationRow["DECK_DURATION_N_" + year].ToString(),
                SuperD = simulationRow["SUP_DURATION_N_" + year].ToString(),
                SubD   = simulationRow["SUB_DURATION_N_" + year].ToString(),
                CulvD  = simulationRow["CULV_DURATION_N_" + year].ToString(),
                Year   = year
            };
            var isDeckConverted  = double.TryParse(yearsData.Deck, out var deck);
            var isCulvConverted  = double.TryParse(yearsData.Culv, out var culv);
            var isSuperConverted = double.TryParse(yearsData.Super, out var super);
            var isSubConverted   = double.TryParse(yearsData.Sub, out var sub);

            if (isDeckConverted && isCulvConverted && isSuperConverted && isSubConverted)
            {
                yearsData.MinC = Math.Min(deck, Math.Min(culv, Math.Min(super, sub)));
            }
            yearsData.SD = yearsData.MinC < 5 ? "Y" : "N";

            yearsData.Project = year != 0 ? projectCostEntry?.TREATMENT : string.Empty;

            double roundedCost = 0;

            if (projectCostEntry != null)
            {
                var amount = projectCostEntry.COST_;
                if (amount >= 500)
                {
                    roundedCost = amount % 1000 >= 500 ? amount + 1000 - amount % 1000 : amount - amount % 1000;
                }
                else
                {
                    roundedCost = 1000;
                }
            }

            yearsData.Cost        = year != 0 ? roundedCost : 0;
            yearsData.Project     = yearsData.Project == null ? "No Treatment" : yearsData.Project;
            yearsData.Budget      = budgetPerBrKey != null ? budgetPerBrKey.Budget : "";
            yearsData.ProjectPick = budgetPerBrKey != null ?
                                    (budgetPerBrKey.ProjectType == 0 ? "BAMs Pick" :
                                     (budgetPerBrKey.ProjectType == 1 ? "Committed Pick" :
                                      (budgetPerBrKey.ProjectType == 2 ? "Cash Flow" : "Scheduled")
                                     )) :
                                    "BAMs Pick";
            yearsData.ProjectPickType = budgetPerBrKey != null ? budgetPerBrKey.ProjectType : 0;
            yearsData.Treatment       = budgetPerBrKey != null ? budgetPerBrKey.Treatment : "";
            return(yearsData);
        }
Example #2
0
        private YearsData AddYearsData(DataRow simulationRow, ReportProjectCost projectCostEntry, int year)
        {
            var yearsData = new YearsData
            {
                Deck   = simulationRow["DECK_SEEDED_" + year].ToString(),
                Super  = simulationRow["SUP_SEEDED_" + year].ToString(),
                Sub    = simulationRow["SUB_SEEDED_" + year].ToString(),
                Culv   = simulationRow["CULV_SEEDED_" + year].ToString(),
                DeckD  = simulationRow["DECK_DURATION_N_" + year].ToString(),
                SuperD = simulationRow["SUP_DURATION_N_" + year].ToString(),
                SubD   = simulationRow["SUB_DURATION_N_" + year].ToString(),
                CulvD  = simulationRow["CULV_DURATION_N_" + year].ToString(),
                Year   = year
            };

            yearsData.MinC = Math.Min(Convert.ToDouble(yearsData.Deck), Convert.ToDouble(yearsData.Culv)).ToString();
            yearsData.SD   = Convert.ToDouble(yearsData.DeckD) < 5 ? "Y" : "N";

            yearsData.Project = year != 0 ? projectCostEntry?.TREATMENT : string.Empty;
            yearsData.Cost    = year != 0 ? (projectCostEntry == null ? 0 : projectCostEntry.COST_) : 0;
            yearsData.Project = yearsData.Cost == 0 ? "No Treatment" : yearsData.Project;
            return(yearsData);
        }