示例#1
0
 private static ISchedule loadSchedule(DataTable dt, int rowNo)
 {
     ISchedule sched = null;
     if (dt != null)
     {
         if (dt.Rows.Count > rowNo)
         {
             int RecurType = Convert.ToInt32(dt.Rows[rowNo]["RecurType"]);
             switch (RecurType)
             {
                 case 4:
                     {
                         YearlySchedule ySched = new YearlySchedule();
                         ySched.StartDate = Convert.ToDateTime(dt.Rows[rowNo]["StartDate"]);
                         ySched.EndDate = Convert.ToDateTime(dt.Rows[rowNo]["EndDate"]);
                         ySched.RecurrencePatternMode = Common.SchedRecurPatternModes.Simple;
                         ySched.EndDateSpecifiedAs = Common.SchedRangeEndTypes.ByEndDate;
                         ySched.OnDay = Convert.ToInt32(dt.Rows[rowNo]["OnDay"]);
                         ySched.OnMonth = Convert.ToInt32(dt.Rows[rowNo]["OnMonth"]);
                         ySched.RecurrencePattern = Common.SchedRecurPatterns.Yearly;
                         ySched.RecurEveryNoOfYears = Convert.ToInt32(dt.Rows[rowNo]["RecurUnits"]);
                         sched = ySched;
                         break;
                     }
                 case 3:
                     {
                         MonthlySchedule mSched = new MonthlySchedule();
                         mSched.StartDate = Convert.ToDateTime(dt.Rows[rowNo]["StartDate"]);
                         mSched.EndDate = Convert.ToDateTime(dt.Rows[rowNo]["EndDate"]);
                         mSched.RecurrencePatternMode = Common.SchedRecurPatternModes.Simple;
                         mSched.EndDateSpecifiedAs = Common.SchedRangeEndTypes.ByEndDate;
                         mSched.OnDay = Convert.ToInt32(dt.Rows[rowNo]["OnDay"]);
                         mSched.RecurrencePattern = Common.SchedRecurPatterns.Monthly;
                         mSched.RecurEveryNoOfMonths = Convert.ToInt32(dt.Rows[rowNo]["RecurUnits"]);
                         sched = mSched;
                         break;
                     }
                 case 2:
                     {
                         WeeklySchedule wSched = new WeeklySchedule();
                         wSched.StartDate = Convert.ToDateTime(dt.Rows[rowNo]["StartDate"]);
                         wSched.EndDate = Convert.ToDateTime(dt.Rows[rowNo]["EndDate"]);
                         wSched.RecurrencePatternMode = Common.SchedRecurPatternModes.Simple;
                         wSched.EndDateSpecifiedAs = Common.SchedRangeEndTypes.ByEndDate;
                         wSched.OnMondays = Convert.ToBoolean(dt.Rows[rowNo]["OnMondays"]);
                         wSched.OnTuesdays = Convert.ToBoolean(dt.Rows[rowNo]["OnTuesdays"]);
                         wSched.OnWednesdays = Convert.ToBoolean(dt.Rows[rowNo]["OnWednesdays"]);
                         wSched.OnThursdays = Convert.ToBoolean(dt.Rows[rowNo]["OnThursdays"]);
                         wSched.OnFridays = Convert.ToBoolean(dt.Rows[rowNo]["OnFridays"]);
                         wSched.OnSaturdays = Convert.ToBoolean(dt.Rows[rowNo]["OnSaturdays"]);
                         wSched.OnSundays = Convert.ToBoolean(dt.Rows[rowNo]["OnSundays"]);
                         wSched.RecurrencePattern = Common.SchedRecurPatterns.Weekly;
                         wSched.RecurEveryNoOfWeeks = Convert.ToInt32(dt.Rows[rowNo]["RecurUnits"]);
                         sched = wSched;
                         break;
                     }
                 default:
                     {
                         DailySchedule dSched = new DailySchedule();
                         dSched.StartDate = Convert.ToDateTime(dt.Rows[rowNo]["StartDate"]);
                         dSched.EndDate = Convert.ToDateTime(dt.Rows[rowNo]["EndDate"]);
                         dSched.RecurrencePatternMode = Common.SchedRecurPatternModes.Simple;
                         dSched.EndDateSpecifiedAs = Common.SchedRangeEndTypes.ByEndDate;
                         dSched.RecurrencePattern = Common.SchedRecurPatterns.Daily;
                         dSched.RecurEveryNoOfDays = Convert.ToInt32(dt.Rows[rowNo]["RecurUnits"]);
                         dSched.WeekDaysOnly = Convert.ToBoolean(dt.Rows[rowNo]["WeekDaysOnly"]);
                         sched = dSched;
                         break;
                     }
             }
         }
     }
     return sched;
 }
