Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
603
Appointment manipulation
posted

Hi. I'm new to this control and VB.NET so please bear with me. Anyway I'd like ask for some ideas on how to do the tasks below. Snippets are welcome.

 1. Prevent multi-selection of appointments

- right now the user can multi-select appointments by simultaneously clicking the mouse and holding down the shift key. I'd like to limit it such that there's only one selected appointment at any given time.

2. Detect conflicting appointments

- Before adding a new appointment via the customized dialog box, I'd like to be able to determine if there's already an existing appointment for the given user in the specified StartDateTime/EndDateTime

 TIA and more power.

Parents
  • 2094
    Offline posted

    1. Prevent multi-selection of appointments

    You can use the CalendarInfo_BeforeSelectedAppointmentsChange or CalendarInfo_AfterSelectedAppointmentsChange events to evaluate the number of Appointments in the SelectedAppointments collection.

    If you capture this in the "before" event then you can call e.cancel = true to cancel the selection of the newly clicked on appointment, but I suspect it will be better to do this in the "After" event as you can do the following.

            Dim apptToAdd As Appointment = Me.CalInfo.SelectedAppointments(Me.CalInfo.SelectedAppointments.Count - 1)
            Me.CalInfo.SelectedAppointments.Clear()
            Me.CalInfo.SelectedAppointments.Add(apptToAdd)
     

     2. Detect conflicting appointments

    You can call CalendarInfo.GetAppointmentsInRange(NewAppointment.StartDateTime, NewAppointment.EndDateTime).Count and retrieve how many appointments are within that time frame.

     

    To check for just a single particular owner, then you can use the overloaded method which accepts an owner

    CalendarInfo.GetAppointmentsInRange(NewAppointment.StartDateTime, NewAppointment.EndDateTime, OwnerToCheck).Count

     

    If you call CalInfo.GetAppointmentsInRange(Now, Now).count BEFORE you create a new appointment then obviously if there is 1 already there then you will cause an overlap. If you call it AFTER you add the new appointment then obviously a count = 2 means there is an overlap.

     

    Cheers

    Aaron

     

     

     

Reply Children