Quintiq file version 2.0
#parent: #root
Method NewSalesSegment (
  internal[GUIComponent] parent,
  SalesSegment_MP parentsalessegment
) as SalesSegment_MP id:Method_DialogCreateEditSalesSegment_NewSalesSegment
{
  #keys: '[107654.0.932618397]'
  Body:
  [*
    // New sales segment
    
    DataHolderParentSalesSegment.Data( parentsalessegment );
    
    // if no sales segment has been created before
    if ( isnull( DataHolderParentSalesSegment.Data() ) )
    {
      CheckBoxParentSalesSegment.Enabled( false );
      CheckBoxParentSalesSegment.Checked( false );
      SelectionParentSalesSegment.Enabled( false );
    }
    else
    {
      SelectionParentSalesSegment.BoundValue( DataHolderParentSalesSegment.Data().Name() );
      SelectionParentSalesSegment.Enabled( true );
      CheckBoxParentSalesSegment.Checked( true );
    }
    result := this.DoModal( parent );
    
    newobj := null( SalesSegment_MP );
    
    if( result > 0 )
    {
      displayindex := 0;
      if( EditorIndex.Text().Length() > 0 )
      {
        displayindex := [Number] EditorIndex.Text();
      }
      parentsalessegment := null ( SalesSegment_MP );
      if ( CheckBoxParentSalesSegment.Checked() )
      {
        parentsalessegment := SelectionParentSalesSegment.Data();
      }
      newobj := SalesSegment_MP::Create( MacroPlan, parentsalessegment, EditorName.Text(), displayindex, false );
    }
    return newobj;
  *]
}
