Quintiq file version 2.0 #parent: #root Method OnOk () id:Method_DialogCreateEditScenario_OnOk { #keys: '[134266.1.2021821381]' Body: [* // Disabled button to prevent the possibility of multiple firing btnOK.Enabled( false, '' ) // On ok execution, create new scenario, copy or edit this.ApplyChanges(); data := DataHolderDialogData.Data(); newscenario := null( Scenario ); strategy := null( Strategy ); // Copy scenario if( isnull( data.WrappedInstance() ) ) { if( DataHolderActionCopy.Data() ) { scenario := data.Parent().astype( ScenarioMP ); strategy := data.SelectedStrategy(); newscenario:= scenario.Copy( data.Parent(), data.Name(), edtAssumption.Text(), data.Comment(), data.State() ); } // If DatasetMDSID is set, it means the scenario // will be linked to an existing dataset else if( data.DatasetMDSID() <> Key::ZeroKey() ) { ScenarioManager.CreateScenarioMPFromDataset( data.Parent(), data.Name(), edtAssumption.Text(), data.Comment(), '', data.DatasetName(), data.DatasetMDSID(), data.State() ); } else { newscenario := ScenarioManager.CreateScenarioMP( data.Parent(), data.Name(), edtAssumption.Text(), data.Comment(), data.State(), '', ApplicationMacroPlanner.GetUserName() ); strategy := data.SelectedStrategy(); } } // Edit scenario else { data.WrappedInstance().Update( data.Name(), data.Comment(), data.State() ); data.WrappedInstance().SelectedStrategy( relset, data.SelectedStrategy() ); } // Post scenario creation // Set kb and strategy after creation of scenario and set the scenario as active if( not isnull( newscenario ) ) { newscenario.SelectedStrategy( relset, strategy ); if ( not DataHolderActionCopy.Data() ) { ApplicationMacroPlanner.SelectScenario( newscenario.astype( ScenarioMP ) ); } } this.Close(); *] }