Quintiq file version 2.0
#parent: #root
Method OnOk () id:Method_DialogCreateEditActualPISPIP_OnOk
{
  #keys: '[139394.1.1046089763]'
  Body:
  [*
    // On ok
    this.ApplyChanges();
    data := DataHolderDialogData.Data();
    
    // New actual
    if( isnull( data.WrappedInstance() ) )
    {
      ActualProductInStockingPointInPeriod::Create( MacroPlan,
                                                    data.ProductInStockingPoint_MP().Product_MP(),
                                                    data.ProductInStockingPoint_MP().StockingPoint_MP(),
                                                    dsDate.Date(),
                                                    dsManufacturedDate.Date(),
                                                    ApplicationMacroPlanner.FormatStringToReal( efQuantity.Text() ),
                                                    efDescription.Text(),
                                                    false /*isfromdb*/ );  
    }
    // Edit
    else
    {
      if( DataHolderDialogDatas.Data().Size() = 1 )
      {
        data.WrappedInstance().Update( data.ProductInStockingPoint_MP().Product_MP(),
                                       data.ProductInStockingPoint_MP().StockingPoint_MP(),
                                       dsDate.Date(),
                                       dsManufacturedDate.Date(),ApplicationMacroPlanner.FormatStringToReal( efQuantity.Text() ),
                                       efDescription.Text(),
                                       false /*isfromdb*/ );
      }
      // Batch
      else
      {
        ActualProductInStockingPointInPeriod::Update( DataHolderDialogDatas.Data(),
                                                      cbBatchEditQuantity.Checked(),
                                                      data.ActualInventoryLevelEnd(),
                                                      cbBatchEditDescription.Checked(),
                                                      data.Description(),
                                                      false );
      }
    }
    
    this.Close();
  *]
}
