/// <summary> /// Attempt to return invoices for the given order /// </summary> /// <param name="transaction"></param> /// <returns></returns> internal static CustomerOrderTransaction ReturnOrderInvoices(CustomerOrderTransaction transaction) { CustomerOrderTransaction result = null; try { if (transaction == null) { // Operation not valid for this type of transaction SalesOrder.InternalApplication.Services.Dialog.ShowMessage(3175, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(null); } if (transaction.OrderType != CustomerOrderType.SalesOrder) { // Operation not valid for this type of transaction SalesOrder.InternalApplication.Services.Dialog.ShowMessage(3175, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(null); } bool retValue = false; string comment = string.Empty; using (DataTable invoices = SalesOrder.GetSalesInvoiceList(ref retValue, ref comment, transaction.OrderId)) { if ((!retValue) || (invoices == null) || (invoices.Rows.Count == 0)) { if (!retValue) { ApplicationLog.Log(SalesOrderActions.LogSource, comment, LogTraceLevel.Error); } // There are no sales orders in the database for this customer.... SalesOrder.InternalApplication.Services.Dialog.ShowMessage(56123, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(null); } // Show the available sales orders for selection... using (frmGetSalesInvoices dlg = new frmGetSalesInvoices(invoices, transaction)) { SalesOrder.InternalApplication.ApplicationFramework.POSShowForm(dlg); if (dlg.DialogResult == System.Windows.Forms.DialogResult.OK) { // Copy the transaction back from the 'return invoices' form result = dlg.Transaction; SalesOrderActions.ProcessReturnReasonCodes(result); } } } } catch (PosisException px) { POSFormsManager.ShowPOSErrorDialog(px); ApplicationExceptionHandler.HandleException(SalesOrderActions.LogSource, px); } catch (Exception x) { ApplicationExceptionHandler.HandleException(SalesOrderActions.LogSource, x); throw; } return(result); }