Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Determining Original RecurrenceState of Item (Read 1937 times)
BudMan
YaBB Newbies
*
Offline


Credidi me felem vidisse

Posts: 45
Joined: Jul 14th, 2007
Determining Original RecurrenceState of Item
Jan 30th, 2008 at 3:23pm
Print Post  
I am using a SQL Server database as a back-end for my Planner.NET calendar. The database has separate tables for Items, Recurrences, and Exceptions; all Items are (currently) Appointment objects. In the calendar, when a user makes a change to an appointment, I need to make the corresponding change in the database. To do this, I need to know the RecurrenceState property of the item so I can post the change to the appropriate table (Items, Recurrences, or Exceptions). For one-time items (i.e., those with RecurrenceState = None), this is easy. The problem I have is with recurring items. For example, take the Calendar's ItemInplaceEdited() event. After the user edits an item, its RecurrenceState will be RecurrenceState.Exception. However, before the user made changes, its RecurrenceState could have been either RecurrenceState.Occurence or RecurrenceState.Exception. If the former, I need to add a new exception to the Exceptions table; if the latter I just need to edit the existing Exception record in the table.

So I need some way to determine the ORIGINAL state of the recurring item before the edit, right? I have an idea how to do this and I just want to verify it is a viable solution. I am using the ItemSelecting() handler of the calendar to set a class-level variable, like the following:
   
    Dim mOrigRecurrenceState As MindFusion.Scheduling.RecurrenceState
     
    Private Sub calendar_ItemSelecting(...) Handles calendar.ItemSelecting
       mOrigRecurrenceState = e.Item.RecurrenceState
    End Sub


Then, after the user edits the item, I have code in the ItemInPlaceEdited() handler like this:

    Private Sub calendar_ItemInplaceEdited(...) Handles calendar.ItemInplaceEdited
      
      If Not e.Item.RecurrenceState = RecurrenceState.None Then

           If mOrigRecurrenceState = RecurrenceState.Exception Then
               ' Original RecurrenceState = Exception,
               ' Put code here to UPDATE existing exception
           Else
               ' Original RecurrenceState = Occurrence,
           ' Put code here to ADD new exception
           End If
       Else
           ' Original RecurrenceState = None,
         ' Put code here to edit one-time item
       End If

       mbItemSelected = False
    End Sub

Does this sound like a good way to go, or do you suggest something else?
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Determining Original RecurrenceState of Item
Reply #1 - Jan 31st, 2008 at 5:53am
Print Post  
Might be a working solution. Have you considered however using the ItemInplaceEditStarting and ItemInplaceEditEnding events? Both should be fired before the item's text has actually been changed.

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