Quintiq file version 2.0
#parent: #root
Method InitializeRecurrencePeriod (
  shadow[LibCal_RecurrencePeriod] sRecurrencePeriod_i,
  Date startDate_i
) id:Method_LibCal_dlgEvent_InitializeRecurrencePeriod
{
  #keys: '[131094.0.1357896159]'
  Body:
  [*
    // First initialize everything as new...
    this.InitializeRecurrencePeriodAsNew( startDate_i );
    
    // ... then take over the existing period (if applicable)
    if( not isnull( sRecurrencePeriod_i ) )
    {
      datStartOfPeriod.Date( sRecurrencePeriod_i.StartDate() );
      vhStartOfPeriod .Data( sRecurrencePeriod_i.StartDate() );
    
      // NoEnd
      if( sRecurrencePeriod_i.istype( shadow[LibCal_RecurrencePeriodWithoutEnd] ) )
      {
        // Is already initialized
      }
    
      // NrOfOccurences
      else if( sRecurrencePeriod_i.istype( shadow[LibCal_RecurrencePeriodNrOfOccurrences] ) )
      {
        period := sRecurrencePeriod_i.astype( shadow[LibCal_RecurrencePeriodNrOfOccurrences] );
    
        ckbNoEndDate.Checked( false );
        ckbEndAfter. Checked(  true );
    
        edtNrOfOccurrences.Text( [String]period.NrOfOccurrences() );
      }
    
      // WithEndDate
      else if( sRecurrencePeriod_i.istype( shadow[LibCal_RecurrencePeriodWithEndDate] ) )
      {
        period := sRecurrencePeriod_i.astype( shadow[LibCal_RecurrencePeriodWithEndDate] );
    
        ckbNoEndDate.Checked( false );
        ckbEndBy.    Checked(  true );
    
        datEndOfPeriod.Date( period.EndDate() );
      }
    }
    
    this.SetEndOfPeriod();
  *]
}
