private bool VoidMenu(out Document chosenDocument, out Document.Transaction chosenTransaction) { Dictionary <int, KeyValuePair <Document, Document.Transaction> > transactionNumberLookup = new Dictionary <int, KeyValuePair <Document, Document.Transaction> >(); int currentTransactionId = 0; foreach (Document document in DocumentManager.GetAllDocuments()) { if (document.IsClosed()) { foreach (Document.Transaction transaction in document.Transactions) { if (!transaction.IsVoided) { transactionNumberLookup[++currentTransactionId] = new KeyValuePair <Document, Document.Transaction>(document, transaction); Console.WriteLine("{0}. Document: {1} OperationId: {2}", currentTransactionId, document.DocumentNr, transaction.OperationID); } } } } Console.WriteLine("Please enter transaction number to be voided"); int chosenTransactionNumber; if (!Int32.TryParse(Console.ReadLine(), out chosenTransactionNumber)) { Console.WriteLine("Invalid transaction number"); } KeyValuePair <Document, Document.Transaction> item; if (transactionNumberLookup.TryGetValue(chosenTransactionNumber, out item)) { chosenDocument = item.Key; chosenTransaction = item.Value; return(true); } chosenDocument = null; chosenTransaction = null; return(false); }
private void PerformVoid(Document document, Document.Transaction transaction) { if (!API.UnlockDevice("999", "John", "VOID", 0, "")) { Console.WriteLine("Failed to unlock device. Void will not be performed"); return; } string errorText; if (API.VoidTransaction(transaction.OperationID, out errorText)) { transaction.IsVoided = true; DocumentManager.SaveDocument(document); Console.WriteLine("Transaction was voided"); } else { Console.WriteLine("Failed to void transaction: " + errorText); } }