Quintiq file version 2.0
#parent: #root
Method OnOk () id:Method_DialogCreateEditFeedbackOperation_OnOk
{
  #keys: '[146140.0.186944172]'
  Body:
  [*
    // When the user click OK, we either create or edit a feedback operation
    
    data := DataHolderDialogData.Data();
    selection := DataHolderFeedbackOperations.Data().Copy();
    isbatchedit := selection.Size() > 1;
    
    // Not using Data.Attributes because ApplyChanges is not used for feedbacks
    quantity := ApplicationMacroPlanner.FormatStringToReal( EditFieldQuantity.Text(), 0.0 );
    description := EditFieldDescription.Text();
    operationid := DropDownListOperation.Data().ID(); 
    datetime := DateTimeSelectorDateTime.DateTime();
    isLocked := CheckBoxIsLocked.Checked();
    
    // New
    if( isnull( data.WrappedInstance() ) )
    {
      FeedbackPeriodTaskOperation::Create( MacroPlan, 
                                           '',  // ID of the feedback. If ID = '', the ID will take MacroPan.IDHolder().GetFeedbackID()                             
                                           operationid, 
                                           datetime, 
                                           quantity,
                                           description,
                                           isLocked,   // is planned exact
                                           false );// is from db
    }
    else 
    { // Edit
      if( isbatchedit ) // Multiple feedback seleted
      {
        FeedbackPeriodTaskOperation::Update( selection,
                                             isLocked, 
                                             CheckBoxBatchEditIsLocked.Checked(), 
                                             quantity,
                                             CheckBoxBatchEditQuantity.Checked(),
                                             description,
                                             CheckBoxBatchEditDescription.Checked() );
      } 
      else // Only one feedback
      {
         data.WrappedInstance().Update( operationid,
                                        datetime,
                                        quantity,
                                        description,
                                        isLocked,    // is planned exact
                                        false );  // is from db
      }
    }
    
    Form.Close();
  *]
}
