예제 #1
0
        private void Search(object obj)
        {
            NotFound = false;


            if (_cur_cat_search != null)
            {
                DishesList = _model.db.DishesSet.Where(i => i.Dishes_categoriesId == Cur_cat_search.Id).ToList();
            }


            if (!string.IsNullOrWhiteSpace(SearchString))
            {
                DishesList = _model.db.DishesSet.Where(i => i.Name.Contains(SearchString) | i.Price.Contains(SearchString) | i.Weight.Contains(SearchString)).ToList();

                if (_cur_cat_search != null)
                {
                    DishesList = _model.db.DishesSet.Where(i => (i.Name.Contains(SearchString) && i.Dishes_categoriesId == Cur_cat_search.Id)
                                                           | (i.Price.Contains(SearchString) && i.Dishes_categoriesId == Cur_cat_search.Id)
                                                           | (i.Weight.Contains(SearchString) && i.Dishes_categoriesId == Cur_cat_search.Id)).ToList();
                }
            }
            if (DishesList.Count == 0)
            {
                NotFound = true;
            }
            UpdateEv?.Invoke(obj, null);
        }
예제 #2
0
        private async void CrateNewDish(object obj)
        {
            Dishes new_dish = new Dishes();

            new_dish.Name = AddNewName;
            new_dish.Dishes_categories   = _model.db.Dishes_categoriesSet.FirstOrDefault(i => i.Name == AddNewCat);
            new_dish.Dishes_categoriesId = _model.db.Dishes_categoriesSet.FirstOrDefault(i => i.Name == AddNewCat).Id;
            new_dish.Weight     = AddNewWeight;
            new_dish.Price      = AddNewPric;
            new_dish.IsSelected = false;



            _model.db.DishesSet.Add(new_dish);
            await _model.db.SaveChangesAsync();

            DishesList.Add(new_dish);
            OnPropertyChanged(new PropertyChangedEventArgs("DishesList"));
            Clear();
            WpfMessageBox.Show("Добавление", "Новое блюдо успешно добавлено в меню", MessageBoxType.Information);
            TableVisible      = false;
            AddVisible        = false;
            HelpBtnVisibility = true;
            UpdateEv?.Invoke(obj, null);
        }
예제 #3
0
        private async void DelProduct(object obj)
        {
            TableVisible = true;
            if (WpfMessageBox.Show("Удаление продуктов", "Вы действительно хотите удалить продукт(ы) ?", System.Windows.MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
            {
                Loading.Invoke(obj, null);
                await Task.Run(() =>
                {
                    List <Product> col = ListProduct.Where(item => item.IsSelected == true).ToList();
                    _model.db.ProductSet.RemoveRange(col);
                    _model.db.SaveChanges();
                    ListProduct = _model.db.ProductSet.ToList();



                    _waitHandle.Set();
                });

                _waitHandle.WaitOne();
                _can_edit = true;
                UpdateEv?.Invoke(obj, null);
                Loading?.Invoke(obj, null);
            }
            TableVisible = false;
        }
예제 #4
0
        private void Search(object obj)
        {
            NotFound = false;


            if (_cur_cat_search != null)
            {
                ListProduct = _model.db.ProductSet.Where(i => i.Product_categoryId == Cur_cat_search.Id).ToList();
            }


            if (!string.IsNullOrWhiteSpace(SearchString))
            {
                ListProduct = _model.db.ProductSet.Where(i => i.Name.Contains(SearchString) | /*i.count.Contains(SearchString) |*/ i.Unit.Contains(SearchString)).ToList();

                if (_cur_cat_search != null)
                {
                    ListProduct = _model.db.ProductSet.Where(i => (i.Name.Contains(SearchString) && i.Product_categoryId == Cur_cat_search.Id)
                                                             //| (i.count.Contains(SearchString) && i.Product_categoryId == Cur_cat_search.Id)
                                                             | (i.Unit.Contains(SearchString) && i.Product_categoryId == Cur_cat_search.Id)).ToList();
                }
            }
            if (ListProduct.Count == 0)
            {
                NotFound = true;
            }
            UpdateEv?.Invoke(obj, null);
        }
예제 #5
0
 private void AddNewProduct(object obj)
 {
     Loading?.Invoke(obj, null);
     AddNewProductEvent?.Invoke(obj, null);
     NotFound = false;
     UpdateListProduct();
     UpdateEv?.Invoke(obj, null);
     Loading?.Invoke(obj, null);
 }