|  |  | 
 |  |  |   [* | 
 |  |  |     // Disabled button to prevent the possibility of multiple firing | 
 |  |  |      | 
 |  |  |     macroPlanOld := MacroPlan; | 
 |  |  |     //macroPlanOld := MacroPlan; | 
 |  |  |      | 
 |  |  |     btnOK.Enabled( false, '' ) | 
 |  |  |      | 
 |  |  | 
 |  |  |     data := DataHolderDialogData.Data(); | 
 |  |  |     newscenario := null( Scenario ); | 
 |  |  |     strategy := null( Strategy ); | 
 |  |  |      | 
 |  |  |     // New version | 
 |  |  |     globalotdtable := GlobalOTDTable; | 
 |  |  |     globalotdsop := GlobalOTDSOP; | 
 |  |  |     testbusinesstype := "集团"; | 
 |  |  |     if( data.IsCreateNewVersion() ){ | 
 |  |  |       VersionControl::CreateNewSceneVersion( globalotdsop, testbusinesstype ); | 
 |  |  |       }else{ | 
 |  |  |         VersionControl::CopyVersion( globalotdsop, testbusinesstype ); | 
 |  |  |         } | 
 |  |  |     versionname := VersionControl::GetVersionInfo( globalotdsop, testbusinesstype ).Element( 3 ); | 
 |  |  |      | 
 |  |  |     // Get Version Name | 
 |  |  |     if( data.Name() = "" ){ | 
 |  |  |       data.Name( versionname ); | 
 |  |  |       } | 
 |  |  |      | 
 |  |  |     // Get Business Type from Scenario Name | 
 |  |  |     businesstype := guard( select( globalotdtable,  | 
 |  |  |                                    BusinessType,  | 
 |  |  |                                    b,  | 
 |  |  |                                    b.ScenarioName()=data.ScenarioName() ).BusinessTypeName(),  | 
 |  |  |                            "" ); | 
 |  |  |     data.BusinessType( businesstype ); | 
 |  |  |      | 
 |  |  |     // Copy scenario | 
 |  |  |     if( isnull( data.WrappedInstance() ) ) | 
 |  |  | 
 |  |  |     } | 
 |  |  |      | 
 |  |  |     macroPlanNew := MacroPlan; | 
 |  |  |     ManufactureLTImputation::Transfer( macroPlanOld, macroPlanNew ); | 
 |  |  |     //ManufactureLTImputation::Transfer( macroPlanOld, macroPlanNew ); | 
 |  |  |      | 
 |  |  |     // sync data | 
 |  |  |     if( data.EnableSync() ) { | 
 |  |  |         MacroPlan::DoSync( macroPlanNew,  | 
 |  |  |                            data.BusinessType(), data.IsKeyProduct(), data.CreatePurchaseSupplyMaterial() ); | 
 |  |  |                            data.BusinessType(), data.IsKeyProduct(), data.CreatePurchaseSupplyMaterial() ,GlobalOTDTable); | 
 |  |  |     } | 
 |  |  |     macroPlanNew.BusinessType( businesstype ); | 
 |  |  |     macroPlanNew.IsKeyProduct( data.IsKeyProduct() ); | 
 |  |  |     macroPlanNew.CreatePurchaseSupplyMaterial( data.CreatePurchaseSupplyMaterial() ); | 
 |  |  |      | 
 |  |  |     this.Close(); | 
 |  |  |   *] |