Example #1
0
        private void cookBtn_Click(object sender, RoutedEventArgs e)
        {
            orderCheck curCheck   = (CurrentChecksGrid.SelectedItem as orderCheck);
            string     dish_name  = curCheck.dish_name;
            int        dish_count = curCheck.dish_count;
            int        checkId    = curCheck.id;
            Button     btn        = (Button)sender;

            if (btn.Content.ToString() == "Розпочати виконання" && btn.IsEnabled)
            {
                IngredientsList listWindow = new IngredientsList(dish_name, dish_count);
                if (listWindow.ShowDialog() == true)
                {
                    cooking newItem = new cooking()
                    {
                        check_id     = checkId,
                        status_id    = 4,
                        receive_time = DateTime.Now,
                        execute_time = DateTime.Now
                    };
                    _db.cooking.Add(newItem);
                    _db.SaveChanges();
                    if (CurrentChecksGrid.SelectedItem != null)
                    {
                        var row =
                            CurrentChecksGrid.ItemContainerGenerator.ContainerFromItem(CurrentChecksGrid.CurrentItem) as
                            DataGridRow;
                        row.IsEnabled  = false;
                        row.Background = Brushes.LightGray;
                    }

                    CurrentChecksGrid.UnselectAll();
                    btn.IsEnabled = false;
                    InProgressGrid.ItemsSource = GetCookingChecks();
                }
                else
                {
                    listWindow.Hide();
                    CurrentChecksGrid.UnselectAll();
                }
            }
        }
Example #2
0
        private void readyBtn_Click(object sender, RoutedEventArgs e)
        {
            cookingCheck     cookCheck  = (InProgressGrid.SelectedItem as cookingCheck);
            int              check_id   = cookCheck.check_id;
            Button           btn        = (Button)sender;
            ConfirmReadiness confWindow = new ConfirmReadiness("Ви підтверджуєте готовність замовлення?");

            if (confWindow.ShowDialog() == true && btn.IsEnabled)
            {
                cooking curCooking = _db.getCurrentCooking(check_id).Single();
                curCooking.status_id    = 3;
                curCooking.execute_time = DateTime.Now;
                _db.SaveChanges();
                btn.Content = "Виконано";
                CurrentChecksGrid.UnselectAll();
                btn.IsEnabled = false;
                InProgressGrid.ItemsSource = GetCookingChecks();
                AllChecksGrid.ItemsSource  = GetChecks(DateTime.Now);
            }
            else
            {
                confWindow.Hide();
            }
        }