Adding new row with total of appointments

15 posts, 0 answers
  1. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 09 Dec 2010 Link to this post

    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
  2. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 13 Dec 2010 Link to this post

    Anyone?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 13 Dec 2010 Link to this post

    Double post...
  5. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 13 Dec 2010 Link to this post

    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.
  6. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 13 Dec 2010 Link to this post

    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
  7. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 16 Dec 2010 Link to this post

    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.
  8. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 17 Dec 2010 Link to this post

    I'll try to replicate the problem in an isolated project and upload it soon.
  9. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 18 Dec 2010 Link to this post

    Sorry for taking so long, I've isolated the problem: http://dl.dropbox.com/u/1929707/IsolatedScheduler.zip

    Thank you for your help.
  10. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 22 Dec 2010 Link to this post

    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.
  11. roshani
    roshani avatar
    45 posts
    Member since:
    Dec 2010

    Posted 23 Dec 2010 Link to this post

    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
  12. roshani
    roshani avatar
    45 posts
    Member since:
    Dec 2010

    Posted 24 Dec 2010 Link to this post

    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
  13. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 03 Jan 2011 Link to this post

    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.
  14. Alan
    Alan avatar
    107 posts
    Member since:
    Oct 2010

    Posted 04 Jan 2011 Link to this post

    Many Thanks Veronica,

    It works, you've been extremely helpful.

    Daryl
  15. Patrick
    Patrick avatar
    1 posts
    Member since:
    Jun 2015

    Posted 08 Dec 2015 in reply to Peter Link to this post

    Can the code by Peter be done in WinForms?  Don't see TimeSlotCreated as a function.
  16. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 11 Dec 2015 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017