Quintiq file version 2.0
#parent: #root
Method NewLaneLegCost (
  internal[GUIComponent] parent,
  shadow[LaneLeg] owner
) id:Method_DialogCreateEditLaneLegCost_NewLaneLegCost_434
{
  #keys: '[124808.1.1621249184]'
  Body:
  [*
    // New lane leg shadow cost
    
    data := owner.LaneLegCost( relnew,
                               ID := MacroPlan.IDHolder().GetLaneLegCostID(),
                               OriginStockingPointID := owner.OriginStockingPointID(),
                               DestinationStockingPointID := owner.DestinationStockingPointID() );
    
    Dialog.Data( data );
    
    // Set default value
    Dialog.SetDefaultValue();
    
    currency := guard( owner.Lane().Unit().Currency_MP(), null( Currency_MP ) );
    unitofmeasure := guard( owner.Lane().Unit().UnitOfMeasure_MP(), null( UnitOfMeasure_MP ) );
    
    Dialog.SetHolders( currency, unitofmeasure );
    
    Dialog.SetValueForStringSelections( LaneLegCost::GetDefinitionName() );
    
    result := Dialog.DoModal( parent );
    
    if( result > 0 )
    {
      data.Commit();
    }
    else
    {
      // If user cancels, delete the instance
      data.Delete();
    }
  *]
}
