Example #1
0
        private void AddOrderBtn_Click(object sender, RoutedEventArgs e)
        {
            DateTime          date  = DateTime.Now.ToLocalTime();
            order_ingredients oItem = new order_ingredients()
            {
                order_time   = date,
                execute_time = date.AddDays(2),
                provider_id  = pr_id,
                status_id    = 4
            };

            _db.order_ingredients.Add(oItem);
            _db.SaveChanges();

            content_order_ingredients item = new content_order_ingredients()
            {
                count                  = Convert.ToInt32(countTextBox.Text),
                ingredient_id          = ing_id,
                unit_of_measurement_id = unit_id,
                price                  = Convert.ToInt32(priceTextBox.Text),
                order_ingredients_id   = (from m in _db.order_ingredients select m.id).ToList().Last()
            };

            _db.content_order_ingredients.Add(item);
            _db.SaveChanges();
            this.Hide();
        }
        private void deleteProviderOrderBtn_Click(object sender, RoutedEventArgs e)
        {
            ConfirmReadiness confWindow = new ConfirmReadiness("Ви підтверджуєте видалення замовлення інгредієнтів?");

            if (confWindow.ShowDialog() == true)
            {
                int content_id    = (providersOrderGrid.SelectedItem as providersOrder).content_id;
                var deleteContent = _db.content_order_ingredients.First(c => c.id == content_id);
                _db.content_order_ingredients.Remove(deleteContent);
                _db.SaveChanges();
                providersOrderGrid.ItemsSource = GetProvidersOrder(DateTime.Now).ToList();
            }
            else
            {
                confWindow.Hide();
            }
        }
Example #3
0
 private void addIngrBtn_Click(object sender, RoutedEventArgs e)
 {
     if (ingrAmountTextBox.Text != "")
     {
         recipes newItem = new recipes()
         {
             menu_id = menuId,
             unit_of_measurement_id = unitId,
             ingredient_id          = ingredientId,
             count = Convert.ToInt32(ingrAmountTextBox.Text)
         };
         _db.recipes.Add(newItem);
         _db.SaveChanges();
         IngredientsGrid.ItemsSource      = GetItems(dishName).ToList();
         ingredientComboBox.SelectedIndex = -1;
         unitComboBox.SelectedIndex       = -1;
         ingrAmountTextBox.Text           = "";
     }
 }
Example #4
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 #5
0
        private void addIngrBtn_Click(object sender, RoutedEventArgs e)
        {
            ingredients newItem = new ingredients()
            {
                name = IngrNameTextBox.Text
            };

            _db.ingredients.Add(newItem);
            _db.SaveChanges();
            this.Hide();
        }
        private void AddStorageItemBtn_Click(object sender, RoutedEventArgs e)
        {
            ingredients newItem = new ingredients()
            {
                name = StorageItemNameTextBox.Text
            };

            _db.ingredients.Add(newItem);
            _db.SaveChanges();
            storage_ingredient newItem2 = new storage_ingredient()
            {
                count                  = 0,
                ingredient_id          = (from m in _db.ingredients select m.id).ToList().Last(),
                unit_of_measurement_id = unit_id
            };

            _db.storage_ingredient.Add(newItem2);
            _db.SaveChanges();
            this.Hide();
        }
Example #7
0
        private void AddWaiterBtn_Click(object sender, RoutedEventArgs e)
        {
            waiters newItem = new waiters()
            {
                name = WaiterNameTextBox.Text
            };

            _db.waiters.Add(newItem);
            _db.SaveChanges();
            this.Hide();
        }
Example #8
0
        private void AddTypeDishBtn_Click(object sender, RoutedEventArgs e)
        {
            type_dish newItem = new type_dish()
            {
                type = typeDishTextBox.Text
            };

            _db.type_dish.Add(newItem);
            _db.SaveChanges();
            this.Hide();
        }
Example #9
0
        private void AddStatusBtn_Click(object sender, RoutedEventArgs e)
        {
            statuses newItem = new statuses()
            {
                name = statusTextBox.Text
            };

            _db.statuses.Add(newItem);
            _db.SaveChanges();
            this.Hide();
        }
