Quintiq file version 2.0
#parent: pnlActions/btnOk
Response OnClick () id:Response_pnlActions_btnOk_OnClick
{
  #keys: '[414702.1.84941735]'
  DefinitionID: 'Responsedef_WebButton_OnClick'
  Precondition:
  [*
    flag := not isnull( GlobalOTDTable ) and not isnull( GlobalOTDLog );
    
    activeScenario := DataHolderActiveScenario.Data();
    currentScenario := DataHolderScenario.Data();
    businessType := ddlBusinessType.Data();
    
    if ( activeScenario = currentScenario or isnull( businessType ) ) {
      flag := false;
      feedback := "无法对当前选中场景进行分发";
    }
    
    isExists := exists( GlobalOTDLog, DataDistributionLog, tempDD, tempDD.ExecuteStatus() = "Running" and tempDD.MacroPlanMDSID() = currentScenario.DatasetMDSID() );
    if ( flag and isExists ) {
      flag := false;
      feedback := "当前场景正在进行分发";
    }
    
    return flag;
  *]
  QuillAction
  {
    Body:
    [*
      Form.ApplyChanges();
      
      DataDistributionLog::Create( GlobalOTDLog, ApplicationMacroPlanner.GetUserName(), DataHolderScenario.Data().DatasetMDSID(), DataHolderScenario.Data().Name() );
      MacroPlan::DoASync( DataHolderScenario.Data(), 
                          ddlBusinessType.Data(),
                          checkboxIsKeyProduct.Checked(), 
                          checkboxCreatePurchaseSupplyProduct.Checked(),
                          GlobalOTDTable );
      
      Form.Close();
    *]
    GroupServerCalls: false
  }
}
