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

Adding new row with total of appointments

14 Answers 194 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 09 Dec 2010, 10:47 AM
Hi,

I have a request from a client that I show the total time for each day in week view. This can either be done externally by looping through the appointments and displaying external to the scheduler.

A neater way to do this is to add a row in scheduler and displaying the totals in that row, is this possible?

Thanks,
Daryl

14 Answers, 1 is accepted

Sort by
0
Alan
Top achievements
Rank 1
answered on 13 Dec 2010, 12:15 PM
Anyone?
0
Alan
Top achievements
Rank 1
answered on 13 Dec 2010, 12:15 PM
Double post...
0
Peter
Telerik team
answered on 13 Dec 2010, 03:26 PM
Hi Daryl,

Please, try the following code and let me know if this is an acceptable solution for your case:
protected void RadScheduler1_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
    {
        if (RadScheduler1.SelectedView == SchedulerViewType.WeekView && e.TimeSlot.Duration.TotalDays == 1)
        {
  
            double totalBookedHoursPerDay = 0;
            foreach (Appointment a in RadScheduler1.Appointments.GetAppointmentsInRange(e.TimeSlot.Start, e.TimeSlot.End))
            {
                totalBookedHoursPerDay += a.Duration.TotalHours;
            }            
            Literal numberOfAppointments = new Literal();
            numberOfAppointments.Text = "Total booked time: " + totalBookedHoursPerDay.ToString() + " hours";
            e.TimeSlot.Control.Controls.Add(numberOfAppointments);
        }
    }


Regards,
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
Alan
Top achievements
Rank 1
answered on 13 Dec 2010, 04:19 PM
Hi Peter,

Thank you for your reply, unfortunately the code provided didn't work as 

e.TimeSlot.Control

is null.

I get what the code is supposed to do, but I'm not sure why Control should be null.

Thanks,
Daryl
0
Veronica
Telerik team
answered on 16 Dec 2010, 02:36 PM
Hi Daryl,

I also tried the code of Peter but e.TimeSlot.Control is not null for me and the code works as expected. Could you please send me your project so I can inspect it and help you?

Thank you!

Regards,
Veronica Milcheva
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
Alan
Top achievements
Rank 1
answered on 17 Dec 2010, 09:52 AM
I'll try to replicate the problem in an isolated project and upload it soon.
0
Alan
Top achievements
Rank 1
answered on 18 Dec 2010, 04:05 PM
Sorry for taking so long, I've isolated the problem: http://dl.dropbox.com/u/1929707/IsolatedScheduler.zip

Thank you for your help.
0
Veronica
Telerik team
answered on 22 Dec 2010, 10:52 AM
Hi Daryl,

Thank you very much for the attached project.

The problem is that you are setting the ShowAllDayRow property of the RadScheduler to false. However in the OnTimeSlotCreated we are creating a label control just in the all-day row to display the total time for each day in week view. Just set the ShowAllDayRow property to true and everything will work as expected.

Please take a look at the picture below for the result:




All the best,
Veronica Milcheva
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
roshani
Top achievements
Rank 1
answered on 24 Dec 2010, 05:21 AM
Hello Admin,

I also have similar type of requirement. Along with per day, I have to calculate total hours, week, Month. I also have to create reports displaying the details of the appointment and the total hours per day, per week, per month. As the recurrence appointments get generated on fly and only the parent appointment get stored into the database. How can I get the total hours including the hours of the recurring appointments?

Please reply asap,

Thanks in advance,
Roshani
0
roshani
Top achievements
Rank 1
answered on 24 Dec 2010, 07:17 AM
Hello Admin,

I also don't want to delete appointments permanently. so I am using IsDeleted(datatype bit) field in the appointment table and the following code :

 protected void RadScheduler1_OnAppointmentDelete(object sender, AppointmentDeleteEventArgs e)
    {
        var str = e.Appointment.Attributes["AppType"].ToString();

        SqlDataSource1.UpdateCommand = "UPDATE [Appointments] SET [IsDeleted]=1  WHERE [Id] =" + Convert.ToInt32(e.Appointment.ID);
        SqlDataSource1.Update();
        upScheduler.Update();
    }

Now my confusion is that what will happen with the recurring appointments. How should I manage these recurring appointments while deleting particular occurrence or series?  Can you please explain what will be the better way to handle this? As stated in the above post, the hours for these recurring appointments are also to be included.
Appointments should not be deleted permanently as this data can be used for other process too.

Thanks,
Roshani
0
Veronica
Telerik team
answered on 03 Jan 2011, 09:35 AM
Hello Daryl,

Please accept my apologies for the late reply.

On your question about how to get the total hours including the hours of the recurring appointments - this should be possible by parsing the recurrence rule. The following kb article will help you get started:
http://www.telerik.com/support/kb/aspnet-ajax/scheduler/how-to-display-all-radscheduler-appointments-in-gridview.aspx.

On your second question - please note that when you try to delete a recurring appointment - dialog window pops up to choose whether you want to delete the whole series or the current occurence. If you try to delete the whole series and set the IsDeleted field in the OnAppointmentDelete event - the master appointment and the recurring appointments will be affected. This is because when you create a recurring serie - only one appointment will be saved in the database - the Master Appointment. Information about recurring appointments will be kept in the RecurrenceRule field of the Master appointment. And again you can manipulate the recurring appointments via parsing the RecuurenceRule..

Please feel free to ask me if you have further questions.

Kind regards,
Veronica Milcheva
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
Alan
Top achievements
Rank 1
answered on 04 Jan 2011, 09:43 AM
Many Thanks Veronica,

It works, you've been extremely helpful.

Daryl
0
Patrick
Top achievements
Rank 1
answered on 08 Dec 2015, 07:57 PM
Can the code by Peter be done in WinForms?  Don't see TimeSlotCreated as a function.
0
Dimitar
Telerik team
answered on 11 Dec 2015, 09:16 AM
Hello Patrick,

Thank you for writing.

The bellow event is not available in the WinForms scheduler. What you can do is to use the CellFormatting event and display the total time in the header cell:
private void RadScheduler1_CellFormatting(object sender, SchedulerCellEventArgs e)
{
    if (e.CellElement is SchedulerHeaderCellElement)
    {
        if (e.CellElement.Parent is DayViewAllDayHeader && e.CellElement.Text != "Local")
        {
            SchedulerHeaderCellElement cell = e.CellElement as SchedulerHeaderCellElement;
            double totalBookedHoursPerDay = 0;
            foreach (var item in radScheduler1.Appointments)
            {
                if (item.Start.Date.Day == cell.Date.Day)
                {
                    totalBookedHoursPerDay += item.Duration.TotalHours;
                }
            }
            e.CellElement.Text = "Total booked: " + totalBookedHoursPerDay;
        }
    }
}

In addition, I want to kindly ask you to post your questions about the WinForms suite in the appropriate forum. And if you have any further questions about this case please post in the Winforms forum or submit a support ticket.

I hope this helps. Thank you for your understanding.

Regards,
Dimitar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Scheduler
Asked by
Alan
Top achievements
Rank 1
Answers by
Alan
Top achievements
Rank 1
Peter
Telerik team
Veronica
Telerik team
roshani
Top achievements
Rank 1
Patrick
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or