Пример #1
0
            /// <summary>
            /// Returns the previous month
            /// </summary>
            /// <param name="presentMonth">Present Month</param>
            /// <returns>Previous Month</returns>
            public static MonthInfo GetPreviousMonth(MonthInfo presentMonth)
            {
                int month = presentMonth.Month;
                int year  = presentMonth.Year;

                month--;

                if (month < 1)
                {
                    year--;
                    month = 12;
                }

                return(new MonthInfo(new DateTime(year, month, 1)));
            }
Пример #2
0
            /// <summary>
            /// Returns the next month
            /// </summary>
            /// <param name="presentMonth">Present Month</param>
            /// <returns></returns>
            public static MonthInfo GetNextMonth(MonthInfo presentMonth)
            {
                int month = presentMonth.Month;
                int year  = presentMonth.Year;

                month++;

                if (month > 12)
                {
                    year++;
                    month = 1;
                }

                return(new MonthInfo(new DateTime(year, month, 1)));
            }
Пример #3
0
            public static void GetNextPrevDates(DTC.RangeEnum range, DateTime date, NextPrevEnum np, out DateTime startDate, out DateTime endDate)
            {
                startDate = DateTime.Today;
                endDate   = DateTime.Today;

                if (range == DTC.RangeEnum.Day)
                {
                    if (np == NextPrevEnum.Next)
                    {
                        startDate = date.AddDays(1);
                        endDate   = startDate;
                    }
                    if (np == NextPrevEnum.Previous)
                    {
                        startDate = date.AddDays(-1);
                        endDate   = startDate;
                    }
                    if (np == NextPrevEnum.Today)
                    {
                        startDate = date;
                        endDate   = startDate;
                    }
                }
                else if (range == DTC.RangeEnum.Week)
                {
                    WeekInfo week = new WeekInfo(date);

                    if (np == NextPrevEnum.Next)
                    {
                        startDate = GetNextWeek(week).StartDate;
                        endDate   = GetNextWeek(week).EndDate;
                    }
                    if (np == NextPrevEnum.Previous)
                    {
                        startDate = GetPreviousWeek(week).StartDate;
                        endDate   = GetPreviousWeek(week).EndDate;
                    }
                    if (np == NextPrevEnum.Today)
                    {
                        startDate = week.StartDate;
                        endDate   = week.EndDate;
                    }
                }
                else if (range == DTC.RangeEnum.Month)
                {
                    MonthInfo month = new MonthInfo(date);

                    if (np == NextPrevEnum.Next)
                    {
                        startDate = GetNextMonth(month).StartDate;
                        endDate   = GetNextMonth(month).EndDate;
                    }
                    if (np == NextPrevEnum.Previous)
                    {
                        startDate = GetPreviousMonth(month).StartDate;
                        endDate   = GetPreviousMonth(month).EndDate;
                    }
                    if (np == NextPrevEnum.Today)
                    {
                        startDate = month.StartDate;
                        endDate   = month.EndDate;
                    }
                }
                else if (range == DTC.RangeEnum.Quarter)
                {
                    QuarterInfo quarter = new QuarterInfo(date);

                    if (np == NextPrevEnum.Next)
                    {
                        startDate = GetNextQuarter(quarter).StartDate;
                        endDate   = GetNextQuarter(quarter).EndDate;
                    }
                    if (np == NextPrevEnum.Previous)
                    {
                        startDate = GetPreviousQuarter(quarter).StartDate;
                        endDate   = GetPreviousQuarter(quarter).EndDate;
                    }
                    if (np == NextPrevEnum.Today)
                    {
                        startDate = quarter.StartDate;
                        endDate   = quarter.EndDate;
                    }
                }
                else if (range == DTC.RangeEnum.Year)
                {
                    if (np == NextPrevEnum.Next)
                    {
                        startDate = new YearInfo(date.Year + 1).StartDate;
                        endDate   = new YearInfo(date.Year + 1).EndDate;
                    }
                    if (np == NextPrevEnum.Previous)
                    {
                        startDate = new YearInfo(date.Year - 1).StartDate;
                        endDate   = new YearInfo(date.Year - 1).EndDate;
                    }
                    if (np == NextPrevEnum.Today)
                    {
                        startDate = new YearInfo(date.Year).StartDate;
                        endDate   = new YearInfo(date.Year).EndDate;
                    }
                }
            }