/// <summary> /// Ajoute un nouveau contact service à la liste à l'aide d'une nouvelle fenêtre /// </summary> public Contact_Service Add() { //Affichage du message "ajout en cours" ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = true; ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Ajout d'une service en cours ..."; //Initialisation de la fenêtre ContactServiceWindow contactserviceWindow = new ContactServiceWindow(); //Création de l'objet temporaire Contact_Service tmp = new Contact_Service(); //Mise de l'objet temporaire dans le datacontext contactserviceWindow.DataContext = tmp; //booléen nullable vrai ou faux ou null bool? dialogResult = contactserviceWindow.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value == true) { //Si j'appuie sur le bouton Ok, je renvoi l'objet banque se trouvant dans le datacontext de la fenêtre return (Contact_Service)contactserviceWindow.DataContext; } else { try { //On détache la commande ((App)App.Current).mySitaffEntities.Detach((Contact_Service)contactserviceWindow.DataContext); } catch (Exception) { } //Si j'appuie sur le bouton annuler, je préviens que j'annule mon ajout ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = false; this.recalculMax(); ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Ajout d'une service annulée : " + this.mesContactsServices.Count() + " / " + this.max; return null; } }
/// <summary> /// Met à jour l'état en bas pour l'utilisateur /// </summary> /// <param name="typeEtat">texte : "Filtrage", "Ajout", "Modification", "Suppression", "Look", "" ("" = Chargement)</param> /// <param name="dao">un objet Commande_Fournisseur soit pour l'ajouter au listing, soit pour afficher qui a été modifié ou supprimé</param> public void MiseAJourEtat(string typeEtat, Contact_Service lib) { //Je racalcul le nombre max d'élements this.recalculMax(); //En service de l'libion, j'affiche le message if (typeEtat == "Filtrage") { ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "filtrage des services terminée : " + this.mesContactsServices.Count() + " / " + this.max; } else if (typeEtat == "Ajout") { //J'ajoute la commande_fournisseur dans le linsting this.mesContactsServices.Add(lib); //Je racalcul le nombre max d'élements après l'ajout this.recalculMax(); ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Ajout d'une service dénommée '" + lib.Libelle + "' effectué avec succès. Nombre d'élements : " + this.mesContactsServices.Count() + " / " + this.max; } else if (typeEtat == "Modification") { //Je raffraichis mon datagrid this._DataGridMain.Items.Refresh(); ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Modification de la service dénommée : '" + lib.Libelle + "' effectuée avec succès. Nombre d'élements : " + this.mesContactsServices.Count() + " / " + this.max; } else if (typeEtat == "Suppression") { //Je supprime de mon listing l'élément supprimé this.mesContactsServices.Remove(lib); //Je racalcul le nombre max d'élements après la suppression this.recalculMax(); ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Suppression de la service dénommée : '" + lib.Libelle + "' effectuée avec succès. Nombre d'élements : " + this.mesContactsServices.Count() + " / " + this.max; } else if (typeEtat == "Look") { } else { ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Chargement des services terminé : " + this.mesContactsServices.Count() + " / " + this.max; } //Je retri les données dans le sens par défaut this.triDatas(); //J'arrete la progressbar ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = false; }