/// <summary> /// Ouvre du contact fonction séléctionné à l'aide d'une nouvelle fenêtre /// </summary> public Contact_Fonction Open() { if (this._DataGridMain.SelectedItem != null) { if (this._DataGridMain.SelectedItems.Count == 1) { //Affichage du message "modification en cours" ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = true; ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Modification d'une fonction en cours ..."; //Création de la fenêtre ContactFonctionWindow contactfonctionWindow = new ContactFonctionWindow(); //Initialisation du Datacontext en Commande_Fournisseur et association à la Commande_Fournisseur sélectionnée contactfonctionWindow.DataContext = new Contact_Fonction(); contactfonctionWindow.DataContext = (Contact_Fonction)this._DataGridMain.SelectedItem; //booléen nullable vrai ou faux ou null bool? dialogResult = contactfonctionWindow.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value == true) { //Si j'appuie sur le bouton Ok, je renvoi l'objet DAO se trouvant dans le datacontext de la fenêtre return (Contact_Fonction)contactfonctionWindow.DataContext; } 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, (Contact_Fonction)(this._DataGridMain.SelectedItem)); //La commande étant un objet "critique" au niveau des associations, je refresh l'edmx et je relance le filtrage s'il y en avait un afin d'avoir les mêmes infos (invisible pour l'user) ((App)App.Current).refreshEDMXSansVidage(); this.filtrage(); //Si j'appuie sur le bouton annuler, je préviens que j'annule ma modification ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = false; this.recalculMax(); ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Modification d'une fonction annulée : " + this.mesContactsFonctions.Count() + " / " + this.max; return null; } } else { MessageBox.Show("Vous ne devez sélectionner qu'une seule fonction.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); return null; } } else { MessageBox.Show("Vous devez sélectionner une fonction.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); return null; } }
/// <summary> /// Ajoute un nouveau contact fonction à la liste à l'aide d'une nouvelle fenêtre /// </summary> public Contact_Fonction 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 fonction en cours ..."; //Initialisation de la fenêtre ContactFonctionWindow contactfonctionWindow = new ContactFonctionWindow(); //Création de l'objet temporaire Contact_Fonction tmp = new Contact_Fonction(); //Mise de l'objet temporaire dans le datacontext contactfonctionWindow.DataContext = tmp; //booléen nullable vrai ou faux ou null bool? dialogResult = contactfonctionWindow.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_Fonction)contactfonctionWindow.DataContext; } else { try { //On détache la commande ((App)App.Current).mySitaffEntities.Detach((Contact_Fonction)contactfonctionWindow.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 fonction annulée : " + this.mesContactsFonctions.Count() + " / " + this.max; return null; } }
/// <summary> /// Ouvre du contact fonction séléctionné à l'aide d'une nouvelle fenêtre /// </summary> public Contact_Fonction Look(Contact_Fonction contact_fonction) { if (this._DataGridMain.SelectedItem != null || contact_fonction != null) { if (this._DataGridMain.SelectedItems.Count == 1 || contact_fonction != null) { //Affichage du message "affichage en cours" ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = true; ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Affichage d'une fonction en cours ..."; //Création de la fenêtre ContactFonctionWindow contactfonctionWindow = new ContactFonctionWindow(); //Initialisation du Datacontext en Commande_Fournisseur et association à l'ativite sélectionnée contactfonctionWindow.DataContext = new Contact_Fonction(); if (contact_fonction == null) { contactfonctionWindow.DataContext = (Contact_Fonction)this._DataGridMain.SelectedItem; } else { contactfonctionWindow.DataContext = contact_fonction; } //Je positionne la lecture seule sur la fenêtre contactfonctionWindow.lectureSeule(); contactfonctionWindow.soloLecture = true; //J'affiche la fenêtre bool? dialogResult = contactfonctionWindow.ShowDialog(); //Affichage du message "affichage en cours" ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = false; ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Affichage d'une fonction terminée : " + this.mesContactsFonctions.Count() + " / " + this.max; //Renvoi null return null; } else { MessageBox.Show("Vous ne devez sélectionner qu'une seule fonction.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); return null; } } else { MessageBox.Show("Vous devez sélectionner une fonction.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); return null; } }