Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How can I prevent overlapping Appointments (Read 6425 times)
SimonL
YaBB Newbies
*
Offline



Posts: 36
Joined: Aug 11th, 2006
How can I prevent overlapping Appointments
Aug 20th, 2006 at 3:03pm
Print Post  
We are evaluating whether we can use the planner.net control in a hotel booking system. So the appointments will actually be room bookings. The rooms will be the locations. Therefore the same room can not be booked more than once in the same period. In the resource view if I create a new  appointment and drag it over an existing appointment it creates another lane. I need to prevent this. I saw in another post in this forum an example using the ItemModifying event. I put similar code in that event.

Private Sub Calendar1_ItemModifying(ByVal sender As Object, ByVal e As MindFusion.Scheduling.WinForms.ItemModifyConfirmEventArgs) Handles Calendar1.ItemModifying
       Dim fromDate As DateTime = e.NewStartTime.Date
       Dim toDate As DateTime = e.NewEndTime.Date

       Dim col As MindFusion.Scheduling.ItemCollection = Calendar1.Schedule.GetAllItems(fromDate, toDate)
       If col.Count < 2 Then Return

       For Each i As MindFusion.Scheduling.Item In col
           If i.Location Is e.Item.Location Then
               e.Confirm = False
           End If
       Next

    End Sub

But it still seems to create a new row and therefore let appointments overlap.

Thanks
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: How can I prevent overlapping Appointments
Reply #1 - Aug 21st, 2006 at 6:36am
Print Post  
Try the following modification of your function:

Code
Select All
Private Sub Calendar1_ItemModifying(ByVal sender As Object, ByVal e As MindFusion.Scheduling.WinForms.ItemModifyConfirmEventArgs) Handles Calendar1.ItemModifying

  Dim fromDate As DateTime = e.NewStartTime
  Dim toDate As DateTime = e.NewEndTime.Subtract(New TimeSpan(1))

  Dim col As MindFusion.Scheduling.ItemCollection = _
    Calendar1.Schedule.GetAllItems(fromDate, toDate, e.Item.Location)

  If Not col.Contains(e.Item) Then col.Add(e.Item)

  If col.Count >= 2 Then e.Confirm = False

End Sub 


You will have to perform addition testing when new items are created to prevent overlapping.

Meppy
  
Back to top
 
IP Logged
 
SimonL
YaBB Newbies
*
Offline



Posts: 36
Joined: Aug 11th, 2006
Re: How can I prevent overlapping Appointments
Reply #2 - Aug 21st, 2006 at 4:00pm
Print Post  
Thanks Meppy,

Another thing we need to is drag the appointments vertically, between locations. How can I do this. Also I tried loading 200 locations:

       locs = Locations.GetLocations()
       Dim l As Ribby.Library.Location

       Dim loc As MindFusion.Scheduling.Location

       For Each l In locs
           loc = New MindFusion.Scheduling.Location
           loc.Address = l.Address
           loc.Id = l.ID.ToString
           loc.Name = l.Address
           Calendar1.Locations.Add(loc)
       Next

unfortunately it took many seconds.

(a) Will the databinding version improve things.
(b) Any idea when this will be released (or is there a pre-release I can try).

Thanks for all your help.

Simon
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: How can I prevent overlapping Appointments
Reply #3 - Aug 22nd, 2006 at 4:53am
Print Post  
Try calling BeginInit and EndInit before and after your initialization code. Here is a sample:

Code
Select All
Calendar1.BeginInit();

' Add the locations here

Calendar1.EndInit(); 



This is done to prevent the calendar from updating itself each time a new location is added.

Meppy
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: How can I prevent overlapping Appointments
Reply #4 - Aug 22nd, 2006 at 6:23am
Print Post  
I forgot to mention that you can drag appointments between locations by holding down the modifier key specified by Calendar.ItemChangeReferenceKey (by default this is the Alt key).

Meppy
  
Back to top
 
IP Logged
 
SimonL
YaBB Newbies
*
Offline



Posts: 36
Joined: Aug 11th, 2006
Re: How can I prevent overlapping Appointments
Reply #5 - Aug 22nd, 2006 at 4:51pm
Print Post  
Thanks Meppy, The BeginInit and EndInit has a huge impact on performance.

I don't seem to be able to drag the appointments between locations (vertically) though even though the Calendar.ItemChangeReferenceKey is set to ALT. If I hold the ALT key down whilst dragging, the appointment doesn't move.

Regards,
Simon
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: How can I prevent overlapping Appointments
Reply #6 - Aug 23rd, 2006 at 4:06am
Print Post  
You have to hold down the ItemChangeReferenceKey before clicking and dragging the item.

Meppy
  
Back to top
 
IP Logged
 
SimonL
YaBB Newbies
*
Offline



Posts: 36
Joined: Aug 11th, 2006
Re: How can I prevent overlapping Appointments
Reply #7 - Aug 23rd, 2006 at 6:49am
Print Post  
Ok that works, but then this code you gave me to prevent collisions doesn't seem to work. i.e. I can now drag an appontment from one location to anaother location where an appointment already exists, the two overlap. I need to prevent this.

Your code from earlier:

Private Sub Calendar1_ItemModifying(ByVal sender As Object, ByVal e As MindFusion.Scheduling.WinForms.ItemModifyConfirmEventArgs) Handles Calendar1.ItemModifying

  Dim fromDate As DateTime = e.NewStartTime
  Dim toDate As DateTime = e.NewEndTime.Subtract(New TimeSpan(1))

  Dim col As MindFusion.Scheduling.ItemCollection = _
    Calendar1.Schedule.GetAllItems(fromDate, toDate, e.Item.Location)

  If Not col.Contains(e.Item) Then col.Add(e.Item)

  If col.Count >= 2 Then e.Confirm = False

End Sub
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: How can I prevent overlapping Appointments
Reply #8 - Aug 23rd, 2006 at 10:48am
Print Post  
Try using e.Resource instead of e.Item.Location, i.e. replace:

Code
Select All
...GetAllItems(..., e.Item.Location) 


with

Code
Select All
...GetAllItems(..., CType(e.Resource, location)) 



Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint