Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Date limitations (Read 5420 times)
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Date limitations
Jan 2nd, 2008 at 7:18am
Print Post  
I have placed various bits of code in my app to restrict users creating appointments before 7:00am but am still having problems.

Here are my problems:

1. 
If an appointment is dragged in timetableview up onto the column heading the appointment appears as an entry on the column header rather than the schedule.

I placed code in the ItemModified event handler to set the time range to be 7:00am - 7:30am if the appointment is dragged to the column header.

This is confirmed when I double click and view its details.

But the appointment remains on the coulmn header.

Is there a simpler way to restrict the minimum time to stop the appointment at 7:00am and remain on the scedule?

2.
If an appointment exists and is dragged to expand it and in doing so it crosses days the appointment appears as entries on the column header for each day the appointment was dragged over.

I have put code in place in the ItemModified event handler so that if this happens the appointment is reset to the startdate day and time and the end time on the same start date.

This is because we do not want appoinments to span days.

However if the user clicks an empty cell on the schedule and drags and highlights any number of days and cells the result is multiple blank entries on the coulmn headers for each day the empty appointment was dragged over?

Is there any easy way to prevent this?

Thanks



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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Date limitations
Reply #1 - Jan 2nd, 2008 at 1:17pm
Print Post  
1. Have you tried handling the ItemModifying event instead and reject the operation if the new start and end time of the item do not satisfy your criteria?

2. Try handling the ItemCreating event instead.

Meppy
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Date limitations
Reply #2 - Jan 3rd, 2008 at 6:20pm
Print Post  
in both cases .... problems solved  Grin

Thanks once again Meppy  Wink
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Date limitations
Reply #3 - Jan 4th, 2008 at 12:33pm
Print Post  
Mmm me thinks I was a bit quick off the mark there as each new scenario produces more problems  Sad

I am trying to prevent the user dragging/modifying an item if the time and date it is being dragged to is in the past.

However the ItemModifying event fires as soon as the user begins to move the item and as such the item still has the date and time values of its current position.

so if I drag an item from 2:00PM on the 4th January to 2:00PM on the 3rd January when the event fires the item has the startdate and time of 2:00PM 4th January and so slips through my trap to cancel the modification?

Have I misunderstood this event or its ability?

Thanks 




  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Date limitations
Reply #4 - Jan 4th, 2008 at 12:58pm
Print Post  
Have started to look at

Schedule.ItemStartTimeChanged Event

to see if this is what I should be using....

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Date limitations
Reply #5 - Jan 4th, 2008 at 1:10pm
Print Post  
The following technique should prevent users from dragging items past their start time:

Handle the ItemModifying, ItemModified and ItemModificationCanceled events. Declare a member of your class of time DateTime:

Code
Select All
private DateTime startTime = DateTime.MinValue; 


Set the following code as a body to both ItemModified and ItemModificationCanceled event handlers:

Code
Select All
startTime = DateTime.MinValue; 


Set the following code as a body to the ItemModifying event handler:

Code
Select All
if (startTime == DateTime.MinValue)
	startTime = e.Item.StartTime;

if (e.NewStartTime < startTime)
	e.Confirm = false; 


Meppy
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Date limitations
Reply #6 - Jan 4th, 2008 at 1:46pm
Print Post  
Hi, nope that does not work either, well to a point it does.

example in timetableview:

the current time is 3:00PM on the 4th January

enter an item at 2:00PM on the 5th January which is created ok.

I am unable to drag it to any time before 2:00PM on the 5th Janaury. But it should allow me to drag to any time after 3:00PM on the 4th January.

I then drag it to 5:00PM on the 5th January and it works OK.

But then I cannot drag it back to any time prior to 5:00PM on 5th January even though the current time and date is 3:00PM on 4th January
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Date limitations
Reply #7 - Jan 4th, 2008 at 2:58pm
Print Post  
It seems I have misunderstood what you want to achieve. But your case is resolved even simpler. Instead of compared to the item's start time, compare to the current time, that is:

Code
Select All
if (e.NewStartTime < DateTime.Now)
	... 


Meppy
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Date limitations
Reply #8 - Jan 5th, 2008 at 2:18pm
Print Post  
Almost, but still not quite.

I had tried the e.item.newstarttime (had not seen the e.newstarttime)!

However this works to a point but there is a situation which slips through the trap!

Create the code as you describe.

Create an item on the calendar in timetableview for tomorrow at 2:00pm.

Drag the item back to today dragging cleanly from right to left and the drag will be refused and the drop undone which is exactly what we want.

But do the same as above but dont drop the item.  While the mouse cursor is a black circle with a line through it drag down and the curor changes to an arrow and allows the item to be dropped even thought the time being dropped on is in the past!

So the item is for 2:00pm on the 6th and it is now 4:00pm on the 5th.

Drag right to 2:00pm on the 5th and drop and it is rejected.

Drag right and then down to 3:00pm on the 5th and it is accepted!

DOH!!!

placing some text boxes on the for to update to the new and old dates when dragging left from the 6th to the 5th the e.newstarttime show the 5th and e.item.starttime shows the 6th.

But if you drag down without dropping the e.item.starttime changes to the 5th and so falls thru the trap!

It needs to store the original starttime without changing it for the comparison to work.

  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Date limitations
Reply #9 - Jan 5th, 2008 at 3:10pm
Print Post  
My testing so far seems to suggest that this works Smiley

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

	  ' if the new time slot pointed to is less than the curent date and time
	  ' set the form variable to the items start time

	  If (e.NewStartTime < DateTime.Now) Then

		dtDateTimeCheck = e.Item.StartTime

	  End If

	  ' if the new time slot pointed to is less than the form variable, or the user is a read only one
	  ' or is less than the current date and time cancel the amendment

	  If (e.NewStartTime < dtDateTimeCheck) Or (intUserAccessLevel = ReadUser) Or _
	     (e.NewStartTime < DateTime.Now) Then

		e.Confirm = False

	  End If

 End Sub

 

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