xiaoding721
2023-11-13 e4edcfd0b987b239526f5375881b919789782dad
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
Quintiq file version 2.0
#parent: #root
Method NewCampaign (
  internal[GUIComponent] parent,
  CampaignType_MP campaigntype,
  Unit owner
) as Campaign_MP id:Method_DialogCreateEditCampaign_MP_NewCampaign
{
  #keys: '[110880.4.851635701]'
  Body:
  [*
    // New campaign
    
    if( isnull( campaigntype ) )
    {
      campaigntype := Campaign_MP::GetDefaultCampaignType( owner );
    }
    
    data := owner.Campaign_MP( relshadow, UnitID := owner.ID(), 
                                          CampaignID := "", // Temporary set CampaignID to empty, will be defined during creation
                                          InputType := campaigntype.InputType() ); // Create will default to campaign type input type
    
    Dialog.Data( data );
    Dialog.SetDefaultValue( campaigntype );
    ValueHolderCampaignAddToLast.Data( true );
    this.InitializeDialog();
    this.SetIndicatorValue();
    
    result := Dialog.DoModal( parent );
    newobj := null( Campaign_MP );
    if( result > 0 )
    {
      campaignid := OS::GenerateGUIDAsString();
      newobj := Campaign_MP::Create( SelectionCampaignType.Data().Unit(),
                                     data.EarliestStart(),
                                     data.SequenceNumberForExcel(),
                                     data.MinQuantity(),
                                     data.MaxQuantity(),
                                     data.MinDuration(),
                                     data.MaxDuration(),
                                     SelectionCampaignType.Data().Name(),
                                     campaignid,
                                     data.Comment(),
                                     data.HasInputMaxQuantity() and RadioButtonGroupQuantityDuration.BoundValue() = GlobalParameters_MP::GetCampaignTransitionsTypeQuantity(),
                                     data.HasInputMaxDuration() and RadioButtonGroupQuantityDuration.BoundValue() = GlobalParameters_MP::GetCampaignTransitionsTypeDuration(),
                                     false );
              }
    return newobj;
  *]
}