/// <summary>
        /// Ajoute une nouvelle Commande_Fournisseur à la liste à l'aide d'une nouvelle fenêtre
        /// </summary>
        public Avance Add()
        {
            //Affichage du message "ajout en cours"
            ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = true;
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Ajout d'une avance en cours ...");

            //Initialisation de la fenêtre
            AvanceWindow avanceWindow = new AvanceWindow();

            //Création de l'objet temporaire
            Avance tmp = new Avance();

            //Mise de l'objet temporaire dans le datacontext
            avanceWindow.DataContext = tmp;

            //booléen nullable vrai ou faux ou null
            bool? dialogResult = avanceWindow.ShowDialog();

            if (dialogResult.HasValue && dialogResult.Value == true)
            {
                //Si j'appuie sur le bouton Ok, je renvoi l'objet commande se trouvant dans le datacontext de la fenêtre
                return (Avance)avanceWindow.DataContext;
            }
            else
            {
                try
                {
                    //On détache l'avance
                    ((App)App.Current).mySitaffEntities.Detach((Avance)avanceWindow.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("Ajout d'une avance annulé : " + this.listAvances.Count() + " / " + this.max);

                return null;
            }
        }
        /// <summary>
        /// Ouvre l'avance séléctionnée en lecture seule à l'aide d'une nouvelle fenêtre
        /// </summary>
        public Avance Look(Avance avance)
        {
            if (this._DataGridMain.SelectedItem != null || avance != null)
            {
                if (this._DataGridMain.SelectedItems.Count == 1 || avance != null)
                {
                    //Affichage du message "affichage en cours"
                    ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = true;
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Affichage d'une commande fournisseur en cours ...");

                    //Création de la fenêtre
                    AvanceWindow avanceWindow = new AvanceWindow();

                    //Initialisation du Datacontext en Commande_Fournisseur et association à la Commande_Fournisseur sélectionnée
                    avanceWindow.DataContext = new Avance();
                    if (avance != null)
                    {
                        avanceWindow.DataContext = avance;
                    }
                    else
                    {
                        avanceWindow.DataContext = (Avance)this._DataGridMain.SelectedItem;
                    }

                    //Je positionne la lecture seule sur la fenêtre
                    avanceWindow.lectureSeule();

                    //J'affiche la fenêtre
                    bool? dialogResult = avanceWindow.ShowDialog();

                    //Affichage du message "affichage en cours"
                    ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = false;
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Affichage d'une avance terminé : " + this.listAvances.Count() + " / " + this.max);

                    //Renvoi null
                    return null;
                }
                else
                {
                    MessageBox.Show("Vous ne devez sélectionner qu'une seule avance.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return null;
                }
            }
            else
            {
                MessageBox.Show("Vous devez sélectionner une avance.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return null;
            }
        }
        /// <summary>
        /// Ouvre la commande fournisseur séléctionnée à l'aide d'une nouvelle fenêtre
        /// </summary>
        public Avance Open()
        {
            if (this._DataGridMain.SelectedItem != null)
            {
                if (this._DataGridMain.SelectedItems.Count == 1)
                {
                    //Affichage du message "modification en cours"
                    ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = true;
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Modification d'une commande fournisseur en cours ...");

                    bool test = true;
                    if (test)
                    {
                        if (((Avance)this._DataGridMain.SelectedItem).Frais1 != null)
                        {
                            test = false;
                            MessageBox.Show("Vous ne pouvez modifier cette avance car elle est liée à une fiche de frais", "Impossible de supprimer", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                            ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = false;
                            this.recalculMax();
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Modification impossible, cause : avance associée à une fiche de frais : " + this.listAvances.Count() + " / " + this.max);
                        }
                    }

                    if (test)
                    {
                        //Création de la fenêtre
                        AvanceWindow avanceWindow = new AvanceWindow();

                        //Initialisation du Datacontext en Avance et association à la Avance sélectionnée
                        avanceWindow.DataContext = new Avance();
                        avanceWindow.DataContext = (Avance)this._DataGridMain.SelectedItem;

                        //booléen nullable vrai ou faux ou null
                        bool? dialogResult = avanceWindow.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 (Avance)avanceWindow.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, (Avance)(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.progressBarMainWindow.IsIndeterminate = false;
                            this.recalculMax();
            ((App)App.Current)._theMainWindow.changementTexteStatusBar("Modification d'une avance annulée : " + this.listAvances.Count() + " / " + this.max);

                            return null;
                        }
                    }
                    else
                    {
                        return null;
                    }
                }
                else
                {
                    MessageBox.Show("Vous ne devez sélectionner qu'une seule avance.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return null;
                }
            }
            else
            {
                MessageBox.Show("Vous devez sélectionner une avance.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return null;
            }
        }
        //Ouvre la fenêtre 'AvanceWindow' pour ajouter une avance
        private void _buttonAjoutAvance_Click(object sender, RoutedEventArgs e)
        {
            DateTime d = new DateTime();
            Salarie salarieCourant = new Salarie();
            AvanceWindow avanceAjoutWindow = new AvanceWindow();
            avanceAjoutWindow.DataContext = new Avance();

            salarieCourant = this.listSalarie.ElementAt(placeSalarieDansList);

            if (!this.listNomUtilisateurAdministrateurModule.Contains(((App)App.Current)._connectedUser.Nom_Utilisateur))
            {
                avanceAjoutWindow._comboBoxSalarie.IsEnabled = false;//bloquer la combox de choix du Nom ( pour ne pas qu'un salarié fasse une demande d'avance sur quelqu'un d'autre que lui)
            }

            ((Avance)avanceAjoutWindow.DataContext).Salarie1 = salarieCourant;
            DateTime.TryParse(DateTime.Today.ToShortDateString(), out d);
            ((Avance)avanceAjoutWindow.DataContext).Date_Avance = d;
            ((Avance)avanceAjoutWindow.DataContext).Somme = 0;

            bool? dialogResult = avanceAjoutWindow.ShowDialog();
            Avance avemaria = (Avance)avanceAjoutWindow.DataContext;

            if (dialogResult.HasValue == true && dialogResult.Value == false)
            {
                try
                {
                    ((App)App.Current).mySitaffEntities.Detach(avemaria);
                }
                catch (Exception)
                {
                    try
                    {
                        ((App)App.Current).mySitaffEntities.Avance.DeleteObject(avemaria);
                    }
                    catch (Exception)
                    {

                    }
                }
            }
            else
            {
                if (avemaria.Date_Avance.Value.Month == datemoiscourant.Month)
                {
                    this.listAvanceDemande.Add(avemaria);
                }
            }

            RefreshAllTotaux();
        }