Example #1
0
 /// <summary>
 /// Returns the previous week
 /// </summary>
 /// <param name="presentWeek">Present Week</param>
 /// <returns>Next Week</returns>
 public static WeekInfo GetPreviousWeek(WeekInfo presentWeek)
 {
     return(new WeekInfo(presentWeek.StartDate.AddDays(-7)));
 }
Example #2
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;
                    }
                }
            }
Example #3
0
 /// <summary>
 /// Returns the next week
 /// </summary>
 /// <param name="presentWeek">Present Week</param>
 /// <returns>Next Week</returns>
 public static WeekInfo GetNextWeek(WeekInfo presentWeek)
 {
     return(new WeekInfo(presentWeek.StartDate.AddDays(7)));
 }