Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Disable a range of days (Read 2081 times)
madrider
YaBB Newbies
*
Offline



Posts: 15
Joined: Jul 30th, 2007
Disable a range of days
Jul 30th, 2007 at 9:21pm
Print Post  
Can I disable a range of days in Resource view? I want to make the past days non editable. Thanks for any info.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Disable a range of days
Reply #1 - Jul 31st, 2007 at 5:03am
Print Post  
By 'disabling' a range of days I presume you would want to prevent users from modifying existing items, creating new items or moving other items into the disabled range. To achieve this you will have to handle the Calendar.ItemModifying and Calendar.ItemCreating events. You can inspect the new start and end date of the item being modified or created and confirm or reject the operation if the item destination doesn't meet particular requirements. The following code prevents users from moving or creating items in the past (assuming that the current time is 31th of July, 2007):

Code
Select All
// Calendar.ItemCreating event handler
private void calendar_ItemCreating(object sender, ItemConfirmEventArgs e)
{
    if (e.Item.StartTime < DateTime.Today)
	  e.Confirm = false;
}

// Calendar.ItemCreating event handler
private void calendar_ItemModifying(object sender, ItemModifyConfirmEventArgs e)
{
    // Do not allow items from the past to be modified at all
    if (e.Item.StartTime < DateTime.Today)
    {
	  e.Confirm = false;
	  return;
    }

    // Do not allow items to be moved to the past
    if (e.NewStartTime < DateTime.Today)
    {
	  e.Confirm = false;
	  return;
    }
} 


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