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
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
80
81
Quintiq file version 2.0
#parent: #root
Method CreateEvent (
  LibCal_Calendar owner_i,
  LibCal_EventCategory category_i,
  DateTime start_i,
  DateTime end_i
) id:Method_LibCal_dlgEvent_CreateEvent_791 #extension
{
  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,
                             IsDefault      := owner_i.istype( LibCal_CommonCalendar ) );
    
    // 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() );
    }
    if( guard( category_i.Name() = LibCal_Event::TYPE_UNAVAILABLE(), false ) )
    {
      pnlEventType.Visible( true );
    }else
    {
      pnlEventType.Visible( false );
    }
    
    // Set the Event and the related controls...
    // The values are explicitly assigned here 'at the beginning' to the controls,
    // so that the values can be used by the rest of the logic. Databinding is executed too late for that.
    // Further initialization is done in the OnCreated of the Dialog.
    dhEvent.Data( &sEvent );
    this.SetEventData();
    
    // ...and an accompanying 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 ) );
    
    // Set the Participation and the related controls
    // (only the DataHolders, the Date-controls are set later on, after the recurrence has been initialized)
    dhStartDate.Data( sLeadPart.StartDate() );
    dhEndDate.Data(   sLeadPart.EndDate()   );
    dhLeadingParticipation.Data( &sLeadPart );
    
    // Initialize the capacity here, when done in the OnCreate() edtCapacity is not disabled correctly.
    this.InitializeCapacity();
    
    // Initialize the category here, when done in the OnCreate() there is no selection in the DropDownList.
    // Select the general category for new events.
    this.InitializeCategories();
    this.InitializeEventTypes();
    ddlCategory.Data( owner_i.CalendarRegistry().GetGeneralEventCategory() );
    ddlEventType.Data( owner_i.CalendarRegistry().GetDefaultEventType() );
    
    // Must be done here, when done in the OnCreate() the checkmarks are not always set when the dialog is opened for editing an event.
    // Pre-select all resources as subscriber when creating a common event.
    this.InitializeSubscribers();
    if( owner_i.istype( LibCal_CommonCalendar ) )
    {
      lstSubscribers.CheckAll();
    }
    
    // Open the dialog.
    this.Show( "modal" );
  *]
}