I can't figure out how to add a reminder to my database. I'm able to view the reminder and set the values but can't figure out how to access it via the AppointmentInsert method. Can someone please help me with this?
<telerik:RadScheduler ID=
"RadScheduler1"
runat=
"server"
TimelineView-NumberOfSlots=
"5"
Width=
"900px"
Skin=
"Web20"
EnableEmbeddedSkins=
"true"
EnableEmbeddedBaseStylesheet=
"false"
DataStartField=
"Start"
DataEndField=
"End"
DataSubjectField=
"Subject"
DataKeyField=
"ID"
DataReminderField=
"Reminder"
EnableDescriptionField=
"true"
EnableReminderField=
"true"
GroupingDirection=
"Vertical"
StartInsertingInAdvancedForm=
"True"
AdvancedForm-Modal=
"False"
OnAppointmentDelete=
"RadScheduler1_AppointmentDelete"
OnAppointmentInsert=
"RadScheduler1_AppointmentInsert"
OnAppointmentUpdate=
"RadScheduler1_AppointmentUpdate"
OnFormCreating=
"RadScheduler1_FormCreating"
OnFormCreated=
"RadScheduler1_FormCreated"
OnAppointmentDataBound=
"RadScheduler1_AppointmentDataBound"
OnDataBound=
"RadScheduler1_OnDataBound"
OnNavigationComplete=
"RadScheduler1_NavigationComplete"
OnTimeSlotCreated=
"RadScheduler1_TimeSlotCreated"
>
<WeekView DayStartTime=
"06:00:00"
DayEndTime=
"23:59:00"
WorkDayStartTime=
"08:00:00"
WorkDayEndTime=
"18:00:00"
/>
<DayView DayStartTime=
"06:00:00"
DayEndTime=
"23:59:00"
WorkDayStartTime=
"08:00:00"
WorkDayEndTime=
"18:00:00"
/>
<MonthView VisibleAppointmentsPerDay=
"20"
AdaptiveRowHeight=
"true"
/>
<TimelineView SlotDuration=
"12:00:00"
NumberOfSlots=
"10"
TimeLabelSpan=
"2"
ColumnHeaderDateFormat=
"dddd, MMMM d"
/>
<Reminders Enabled=
"true"
/>
<ResourceStyles>
<telerik:ResourceStyleMapping Type=
"Category"
Text=
"Out of Office"
ApplyCssClass=
"rsCategoryViolet"
/>
<telerik:ResourceStyleMapping Type=
"Category"
Text=
"After Hours"
ApplyCssClass=
"rsCategoryRed"
/>
<telerik:ResourceStyleMapping Type=
"Category"
Text=
"Projects"
ApplyCssClass=
"rsCategoryDarkGreen"
/>
<telerik:ResourceStyleMapping Type=
"Category"
Text=
"MACs"
ApplyCssClass=
"rsCategoryGreen"
/>
<telerik:ResourceStyleMapping Type=
"Category"
Text=
"VNMS"
ApplyCssClass=
"rsCategoryDarkBlue"
/>
<telerik:ResourceStyleMapping Type=
"Category"
Text=
"IPT/Engineering"
ApplyCssClass=
"rsCategoryDarkRed"
/>
<telerik:ResourceStyleMapping Type=
"Category"
Text=
"Other"
ApplyCssClass=
"rsCategoryOrange"
/>
<telerik:ResourceStyleMapping Type=
"Category"
Text=
"Remote Day"
ApplyCssClass=
"rsCategoryYellow"
/>
<telerik:ResourceStyleMapping Type=
"Category"
Text=
"Region Coverage"
ApplyCssClass=
"rsCategoryPink"
/>
</ResourceStyles>
<TimeSlotContextMenuSettings EnableDefault=
"true"
/>
<AppointmentContextMenuSettings EnableDefault=
"true"
/>
</telerik:RadScheduler>
protected
void
RadScheduler1_AppointmentInsert(
object
sender, SchedulerCancelEventArgs e)
{
int
userCount = 0;
foreach
(Resource user
in
e.Appointment.Resources.GetResourcesByType(
"User Name"
))
{
userCount++;
}
string
categoryName =
""
;
if
(e.Appointment.Resources.GetResourceByType(
"Category"
) !=
null
)
{ categoryName = e.Appointment.Resources.GetResourceByType(
"Category"
).Text; }
e.Cancel = userCount == 0 || categoryName ==
""
;
if
(e.Cancel)
{
ScriptManager.RegisterClientScriptBlock(lblJscript,
this
.GetType(),
"alert"
,
"alert('Please select a user and category to continue');"
,
true
);
pnlJScript.Update();
e.Cancel =
true
;
}
else
{
if
(userCount == 1)
{
using
(ProNetData d =
new
ProNetData())
{
Resource user = e.Appointment.Resources.GetResourceByType(
"User Name"
);
Resource client = e.Appointment.Resources.GetResourceByType(
"Client Name"
);
Resource category = e.Appointment.Resources.GetResourceByType(
"Category"
);
string
RecurrenceRule = e.Appointment.RecurrenceRule;
int
userID = SafeValue.SafeInt0(user.Key.ToString());
TED.BLL.Appointment a =
new
TED.BLL.Appointment();
AppointmentUsers u = d.AppointmentUsers.Where(i => i.UserID == userID).FirstOrDefault();
a.Subject = e.Appointment.Subject;
a.Description = e.Appointment.Description !=
string
.Empty ? e.Appointment.Description :
null
;
a.Start = e.Appointment.Start.ToUniversalTime();
a.End = e.Appointment.End.ToUniversalTime();
a.CreationTime = DateTime.Now;
a.LastModificationTime = DateTime.Now;
if
(user !=
null
)
{ a.UserID = SafeValue.SafeInt0(user.Key.ToString()); }
if
(client !=
null
)
{ a.ClientID = SafeValue.SafeInt0(client.Key.ToString()); }
if
(category !=
null
)
{ a.CategoryID = SafeValue.SafeInt0(category.Key.ToString()); }
a.Mailbox = u.Email;
a.OutlookCreated =
false
;
if
(RecurrenceRule !=
""
)
{
//int index = RecurrenceRule.LastIndexOf(":");
int
index = RecurrenceRule.LastIndexOf(
"FREQ"
) - 1;
string
s = RecurrenceRule.Substring(index + 1).Replace(
"\r\n"
,
""
) +
";WKST=SU"
;
a.RecurrenceRule = s;
if
(RecurrenceRule.Contains(
"DAILY"
))
{ a.RecurrenceType = 0; }
else
if
(RecurrenceRule.Contains(
"WEEKLY"
))
{ a.RecurrenceType = 1; }
else
if
(RecurrenceRule.Contains(
"MONTHLY"
))
{ a.RecurrenceType = 2; }
else
if
(RecurrenceRule.Contains(
"YEARLY"
))
{ a.RecurrenceType = 6; }
a.IsRecurring =
true
;
}
else
{
a.IsRecurring =
false
;
a.RecurrenceType =
null
;
}
if
(e.Appointment.RecurrenceParentID !=
null
)
{ a.RecurrenceParentID =
int
.Parse(e.Appointment.RecurrenceParentID.ToString()); }
a.SyncToExchange =
true
;
d.AddToAppointments(a);
d.SaveChanges();
if
(a.ID > 0)
{
try
{
string
desc =
""
;
string
clientName =
""
;
if
(a.Description !=
null
) { desc = a.Description; }
if
(client !=
null
) { clientName = client.Text; }
//if (pm != null) { pmID = int.Parse(pm.Key.ToString()); }
SendMail(a.UserID,
"<b>Subject:</b> "
+ a.Subject +
"<br><b>Start:</b> "
+ a.Start +
"<br><b>End:</b> "
+ a.End +
"<br><b>Description:</b> "
+ desc +
"<br><b>Client:</b> "
+ clientName, (
int
)InsertUpdateDelete.Insert);
}
catch
{ }
}
}
}
else
{
foreach
(Resource user
in
e.Appointment.Resources.GetResourcesByType(
"User Name"
))
{
using
(ProNetData d =
new
ProNetData())
{
//Resource pm = e.Appointment.Resources.GetResourceByType("Email PM");
Resource client = e.Appointment.Resources.GetResourceByType(
"Client Name"
);
Resource category = e.Appointment.Resources.GetResourceByType(
"Category"
);
string
RecurrenceRule = e.Appointment.RecurrenceRule;
int
userID = SafeValue.SafeInt0(user.Key.ToString());
TED.BLL.Appointment a =
new
TED.BLL.Appointment();
AppointmentUsers u = d.AppointmentUsers.Where(i => i.UserID == userID).FirstOrDefault();
a.Subject = e.Appointment.Subject;
a.Description = e.Appointment.Description !=
string
.Empty ? e.Appointment.Description :
null
;
a.Start = e.Appointment.Start.ToUniversalTime();
a.End = e.Appointment.End.ToUniversalTime();
a.CreationTime = DateTime.Now;
a.LastModificationTime = DateTime.Now;
if
(user !=
null
)
{ a.UserID = SafeValue.SafeInt0(user.Key.ToString()); }
if
(client !=
null
)
{ a.ClientID = SafeValue.SafeInt0(client.Key.ToString()); }
if
(category !=
null
)
{ a.CategoryID = SafeValue.SafeInt0(category.Key.ToString()); }
a.Mailbox = u.Email;
a.OutlookCreated =
false
;
if
(RecurrenceRule !=
""
)
{
//int index = RecurrenceRule.LastIndexOf(":");
int
index = RecurrenceRule.LastIndexOf(
"FREQ"
) - 1;
string
s = RecurrenceRule.Substring(index + 1).Replace(
"\r\n"
,
""
) +
";WKST=SU"
;
a.RecurrenceRule = s;
if
(RecurrenceRule.Contains(
"DAILY"
))
{ a.RecurrenceType = 0; }
else
if
(RecurrenceRule.Contains(
"WEEKLY"
))
{ a.RecurrenceType = 1; }
else
if
(RecurrenceRule.Contains(
"MONTHLY"
))
{ a.RecurrenceType = 2; }
else
if
(RecurrenceRule.Contains(
"YEARLY"
))
{ a.RecurrenceType = 6; }
a.IsRecurring =
true
;
}
else
{
a.IsRecurring =
false
;
a.RecurrenceType =
null
;
}
if
(e.Appointment.RecurrenceParentID !=
null
)
{ a.RecurrenceParentID =
int
.Parse(e.Appointment.RecurrenceParentID.ToString()); }
a.SyncToExchange =
true
;
d.AddToAppointments(a);
d.SaveChanges();
if
(a.ID > 0)
{
try
{
string
desc =
""
;
string
clientName =
""
;
if
(a.Description !=
null
) { desc = a.Description; }
if
(client !=
null
) { clientName = client.Text; }
SendMail(a.UserID,
"<b>Subject:</b> "
+ a.Subject +
"<br><b>Start:</b> "
+ a.Start +
"<br><b>End:</b> "
+ a.End +
"<br><b>Description:</b> "
+ desc +
"<br><b>Client:</b> "
+ clientName, (
int
)InsertUpdateDelete.Insert);
}
catch
{ }
}
}
}
}
}
BindSchedule();
}