| Quintiq file version 2.0 | 
| #parent: #root | 
| Method OnOK () id:Method_DialogCreateEditServiceLevel_OnOK | 
| { | 
|   #keys: '[146140.0.1162682032]' | 
|   Body: | 
|   [* | 
|     // When the user click OK, we either create or edit a service level | 
|      | 
|     data := DataHolderDialogData.Data(); | 
|     selection := DataHolderServicesLevel.Data(); | 
|     isbatchedit := selection.Size() > 1; | 
|      | 
|     // New | 
|     if( isnull( data.WrappedInstance() ) ) | 
|     { | 
|       ServiceLevel::Create( MacroPlan, | 
|                             '', // Automaticaly generated | 
|                             true, // isEnable | 
|                             EditFieldName.Text(), | 
|                             DropDownListProduct.Data(), | 
|                             DropDownListStockingPoint.Data(), | 
|                             data.SalesSegment_MP(), | 
|                             ApplicationMacroPlanner.FormatStringToReal( EditFieldTargetPercentage.Text() ), | 
|                             DateSelectorStart.Date(), | 
|                             DateSelectorEnd.Date(),  | 
|                             true, | 
|                             false, | 
|                             false ); | 
|     } | 
|     else | 
|     { | 
|       if( isbatchedit ) // Btach Edit | 
|       { | 
|         if( CheckBoxBatchEditTargetPercentage.Checked() ) | 
|         { | 
|           ServiceLevel::Update( selection, | 
|                                 ApplicationMacroPlanner.FormatStringToReal( EditFieldTargetPercentage.Text() ) ); | 
|         } | 
|       } | 
|       else | 
|       { | 
|         data.WrappedInstance().Update( data.IsEnabled(), | 
|                                        EditFieldName.Text(), | 
|                                        DropDownListProduct.Data(), | 
|                                        DropDownListStockingPoint.Data(), | 
|                                        data.SalesSegment_MP(), | 
|                                        ApplicationMacroPlanner.FormatStringToReal( EditFieldTargetPercentage.Text() ), | 
|                                        DateSelectorStart.Date(), | 
|                                        DateSelectorEnd.Date(), | 
|                                        true, | 
|                                        false, | 
|                                        false ); | 
|       } | 
|     } | 
|     Form.Close(); | 
|   *] | 
| } |