lazhen
2025-01-07 b3987122cbbc46c5c59d3173f37fca3170b6dc5a
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
Quintiq file version 2.0
#parent: #root
Method OnOK () id:Method_DialogCreateEditTransitionType_OnOK
{
  #keys: '[139394.0.1557805857]'
  Body:
  [*
    // On ok
    this.ApplyChanges();
    
    data := DataHolderDialogData.Data();
    
    // Manually ApplyChanges for HasInputMaxQuantity and HasInputMaxDuration ( Workaround: no data binding on actionlink )
    quantitybased := RadioButtonGroupQuantityDuration.BoundValue() = GlobalParameters_MP::GetCampaignTransitionsTypeQuantity();
    data.HasInputMaxQuantity( quantitybased and EditFieldDefaultMaxQty.Enabled() )
    data.HasInputMaxDuration( not quantitybased and DurationSelectorMaxDuration.Enabled() );
    
    // New
    if( isnull( data.WrappedInstance() ) )
    {
      newtransitiontype := TransitionType_MP::Create( DropDownListUnit.Data(),
                                                      data.DefaultMinQuantity(),
                                                      data.DefaultMaxQuantity(),
                                                      data.DefaultMinDuration(),
                                                      data.DefaultMaxDuration(),
                                                      DropDownListFromCampaignType.Data(),
                                                      DropDownListToCampaignType.Data(),
                                                      data.HasInputMaxQuantity(),
                                                      data.HasInputMaxDuration(),
                                                      false /*isfromdb*/ );
      // Access the form, select the new transition type
      DataHolderForm.Data().ListTransitionType().SelectByKey( newtransitiontype.Key() );
    }
    else
    {
      data.WrappedInstance().Update( DropDownListUnit.Data(),
                                     data.DefaultMinQuantity(),
                                     data.DefaultMaxQuantity(),
                                     data.DefaultMinDuration(),
                                     data.DefaultMaxDuration(),
                                     DropDownListFromCampaignType.Data(),
                                     DropDownListToCampaignType.Data(),
                                     RadioButtonGroupQuantityDuration.BoundValue().TrimBoth(),
                                     data.HasInputMaxQuantity(),
                                     data.HasInputMaxDuration(),
                                     false /*isfromdb*/ );  
    }
    
    this.Close();
  *]
}