private void InputOrderQuantity(object sender, EventArgs e) { string textBoxValue = ""; if (CustomLibrary.CheckTextisNumber(quantityTextBox.Text)) { textBoxValue = quantityTextBox.Text; } else { quantityTextBox.Text = textBoxValue; } order.itemQuantity = (textBoxValue == "") ? 0 : int.Parse(textBoxValue); CalculateTotalPrice(); }
private void AddCustomerData(object sender, EventArgs e) { outputRichTextBox.Text = ""; string message = ""; try { if (order.name == "") { message = "Please input name."; } if (order.contact == "") { message = "Please input contact."; } if (order.menuItem == "") { message = "Please select an item."; } if (order.itemQuantity == 0) { message = "Please input order quantity."; } if (CustomLibrary.HasDuplicateContacts(customersOrders, order.contact)) { message = "Contact already exists. Please provide a different contact."; } if (message != "") { MessageBox.Show(message); return; } else { OrderDetails newOrder = new OrderDetails(order.name, order.contact, order.menuItem, order.itemPrice, order.itemQuantity, order.totalPrice); customersOrders.Add(newOrder); outputRichTextBox.Text = newOrder.ShowOrderDetails(); Reset(); } } catch (Exception exception) { MessageBox.Show(exception.Message); } }