Quintiq file version 2.0
|
#parent: #root
|
Method OnOk () id:Method_DialogCreateEditCampaign_OnOk
|
{
|
#keys: '[134266.1.1955254560]'
|
Body:
|
[*
|
// Set data binding before apply changes
|
data := DataHolderDialogData.Data();
|
|
// Workaround: No databinding, so we set the dialog data manually before apply changes
|
data.HasInputMaxQuantity( EditorCampaignMaxQuantity.Enabled() );
|
data.HasInputMaxDuration( DurationSelectorMaxDuration.Enabled() );
|
|
data.MinQuantity( ApplicationMacroPlanner.FormatStringToReal( EditorCampaignMinQuantity.Text() ) );
|
data.MaxQuantity( ApplicationMacroPlanner.FormatStringToReal( EditorCampaignMaxQuantity.Text() ) );
|
data.MinDuration( DurationSelectorMinDuration.Duration() );
|
data.MaxDuration( DurationSelectorMaxDuration.Duration() );
|
|
// Disabled button to prevent the possibility of multiple firing
|
btnOK.Enabled( false, '' );
|
|
// When the user clicks ok,
|
// we either create or edit the data
|
this.ApplyChanges();
|
|
|
|
if( isnull( data.WrappedInstance() ) )
|
{
|
newcampaign := null( Campaign_MP );
|
campaignid := OS::GenerateGUIDAsString();
|
|
if( CheckBoxIsCreateAndResequence.Checked() )
|
{
|
newcampaign := Campaign_MP::CreateAndResequence( selCampaignType_MP.Data().Unit(),
|
data.EarliestStart(),
|
data.SequenceNumberForExcel(),
|
data.MinQuantity(),
|
data.MaxQuantity(),
|
data.MinDuration(),
|
data.MaxDuration(),
|
selCampaignType_MP.Data().Name(),
|
campaignid,
|
data.Comment(),
|
data.HasInputMaxQuantity() and RadioButtonGroupQuantityDuration.BoundValue() = GlobalParameters_MP::GetCampaignTransitionsTypeQuantity(),
|
data.HasInputMaxDuration() and RadioButtonGroupQuantityDuration.BoundValue() = GlobalParameters_MP::GetCampaignTransitionsTypeDuration(),
|
false,
|
DataHolderTargetCampaignForResequence.Data(),
|
DataHolderTransitionForReseuqnece.Data(),
|
DateTimeSelectorDroptimeForResequence.DateTime() );
|
}
|
else
|
{
|
newcampaign := Campaign_MP::Create( selCampaignType_MP.Data().Unit(),
|
data.EarliestStart(),
|
data.SequenceNumberForExcel(),
|
data.MinQuantity(),
|
data.MaxQuantity(),
|
data.MinDuration(),
|
data.MaxDuration(),
|
selCampaignType_MP.Data().Name(),
|
campaignid,
|
data.Comment(),
|
data.HasInputMaxQuantity() and RadioButtonGroupQuantityDuration.BoundValue() = GlobalParameters_MP::GetCampaignTransitionsTypeQuantity(),
|
data.HasInputMaxDuration() and RadioButtonGroupQuantityDuration.BoundValue() = GlobalParameters_MP::GetCampaignTransitionsTypeDuration(),
|
false /*isfromdb*/ );
|
}
|
// Access the form, select the new campaign
|
formCampaign := DataHolderForm.Data();
|
// Update the form selection only if the dialog is opened from the form
|
if( not isnull( formCampaign ) )
|
{
|
DataHolderForm.Data().ListCampaign().SelectByKey( newcampaign.Key() );
|
}
|
|
}
|
else
|
{
|
data.WrappedInstance().Update( selCampaignType_MP.Data().Unit(),
|
data.EarliestStart(),
|
data.SequenceNumberForExcel(),
|
data.MinQuantity(),
|
data.MaxQuantity(),
|
data.MinDuration(),
|
data.MaxDuration(),
|
selCampaignType_MP.Data().Name(),
|
data.CampaignID(),
|
data.Comment(),
|
data.HasInputMaxQuantity() and RadioButtonGroupQuantityDuration.BoundValue() = GlobalParameters_MP::GetCampaignTransitionsTypeQuantity(),
|
data.HasInputMaxDuration() and RadioButtonGroupQuantityDuration.BoundValue() = GlobalParameters_MP::GetCampaignTransitionsTypeDuration(),
|
false /*isfromdb*/ );
|
}
|
|
this.Close();
|
*]
|
}
|