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

Save the appointment in a SharePoint List

5 Answers 54 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
H.
Top achievements
Rank 1
H. asked on 09 Aug 2011, 06:34 PM
Hi, 

I have a RadScheduler and I trying to save the new appointment or the changes to a Calendar List. I use the code below to get all the item in the calendar but I have expend 2 days try to find out what is the event that is triggering when the user press the button save.

With the code I was able to fill my calendar.  I only need to know what event to use where I can put all the logic to write to the Calendar List. Thanks!! 

Note. I am working with ASP.NET
 private SPCalendarItemCollection GetCalendarItems()
        {
            // Create a new collection for the calendar items        
            // This is an item with a start and end date.        
            SPCalendarItemCollection items = new SPCalendarItemCollection();


            SPWeb oWeb = SPControl.GetContextWeb(Context);
            SPList oCalendarList = oWeb.Lists["Calendar"];
            SPView oView = oCalendarList.Views["Calendar"];


            SPQuery query = new SPQuery();
            query.Query = "<OrderBy><FieldRef Name='ID' /></OrderBy>";




       
            query.Query = "<Where><Eq><FieldRef Name='fRecurrence' /><Value Type='Recurrence'>0</Value></Eq></Where><OrderBy><FieldRef Name='ID' /></OrderBy>";
       
            //For Team members (not for recurrent events)      
            foreach (SPListItem listItem in oCalendarList.GetItems(query))
            {
                SPCalendarItem calItem = new SPCalendarItem();
                calItem.ItemID = listItem["ID"].ToString();
                calItem.Title = listItem["Title"].ToString();
                calItem.CalendarType = Convert.ToInt32(SPCalendarType.Gregorian);
                calItem.StartDate = (DateTime)listItem["Start Time"];
                calItem.ItemID = listItem.ID.ToString();


                if (listItem["End Time"] != null)
                {
                    calItem.hasEndDate = true;
                    calItem.EndDate = (DateTime)listItem["End Time"];
                }
                else
                    calItem.hasEndDate = false;


                if (listItem["Description"] != null)
                    calItem.Description = listItem["Description"].ToString();


                if (listItem["Location"] != null)
                    calItem.Location = listItem["Location"].ToString();


                calItem.IsRecurrence = Convert.ToBoolean(listItem["Recurrence"]);




                items.Add(calItem);


            }


            //Only for Reccurent events (like weekley meetings)      
            SPQuery queryRecurrence = new SPQuery();
            queryRecurrence.ExpandRecurrence = true;
            queryRecurrence.Query = "<Where>" +
                                       "<And>" +
                                          "<Eq>" +
                                             "<FieldRef Name='fRecurrence' />" +
                                             "<Value Type='Recurrence'>1</Value>" +
                                          "</Eq>" +
                                          "<DateRangesOverlap>" +
                                             "<FieldRef Name='EventDate' />" +
                                             "<FieldRef Name='EndDate' />" +
                                             "<FieldRef Name='RecurrenceID' />" +
                                                 "<Value Type='DateTime'>" +
                                                    "<Month />" +
                                                 "</Value>" +
                                          "</DateRangesOverlap>" +
                                       "</And>" +
                                    "</Where>" +
                                    "<ViewFields>" +
                                       "<FieldRef Name='Title' />" +
                                       "<FieldRef Name='EventDate' />" +
                                       "FieldRef Name='EndDate' />" +
                                       "<FieldRef Name='fRecurrence' />" +
                                       "<FieldRef Name='Absentee' />" +
                                    "</ViewFields>";


            // Look forward from the beginning of the current month      
            queryRecurrence.CalendarDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);


            // Returns all items (including recurrence instances) that      
            // would appear in the calendar view for the current month      


            SPListItemCollection calendarItems = oCalendarList.GetItems(queryRecurrence);


            foreach (SPListItem listItem in oCalendarList.GetItems(queryRecurrence))
            {
                SPCalendarItem calItem = new SPCalendarItem();
                calItem.ItemID = listItem["ID"].ToString();
                calItem.Title = listItem["Title"].ToString();
                calItem.CalendarType = Convert.ToInt32(SPCalendarType.Gregorian);
                calItem.StartDate = (DateTime)listItem["Start Time"];
                calItem.ItemID = listItem.ID.ToString();


                if (listItem["End Time"] != null)
                {
                    calItem.hasEndDate = true;
                    calItem.EndDate = (DateTime)listItem["End Time"];
                }
                else
                    calItem.hasEndDate = false;


                if (listItem["Description"] != null)
                    calItem.Description = listItem["Description"].ToString();


                if (listItem["Location"] != null)
                    calItem.Location = listItem["Location"].ToString();


                items.Add(calItem);
            }




            // return the collection        
            return items;
        }

5 Answers, 1 is accepted

Sort by
0
H.
Top achievements
Rank 1
answered on 10 Aug 2011, 04:50 PM
Sorry, Can someone help me with this???
0
Peter
Telerik team
answered on 11 Aug 2011, 12:47 PM
Hi H.,

Please, refer to this help topic -
http://www.telerik.com/help/aspnet-ajax/moss-display-and-edit-appointments.html


All the best,
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.

0
H.
Top achievements
Rank 1
answered on 11 Aug 2011, 03:13 PM
Thanks Peter for your reply but I am using the RadScheduler user control and not the SPRadSheduler web part. I need extra functionality that this web part does not have.Example to allow the user to subscribe to many calendar. Do you think it is possible to validate data before is save in the server side? or is it possible to use the SharePoint forms to add, edit and delete appointment in the RADScheduler? What event is triggering when the user press the button save?



Best Regards
HANK
0
Kalina
Telerik team
answered on 17 Aug 2011, 02:12 PM
Hello H.,

I have attached here a basic RadScheduler WebPart sample - it is simplified but I believe that it will help you get started.

All the best,
Kalina
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.

0
H.
Top achievements
Rank 1
answered on 17 Aug 2011, 03:28 PM
Thanks Kalina!
Tags
Scheduler
Asked by
H.
Top achievements
Rank 1
Answers by
H.
Top achievements
Rank 1
Peter
Telerik team
Kalina
Telerik team
Share this question
or