lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Quintiq file version 2.0
#parent: #root
Method SetEndOfPeriod () id:Method_LibCal_dlgEvent_SetEndOfPeriod
{
  #keys: '[131092.1.1284157]'
  Body:
  [*
    // When this method is called from response dsStartOfPeriod.OnChanged() because the value is set during
    // InitializeRecurrencePeriod(), the value of ckbEndOfPeriod.Checked() is *always* 'false', even when it is
    // explicitly set to 'true' during the initialization. This seems to be a bug in the Software.
    // As a workaround, the value of lblWorkaround.Text() is set to "initialized" when the value of ckbEndOfPeriod.Checked() is set.
    // When this method is called during initialization, the value of the label is still "" (which is WRONG, it should have been set!).
    // This can be used to let this method not be executed with a value of ckbEndOfPeriod.Checked() that is not
    // properly initialized.
    if( lblWorkaround.Text() <> "" )
    {
      if( this.ValuesRecurrenceOK() )
      {
        if( btnOnce.IsPressed() )
        {
          dsEndOfPeriod.Date( dsStartOfPeriod.Date() );
        }
        else
        {
          // Set the end of the period based on the start of the period and the #occurrences
          // IFF the end of the period is not manually set.
          if( not ckbEndBy.Checked() )
          {
            endDate := this.DetermineEndDate( dsStartOfPeriod.Date(), [Number]edtNrOfOccurrences.Text() );
            dsEndOfPeriod.Date( endDate );
          }
        }
      }
      
      // else keep the value as it is, setting it to MinDate looks 'strange'.
      
      Form.UpdateTextualInfo();
    }
  *]
}