Ejemplo n.º 1
0
        }         // QueryHour

        // ----------------------------------------------------------------------
        public bool QueryMinute()
        {
            int?minute = ConsoleTool.QueryNumber("Minute (0..59) [enter=" + Minute + "]: ", Minute, 0, TimeSpec.MinutesPerHour - 1);

            if (!minute.HasValue)
            {
                return(false);
            }
            Minute = minute.Value;
            return(true);
        }         // QueryMinute
Ejemplo n.º 2
0
        }         // QueryCulture

        // ----------------------------------------------------------------------
        public bool QueryPeriodCount()
        {
            int?periodCount = ConsoleTool.QueryNumber("Period count [enter=" + PeriodCount + "]: ", PeriodCount, 1, 10000);

            if (!periodCount.HasValue)
            {
                return(false);
            }
            PeriodCount = periodCount.Value;
            return(true);
        }         // QueryPeriodCount
Ejemplo n.º 3
0
        }         // QueryDay

        // ----------------------------------------------------------------------
        public bool QueryHour()
        {
            int?hour = ConsoleTool.QueryNumber("Hour (0..23) [enter=" + Hour + "]: ", Hour, 0, TimeSpec.HoursPerDay - 1);

            if (!hour.HasValue)
            {
                return(false);
            }
            Hour = hour.Value;
            return(true);
        }         // QueryHour
Ejemplo n.º 4
0
        }         // QueryYearMonth

        // ----------------------------------------------------------------------
        public bool QueryWeek()
        {
            int?week = ConsoleTool.QueryNumber("Week (1..53) [enter=" + Week + "]: ", Week, 1, 53);

            if (!week.HasValue)
            {
                return(false);
            }
            Week = week.Value;
            return(true);
        }         // QueryWeek
Ejemplo n.º 5
0
        }         // QueryPeriodCount

        // ----------------------------------------------------------------------
        public bool QueryYear()
        {
            int?year = ConsoleTool.QueryNumber("Year [enter=" + Year + "]: ", Year, DateTime.MinValue.Year, DateTime.MaxValue.Year);

            if (!year.HasValue)
            {
                return(false);
            }
            Year = year.Value;
            return(true);
        }         // QueryYear
Ejemplo n.º 6
0
        }         // QueryYearWeekType

        // ----------------------------------------------------------------------
        public bool QueryDay()
        {
            int?day = ConsoleTool.QueryNumber("Day (1..31) [enter=" + Day + "]: ", Day, 1, 31);

            if (!day.HasValue)
            {
                return(false);
            }
            Day = day.Value;
            return(true);
        }         // QueryDay
Ejemplo n.º 7
0
        }         // QueryWeek

        // ----------------------------------------------------------------------
        public bool QueryYearWeekType()
        {
            int?weekType = ConsoleTool.QueryNumber("Week type (0..1) [enter=" + (int)YearWeekType + "/" + YearWeekType + "]: ",
                                                   (int)YearWeekType, 0, 2);

            if (!weekType.HasValue)
            {
                return(false);
            }
            YearWeekType = (YearWeekType)weekType.Value;
            return(true);
        }         // QueryYearWeekType
Ejemplo n.º 8
0
        }         // QueryYearQuarter

        // ----------------------------------------------------------------------
        public bool QueryYearMonth()
        {
            int?yearMonth = ConsoleTool.QueryNumber("Month (1..12) [enter=" + (int)Month + "/" + Month + "]: ",
                                                    (int)Month, 1, TimeSpec.QuartersPerYear);

            if (!yearMonth.HasValue)
            {
                return(false);
            }
            Month = (YearMonth)yearMonth.Value;
            return(true);
        }         // QueryYearMonth
Ejemplo n.º 9
0
        }         // QueryYearHalfyear

        // ----------------------------------------------------------------------
        public bool QueryYearQuarter()
        {
            int?yearQuarter = ConsoleTool.QueryNumber("Quarter (1..4) [enter=" + (int)Quarter + "/" + Quarter + "]: ",
                                                      (int)Quarter, 1, TimeSpec.QuartersPerYear);

            if (!yearQuarter.HasValue)
            {
                return(false);
            }
            Quarter = (YearQuarter)yearQuarter.Value;
            return(true);
        }         // QueryYearQuarter
Ejemplo n.º 10
0
        }         // QueryYearBaseMonth

        // ----------------------------------------------------------------------
        public bool QueryYearHalfyear()
        {
            int?halfyear = ConsoleTool.QueryNumber("Halfyear (1..2) [enter=" + (int)Halfyear + "/" + Halfyear + "]: ",
                                                   (int)Halfyear, 1, TimeSpec.HalfyearsPerYear);

            if (!halfyear.HasValue)
            {
                return(false);
            }
            Halfyear = (YearHalfyear)halfyear.Value;
            return(true);
        }         // QueryYearHalfyear
Ejemplo n.º 11
0
        }         // QueryYear

        // ----------------------------------------------------------------------
        public bool QueryYearBaseMonth()
        {
            int?yearStartMonth = ConsoleTool.QueryNumber("Year start month (1..12) [enter=" + (int)YearBaseMonth + "/" + YearBaseMonth + "]: ",
                                                         (int)YearBaseMonth, 1, TimeSpec.MonthsPerYear);

            if (!yearStartMonth.HasValue)
            {
                return(false);
            }
            YearBaseMonth = (YearMonth)yearStartMonth.Value;
            return(true);
        }         // QueryYearBaseMonth