示例#2
0
        public ISchedule GetSchedule()
        {
            ISchedule sched = null;
            if (this.rdobtnDaily.Checked)
            {
                DailySchedule dSched = new DailySchedule();
                dSched.EndDate = this.dtpEndDate.Value;
                dSched.RecurrencePattern = UBRS.Common.SchedRecurPatterns.Daily;
                dSched.RecurrencePatternMode = UBRS.Common.SchedRecurPatternModes.Simple;
                dSched.StartDate = this.dtpStartDate.Value;
                if (this.rdobtnDlyWeekdaysOnly.Checked)
                {
                    dSched.RecurEveryNoOfDays = 1;
                }
                else
                {
                    dSched.RecurEveryNoOfDays = Convert.ToInt32(this.txtDlyUnits.Text);
                }
                dSched.WeekDaysOnly = this.rdobtnDlyWeekdaysOnly.Checked;

                sched = dSched;
            }
            else if (this.rdobtnWeekly.Checked)
            {
                WeeklySchedule wSched = new WeeklySchedule();
                wSched.RecurrencePattern = SchedRecurPatterns.Weekly;
                wSched.RecurrencePatternMode = SchedRecurPatternModes.Simple;
                wSched.EndDate = this.dtpEndDate.Value;
                wSched.EndDateSpecifiedAs = SchedRangeEndTypes.ByEndDate;
                wSched.OnFridays = this.chkFriday.Checked;
                wSched.OnMondays = this.chkMonday.Checked;
                wSched.OnSaturdays = this.chkSaturday.Checked;
                wSched.OnSundays = this.chkSunday.Checked;
                wSched.OnThursdays = this.chkThursday.Checked;
                wSched.OnTuesdays = this.chkTuesday.Checked;
                wSched.OnWednesdays = this.chkWednesday.Checked;
                wSched.RecurEveryNoOfWeeks = Convert.ToInt32(this.txtWlyUnits.Text);
                wSched.StartDate = this.dtpStartDate.Value;
                sched = wSched;
            }
            else if (this.rdobtnMonthly.Checked)
            {
                MonthlySchedule mSched = new MonthlySchedule();
                mSched.RecurrencePattern = SchedRecurPatterns.Monthly;
                mSched.RecurrencePatternMode = SchedRecurPatternModes.Simple;
                mSched.EndDate = this.dtpEndDate.Value;
                mSched.EndDateSpecifiedAs = SchedRangeEndTypes.ByEndDate;
                mSched.OnDay = Convert.ToInt32(this.txtMlyOnDay.Text);
                mSched.RecurEveryNoOfMonths = Convert.ToInt32(this.txtMlyUnits.Text);
                mSched.StartDate = this.dtpStartDate.Value;
                sched = mSched;
            }
            else
            {
                YearlySchedule ySched = new YearlySchedule();
                ySched.EndDate = this.dtpEndDate.Value;
                ySched.EndDateSpecifiedAs = SchedRangeEndTypes.ByEndDate;
                ySched.OnDay = Convert.ToInt32(this.txtYlyOnDay.Text);
                ySched.OnMonth = Convert.ToInt32(this.cboYlyOnMonth.SelectedIndex);
                ySched.RecurEveryNoOfYears = Convert.ToInt32(this.txtYlyUnits.Text);
                ySched.RecurrencePattern = SchedRecurPatterns.Yearly;
                ySched.RecurrencePatternMode = SchedRecurPatternModes.Advanced;
                ySched.StartDate = this.dtpStartDate.Value;
                sched = ySched;
            }

            return sched;
        }
示例#3
0
 private static List<DateTime> getYearlyInstanceDates(YearlySchedule sched, DateTime startDate, DateTime finishDate)
 {
     List<DateTime> dates = new List<DateTime>();
     if (startDate <= finishDate)
     {
         DateTime tmpDate = Convert.ToDateTime(getMonthText(sched.OnMonth) + "/" + sched.OnDay.ToString() + "/" + startDate.Year.ToString());
         while (tmpDate <= finishDate)
         {
             if (tmpDate >= startDate)
             {
                 dates.Add(tmpDate);
             }
             tmpDate = tmpDate.AddYears(sched.RecurEveryNoOfYears);
         }
     }
     return dates;
 }