private void Edit_Button_Click(object sender, RoutedEventArgs e) { if (this._bienSelectionne == null) { return; } AddEditWindow w = new AddEditWindow(this._bienSelectionne); w.Owner = this; if (w.ShowDialog() == true) { // Appel au service WCF try { ServiceAgence.ResultatBool resultat = null; resultat = this._service.ModifierBienImmobilier(w.Bien); if (resultat.SuccesExecution) { if (resultat.Valeur) { MessageBox.Show(this, "Le bien sélectionné a été mis à jour avec succès.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information); ChargerBiensImmobiliers(); } } else { AfficherErreur(resultat); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Erreur", MessageBoxButton.OK, MessageBoxImage.Error); } } }
private void Delete_Button_Click(object sender, RoutedEventArgs e) { if (this._bienBaseSelectionne == null) { return; } if (MessageBox.Show(this, "Êtes-vous sûr de vouloir supprimer le bien sélectionné ?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes) { return; } // Appel au service WCF try { ServiceAgence.ResultatBool resultat = null; resultat = this._service.SupprimerBienImmobilier(this._bienBaseSelectionne.Id.ToString()); if (resultat.SuccesExecution) { if (resultat.Valeur) { MessageBox.Show(this, "Le bien sélectionné a été supprimé avec succès.", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information); ChargerBiensImmobiliers(); } } else { AfficherErreur(resultat); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Erreur", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void save_Click(object sender, RoutedEventArgs e) { using (ServiceAgence.AgenceClient client = new ServiceAgence.AgenceClient()) { client.Open(); if (id_bien == -1) // Ajouter { bien.DateMiseEnTransaction = DateTime.Now; bien.DateTransaction = null; bien.TransactionEffectuee = false; if (u == null) { u = new Uri(@".\images\nothumbnail.png", UriKind.Relative); } BitmapImage bi = new BitmapImage(u); bien.PhotoPrincipaleBase64 = BitmapImagetoBase64(bi); bien.PhotosBase64 = new ObservableCollection <string>(); bien.PhotosBase64.Add(bien.PhotoPrincipaleBase64); ServiceAgence.ResultatBool r = client.AjouterBienImmobilier(bien); } else // Modifier { if (u != null) { BitmapImage bi = new BitmapImage(u); bien.PhotoPrincipaleBase64 = BitmapImagetoBase64(bi); bien.PhotosBase64 = new ObservableCollection <string>(); bien.PhotosBase64.Add(bien.PhotoPrincipaleBase64); } ServiceAgence.ResultatBool res = client.ModifierBienImmobilier(bien); } client.Close(); } this.DialogResult = true; this.Close(); }