Quintiq file version 2.0
#parent: #root
Method CreateUpdateEventAndParticipation () as LibCal_Event id:Method_LibCal_dlgEvent_CreateUpdateEventAndParticipation #extension
{
  Body:
  [*
    sEvent    := dhEvent.Data();
    sLeadPart := dhLeadingParticipation.Data();
    
    // Get the values from the controls.
    
    // Event and LeadingParticipation
    subject        := edtName.Text();
    description    := edtDescription.Text();
    category       := ddlCategory.Data();
    eventTypeList  := ddlEventType.Data();
    isDefault      := ckbApplyToNewResources.Checked();
    startDate      := dsStartDate.Date();
    startTimeOfDay := durStartTimeOfDay.Duration();
    endDate        := dsEndDate.Date();
    endTimeOfDay   := durEndTimeOfDay.Duration();
    isAllDay       := ckbIsAllDay.Checked();
    
    eventType := ddslType.Text();
    capacity  := this.StringToReal( edtCapacity.Text() );  // Always fill the capacity.
    
    // RecurrencePattern
    isRecurring        := not btnOnce.IsPressed();
    recurrenceInterval := this.GetRecurrenceInterval();
    patternType        := this.GetPatternType();
    
    // Daily
    daily_IsEveryWeekday := ckbEveryWeekday.Checked();
    
    // Weekly
    weekly_Weekdays := ifexpr( btnMonday   .IsPressed(), "Mon;", "" )
                     + ifexpr( btnTuesday  .IsPressed(), "Tue;", "" )
                     + ifexpr( btnWednesday.IsPressed(), "Wed;", "" )
                     + ifexpr( btnThursday .IsPressed(), "Thu;", "" )
                     + ifexpr( btnFriday   .IsPressed(), "Fri;", "" )
                     + ifexpr( btnSaturday .IsPressed(), "Sat;", "" )
                     + ifexpr( btnSunday   .IsPressed(), "Sun;", "" );
    
    // Monthly
    monthly_IsDay       := ckbMonthlyDay.Checked();
    monthly_Day         := [Number]edtMonthlyDay.Text();
    monthly_WeekOfMonth := ssMonthlyPatternWeekOfMonth.Text();
    monthly_DayOfWeek   := ssMonthlyPatternDayOfWeek.Text();
    
    // Yearly
    yearly_IsDate      := ckbYearlyDay.Checked();
    month              := ifexpr( yearly_IsDate, ssYearlyMonth.Text(), ssYearlyPatternMonth.Text() );
    yearly_Month       := this.GetNrOfMonth( month );
    yearly_Day         := [Number]ssYearlyDayOfMonth.Text();
    yearly_WeekOfMonth := ssYearlyPatternWeekOfMonth.Text();
    yearly_DayOfWeek   := ssYearlyPatternDayOfWeek.Text();
    
    // RecurrencePeriod
    periodType      := this.GetPeriodType();
    periodStartDate := dsStartOfPeriod.Date();
    periodEndDate   := dsEndOfPeriod.Date();
    nrOfOccurrences := [Number]edtNrOfOccurrences.Text();
    
    // All values are passed to the Server, only the relevant values are used there.
    event := LibCal_Event::CreateUpdateFromUI( sEvent.Calendar(), sLeadPart.WrappedInstance(),
                                               subject, description, eventType, eventTypeList, capacity, category, isDefault,
                                               startDate, startTimeOfDay, endDate, endTimeOfDay, isAllDay,
                                               // RecurrencePattern
                                               isRecurring, recurrenceInterval, patternType,
                                               daily_IsEveryWeekday,
                                               weekly_Weekdays,
                                               monthly_IsDay, monthly_Day,  monthly_WeekOfMonth, monthly_DayOfWeek,
                                               yearly_IsDate, yearly_Month, yearly_Day, yearly_WeekOfMonth, yearly_DayOfWeek,
                                               // RecurrencePeriod
                                               periodType, periodStartDate, nrOfOccurrences, periodEndDate,
                                               // Subscribers
                                               dhSubscribers.Data() );
    return event;
  *]
}
