Quintiq file version 2.0
#parent: #root
Method OnOK () id:Method_DialogCreateEditSalesSegment_OnOK
{
  #keys: '[135040.0.183113912]'
  Body:
  [*
    // When the user clicks ok,       
    // we either create or edit the data
    
    this.ApplyChanges();
    
    data := DataHolderDialogData.Data();
    
    if( isnull( data.WrappedInstance() ) )
    {
    
      salesegment := SalesSegment_MP::Create( data.MacroPlan(),
                                              data.Parent(),
                                              data.Name(),
                                              data.DisplayIndex(),
                                              false  //isfromdb
                                             );
                              
      // Access the form, select new sales segment
      DataHolderForm.Data().ListSalesSegment().SelectByKey( salesegment.Key() );                          
    }
    else
    {
      data.WrappedInstance().Update( edtName.Text(),  // Read-only, apply changes to shadow is not taking place for read-only attribute when editing
                                     data.Parent(),
                                     data.DisplayIndex(),
                                     false //isfromdb
                                    );
    }
    
    this.Close();
  *]
}
