Ejemplo n.º 1
0
        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            Service selectedItem = (Service)serviceDataGrid.SelectedItem;

            if (selectedItem != null)
            {
                var newService = new EditServiceWindow(selectedItem);

                if (newService.ShowDialog() == true)
                {
                    var update = (from service in MainWindow.db.Services where service.ID == selectedItem.ID select service).Single();
                    update.Name  = newService.S_Name;
                    update.Price = newService.S_Price;
                    MainWindow.db.SaveChanges();

                    serviceDataGrid.ItemsSource = MainWindow.db.Services.ToList();
                }
            }
        }
Ejemplo n.º 2
0
        private void serviceDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DataGridRow row = ItemsControl.ContainerFromElement((DataGrid)sender, e.OriginalSource as DependencyObject) as DataGridRow;

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

                var newService = new EditServiceWindow(selectedItem);

                if (newService.ShowDialog() == true)
                {
                    var update = (from service in MainWindow.db.Services where service.ID == selectedItem.ID select service).Single();
                    update.Name  = newService.S_Name;
                    update.Price = newService.S_Price;
                    MainWindow.db.SaveChanges();

                    serviceDataGrid.ItemsSource = MainWindow.db.Services.ToList();
                }
            }
        }