/// <summary> /// Ajoute une nouvelle civilité à la liste à l'aide d'une nouvelle fenêtre /// </summary> public Type_Remboursement 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 type de remboursement en cours ..."; //Initialisation de la fenêtre TypeRemboursementWindow TypeRemboursementWindow = new TypeRemboursementWindow(); //Création de l'objet temporaire Type_Remboursement tmp = new Type_Remboursement(); //Mise de l'objet temporaire dans le datacontext TypeRemboursementWindow.DataContext = tmp; //booléen nullable vrai ou faux ou null bool? dialogResult = TypeRemboursementWindow.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 (Type_Remboursement)TypeRemboursementWindow.DataContext; } else { try { //On détache la commande ((App)App.Current).mySitaffEntities.Detach((Type_Remboursement)TypeRemboursementWindow.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 type de remboursement annulé : " + this.listTypeRemb.Count() + " / " + this.max; this._DataGridMain.Items.Refresh(); return null; } }
/// <summary> /// Ouvre le motif séléctionné à l'aide d'une nouvelle fenêtre /// </summary> public Type_Remboursement 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 type de remboursement en cours ..."; //Création de la fenêtre TypeRemboursementWindow TypeRemboursementWindow = new TypeRemboursementWindow(); //Initialisation du Datacontext TypeRemboursementWindow.DataContext = new Type_Remboursement(); TypeRemboursementWindow.DataContext = (Type_Remboursement)this._DataGridMain.SelectedItem; //Je positionne la lecture seule sur la fenêtre TypeRemboursementWindow.lectureSeule(); //J'affiche la fenêtre bool? dialogResult = TypeRemboursementWindow.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 type de remboursement terminé : " + this.listTypeRemb.Count() + " / " + this.max; //Renvoi null return null; } else { MessageBox.Show("Vous ne devez sélectionner qu'un seul type de remboursement.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); this._DataGridMain.Items.Refresh(); return null; } } else { MessageBox.Show("Vous devez sélectionner un type de remboursement.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); this._DataGridMain.Items.Refresh(); return null; } }
/// <summary> /// Ouvre le motif séléctionnée à l'aide d'une nouvelle fenêtre /// </summary> public Type_Remboursement 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 type de remboursement en cours ..."; //Création de la fenêtre TypeRemboursementWindow TypeRemboursementWindow = new TypeRemboursementWindow(); //Initialisation du Datacontext TypeRemboursementWindow.DataContext = new Type_Remboursement(); TypeRemboursementWindow.DataContext = (Type_Remboursement)this._DataGridMain.SelectedItem; //booléen nullable vrai ou faux ou null bool? dialogResult = TypeRemboursementWindow.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 (Type_Remboursement)TypeRemboursementWindow.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, (Type_Remboursement)(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 type de remboursement annulé : " + this.listTypeRemb.Count() + " / " + this.max; return null; } } else { MessageBox.Show("Vous ne devez sélectionner qu'un seul type de remboursement.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); this._DataGridMain.Items.Refresh(); return null; } } else { MessageBox.Show("Vous devez sélectionner un type de remboursement.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); this._DataGridMain.Items.Refresh(); return null; } }
public Type_Remboursement Duplicate() { if (this._DataGridMain.SelectedItem != null) { if (this._DataGridMain.SelectedItems.Count == 1) { //Affichage du message "ajout en cours" ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = true; ((App)App.Current)._theMainWindow.changementTexteStatusBar("Dupliquer un type remboursement en cours ..."); TypeRemboursementWindow typeWindow = new TypeRemboursementWindow(); Type_Remboursement tmp = new Type_Remboursement(); tmp = duplicateTypeRemboursement((Type_Remboursement)this._DataGridMain.SelectedItem); typeWindow.DataContext = tmp; bool? dialogResult = typeWindow.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value == true) { return (Type_Remboursement)typeWindow.DataContext; } else { try { ((App)App.Current).mySitaffEntities.Detach((Type_Remboursement)typeWindow.DataContext); } catch (Exception) { } //Si j'appuie sur le bouton annuler, je préviens que j'annule mon ajout ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = false; this.recalculMax(); ((App)App.Current)._theMainWindow.changementTexteStatusBar("Duplication d'un type remboursement annulé : " + this.listTypeRemb.Count() + " / " + this.max); return null; } } else { MessageBox.Show("Vous ne devez sélectionner qu'un seul type remboursement.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); return null; } } else { MessageBox.Show("Vous devez sélectionner un type remboursement.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation); return null; } }