// allowing user to chose quantity of items in numbers (quantity box) public void QuantityBox_TextChanged(object sender, TextChangedEventArgs e) { string value = QuantityBox.Text; if (!string.IsNullOrEmpty(value)) { int.TryParse(value, out _quantity); if (_quantity > 0) { _quantity = int.Parse(QuantityBox.Text); } if (_quantity > 10) { MessageBox.Show( "Quantity is too high. \nIf you would like to order more than 10 items - contact our manager"); QuantityBox.Clear(); } if (_quantity < 1) { MessageBox.Show( "Quantity cannot be less than 1"); QuantityBox.Clear(); } if (!int.TryParse(value, out _quantity)) { MessageBox.Show("Invalid input. Use numbers"); QuantityBox.Clear(); } } AddButtonIsEnabled(); }
private void InvalidVariableQuantity(NotificationMessage msg) { if (!string.IsNullOrEmpty(msg.Notification)) { QuantityBox.SelectionStart = QuantityBox.Text.IndexOf(msg.Notification); QuantityBox.SelectionLength = msg.Notification.Length; QuantityBox.Focus(); } }
private void button2_Click_1(object sender, EventArgs e) { BarcodeBox.Clear(); ItemDescriptionBox.Clear(); UnitBox.Clear(); QuantityBox.Clear(); UnitPriceBox.Clear(); RetailPriceBox.Clear(); }
public IViewComponentResult Invoke(string packageRFID = "") { QuantityBox boxCount = new QuantityBox { BoxCount = ctx.Boxes.Count(p => p.PackageRFID == packageRFID && p.Status == true) }; return(View(boxCount)); }
private void AddToCart_Click(object sender, System.EventArgs e) { if (BookList.SelectedItem == null || CustomerList.SelectedItem == null) { // user has not chosen a book MessageBox.Show("Please choose a book and a customer first"); BookList.Focus(); } else if (QuantityBox.Value == 0 && (BookList.SelectedItem != null && CustomerList.SelectedItem != null)) { // user has not chosen the quantity (it is still 0) MessageBox.Show("Please set \"Quantity\" to a non-zero positive value"); QuantityBox.Focus(); } else if (Math.Round(QuantityBox.Value) == 0 || QuantityBox.Value / Math.Round(QuantityBox.Value) != 1 ) { // user has chosen 0 books MessageBox.Show("Please set \"Quantity\" to a whole number"); QuantityBox.Focus(); QuantityBox.Value = 0; } else { string selectedTitle = RetrievedBooks.Tables[0].Rows[BookList.SelectedIndex]["title"].ToString(); decimal selectedPrice = decimal.Parse(RetrievedBooks.Tables[0].Rows[BookList.SelectedIndex]["price"].ToString()); int selectedCustID = Convert.ToInt32(CustomerIDStorage[CustomerList.SelectedIndex]); string selectedCustName = RetrievedCustomers.Tables[0].Rows[CustomerList.SelectedIndex]["first_name"].ToString() + " " + RetrievedCustomers.Tables[0].Rows[CustomerList.SelectedIndex]["last_name"].ToString(); int selectedBookID = Convert.ToInt32(BookIDStorage[BookList.SelectedIndex]); // calculate amount fields SubtotalAmount += Math.Round(QuantityBox.Value * selectedPrice, 2); // calculate subtotal field TaxAmount = Math.Round(0.1m * SubtotalAmount, 2); // calculate tax. 10% of SubtotalAmount TotalAmount = SubtotalAmount + TaxAmount; // calculate the total amount. SubtotalAmount + TaxAmount // update amount fields UpdateAmountFields(SubtotalAmount, TaxAmount, TotalAmount); // add selected book and QTY to the DataGridView OrderSummarydataGridView.Rows.Add(selectedBookID, selectedTitle, QuantityBox.Value, "$" + selectedPrice, "$" + QuantityBox.Value * selectedPrice, selectedCustID, selectedCustName); } }
private void AddToCart_Click(object sender, System.EventArgs e) { if (BookList.SelectedItem == null) { // user has not chosen a book MessageBox.Show("Please choose the book first"); BookList.Focus(); } else if (QuantityBox.Value == 0 && BookList.SelectedItem != null) { // user has not chosen the quantity (it is still 0) MessageBox.Show("Please set \"Quantity\" to a non-zero positive value"); QuantityBox.Focus(); } else if (Math.Round(QuantityBox.Value) == 0 || QuantityBox.Value / Math.Round(QuantityBox.Value) != 1 ) { // user has chosen 0 books MessageBox.Show("Please set \"Quantity\" to a whole number"); QuantityBox.Focus(); QuantityBox.Value = 0; } else { // calculate amount fields SubtotalAmount += Math.Round(QuantityBox.Value * Books[BookList.SelectedIndex].Price, 2); // calculate subtotal field TaxAmount = Math.Round(0.1m * SubtotalAmount, 2); // calculate tax. 10% of SubtotalAmount TotalAmount = SubtotalAmount + TaxAmount; // calculate the total amount. SubtotalAmount + TaxAmount // update amount fields UpdateAmountFields(SubtotalAmount, TaxAmount, TotalAmount); // add selected book and QTY to the DataGridView OrderSummarydataGridView.Rows.Add(Books[BookList.SelectedIndex].Title, QuantityBox.Value, "$" + Books[BookList.SelectedIndex].Price, "$" + QuantityBox.Value * Books[BookList.SelectedIndex].Price); } }
// adding food items when "Add" button is clicked, only if every box has been filled in public void AddItem_Click(object sender, RoutedEventArgs e) { try { if (TypeItems.SelectedItem?.ToString() != null && NextItemsCombo.SelectedItem?.ToString() != null && QuantityBox.Text != "" && NameBox.Text != "") { switch (_size) { case "Small": _price *= 0.75; break; case "Large": _price *= 1.25; break; } _price *= _quantity; _totalPrice += _price; TotalBlock.Text = _totalPrice.ToString("C2", System.Globalization.CultureInfo.GetCultureInfo("en-US")); DeliveryBlock.Text = _deliveryPrice.ToString("C2", System.Globalization.CultureInfo.GetCultureInfo("en-US")); var foodItem = new FoodItems( TypeItems.SelectionBoxItem.ToString(), NextItemsCombo.SelectedItem.ToString(), _price, _quantity ); _foodItems.Add(foodItem); DataGridOrderFood.ItemsSource = null; DataGridOrderFood.ItemsSource = _foodItems; } } catch (FormatException) { MessageBox.Show( "Invalid Input Values"); } catch (Exception ex) { // Some other error occurred. // Report the error to the user. MessageBox.Show(ex.Message, "Error"); } // clearing all the boxes QuantityBox.Clear(); AddItem.IsEnabled = false; _price = 0; _quantity = 0; _size = ""; NextItemsCombo.ItemsSource = null; PizzaCrustCombo.SelectedIndex = -1; NextItemsCombo.Visibility = Visibility.Hidden; PizzaCrustCombo.Visibility = Visibility.Hidden; PizzaSizeCombo.Visibility = Visibility.Hidden; PizzaCrustBlock.Text = ""; PizzaSizeBlock.Text = ""; PizzaSizeCombo.SelectedIndex = -1; TypeItems.SelectedIndex = -1; FoodBlock.Text = ""; NameBox.Text = _name; NameBox.IsEnabled = false; }