Example #10
0
        private void AddTableBtn_Click(object sender, RoutedEventArgs e)
        {
            platens newItem = new platens()
            {
                number        = Convert.ToInt32(NumberTableTextBox.Text),
                people_amount = Convert.ToInt32(CountPersonsTextBox.Text)
            };

            _db.platens.Add(newItem);
            _db.SaveChanges();
            this.Hide();
        }
Example #11
0
 private void insertUserBtn_Click(object sender, RoutedEventArgs e)
 {
     if (userId == 0)
     {
         users newItem = new users()
         {
             login    = nameTextBox.Text,
             password = passwordTextBox.Password
         };
         _db.users.Add(newItem);
         _db.SaveChanges();
         this.Hide();
     }
     else
     {
         users thisUser = _db.getUserInfo(userId).Single();
         thisUser.password = passwordTextBox.Password;
         thisUser.login    = nameTextBox.Text;
         _db.SaveChanges();
         this.Hide();
     }
 }
Example #12
0
 private void addDishBtn_Click(object sender, RoutedEventArgs e)
 {
     if (unit_id != 0 && dishType_id != 0 && dishNameTextBox.Text != "")
     {
         menu newItem = new menu()
         {
             unit_of_measurement_id = unit_id,
             type_dish_id           = dishType_id,
             dish_name = dishNameTextBox.Text,
             size      = Convert.ToInt32(sizeDishTextBox.Text)
         };
         _db.menu.Add(newItem);
         _db.SaveChanges();
         this.Hide();
         EditRecipe editWindow = new EditRecipe(dishNameTextBox.Text);
         editWindow.ShowDialog();
     }
 }
Example #13
0
 private void Accept_Click(object sender, RoutedEventArgs e)
 {
     foreach (var ingredient in newList)
     {
         storage_ingredient upd = _db.getStorageState(ingredient.id).Single();
         if (upd.count < ingredient.count)
         {
             MessageBox.Show("Недостатня кількість інгредієнтів.");
             this.DialogResult = false;
             return;
         }
         else
         {
             upd.count = upd.count - ingredient.count;
             _db.SaveChanges();
         }
     }
     this.DialogResult = true;
 }
Example #14
0
        private void ChooseDish_Click(object sender, RoutedEventArgs e)
        {
            id_menu = (orderGrid.SelectedItem as MenuTable).id;
            int myCount = (orderGrid.SelectedItem as MenuTable).count;

            myOrder_id = (from m in _db.orders select m.id).ToList().Last();
            checks item = new checks()
            {
                order_id = myOrder_id,
                menu_id  = id_menu,
                count    = myCount
            };

            _db.checks.Add(item);
            _db.SaveChanges();
        }
        //orderIngredients delete
        private void deleteOrderIngredientsBtn_Click(object sender, RoutedEventArgs e)
        {
            ConfirmReadiness confWindow = new ConfirmReadiness("Ви підтверджуєте видалення замовлення?");

            if (confWindow.ShowDialog() == true)
            {
                int id            = (ordIngrGrid.SelectedItem as OrderIngredientTable).id;
                var deleteContent = _db.content_order_ingredients.Where(m => m.order_ingredients_id == id).Single();
                _db.content_order_ingredients.Remove(deleteContent);
                _db.SaveChanges();
                var deleteOrderIngredient = _db.order_ingredients.Where(m => m.id == id).Single();
                _db.order_ingredients.Remove(deleteOrderIngredient);
                _db.SaveChanges();
                ordIngrGrid.ItemsSource = GetOrderIngredients();
            }
            else
            {
                confWindow.Hide();
            }
        }
Example #16
0
        private void updateBtn_Click(object sender, RoutedEventArgs e)
        {
            MenuTable        curDish    = (MenuGrid.SelectedItem as MenuTable);
            Button           btn        = (Button)sender;
            ConfirmReadiness confWindow = new ConfirmReadiness("Ви підтверджуєте зміни?");

            if (confWindow.ShowDialog() == true && btn.IsEnabled)
            {
                menu curMenuItem = _db.getDishInfo(curDish.menu_id).Single();
                curMenuItem.price     = curDish.price;
                curMenuItem.dish_name = curDish.name;
                curMenuItem.size      = curDish.size;
                _db.SaveChanges();
                MenuGrid.ItemsSource = GetItems(typeId);
                MessageBox.Show("Зміни успішно збережено");
            }
            else
            {
                confWindow.Hide();
            }
        }