public void LookSortieAtelier(UIElement uIElement, Sortie_Atelier sortieToLook)
 {
     ((ListeSortieAtelierControl)uIElement).Look(sortieToLook);
 }
        /// <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 Sortie_Atelier soit pour l'ajouter au listing, soit pour afficher qui a été modifié ou supprimé</param>
        public void MiseAJourEtat(string typeEtat, Sortie_Atelier om)
        {
            //Je recalcul le nombre max d'élements
            this.recalculMax();
            //En fonction de l'action, j'affiche le message
            if (typeEtat == "Filtrage")
            {
                ((App)App.Current)._theMainWindow.changementTexteStatusBar("Filtrage des sorties atelier terminé : " + this.listSorties.Count() + " / " + this.max);
            }
            else if (typeEtat == "Ajout")
            {
                //J'ajoute sortie atelier dans le linsting
                this.listSorties.Add(om);
                //Je recalcul le nombre max d'élements après l'ajout
                this.recalculMax();
                ((App)App.Current)._theMainWindow.changementTexteStatusBar("Ajout d'une sortie atelier effectuée avec succès. Nombre d'élements : " + this.listSorties.Count() + " / " + this.max);
                try
                {
                    this._DataGridMain.SelectedItem = om;
                }
                catch (Exception) { }
            }
            else if (typeEtat == "Modification")
            {
                //Je raffraichis mon datagrid
                this._DataGridMain.Items.Refresh();
                ((App)App.Current)._theMainWindow.changementTexteStatusBar("Modification de la sortie atelier effectuée avec succès. Nombre d'élements : " + this.listSorties.Count() + " / " + this.max);
            }
            else if (typeEtat == "Suppression")
            {
                //Je supprime de mon listing l'élément supprimé
                this.listSorties.Remove(om);
                //Je recalcul le nombre max d'élements après la suppression
                this.recalculMax();
                ((App)App.Current)._theMainWindow.changementTexteStatusBar("Suppression de la sortie atelier effectuée avec succès. Nombre d'élements : " + this.listSorties.Count() + " / " + this.max);
            }
            else if (typeEtat == "Look")
            {

            }
            else if (typeEtat == "Duplicate")
            {
                //J'ajoute sortie atelier dans le linsting
                this.listSorties.Add(om);
                //Je recalcul le nombre max d'élements après l'ajout
                this.recalculMax();
                ((App)App.Current)._theMainWindow.changementTexteStatusBar("Dupliquer une sortie atelier effectué avec succès. Nombre d'élements : " + this.listSorties.Count() + " / " + this.max);
            }
            else
            {
                ((App)App.Current)._theMainWindow.changementTexteStatusBar("Chargement des sorties ateliers terminé : " + this.listSorties.Count() + " / " + this.max);
            }
            //Je retri les données dans le sens par défaut
            this.triDatas();
            //J'arrete la progressbar
            ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = false;
        }
        /// <summary>
        /// Ajoute une nouvelle entreprise à la liste à l'aide d'une nouvelle fenêtre
        /// </summary>
        public Sortie_Atelier Add()
        {
            //Affichage du message "ajout en cours"
                ((App)App.Current)._theMainWindow.progressBarMainWindow.IsIndeterminate = true;
                ((App)App.Current)._theMainWindow.changementTexteStatusBar("Ajout d'une sortie atelier en cours ...");

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

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

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

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

                if (dialogResult.HasValue && dialogResult.Value == true)
                {
                    //Si j'appuie sur le bouton Ok, je renvoi l'objet sortieAtelier dans le datacontext de la fenêtre
                    return (Sortie_Atelier)SortieAtelierWindow.DataContext;
                }
                else
                {
                    try
                    {
                        //Detachement de tous les éléments liés à une Mission tiers
                        if (((Sortie_Atelier)SortieAtelierWindow.DataContext).Contenu_Sortie_Atelier != null)
                        {
                            while (((Sortie_Atelier)SortieAtelierWindow.DataContext).Contenu_Sortie_Atelier.Count() > 0)
                            {
                                ((App)App.Current).mySitaffEntities.Detach(((Sortie_Atelier)SortieAtelierWindow.DataContext).Contenu_Sortie_Atelier.First());
                            }
                            ((App)App.Current).mySitaffEntities.Detach(((Sortie_Atelier)SortieAtelierWindow.DataContext).Contenu_Sortie_Atelier);
                        }
                    }
                    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 sortie atelier annulé : " + this.listSorties.Count() + " / " + this.max);

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

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

                    //Initialisation du Datacontext en ordre de mission et association à l'sortieAtelier sélectionnée
                    SortieAtelierWindow.DataContext = new Sortie_Atelier();
                    if (sortieAtelier != null)
                    {
                        SortieAtelierWindow.DataContext = sortieAtelier;
                    }
                    else
                    {
                        SortieAtelierWindow.DataContext = (Sortie_Atelier)this._DataGridMain.SelectedItem;
                    }

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

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

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

                    //Renvoi null
                    return null;
                }
                else
                {
                    MessageBox.Show("Vous ne devez sélectionner qu'une seule sortie atelier.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    return null;
                }
            }
            else
            {
                MessageBox.Show("Vous devez sélectionner une sortie atelier.", "Attention", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return null;
            }
        }