Example #1
0
        private void cbTypeProduct_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int index = cbTypeProduct.SelectedIndex;

            if (index == -1)
            {
                return;
            }

            var category = cbTypeProduct.SelectedItem as CategoryDb;

            if (category.id == 6)
            {
                reloadData();
            }
            else
            {
                List <ProductDb> models = (from p in dc.ProductDbs where p.category == category.id select p).ToList();

                try
                {
                    ProductDataGrid.ItemsSource = null;
                    ProductVMs itemsource = new ProductVMs(models);
                    ProductDataGrid.ItemsSource = itemsource.getProductViewModel();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Không thể tải dữ liệu mới");
                }
            }
        }
Example #2
0
 private void reloadData()
 {
     try
     {
         ProductDataGrid.ItemsSource = null;
         ProductVMs itemsource = new ProductVMs(dc.ProductDbs.ToList());
         ProductDataGrid.ItemsSource = itemsource.getProductViewModel();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Không thể tải dữ liệu mới");
     }
 }
Example #3
0
        public Product()
        {
            isManager = true;
            InitializeComponent();

            try
            {
                ProductVMs itemsource = new ProductVMs(dc.ProductDbs.ToList());
                ProductDataGrid.ItemsSource = itemsource.getProductViewModel();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Không thể tải dữ liệu");
            }

            cbTypeProduct.ItemsSource = dc.CategoryDbs;
        }
Example #4
0
        public Product(bool isManager)
        {
            this.isManager = isManager;

            InitializeComponent();

            try
            {
                ProductVMs itemsource = new ProductVMs(dc.ProductDbs.ToList());
                ProductDataGrid.ItemsSource = itemsource.getProductViewModel();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Không thể tải dữ liệu");
            }

            if (isManager == false)
            {
                btnAdd.Visibility = Visibility.Collapsed;
            }

            cbTypeProduct.ItemsSource = dc.CategoryDbs.ToList();
        }