private void _ButtonLitigeNouveau_Click_1(object sender, RoutedEventArgs e) { LitigeFactureClientWindow litigeWindow = new LitigeFactureClientWindow(); litigeWindow.DataContext = new Litige_Facture(); ((Litige_Facture)litigeWindow.DataContext).Facture1 = (Facture)this.DataContext; ((Litige_Facture)litigeWindow.DataContext).Date_Litige = DateTime.Today; bool? dialogResult = litigeWindow.ShowDialog(); if (dialogResult.HasValue && dialogResult == true) { ((Facture)this.DataContext).Litige_Facture.Add((Litige_Facture)litigeWindow.DataContext); } else { try { ((App)App.Current).mySitaffEntities.Detach((Litige_Facture)litigeWindow.DataContext); } catch (Exception) { } } this._dataGridLitigeFactureClient.Items.Refresh(); }
private void _ButtonLitigeModifier_Click_1(object sender, RoutedEventArgs e) { if (this._dataGridLitigeFactureClient.SelectedItems.Count == 1) { LitigeFactureClientWindow litigeWindow = new LitigeFactureClientWindow(); litigeWindow.DataContext = (Litige_Facture)this._dataGridLitigeFactureClient.SelectedItem; bool? dialogResult = litigeWindow.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, (Litige_Facture)(litigeWindow.DataContext)); } } else { MessageBox.Show("Vous devez sélectionner un litige.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }