Quintiq file version 2.0
#parent: #root
Method OnOK () id:Method_DialogCreateEditOperation_OnOK
{
  #keys: '[139394.0.1386371196]'
  Body:
  [*
    // On ok
    this.ApplyChanges();
    
    data := DataHolderDialogData.Data();
    // Special handle for lead time and lot size because they don't bind to the real attributes
    // we are about to update
    data.HasUserMaximumQuantity( CheckboxHasUserLotSize.Checked() and CheckboxHasUserMaximumQuantity.Checked() );
    if( CheckboxHasUserLotSize.Checked() )
    {
      data.UserMinimumQuantity( ApplicationMacroPlanner.FormatStringToReal( EditFieldUserMinimumQuantity.Text() ) );
      data.UserMaximumQuantity( ApplicationMacroPlanner.FormatStringToReal( EditFieldUserMaximumQuantity.Text() ) );
      data.UserLotSize( ApplicationMacroPlanner.FormatStringToReal( EditFieldUserLotSize.Text() ) );
    }
    
    // New
    if( isnull( data.WrappedInstance() ) )
    {
      data.Commit();
    }
    else if( DataHolderDialogDatas.Data().Size() =1 )
    {
      data.WrappedInstance().Update( DropDownListUnit.Data(),
                                     EditFieldID.Text(),
                                     data.Name(),
                                     data.RoutingStep(),
                                     data.UserLeadTime(),
                                     data.StandardDeviationLeadTimeOperation(),
                                     data.Throughput(),
                                     data.HasUserLotSize(),
                                     data.UserMinimumQuantity(),
                                     data.HasUserMaximumQuantity(),
                                     data.UserMaximumQuantity(),
                                     data.UserLotSize(),
                                     data.CO2Emission(),
                                     false /*isfromdb*/ );
    }
    else
    {
      Operation::Update( DataHolderDialogDatas.Data(),
                         data.Unit(),
                         EditFieldID.Text(),
                         data.Name(),
                         CheckBoxBatchEditLeadTime.Checked(),
                         data.UserLeadTime(),
                         CheckBoxBatchEditStandardDeviation.Checked(),
                         data.StandardDeviationLeadTimeOperation(),
                         CheckBoxBatchEditThroughput.Checked(),
                         data.Throughput(),
                         CheckBoxBatchEditHasUserLotSize.Checked(),
                         data.HasUserLotSize(),
                         data.UserMinimumQuantity(),
                         data.HasUserMaximumQuantity(),
                         data.UserMaximumQuantity(),
                         data.UserLotSize(),
                         CheckboxBatchCO2.Checked(),
                         data.CO2Emission() );
    }
    
    this.Close();
  *]
}
