private void _buttonDaillyFactureNouveau_Click_1(object sender, RoutedEventArgs e) { DaillyFactureWindow daillyFactureWindow = new DaillyFactureWindow(new ObservableCollection<Commande>(((Dailly)this.DataContext).Commande)); daillyFactureWindow.DataContext = new Dailly_Cession_Facture(); bool? dialogResult = daillyFactureWindow.ShowDialog(); if (dialogResult.HasValue && dialogResult == true) { ((Dailly)this.DataContext).Dailly_Cession_Facture.Add((Dailly_Cession_Facture)daillyFactureWindow.DataContext); } else { try { ((App)App.Current).mySitaffEntities.Detach((Dailly_Cession_Facture)daillyFactureWindow.DataContext); } catch (Exception) { } } this._dataGridFacture.Items.Refresh(); }
private void _buttonDaillyFactureModifier_Click_1(object sender, RoutedEventArgs e) { if (this._dataGridFacture.SelectedItems.Count == 1) { DaillyFactureWindow daillyFactureWindow = new DaillyFactureWindow(new ObservableCollection<Commande>(((Dailly)this.DataContext).Commande)); daillyFactureWindow.DataContext = (Dailly_Cession_Facture)this._dataGridFacture.SelectedItem; bool? dialogResult = daillyFactureWindow.ShowDialog(); if (dialogResult.HasValue && dialogResult == true) { } else { //Je récupère les anciennes données de la base sur les modifications effectuées ((App)App.Current).mySitaffEntities.Refresh(System.Data.Objects.RefreshMode.StoreWins, (Dailly_Cession_Facture)(daillyFactureWindow.DataContext)); } } else { MessageBox.Show("Vous devez sélectionner un litige.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }