Quintiq file version 2.0 #parent: #root Method OnOk () id:Method_DialogCreateEditScenario_OnOk #extension { Body: [* // Disabled button to prevent the possibility of multiple firing macroPlanOld := MacroPlan; 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() ); scenario.EnableSync( data.EnableSync() ); scenario.BusinessType( data.BusinessType() ); scenario.IsKeyProduct( data.IsKeyProduct() ); scenario.CreatePurchaseSupplyMaterial( data.CreatePurchaseSupplyMaterial() ); } // If DatasetMDSID is set, it means the scenario // will be linked to an existing dataset else if( data.DatasetMDSID() <> Key::ZeroKey() ) { sc := ScenarioManager.CreateScenarioMPFromDataset( data.Parent(), data.Name(), edtAssumption.Text(), data.Comment(), '', data.DatasetName(), data.DatasetMDSID(), data.State() ); sc.EnableSync( data.EnableSync() ); sc.BusinessType( data.BusinessType() ); sc.IsKeyProduct( data.IsKeyProduct() ); sc.CreatePurchaseSupplyMaterial( data.CreatePurchaseSupplyMaterial() ); } else { newscenario := ScenarioManager.CreateScenarioMP( data.Parent(), data.Name(), edtAssumption.Text(), data.Comment(), data.State(), '', ApplicationMacroPlanner.GetUserName() ); newscenario.EnableSync( data.EnableSync() ); newscenario.BusinessType( data.BusinessType() ); newscenario.IsKeyProduct( data.IsKeyProduct() ); newscenario.CreatePurchaseSupplyMaterial( data.CreatePurchaseSupplyMaterial() ); strategy := data.SelectedStrategy(); } } // Edit scenario else { data.WrappedInstance().Update( data.Name(), data.Comment(), data.State() ); data.WrappedInstance().SelectedStrategy( relset, data.SelectedStrategy() ); data.WrappedInstance().EnableSync( data.EnableSync() ); data.WrappedInstance().BusinessType( data.BusinessType() ); data.WrappedInstance().IsKeyProduct( data.IsKeyProduct() ); data.WrappedInstance().CreatePurchaseSupplyMaterial( data.CreatePurchaseSupplyMaterial() ); } // 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 ) ); } } // sync data if( data.EnableSync() ) { MacroPlan::DoSyncNew( DataHolderMacroPlanner.Data(), MPSync, data.BusinessType(), data.IsKeyProduct(), data.CreatePurchaseSupplyMaterial() ); } macroPlanNew := MacroPlan; ManufactureLTImputation::Transfer( macroPlanOld, macroPlanNew ); this.Close(); *] }