Beispiel #1
0
        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            Category selectedItem = (Category)categoryDataGrid.SelectedItem;

            if (selectedItem != null)
            {
                var newCategory = new EditCategoryWindow(selectedItem);

                if (newCategory.ShowDialog() == true)
                {
                    var updatecategory = (from category in MainWindow.db.Categories where category.ID == selectedItem.ID select category).Single();
                    updatecategory.Name = newCategory.CT_Name;
                    MainWindow.db.SaveChanges();
                    ProductControl.product_notification.CategoryChange = true;

                    categoryDataGrid.ItemsSource = MainWindow.db.Categories.ToList();
                }
            }
        }
Beispiel #2
0
        private void categoryDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DataGridRow row = ItemsControl.ContainerFromElement((DataGrid)sender, e.OriginalSource as DependencyObject) as DataGridRow;

            if (row != null)
            {
                Category selectedItem = (Category)row.Item;

                var newCategory = new EditCategoryWindow(selectedItem);

                if (newCategory.ShowDialog() == true)
                {
                    var updatecategory = (from category in MainWindow.db.Categories where category.ID == selectedItem.ID select category).Single();
                    updatecategory.Name = newCategory.CT_Name;
                    MainWindow.db.SaveChanges();
                    ProductControl.product_notification.CategoryChange = true;

                    categoryDataGrid.ItemsSource = MainWindow.db.Categories.ToList();
                }
            }
        }