陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Quintiq file version 2.0
#parent: #root
Method GetDateOfFirstRecurrence (
  Date startOfPeriod_i
) as Date id:Method_LibCal_dlgEvent_GetDateOfFirstRecurrence
{
  #keys: '[131092.1.1290429]'
  Accessibility: 'Public'
  Body:
  [*
    date          := Date::MinDate();
    earliestStart := startOfPeriod_i;
    patternType   := this.GetPatternType();
    timezone      := this.GetCalendarTimeZone();
    
    if( patternType = LibCal_RecurrencePattern::TYPE_DAILY() )
    {
      date := LibCal_RecurrencePatternDaily::GetDateOfFirstRecurrence( startOfPeriod_i, earliestStart,
                                                                       [Number]edtEveryNrOfDays.Text(),
                                                                       ckbEveryWeekday.Checked() );
    }
    
    else if( patternType = LibCal_RecurrencePattern::TYPE_WEEKLY() )
    {
      date := LibCal_RecurrencePatternWeekly::GetDateOfFirstRecurrence( startOfPeriod_i, earliestStart, 
                                                                        [Number]edtEveryNrOfWeeks.Text() );
    }
    
    else if( patternType = LibCal_RecurrencePattern::TYPE_MONTHLY() )
    {
      // Make sure that the entered day of the month is valid.
      day := guard( [Number]edtMonthlyDay.Text(), 0 );
      
      if( day > 0 )
      {
        everyNrOfMonths := ifexpr( ckbMonthlyDay.Checked(), edtMonthlyDayEveryNrOfMonths.Text(),
                                                            edtMonthlyPatternEveryNrOfMonths.Text() );
    
        /* BUG: referencing the DropDownStringLists results in an error in the TCE !!!
        // As a WORKAROUND, the values are also set in a hidden label, which càn be used here.
        weekOfMonth := ssMonthlyPatternWeekOfMonth.Text();
        dayOfWeek   := ssMonthlyPatternDayOfWeek.Text();
        */
    
        weekOfMonth := lblMonthlyPatternWeekOfMonth.Text();
        dayOfWeek   := lblMonthlyPatternDayOfWeek.Text();
    
        date := LibCal_RecurrencePatternMonthly::GetDateOfFirstRecurrence( timezone, startOfPeriod_i, durStartTimeOfDay.Duration(), durEndTimeOfDay.Duration(), dhDuration.Data(),
                                                                           earliestStart, [Number]everyNrOfMonths,
                                                                           ckbMonthlyDay.Checked(), day, weekOfMonth, dayOfWeek );
      }
    }
    
    else if( patternType = LibCal_RecurrencePattern::TYPE_YEARLY() )
    {
      /* BUG: referencing the DropDownStringLists results in an error in the TCE !!! 
      // As a WORKAROUND, the values are also set in a hidden label, which càn be used here.
      month       := ifexpr( ckbYearlyDate.Checked(), ssYearlyMonth.Text(), ssYearlyPatternMonth.Text() );
      nrOfMonth   := this.GetNrOfMonth( month );
      dayOfMonth  := [Number]ssYearlyDayOfMonth.Text();
      weekOfMonth := ssYearlyPatternWeekOfMonth.Text();
      dayOfWeek   := ssYearlyPatternDayOfWeek.Text();
      */
    
      month       := ifexpr( ckbYearlyDay.Checked(), lblYearlyMonth.Text(), lblYearlyPatternMonth.Text() );
      nrOfMonth   := this.GetNrOfMonth( month );
      dayOfMonth  := [Number]lblYearlyDayOfMonth.Text();
      weekOfMonth := lblYearlyPatternWeekOfMonth.Text();
      dayOfWeek   := lblYearlyPatternDayOfWeek.Text();
      
      date := LibCal_RecurrencePatternYearly::GetDateOfFirstRecurrence( timezone, startOfPeriod_i, durStartTimeOfDay.Duration(), durEndTimeOfDay.Duration(), dhDuration.Data(),
                                                                        earliestStart, [Number]edtEveryNrOfYears.Text(),
                                                                        nrOfMonth, ckbYearlyDay.Checked(), dayOfMonth, weekOfMonth, dayOfWeek );
    }
    
    return date;
  *]
  UseInheritedAccessibility: false
}