Пример #1
0
    public VolunteerTracker.Period GetCurrentPeriod()
    {
        VolunteerTracker.Period period = new VolunteerTracker.Period(DateTime.Now.Year, DateTime.Now.Month);
        if (GetDefaultPeriod != null)
        {
            period = GetDefaultPeriod();
        }
        int year, month;
        if (Request["Year"] != null && Int32.TryParse(Request["Year"], out year))
        {
            period.Year = year;
        }

        if (Request["Month"] != null && Int32.TryParse(Request["Month"], out month))
        {
            period.Month = month;
        }
        return period;
    }
Пример #2
0
 protected void SelectMonth_TextChanged(object sender, EventArgs e)
 {
     string value = DropDownListSelectMonth.SelectedValue;
     if (value == null)
     {
         return;
     }
     string sMonth = value.Split(new char[] { ':' })[0];
     string sYear = value.Split(new char[] { ':' })[1];
     VolunteerTracker.Period period = new VolunteerTracker.Period(Int32.Parse(sYear), Int32.Parse(sMonth));
     if (PeriodChanged != null)
     {
         PeriodChanged();
     }
     Response.Redirect(Request.Path + "?" + GetPeriodQuery(period));
 }
Пример #3
0
 public Period SubtractMonth()
 {
     Period period = new Period(year, month);
     if (period.Month > 1)
     {
         period.Month--;
         return period;
     }
     period.Month = 12;
     period.Year--;
     return period;
 }
Пример #4
0
 public Period AddYears(int numYears)
 {
     Period p = new Period(year, month);
     p.Year += numYears;
     return p;
 }
Пример #5
0
 public Period AddMonths(int numMonths)
 {
     Period period = new Period(year, month);
     if (numMonths >= 0)
     {
         for (int i = 0; i < numMonths; i++)
         {
             period = period.AddMonth();
         }
     }
     if (numMonths < 0)
     {
         for (int i = 0; i < -numMonths; i++)
         {
             period = period.SubtractMonth();
         }
     }
     return period;
 }
Пример #6
0
 public Period AddMonth()
 {
     Period period = new Period(year, month);
     if (period.Month < 12)
     {
         period.Month += 1;
     }
     else
     {
         period.Month = 1;
         period.Year += 1;
     }
     return period;
 }