Beispiel #1
0
        private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string cs = ConfigurationManager.ConnectionStrings["ShopDBEntities"].ConnectionString;
            try
            {
                ICategoryManager categoryManager = new CategoryManager(cs);
                IMeasureManager measureManager = new MeasureManager(cs);
                IPackageManager packageManager = new PackageManager(cs);
                IPriceManager priceManager = new PriceManager(cs);
                IProducerManager producerManager = new ProducerManager(cs);
                IProductManager productManager = new ProductManager(cs);

                CatalogViewModel catalogViewModel =
                    new CatalogViewModel(
                         categoryManager,
                         measureManager,
                         packageManager,
                         priceManager,
                         producerManager,
                         productManager
                        );
                if (comboBox.SelectedIndex != comboBox.Items.Count - 1)
                {
                    vwCatalog.dgCatalogUC.DataContext = catalogViewModel.CatalogFilterByCategory(comboBox.SelectedItem.ToString());
                }
                else
                {
                    vwCatalog.dgCatalogUC.DataContext = catalogViewModel.Catalog;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            string cs = ConfigurationManager.ConnectionStrings["ShopDBEntities"].ConnectionString;
            try
            {
                ICategoryManager categoryManager = new CategoryManager(cs);
                IMeasureManager measureManager = new MeasureManager(cs);
                IPackageManager packageManager = new PackageManager(cs);
                IPriceManager priceManager = new PriceManager(cs);
                IProducerManager producerManager = new ProducerManager(cs);
                IProductManager productManager = new ProductManager(cs);

                CatalogViewModel catalogViewModel =
                    new CatalogViewModel(
                         categoryManager,
                         measureManager,
                         packageManager,
                         priceManager,
                         producerManager,
                         productManager
                        );

                vwCatalog.dgCatalogUC.DataContext = catalogViewModel.Catalog;
                comboBox.ItemsSource = catalogViewModel.Categories;
                comboBox.SelectedItem = catalogViewModel.Categories.FirstOrDefault(x => x == "Всі категорії");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }