private double GetOrderItemPrice(int quantity, int itemID) { if (quantity > 0) { double orderItemPrice; // Setting up a variable for the datatable from the database RestaurantDataSet.MenuItemsDataTable items = new RestaurantDataSet.MenuItemsDataTable(); // Setting up a menu items adaptor and it's to fill in the datatable RestaurantDataSetTableAdapters.MenuItemsTableAdapter ItemsTableAdap = new RestaurantDataSetTableAdapters.MenuItemsTableAdapter(); // Getting the item data from the database ItemsTableAdap.GetData(); // Filling the data to the datatable ItemsTableAdap.Fill(items); RestaurantDataSet.MenuItemsRow menuItemRow = items.FindBymenuItemId(itemID); orderItemPrice = quantity * double.Parse(menuItemRow.menuItemPrice); return(orderItemPrice); } else { return(0); } }
private void BtnLoadOrderThree_Click(object sender, EventArgs e) { // Load order from the queue GetDataTables(); // Checking to see if there are more orders to display if (ActiveOrders.Where(a => a.orderNumber != orderTwo && a.orderNumber != orderOne).Count() > 0) { //Find next available order nextOrder = FindNextOrder(orderTwo, orderOne); orderThree = ActiveOrders[nextOrder].orderNumber; // Load order from the queue lstOrderThree.Items.Add("Table number: " + ActiveOrders[nextOrder].tableNumber); // Displaying the order items and details in the list view foreach (RestaurantDataSet.OrderItemsRow orderitem in orderItems.Where(o => o.Orders_orderNumber == ActiveOrders[nextOrder].orderNumber)) { RestaurantDataSet.MenuItemsRow menuitem = menuItems.Where(m => m.menuItemId == orderitem.MenuItems_menuItemID).FirstOrDefault(); lstOrderThree.Items.Add(menuitem.menuItemName + " Qty: " + orderitem.quantity); } nextOrder++; // Disable Load Next Order button btnLoadOrderThree.Enabled = false; } else { MessageBox.Show("No more orders to be fufilled."); } }
private void btnDeleteItem_Click(object sender, EventArgs e) { // Validate that the item number is a integer if (int.TryParse(txtItemNumber.Text, out itemNumber) == false) { MessageBox.Show("Please enter a valid item number."); } else { // Make sure there is an item with that number // Setting up a variable for the datatable from the database RestaurantDataSet.MenuItemsDataTable items = new RestaurantDataSet.MenuItemsDataTable(); // Setting up a employee adaptor and it's to fill in the datatable RestaurantDataSetTableAdapters.MenuItemsTableAdapter ItemsTableAdap = new RestaurantDataSetTableAdapters.MenuItemsTableAdapter(); // Getting the item data from the database ItemsTableAdap.GetData(); // Filling the data to the datatable ItemsTableAdap.Fill(items); // Going and looking in the datatable for a given item number and returning the row. RestaurantDataSet.MenuItemsRow itemRow = items.FindBymenuItemId(itemNumber); // Check if the item row was found (If null, item number does not exist in database) if (itemRow == null) { MessageBox.Show("Could not find item number, please try again."); itemNumber = 0; } else { // Get current record data menuItemId = itemRow.menuItemId; menuItemName = itemRow.menuItemName; menuItemPrice = itemRow.menuItemPrice; menuItemDescription = itemRow.menuItemDescription; isActive = itemRow.isItemActive; menuMenuId = itemRow.Menu_MenuId; // Delete the desired record ItemsTableAdap.Delete(menuItemId, menuMenuId); // Close the Add Menu Item form and notify the user this.Close(); MessageBox.Show("Item has been successfully deleted."); // Need to update the dataset to show database upadate } } }
private void ChefForm_Load(object sender, EventArgs e) { GetDataTables(); // Checking to see if there are any orders to be fufilled if (nextOrder < ActiveOrders.Count()) { lstOrderOne.Items.Add("Table number: " + ActiveOrders[nextOrder].tableNumber); orderOne = ActiveOrders[nextOrder].orderNumber; foreach (RestaurantDataSet.OrderItemsRow orderitem in orderItems.Where(o => o.Orders_orderNumber == ActiveOrders[nextOrder].orderNumber)) { RestaurantDataSet.MenuItemsRow menuitem = menuItems.Where(m => m.menuItemId == orderitem.MenuItems_menuItemID).FirstOrDefault(); lstOrderOne.Items.Add(menuitem.menuItemName + " Qty: " + orderitem.quantity); } btnLoadOrderOne.Enabled = false; nextOrder++; } else { // No orders to display, disabable complete order one MessageBox.Show("No orders to display"); btnCompleteOrderOne.Enabled = false; } // Checking to see if there is a second order if (nextOrder < ActiveOrders.Count()) { lstOrderTwo.Items.Add("Table number: " + ActiveOrders[nextOrder].tableNumber); orderTwo = ActiveOrders[nextOrder].orderNumber; foreach (RestaurantDataSet.OrderItemsRow orderitem in orderItems.Where(o => o.Orders_orderNumber == ActiveOrders[nextOrder].orderNumber)) { RestaurantDataSet.MenuItemsRow menuitem = menuItems.Where(m => m.menuItemId == orderitem.MenuItems_menuItemID).FirstOrDefault(); lstOrderTwo.Items.Add(menuitem.menuItemName + " Qty: " + orderitem.quantity); } btnLoadOrderTwo.Enabled = false; nextOrder++; } else { // No orders to display, disabable complete order two btnCompleteOrderTwo.Enabled = false; } // Checking to see if there is a third order if (nextOrder < ActiveOrders.Count()) { lstOrderThree.Items.Add("Table number: " + ActiveOrders[nextOrder].tableNumber); orderThree = ActiveOrders[nextOrder].orderNumber; foreach (RestaurantDataSet.OrderItemsRow orderitem in orderItems.Where(o => o.Orders_orderNumber == ActiveOrders[nextOrder].orderNumber)) { RestaurantDataSet.MenuItemsRow menuitem = menuItems.Where(m => m.menuItemId == orderitem.MenuItems_menuItemID).FirstOrDefault(); lstOrderThree.Items.Add(menuitem.menuItemName + " Qty: " + orderitem.quantity); } btnLoadOrderThree.Enabled = false; nextOrder++; } else { // No orders to display, disabable complete order three btnCompleteOrderThree.Enabled = false; } }