Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Disable meetings sharing 1 slot (Read 2956 times)
Nick
YaBB Newbies
*
Offline



Posts: 7
Joined: Jun 23rd, 2010
Disable meetings sharing 1 slot
Jun 30th, 2010 at 2:36pm
Print Post  
Hi.

I want to dissallow two or more scedule items from sharing the same time slot. Is it possible to do using the control or should I just try to do it in the surrounding code?

Many thanks
Nick
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Disable meetings sharing 1 slot
Reply #1 - Jul 1st, 2010 at 9:12am
Print Post  
Try to handle the Calendar.ItemsModifying event and cancel the operation if the item being modified will collide with another item. Here is a sample code illustrating how you could do this:

Code
Select All
private void Calendar_ItemModifying(object sender, ItemModifyConfirmEventArgs e)
{
	var items = c.Schedule.GetAllItems(e.Item.StartTime, e.Item.EndTime);
	for (int i = 0; i < items.Count; )
	{
		if (items[i] == e.Item)
		{
			items.RemoveAt(i);
			continue;
		}

		if (items[i].StartTime == e.Item.EndTime)
		{
			items.RemoveAt(i);
			continue;
		}

		i++;
	}

	e.Confirm = items.Count == 0;
} 


Let me know if this works.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Nick
YaBB Newbies
*
Offline



Posts: 7
Joined: Jun 23rd, 2010
Re: Disable meetings sharing 1 slot
Reply #2 - Jul 2nd, 2010 at 8:30am
Print Post  
Works like a charm!! Thank you
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint