Quintiq file version 2.0
#parent: #root
Method OnOK () id:Method_DialogCreateEditUnit_OnOK
{
  #keys: '[135040.0.219519607]'
  Body:
  [*
    // When the user clicks ok,       
    // we either create or edit the data
    this.ApplyChanges();
    this.SetAttributeAfterApplyData();
    
    data := DataHolderDialogData.Data();
    
    if( isnull( data.WrappedInstance() ) )
    { //new
      data.Commit();
      
      // Access the form, select the new unit
      DataHolderForm.Data().ListEntity().SelectByKey( data.WrappedInstance().Key() );
    }
    else
    { //edit & batch edit
      Unit::Update( DataHolderDialogDatas.Data()
                   ,CheckBoxBatchEditValidity.Checked()
                   ,false //CheckBoxBatchEditGIS.Checked()
                   ,CheckBoxBatchEditMisc.Checked()
                   ,CheckBoxBatchEditNote.Checked()
                   ,CheckBoxBatchEditUseShiftPatternOptimization.Checked()
                   ,EditFieldID.Text()
                   ,data.Name()
                   ,data.Parent()
                   ,data.CapacityType()
                   ,data.Group()
                   ,data.UnitOfMeasure_MP()
                   ,data.Currency_MP()
                   ,data.StartDate()
                   ,data.EndDate()
                   ,data.CampaignTypeDuration()
                   ,data.IsPlannedInfinite()
                   ,data.MinimumQuantity()
                   ,data.HasMaximumQuantity()
                   ,data.MaximumQuantity()
                   ,data.LotSize()
                   ,data.IconName()
                   ,data.QuantityToProcess()
                   ,data.GISCountryCode()
                   ,data.GISCity()
                   ,data.GISPostalCode()
                   ,data.Notes()
                   ,data.HasCapacitySmoothing()
                   ,data.IsSmoothCapacityOverAllPeriods()
                   ,data.UserCapacitySmoothingLength()
                   ,data.CapacitySmoothingPercentageDelta()
                   ,data.IsOverlapCapacitySmoothing()
                   ,data.IsIncludedInSupplySpecification()
                   ,data.IsSupplier()
                   ,data.HasUserFrozenFutureDuration()
                   ,data.UserFrozenFutureDuration()
                   ,data.UseShiftOptimization()
                   ,false );
    }
    
    this.Close();
  *]
}
