private void _buttonModifierRIB_Click_1(object sender, RoutedEventArgs e) { if (this._dataGridRIB.SelectedItems.Count <= 0) { MessageBox.Show("Vous devez sélectionner un RIB à modifier.", "Erreur", MessageBoxButton.OK, MessageBoxImage.Stop); } else if (this._dataGridRIB.SelectedItems.Count > 1) { MessageBox.Show("Vous ne devez sélectionner qu'un RIB à modifier.", "Erreur", MessageBoxButton.OK, MessageBoxImage.Stop); } else if (this._dataGridRIB.SelectedItem != null) { EntrepriseRIBWindow entrepriseRIBWindow = new EntrepriseRIBWindow(); entrepriseRIBWindow.DataContext = (Entreprise_RIB)this._dataGridRIB.SelectedItem; bool? dialogResult = entrepriseRIBWindow.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value == true) { this._dataGridRIB.Items.Refresh(); } else { try { ((App)App.Current).mySitaffEntities.Refresh(System.Data.Objects.RefreshMode.StoreWins, ((Entreprise_RIB)entrepriseRIBWindow.DataContext)); } catch (Exception) { } } this._dataGridRIB.Items.Refresh(); } }
private void _buttonAjouterRIB_Click_1(object sender, RoutedEventArgs e) { EntrepriseRIBWindow entrepriseRIBWindow = new EntrepriseRIBWindow(); entrepriseRIBWindow.DataContext = new Entreprise_RIB(); bool? dialogResult = entrepriseRIBWindow.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value == true) { ((Entreprise_RIB)entrepriseRIBWindow.DataContext).Entreprise1 = (Entreprise)this.DataContext; } else { try { ((App)App.Current).mySitaffEntities.Detach((Entreprise_RIB)entrepriseRIBWindow.DataContext); } catch (Exception) { } } this._dataGridRIB.Items.Refresh(); }