コード例 #1
0
ファイル: frmRecur.cs プロジェクト: kalirajanl/UBRS
        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;
        }
コード例 #2
0
ファイル: Schedule.cs プロジェクト: kalirajanl/UBRS
 private static bool isInstanceDay(DateTime tmpDate, WeeklySchedule sched, DateTime startDate, DateTime finishDate)
 {
     bool addDay = false;
     if (tmpDate <= finishDate)
     {
         switch (tmpDate.DayOfWeek)
         {
             case DayOfWeek.Monday:
                 {
                     if (sched.OnMondays)
                     {
                         addDay = true;
                     }
                     break;
                 }
             case DayOfWeek.Tuesday:
                 {
                     if (sched.OnTuesdays)
                     {
                         addDay = true;
                     }
                     break;
                 }
             case DayOfWeek.Wednesday:
                 {
                     if (sched.OnWednesdays)
                     {
                         addDay = true;
                     }
                     break;
                 }
             case DayOfWeek.Thursday:
                 {
                     if (sched.OnThursdays)
                     {
                         addDay = true;
                     }
                     break;
                 }
             case DayOfWeek.Friday:
                 {
                     if (sched.OnFridays)
                     {
                         addDay = true;
                     }
                     break;
                 }
             case DayOfWeek.Saturday:
                 {
                     if (sched.OnSaturdays)
                     {
                         addDay = true;
                     }
                     break;
                 }
             case DayOfWeek.Sunday:
                 {
                     if (sched.OnSundays)
                     {
                         addDay = true;
                     }
                     break;
                 }
         }
     }
     return addDay;
 }
コード例 #3
0
ファイル: DALSchedule.cs プロジェクト: kalirajanl/UBRS
 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;
 }
コード例 #4
0
ファイル: Schedule.cs プロジェクト: kalirajanl/UBRS
 private static List<DateTime> getWeeklyInstanceDates(WeeklySchedule sched, DateTime startDate, DateTime finishDate)
 {
     List<DateTime> dates = new List<DateTime>();
     if (startDate <= finishDate)
     {
         DateTime tmpDate = startDate;
         while (tmpDate <= finishDate)
         {
             if (tmpDate >= startDate)
             {
                 for (int i = 0; i <= 6; i++)
                 {
                     bool addDay = isInstanceDay(tmpDate.AddDays(i) , sched, startDate, finishDate);
                     if (addDay)
                     {
                         dates.Add(tmpDate.AddDays(i));
                     }
                 }
             }
             tmpDate = tmpDate.AddDays(7 * sched.RecurEveryNoOfWeeks);
         }
     }
     return dates;
 }