![]() Gravitybox Schedule.NET
1998-2005 Gravitybox Software LLC
Page 57 of 90
ending recurrence pattern would create an infinite number of appointments and this is
not going to fit in any database.
In code you can create a recurrence pattern, and in the process create more
appointments in the AppointmentCollection by manipulating a Recurrence object. This
object can be created and then used in conjunction with an existing appointment to
create a group of appointments. For instance, to follow the example above we will
create an appointment and then repeat it until June 27, 2005.
Dim appointment As Appointment
appointment = Schedule1.AppointmentCollection.Add("", #6/6/2005#, _
#8:00:00 AM#, 60)
appointment.Subject = "John Doe"
'Create and setup the recurrence
Dim recurrence As New Recurrence
'End the recurrence by date and on this date
recurrence.StartDate = appointment.StartDate
recurrence.EndDate = #6/27/2005#
recurrence.EndType = RecurrenceEndConstants.recEndByDate
recurrence.RecurrenceInterval = RecurrenceIntervalConstants.ricDaily
'Setup the RecurrenceDay object
'Every 7 days for all days including weekends
recurrence.RecurrenceDay.DayInterval = 7
recurrence.RecurrenceDay.RecurrenceMode = _
RecurrenceDayConstants.DayInterval
'Add the recurrence
Schedule1.AppointmentCollection.AddRecurrence(appointment, recurrence)
The above code snippet creates an appointment on June 6, 2005. Then a recurrence
object is created for a daily recurrence every 7 days to stop on June 27, 2005. This will
add four appointments to the AppointmentCollection. If the DayInterval had been set to
3 then the appointments would have been created on Monday, Wednesday, Friday,
Sunday, Tuesday, etc. until June 27, 2005. You can even skip weekends if you wish by
setting the RecurrenceMode property to DayWeekdays. This will ensure that no
appointments are scheduled on Saturday or Sunday.
The same effect as above can be created with a weekly recurrence of coarse, since the
above pattern created an appointment once every seven days, which is a week. The
code snippet below does the same thing but with a weekly recurrence.
Dim appointment As Appointment
appointment = Schedule1.AppointmentCollection.Add("", #6/6/2005#, _
#8:00:00 AM#, 60)
appointment.Subject = "John Doe"
'Create and setup the recurrence
Dim recurrence As New Recurrence
|