示例#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
文件: Period.cs 项目: Devang83/csc131
 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
文件: Period.cs 项目: Devang83/csc131
 public Period AddYears(int numYears)
 {
     Period p = new Period(year, month);
     p.Year += numYears;
     return p;
 }
示例#5
0
文件: Period.cs 项目: Devang83/csc131
 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
文件: Period.cs 项目: Devang83/csc131
 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;
 }