/// <summary> /// Ouvre la condition de réglement séléctionnée à l'aide d'une nouvelle fenêtre /// </summary> public Statut 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'un statut en cours ..."; //Création de la fenêtre StatutWindow statutWindow = new StatutWindow(); //Initialisation du Datacontext en Commande_Fournisseur et association à la Commande_Fournisseur sélectionnée statutWindow.DataContext = new Statut(); statutWindow.DataContext = (Statut)this._DataGridMain.SelectedItem; //booléen nullable vrai ou faux ou null bool? dialogResult = statutWindow.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 (Statut)statutWindow.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, (Statut)(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'un statut annulé : " + this.listStatut.Count() + " / " + this.max; return null; } } else { MessageBox.Show("Vous ne devez sélectionner qu'un seul statut.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); return null; } } else { MessageBox.Show("Vous devez sélectionner un statut.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); return null; } }
/// <summary> /// Ajoute une nouvelle condition de réglement fonction à la liste à l'aide d'une nouvelle fenêtre /// </summary> public Statut Add() { //Affichage du message "ajout en cours" ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = true; ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Ajout d'un statut en cours ..."; //Initialisation de la fenêtre StatutWindow statutWindow = new StatutWindow(); //Création de l'objet temporaire Statut tmp = new Statut(); //Mise de l'objet temporaire dans le datacontext statutWindow.DataContext = tmp; //booléen nullable vrai ou faux ou null bool? dialogResult = statutWindow.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 (Statut)statutWindow.DataContext; } else { try { //On détache la commande ((App)App.Current).mySitaffEntities.Detach((Statut)statutWindow.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'un statut annulé : " + this.listStatut.Count() + " / " + this.max; return null; } }
/// <summary> /// Ouvre de la condition de réglement séléctionné à l'aide d'une nouvelle fenêtre /// </summary> public Statut Look() { if (this._DataGridMain.SelectedItem != null) { if (this._DataGridMain.SelectedItems.Count == 1) { //Affichage du message "affichage en cours" ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = true; ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Affichage d'un statut en cours ..."; //Création de la fenêtre StatutWindow statutWindow = new StatutWindow(); //Initialisation du Datacontext en Commande_Fournisseur et association à l'ativite sélectionnée statutWindow.DataContext = new Statut(); statutWindow.DataContext = (Statut)this._DataGridMain.SelectedItem; //Je positionne la lecture seule sur la fenêtre statutWindow.lectureSeule(); statutWindow.soloLecture = true; //J'affiche la fenêtre bool? dialogResult = statutWindow.ShowDialog(); //Affichage du message "affichage en cours" ((App)App.Current)._theMainWindow.parametreMain.progressBarMainWindow.IsIndeterminate = false; ((App)App.Current)._theMainWindow.parametreMain.textBlockMainWindow.Text = "Affichage d'un statut terminé : " + this.listStatut.Count() + " / " + this.max; //Renvoi null return null; } else { MessageBox.Show("Vous ne devez sélectionner qu'un statut.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); return null; } } else { MessageBox.Show("Vous devez sélectionner un statut.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); return null; } }