private void submitTransactionButton_Click(object sender, EventArgs e) { if (this.itemsToPurchase.Count == 0) { ErrorHandler.DisplayErrorBox("Error", "Cannot submit an empty transaction."); return; } if (this.customerID == "null") { ErrorHandler.DisplayErrorBox("Error", "Must select a customer."); return; } try { var theController = new TransactionController(); var furnitureController = new FurnitureController(); var transaction = new PurchaseTransaction { TransactionTime = DateTime.Now, CustomerId = this.customerID, EmployeeId = this.session.Id.ToString(), Items = new List <PurchaseTransaction_Item>(this.itemsToPurchase) }; theController.AddPurchaseTransaction(transaction); furnitureController.UpdateQuantitiesByIds(transaction.Items); MessageBox.Show(this.itemsToPurchase.Count + @" item(s) were purchased for a total of " + this.totalPriceLabel.Text + ".", @"Transaction Successful", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1); this.clearTransaction(); } catch (NullReferenceException nullReference) { ErrorHandler.DisplayErrorMessageToUserAndLog("Session Error", "The login session is null.", nullReference); } catch (InvalidCastException invalidCast) { ErrorHandler.DisplayErrorMessageToUserAndLog("Session Error", "The tag cannot be cast as a login session.", invalidCast); } catch (MySqlException sqlException) { ErrorHandler.DisplayErrorMessageToUserAndLog("SQL Error", "The transaction could not be added to the database.", sqlException); } catch (ArgumentOutOfRangeException rangeException) { ErrorHandler.DisplayErrorMessageToUserAndLog("Quantity Error", rangeException.Message, rangeException); } }