Esempio n. 1
0
        private DateTime Get_next_unplanned_month <TRecordType>(
            ISpreadsheet spreadsheet,
            BudgetItemListData budget_item_list_data)
            where TRecordType : ICSVRecord, new()
        {
            DateTime default_month        = _clock.Today_date_time();
            DateTime next_unplanned_month = default_month;
            bool     bad_input            = false;

            try
            {
                next_unplanned_month = spreadsheet.Get_next_unplanned_month <TRecordType>(budget_item_list_data);
            }
            catch (MonthlyBudgetedRowNotFoundException exception)
            {
                string new_month = _input_output.Get_input(String.Format(ReconConsts.CantFindPreviousBudgetRow, exception.Message));
                try
                {
                    if (!String.IsNullOrEmpty(new_month) && Char.IsDigit(new_month[0]))
                    {
                        int actual_month = Convert.ToInt32(new_month);
                        if (actual_month < 1 || actual_month > 12)
                        {
                            bad_input = true;
                        }
                        else
                        {
                            var year = default_month.Year;
                            if (actual_month < default_month.Month)
                            {
                                if (Month_is_smaller_because_end_of_year(actual_month, default_month.Month))
                                {
                                    year++;
                                }
                            }
                            next_unplanned_month = new DateTime(year, actual_month, 1);
                        }
                    }
                    else
                    {
                        bad_input = true;
                    }
                }
                catch (Exception)
                {
                    bad_input = true;
                }
            }

            if (bad_input)
            {
                _input_output.Output_line(ReconConsts.DefaultUnplannedMonth);
                next_unplanned_month = default_month;
            }

            return(next_unplanned_month);
        }
        private DateTime Get_next_unplanned_month(ISpreadsheet spreadsheet)
        {
            DateTime default_month        = DateTime.Today;
            DateTime next_unplanned_month = default_month;
            bool     bad_input            = false;

            try
            {
                next_unplanned_month = spreadsheet.Get_next_unplanned_month();
            }
            catch (Exception)
            {
                string new_month = _input_output.Get_input(ReconConsts.CantFindMortgageRow);
                try
                {
                    if (!String.IsNullOrEmpty(new_month) && Char.IsDigit(new_month[0]))
                    {
                        int actual_month = Convert.ToInt32(new_month);
                        if (actual_month < 1 || actual_month > 12)
                        {
                            bad_input = true;
                        }
                        else
                        {
                            var year = default_month.Year;
                            if (actual_month < default_month.Month)
                            {
                                year++;
                            }
                            next_unplanned_month = new DateTime(year, actual_month, 1);
                        }
                    }
                    else
                    {
                        bad_input = true;
                    }
                }
                catch (Exception)
                {
                    bad_input = true;
                }
            }

            if (bad_input)
            {
                _input_output.Output_line(ReconConsts.DefaultUnplannedMonth);
                next_unplanned_month = default_month;
            }

            return(next_unplanned_month);
        }