internal static void UpdateServedStatus(string orderId, OrderedFood orderedFood) { foreach (var ord in Instance.ordersInProcessingList) { if (ord.OrderId == orderId) { foreach (var food in ord.OrderedFoods) { if (food.FoodId == orderedFood.FoodId) { if (food.Quantity == orderedFood.Quantity && food.ServedStatus == false) { food.ServedStatus = true; if (Instance.order != null && Instance.order.OrderId == ord.OrderId) { Instance.Sp_CurrentOrderDetails.DataContext = ord; Instance.Dg_OrderedFoods.Items.Refresh(); } } break; } } break; } } MyStorage.WriteXML <ObservableCollection <Order> >("ordersInProcessing.xml", Instance.ordersInProcessingList); }
private void Btn_FinishOrder_Click(object sender, RoutedEventArgs e) { var ord = Dg_ProcessingOrders.SelectedItem as Order; bool removeFromProcessingList = true; foreach (var food in ord.OrderedFoods) { if (!food.ServedStatus) { removeFromProcessingList = false; } } if (removeFromProcessingList) { ordersInProcessingList.Remove(ord); App.ordersCompletedList.Add(ord); OrdersInKitchenWindow.UpdateFoodsServed(ord); Dg_ProcessingOrders.ItemsSource = ordersInProcessingList; Dg_CompletedOrders.ItemsSource = App.ordersCompletedList; MyStorage.WriteXML <ObservableCollection <Order> >("ordersInProcessing.xml", ordersInProcessingList); MyStorage.WriteXML <ObservableCollection <Order> >("ordersCompleted.xml", App.ordersCompletedList); } else { MessageBox.Show("There are still orders to be served"); } }
private void Btn_Click_SendOrderKitchen(object sender, RoutedEventArgs e) { bool orderInKitchen = false; if (order.OrderedFoods.Count() > 0) { foreach (var item in ordersInProcessingList) { if (item.OrderId == order.OrderId) { foreach (var food in order.OrderedFoods) { var lst = item.OrderedFoods.Where(S => S.FoodId == food.FoodId) .Select(S => { S.Quantity = food.Quantity; S.TotalPrice = food.TotalPrice; return(S); }).ToList(); if (lst == null) { item.OrderedFoods.Add(food); } } orderInKitchen = true; break; } } if (!orderInKitchen) { ordersInProcessingList.Add(order); } MyStorage.WriteXML <ObservableCollection <Order> >("ordersInProcessing.xml", ordersInProcessingList); OrdersInKitchenWindow.UpdateFoodsServed(order); order = null; Sp_CurrentOrderDetails.DataContext = null; Dg_OrderedFoods.ItemsSource = null; Dg_ProcessingOrders.ItemsSource = ordersInProcessingList; CoBx_TableNo.SelectedItem = null; Sp_EditOrderDetails.Visibility = Visibility.Hidden; TBl_EditNoOrders.Visibility = Visibility.Hidden; TBl_EditViewOrders.Visibility = Visibility.Visible; totalPrice = 0.0; SetTotalPrice(); MessageBox.Show("Order is sent to Kitchen"); EnableDisableComponents(); } else { MessageBox.Show("No Food is selected to place order!!"); } }
private void Window_Closed(object sender, EventArgs e) { MyStorage.WriteXML <ObservableCollection <Order> >("ordersInProcessing.xml", ordersInProcessingList); MyStorage.WriteXML <ObservableCollection <Order> >("ordersCompleted.xml", App.ordersCompletedList); }