This is a migrated thread and some comments may be shown as answers.

Reminder Help

1 Answer 61 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Timothy Kruszewski
Top achievements
Rank 1
Timothy Kruszewski asked on 15 Dec 2010, 06:04 PM
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();
   }

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 21 Dec 2010, 02:16 PM
Hello Timothy,

Please, review the description of the Reminders demo. Since you don't use a provider to bind RadScheduler, you just need to set only DataReminderField="Reminder" and remove
EnableReminderField="true". But you also need to set:

<telerik:RadScheduler runat="server" ID="RadScheduler1" 
      <Reminders Enabled="true" />
  </telerik:RadScheduler>

Then you can get the appiontment's reminder like this:
protected void RadScheduler1_AppointmentInsert(object sender, AppointmentInsertEventArgs e)
   {
       Response.Write(e.Appointment.Reminders[0].ToString());
   }

I hope this helps.

Greetings,
Peter
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Scheduler
Asked by
Timothy Kruszewski
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or