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!!"); } }
public OrdersInKitchenWindow() { InitializeComponent(); Instance = this; kitchenlist = MyStorage.ReadXML <ObservableCollection <Order> >("ordersInProcessing.xml"); if (kitchenlist == null) { kitchenlist = new ObservableCollection <Order>(); } }
public TakeOrdersWindow() { InitializeComponent(); Instance = this; ordersInProcessingList = MyStorage.ReadXML <ObservableCollection <Order> >("ordersInProcessing.xml"); if (ordersInProcessingList == null) { ordersInProcessingList = new ObservableCollection <Order>(); } //extrafoods = new ObservableCollection<OrderedFood>(); }
private void Application_Startup(object sender, StartupEventArgs e) { categories = MyStorage.GetEmbeddedXML <ObservableCollection <Category> >("Data.foods.xml"); ordersCompletedList = MyStorage.ReadXML <ObservableCollection <Order> >("ordersCompleted.xml"); if (ordersCompletedList == null) { ordersCompletedList = new ObservableCollection <Order>(); } tables = new ObservableCollection <string> { "Table01", "Table02", "Table03", "Table04", "Table05" }; TakeOrdersWindow takeOrdersWindow = new TakeOrdersWindow(); takeOrdersWindow.Show(); OrdersInKitchenWindow ordersInKitchenWindow = new OrdersInKitchenWindow(); ordersInKitchenWindow.Show(); }
private void Window_Closed(object sender, EventArgs e) { MyStorage.WriteXML <ObservableCollection <Order> >("ordersInProcessing.xml", ordersInProcessingList); MyStorage.WriteXML <ObservableCollection <Order> >("ordersCompleted.xml", App.ordersCompletedList); }