private void Confirmer_Click(object sender, RoutedEventArgs e)
 {
     if (DateArrivee.SelectedDate == null)
     {
         MessageBoxResult result = MessageBox.Show("Error : Aucune date sélectionnée");
     }
     else if (StringCheck(Nom.Text) || StringCheck(Prenom.Text))
     {
         MessageBoxResult result = MessageBox.Show("Error : veuillez saisir votre nom complet");
     }
     else if (StringCheck(AdresseMail.Text) || StringCheck(Service.Text) || StringCheck(Metier.Text) || StringCheck(LinkedIn.Text) || StringCheck(Entreprise.Text))
     {
         MessageBoxResult result = MessageBox.Show("Error : Veuillez remplir tous les champs");
     }
     else if (DateDepart.SelectedDate < DateArrivee.SelectedDate)
     {
         MessageBoxResult result = MessageBox.Show("Error : Incohérence dans les dates");
     }
     else if ((!(Interne.IsChecked.Value) && ChefDeService.IsChecked.Value))
     {
         MessageBoxResult result = MessageBox.Show("Error : Incohérence des rôles (Impossible d'être externe et chef de service");
     }
     else
     {
         using (var db = new BBD_projetEntities())
         {
             foreach (var x in ListLangue)
             {
                 System.Diagnostics.Debug.WriteLine((ListLangueOrigin.Where(l => l.Id_Langue == x.Id_Langue).Count()));
                 System.Diagnostics.Debug.WriteLine(x.Id_Langue);
                 if ((ListLangueOrigin.Where(l => l.Id_Langue == x.Id_Langue).Count() > 0))
                 {
                     System.Diagnostics.Debug.WriteLine((ListLangueOrigin.Where(l => l.Id_Langue == x.Id_Langue).First()).Id_Langue);
                 }
                 if (ListLangueOrigin.Where(l => l.Id_Langue == x.Id_Langue).Count() == 0)
                 {
                     DAL.LanguePossede languePossede = new DAL.LanguePossede
                     {
                         Default    = false,
                         Id_Employe = Employe.Id_Employe,
                         Id_Langue  = x.Id_Langue
                     };
                     db.LanguePossedes.Add(languePossede);
                 }
             }
             foreach (var y in ListLangueOrigin)
             {
                 if (ListLangue.Where(l => l.Id_Langue == y.Id_Langue).Count() == 0)
                 {
                     var languePossede = new DAL.LanguePossede
                     {
                         Default    = false,
                         Id_Employe = Employe.Id_Employe,
                         Id_Langue  = y.Id_Langue
                     };
                     db.LanguePossedes.Attach(languePossede);
                     db.LanguePossedes.Remove(languePossede);
                 }
             }
             foreach (var w in ListCompetence)
             {
                 if (ListCompetenceOrigin.Where(c => c.Id_Competence == w.Id_Competence).Count() == 0)
                 {
                     var competencePossede = new DAL.LiaisonCompetence
                     {
                         Id_Competence = w.Id_Competence,
                         Id_Employe    = Employe.Id_Employe,
                         EstTutorant   = false
                     };
                     db.LiaisonCompetences.Add(competencePossede);
                 }
             }
             foreach (var z in ListCompetenceOrigin)
             {
                 if (ListCompetence.Where(c => c.Id_Competence == z.Id_Competence).Count() == 0)
                 {
                     var competencePossede = new DAL.LiaisonCompetence
                     {
                         Id_Competence = z.Id_Competence,
                         Id_Employe    = Employe.Id_Employe,
                         EstTutorant   = false
                     };
                     db.LiaisonCompetences.Attach(competencePossede);
                     db.LiaisonCompetences.Remove(competencePossede);
                 }
             }
             var DALEmploye = db.Employes.Find(Employe.Id_Employe);
             if (Service.Text != DALEmploye.Service)
             {
                 DALEmploye.Service = Service.Text;
             }
             if (Entreprise.Text != DALEmploye.Entreprise)
             {
                 DALEmploye.Entreprise = Entreprise.Text;
             }
             if (Metier.Text != Employe.Metier)
             {
                 DALEmploye.Metier = Metier.Text;
             }
             if (Nom.Text != DALEmploye.Nom)
             {
                 DALEmploye.Nom = Nom.Text;
             }
             if (Prenom.Text != DALEmploye.Prenom)
             {
                 DALEmploye.Prenom = Prenom.Text;
             }
             if (DateArrivee.SelectedDate != DALEmploye.DateArrive)
             {
                 DALEmploye.DateArrive = DateArrivee.SelectedDate.Value;
             }
             if (Employe.DateDepart != null)
             {
                 if (DateDepart.SelectedDate != DALEmploye.DateDepart)
                 {
                     DALEmploye.DateDepart = DateDepart.SelectedDate.Value;
                 }
             }
             if (ChefDeService.IsChecked != DALEmploye.EstChefDeService)
             {
                 DALEmploye.EstChefDeService = ChefDeService.IsChecked.Value;
             }
             if (Admin.IsChecked != DALEmploye.EstAdmin)
             {
                 DALEmploye.EstAdmin = Admin.IsChecked.Value;
             }
             if (Actif.IsChecked != DALEmploye.Actif)
             {
                 DALEmploye.Actif = Actif.IsChecked.Value;
             }
             if (Interne.IsChecked != DALEmploye.EstInterne)
             {
                 DALEmploye.EstInterne = Interne.IsChecked.Value;
             }
             if (AdresseMail.Text != Employe.AdresseMail)
             {
                 DALEmploye.AdresseMail = AdresseMail.Text;
             }
             if (LinkedIn.Text != Employe.LinkedIn)
             {
                 DALEmploye.LienLinkedin = LinkedIn.Text;
             }
             db.SaveChanges();
             this.NavigationService.Navigate(new Uri("ListViewEmploye.xaml", UriKind.Relative));
         }
     }
 }
 private void Confirmer_Click(object sender, RoutedEventArgs e)
 {
     if (DateArrivee.SelectedDate == null)
     {
         MessageBoxResult result = MessageBox.Show("Error : Aucune date sélectionnée");
     }
     else if (StringCheck(Nom.Text) || StringCheck(Prenom.Text))
     {
         MessageBoxResult result = MessageBox.Show("Error : veuillez saisir votre nom complet");
     }
     else if (StringCheck(AdresseMail.Text) || StringCheck(Service.Text) || StringCheck(Metier.Text) || StringCheck(LinkedIn.Text) || StringCheck(Entreprise.Text))
     {
         MessageBoxResult result = MessageBox.Show("Error : Veuillez remplir tous les champs");
     }
     else if (DateDepart.SelectedDate < DateArrivee.SelectedDate)
     {
         MessageBoxResult result = MessageBox.Show("Error : Incohérence dans les dates");
     }
     else
     {
         using (var db = new BBD_projetEntities())
         {
             DAL.Employe employe = new DAL.Employe
             {
                 Actif            = Actif.IsChecked.Value,
                 EstAdmin         = Admin.IsChecked.Value,
                 EstChefDeService = ChefDeService.IsChecked.Value,
                 EstInterne       = Interne.IsChecked.Value,
                 AdresseMail      = AdresseMail.Text,
                 Metier           = Metier.Text,
                 Service          = Service.Text,
                 Nom          = Nom.Text,
                 Prenom       = Prenom.Text,
                 DateArrive   = DateArrivee.SelectedDate.Value,
                 Entreprise   = Entreprise.Text,
                 LienLinkedin = LinkedIn.Text,
                 Identifiant  = ComputeSha256Hash(Nom + "." + Prenom),
                 MotDePasse   = ComputeSha256Hash("Epsi2018!")
             };
             if (DateDepart.SelectedDate != null)
             {
                 employe.DateDepart = DateDepart.SelectedDate.Value;
             }
             System.Diagnostics.Debug.Write(employe.DateDepart);
             db.Employes.Add(employe);
             foreach (var x in ListBoC)
             {
                 DAL.LiaisonCompetence competence = new DAL.LiaisonCompetence
                 {
                     EstTutorant   = false,
                     Id_Competence = x.Id_Competence,
                     Employe       = employe
                 };
                 db.LiaisonCompetences.Add(competence);
             }
             foreach (var y in ListBoL)
             {
                 DAL.LanguePossede langue = new DAL.LanguePossede
                 {
                     Employe   = employe,
                     Id_Langue = y.Id_Langue,
                     Default   = false
                 };
                 db.LanguePossedes.Add(langue);
             }
             db.SaveChanges();
             this.NavigationService.Navigate(new Uri("ListViewEmploye.xaml", UriKind.Relative));
         }
     }
 }