Ejemplo n.º 12
0
        }         // Reset

        // ----------------------------------------------------------------------
        private bool UpdateCulture(string cultureName)
        {
            try
            {
                culture = new CultureInfo(cultureName);
            }
            catch (Exception e)
            {
                ConsoleTool.WriteLine(e.Message);
                return(false);
            }
            CultureName = cultureName;
            return(true);
        }         // UpdateCulture
Ejemplo n.º 13
0
        // ----------------------------------------------------------------------
        public bool QueryCulture()
        {
            string cultureName = ConsoleTool.QueryText("Culture [enter=" + CultureInfo.CurrentCulture.Name + "]: ", CultureInfo.CurrentCulture.Name);

            if (cultureName == null)
            {
                return(false);
            }
            if (UpdateCulture(cultureName) == false)
            {
                return(false);
            }
            return(true);
        }         // QueryCulture
Ejemplo n.º 14
0
        }         // WriteIndentLine

        // ----------------------------------------------------------------------
        protected static string Format(DateTime dateTime, bool compact = true)
        {
            return(ConsoleTool.Format(dateTime, compact));
        } // Format
Ejemplo n.º 15
0
        }         // WriteIndentLine

        // ----------------------------------------------------------------------
        protected static void WriteIndentLine(string format, params object[] args)
        {
            ConsoleTool.WriteIndentLine(format, args);
        }         // WriteIndentLine
Ejemplo n.º 16
0
        }         // WriteLine

        // ----------------------------------------------------------------------
        protected static void WriteLine()
        {
            ConsoleTool.WriteLine();
        }         // WriteLine
Ejemplo n.º 17
0
        }         // WriteLine

        // ----------------------------------------------------------------------
        protected static void WriteIndentLine(string text)
        {
            ConsoleTool.WriteIndentLine(text);
        }         // WriteIndentLine
Ejemplo n.º 18
0
        }         // Main

        // ----------------------------------------------------------------------
        private static bool QueryPeriodData(ref string periodType, TimePeriodDemoData demoData)
        {
            ConsoleTool.WriteSeparatorLine();
            do
            {
                string input = ConsoleTool.QueryText("Period type (y/by/hy/q/m/bm/w/bw/d/h/min) [enter=" + periodType + "]: ", periodType);
                if (string.IsNullOrEmpty(input))
                {
                    return(false);
                }

                switch (input)
                {
                case "Y":
                    Console.Clear();
                    goto case "y";

                case "y":
                    periodType = input;
                    return
                        (demoData.QueryPeriodCount() &&
                         demoData.QueryYear() &&
                         demoData.QueryYearBaseMonth());

                case "BY":
                    Console.Clear();
                    goto case "by";

                case "by":
                    periodType = input;
                    return
                        (demoData.QueryYear());

                case "HY":
                    Console.Clear();
                    goto case "hy";

                case "hy":
                    periodType = input;
                    return
                        (demoData.QueryPeriodCount() &&
                         demoData.QueryYear() &&
                         demoData.QueryYearBaseMonth() &&
                         demoData.QueryYearHalfyear());

                case "Q":
                    Console.Clear();
                    goto case "q";

                case "q":
                    periodType = input;
                    return
                        (demoData.QueryPeriodCount() &&
                         demoData.QueryYear() &&
                         demoData.QueryYearBaseMonth() &&
                         demoData.QueryYearQuarter());

                case "M":
                    Console.Clear();
                    goto case "m";

                case "m":
                    periodType = input;
                    return
                        (demoData.QueryPeriodCount() &&
                         demoData.QueryYear() &&
                         demoData.QueryYearMonth());

                case "BM":
                    Console.Clear();
                    goto case "bm";

                case "bm":
                    periodType = input;
                    return
                        (demoData.QueryYear() &&
                         demoData.QueryYearMonth());

                case "W":
                    Console.Clear();
                    goto case "w";

                case "w":
                    periodType = input;
                    return
                        (demoData.QueryPeriodCount() &&
                         demoData.QueryYear() &&
                         demoData.QueryYearWeekType() &&
                         demoData.QueryWeek());

                case "BW":
                    Console.Clear();
                    goto case "bw";

                case "bw":
                    periodType = input;
                    return
                        (demoData.QueryYear() &&
                         demoData.QueryWeek());

                case "D":
                    Console.Clear();
                    goto case "d";

                case "d":
                    periodType = input;
                    return
                        (demoData.QueryPeriodCount() &&
                         demoData.QueryYear() &&
                         demoData.QueryYearMonth() &&
                         demoData.QueryDay());

                case "H":
                    Console.Clear();
                    goto case "h";

                case "h":
                    periodType = input;
                    return
                        (demoData.QueryPeriodCount() &&
                         demoData.QueryYear() &&
                         demoData.QueryYearMonth() &&
                         demoData.QueryDay() &&
                         demoData.QueryHour());

                case "Min":
                    Console.Clear();
                    goto case "min";

                case "min":
                    periodType = input;
                    return
                        (demoData.QueryPeriodCount() &&
                         demoData.QueryYear() &&
                         demoData.QueryYearMonth() &
                         demoData.QueryDay() &&
                         demoData.QueryHour() &&
                         demoData.QueryMinute());
                }
            } while (true);
        }         // QueryPeriodData