admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
Quintiq file version 2.0
#parent: #root
Method CreateEvent (
  internal[GUIComponent] parent_i,
  LibCal_Calendar owner_i,
  LibCal_EventCategory category_i,
  DateTime start_i,
  DateTime end_i
) as LibCal_Event id:Method_LibCal_dlgEvent_CreateEvent_653
{
  #keys: '[131094.0.1233348206]'
  Body:
  [*
    timezone := owner_i.GetTimeZone();
    
    // Create a new Event.
    sEvent := owner_i.Event( relshadow,
                             EventID        := [String]Key::NextPersistentKey(),
                             StartTimeOfDay := start_i.TimeOfDay( timezone ),
                             EndTimeOfDay   := end_i.TimeOfDay( timezone ),
                             EventCategory  := category_i );
    
    // Special case: by default the EventType is 'Unavailable', but when an event is created for
    // category 'Available' or 'Partial' then set the Type to 'Available' resp. 'Partial'. 
    if( guard( category_i.Name() = LibCal_Event::TYPE_AVAILABLE(), false ) )
    {
      sEvent.Type( LibCal_Event::TYPE_AVAILABLE() );
    }
    else if( guard( category_i.Name() = LibCal_Event::TYPE_PARTIAL(), false ) )
    {
      sEvent.Type( LibCal_Event::TYPE_PARTIAL() );
    }
                             
    Dialog.Data( sEvent );
    
    // Create a new LeadingParticipation.
    // Only set the dates, the times will be updated from the Event later if necessary.
    sLeadPart := owner_i.Participation( relshadow, LibCal_LeadingParticipation,
                                        ParticipationID := [String]Key::NextPersistentKey(),
                                        StartDate       := start_i.Date( timezone ),
                                        EndDate         := end_i.Date( timezone ) );
    dhLeadingParticipation.Data( &sLeadPart );
    this.InitializeRecurrence( start_i.Date( timezone ) ); 
    
    event := null( LibCal_Event );
    
    if( Dialog.DoModal( parent_i ) > 0 )
    {
      event := this.CreateUpdateEventAndParticipation();
    }
    
    return event;
  *]
}