Quintiq file version 2.0
#parent: #root
Method SetAttributeAfterApplyData () id:Method_DialogCreateEditUnit_SetAttributeAfterApplyData
{
  #keys: '[135040.0.232650761]'
  Body:
  [*
    // Set attributes before commitng the data
    //..following TC style
    
    data := DataHolderDialogData.Data();
    
    // Software bug, data binding on dropdown didn't clear when user select empty parent (it still remembers the last selected parent)
    if( isnull( selParentUnit.Data() ) )
    {
      data.Parent( relset, null( Unit ) );
    }
    
    //handle validity start/end
    start := Date::MinDate();
    end := Date::MaxDate();
    if( CheckboxHasStart.Checked() )
    {
      start := dsStart.Date();
    }
    if( CheckboxHasEnd.Checked() )
    {
      end := dsEnd.Date();
    }
    
    data.StartDate( start );
    data.EndDate( end );
    
    //handle capacitySmoothing
    capacitytype := data.CapacityType()
    istransport := capacitytype = GlobalParameters_MP::GetCapacityTypeTransportTime()
                   or capacitytype = GlobalParameters_MP::GetCapacityTypeTransportQuantity();
    // set to false if user set it to true and change to transport type later              
    if ( istransport )
    {
      data.HasCapacitySmoothing( false );
    }
    
    //handle user frozen duration
    if( CheckboxUserFrozenFutureDuration.Checked() )
    {
      DurationSelectorUserFrozenFutureDuration.Enabled( false, "" );
      data.UserFrozenFutureDuration( DurationSelectorUserFrozenFutureDuration.Duration() );
    }
  *]
}
