private void ReturnItemsFromInvoice() { bool retValue = false; string comment = string.Empty; string invoiceId = SelectedInvoiceId; CustomerOrderTransaction invoiceTransaction; DialogResult results = DialogResult.None; try { // Construct a transaction from the given Invoice SalesOrder.GetSalesInvoiceTransaction(ref retValue, ref comment, invoiceId, out invoiceTransaction); if (retValue) { ReturnTransactionConfirmation returnTransactionConfirmation = new ReturnTransactionConfirmation() { PosTransaction = invoiceTransaction, }; InteractionRequestedEventArgs request = new InteractionRequestedEventArgs(returnTransactionConfirmation, () => { if (returnTransactionConfirmation.Confirmed) { // The user selected to return items... // Transfer the items to the posTranscation for the return // Updates customer and calculates taxes based upon items and customer SalesOrderActions.InsertReturnedItemsIntoTransaction(returnTransactionConfirmation.ReturnedLineNumbers, invoiceTransaction, this.Transaction); // We only support returning a single-invoice at a time, so Close the form after processing the first one. results = System.Windows.Forms.DialogResult.OK; this.Close(); } } ); SalesOrder.InternalApplication.Services.Interaction.InteractionRequest(request); } else { //An error occurred in the operation... SalesOrder.InternalApplication.Services.Dialog.ShowMessage(10002, MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { ApplicationExceptionHandler.HandleException(this.ToString(), ex); } this.DialogResult = results; }