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

            if (selectedItem != null)
            {
                var newCustomer = new EditCustomerWindow(selectedItem);

                if (newCustomer.ShowDialog() == true)
                {
                    var update = (from customer in MainWindow.db.Customers where customer.ID == selectedItem.ID select customer).Single();
                    update.Name      = newCustomer.C_Name;
                    update.Telephone = newCustomer.C_Telephone;
                    update.Address   = newCustomer.C_Address;
                    MainWindow.db.SaveChanges();

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

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

                var newCustomer = new EditCustomerWindow(selectedItem);

                if (newCustomer.ShowDialog() == true)
                {
                    var update = (from customer in MainWindow.db.Customers where customer.ID == selectedItem.ID select customer).Single();
                    update.Name      = newCustomer.C_Name;
                    update.Telephone = newCustomer.C_Telephone;
                    update.Address   = newCustomer.C_Address;
                    MainWindow.db.SaveChanges();

                    customerDataGrid.ItemsSource = MainWindow.db.Customers.ToList();
                }
            }
        }