private void Suppression_Click(object sender, RoutedEventArgs e) { using (var db = new BBD_projetEntities()) { var ObjSupp = (from g in db.Groupes where g.Id_Groupe == ((BO.Groupe)List.SelectedItem).Id_Groupe select g).ToList(); if (ObjSupp.Count != 0) { var ObjSupp2 = (from m in db.Membres where m.Id_Groupe == ((BO.Groupe)List.SelectedItem).Id_Groupe select m).ToList(); foreach (var x in ObjSupp2) { db.Membres.Remove(x); } var ObjSupp3 = (from x in db.Messageries where x.Id_Groupe == ((BO.Groupe)List.SelectedItem).Id_Groupe select x).ToList(); foreach (var w in ObjSupp3) { db.Messageries.Remove(w); } db.Groupes.Remove(ObjSupp.First()); db.SaveChanges(); listGroupes.Remove((BO.Groupe)List.SelectedItem); List.Items.Refresh(); } } }
private void ToggleButton_Click(object sender, RoutedEventArgs e) { using (var db = new BBD_projetEntities()) { var Item = db.Langues.Find(Langue.Id_Langue); //MessageBoxResult result = MessageBox.Show(Langue.Nom); Item.Nom = NewLangue.Text; Item.Default = NewDefault.IsChecked.Value; db.SaveChanges(); } NavigationService.Navigate(new ListViewLangue()); }
private void DeleteLangue_Click(object sender, RoutedEventArgs e) { var Item = (DAL.Langue)listDal.SelectedItem; MessageBoxResult result = MessageBox.Show("Warning : Vous allez supprimer " + Item.Nom); using (var db = new BBD_projetEntities()) { db.Langues.Attach(Item); db.Langues.Remove(Item); db.SaveChanges(); } NavigationService.Navigate(new ListViewLangue()); }
private void Suppression_Click(object sender, RoutedEventArgs e) { using (var db = new BBD_projetEntities()) { var ObjSupp5 = (from c in db.Competences where c.Id_Competence == ((BO.Competence)list.SelectedItem).Id_Competence select c).ToList(); if (ObjSupp5.Count != 0) { var ObjSupp = (from ic in db.IntituleCompetences where ic.Id_Competence == ((BO.Competence)list.SelectedItem).Id_Competence select ic).ToList(); foreach (var x in ObjSupp) { db.IntituleCompetences.Remove(x); } var ObjSupp2 = (from lc in db.LiaisonCompetences where lc.Id_Competence == ((BO.Competence)list.SelectedItem).Id_Competence select lc).ToList(); foreach (var x in ObjSupp2) { db.LiaisonCompetences.Remove(x); } var ObjSupp3 = (from d in db.Demandes where d.Id_Competence == ((BO.Competence)list.SelectedItem).Id_Competence select d).ToList(); foreach (var z in ObjSupp3) { db.Demandes.Remove(z); } var ObjSupp4 = (from n in db.Notes where n.Id_Competence == ((BO.Competence)list.SelectedItem).Id_Competence select n).ToList(); foreach (var m in ObjSupp4) { db.Notes.Remove(m); } db.Competences.Remove(ObjSupp5.First()); db.SaveChanges(); listCompetences.Remove(((BO.Competence)list.SelectedItem)); list.Items.Refresh(); } } }
private void ToggleButton_Click(object sender, RoutedEventArgs e) { var newCategorie = (DAL.Categorie)listCategorieDal.SelectedItem; try { using (var db = new BBD_projetEntities()) { var Item = db.Categories.Find(Categorie.Id_Categorie); Item.Intitule = CategorieName.Text; Item.Id_Super_Categorie = newCategorie.Id_Categorie; db.SaveChanges(); } NavigationService.Navigate(new ListViewCategorie()); } catch (Exception) { MessageBoxResult result = MessageBox.Show("Warning : vous n'avez pas saisie d'id_super_categorie"); } }
private void ToggleButton_Click(object sender, RoutedEventArgs e) { var checkError = 0; foreach (var item in langue) { if (NewLangue.Text == item.Nom) { checkError = 1; } } if (NewLangue.Text == "") { checkError = 2; } if (checkError == 0) { using (var db = new BBD_projetEntities()) { var newLangue = NewLangue.Text; var dalLangue = new DAL.Langue(); dalLangue.Nom = newLangue; dalLangue.Default = defaultLangue.IsChecked.Value; db.Langues.Add(dalLangue); db.SaveChanges(); NavigationService.Navigate(new ListViewLangue()); } } else if (checkError == 1) { MessageBoxResult resultDelta = MessageBox.Show("Warning : Nom de langue deja créer"); } else { MessageBoxResult resultDelta = MessageBox.Show("Warning : Vous n'avez pas mis de nom"); } }
private void Suppression_Click(object sender, RoutedEventArgs e) { using (var db = new BBD_projetEntities()) { if (list.SelectedItem != null) { var DALObject4 = (from m in db.Membres where m.Id_Employe == ((BO.Employe)list.SelectedItem).Id_Employe select m).ToList(); foreach (var w in DALObject4) { db.Membres.Remove(w); } var DALObject3 = (from lc in db.LiaisonCompetences where lc.Id_Employe == ((BO.Employe)list.SelectedItem).Id_Employe select lc).ToList(); foreach (var y in DALObject3) { db.LiaisonCompetences.Remove(y); } var DALObject2 = (from lp in db.LanguePossedes where lp.Id_Employe == ((BO.Employe)list.SelectedItem).Id_Employe select lp).ToList(); foreach (var x in DALObject2) { db.LanguePossedes.Remove(x); } var DALObject = (from e2 in db.Employes where e2.Id_Employe == ((BO.Employe)list.SelectedItem).Id_Employe select e2).First(); db.Employes.Remove(DALObject); listemploye.Remove((BO.Employe)list.SelectedItem); list.Items.Refresh(); } db.SaveChanges(); } }
private void DeleteCategorie_Click(object sender, RoutedEventArgs e) { if (listDal.SelectedItem != null) { var Item = (DAL.Categorie)listDal.SelectedItem; MessageBoxResult result = MessageBox.Show("Warning : Vous allez supprimer " + Item.Intitule); using (var db = new BBD_projetEntities()) { List <DAL.IntituleCategorie> listIntitule = new List <DAL.IntituleCategorie>(); List <DAL.Categorie> listEnfant = new List <DAL.Categorie>(); //partie liaison var req = (from c in db.IntituleCategories where c.Id_Categorie == Item.Id_Categorie select new { IdCategorie = c.Id_Categorie, intitule = c.intitule, Id_Langue = c.Id_Langue }).ToList().Select(l => new DAL.IntituleCategorie { Id_Categorie = l.IdCategorie, intitule = l.intitule, Id_Langue = l.Id_Langue }); listIntitule = req.ToList(); foreach (var itemIntitule in listIntitule) { db.IntituleCategories.Attach(itemIntitule); db.IntituleCategories.Remove(itemIntitule); db.SaveChanges(); //MessageBoxResult unAutreTruc = MessageBox.Show(itemIntitule.intitule); } var IdParent = Item.Id_Super_Categorie; var reqEnfant = (from c in db.Categories where c.Id_Super_Categorie == Item.Id_Categorie select new { IdCategorie = c.Id_Categorie, Intitule = c.Intitule, Id_Super_Categorie = c.Id_Super_Categorie }).ToList().Select(l => new DAL.Categorie { Id_Categorie = l.IdCategorie, Id_Super_Categorie = l.Id_Super_Categorie, Intitule = l.Intitule }); listEnfant = reqEnfant.ToList(); foreach (var itemEnfant in listEnfant) { var ItemEnfant = db.Categories.Find(itemEnfant.Id_Categorie); ItemEnfant.Id_Super_Categorie = IdParent; db.SaveChanges(); } db.Categories.Attach(Item); db.Categories.Remove(Item); db.SaveChanges(); } NavigationService.Navigate(new ListViewCategorie()); } else { MessageBoxResult result = MessageBox.Show("Warning : Vous allez n'avez rien selectionné"); } }
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 Enregistrement_Click(object sender, RoutedEventArgs e) { using (var db = new BBD_projetEntities()) { if (Date.SelectedDate == null) { MessageBoxResult result = MessageBox.Show("Error : Aucune date sélectionnée"); } else if (Titre.Text.Count() <= 0) { MessageBoxResult result = MessageBox.Show("Error : Aucun Titre sélectionné"); } else if (Competence == null) { MessageBoxResult result = MessageBox.Show("Error : Veuillez indiqué la compétence enseigné"); } else { System.Diagnostics.Debug.WriteLine(Competence.Id_Competence); //Groupe var groupe = new DAL.Groupe { Id_Competence = Competence.Id_Competence, DateReunion = Date.SelectedDate.Value, DateCreation = DateTime.Now, Titre = Titre.Text, EstValider = true }; db.Groupes.Add(groupe); System.Diagnostics.Debug.WriteLine(groupe.Id_Competence); System.Diagnostics.Debug.WriteLine(groupe.DateReunion); System.Diagnostics.Debug.WriteLine(groupe.Titre); //Membre et tuteur var tuteur = false; if (ListParticipant.Count <= 0) { MessageBoxResult result = MessageBox.Show("Warning : Vous n'avez pas de participants"); } foreach (var x in ListParticipant) { var membre = new DAL.Membre(); if (x.Id_Employe == Tuteur.Id_Employe) { tuteur = true; membre = new DAL.Membre { EstTutorant = true, Id_Employe = x.Id_Employe, //Groupe = groupe }; } else { membre = new DAL.Membre { EstTutorant = false, Id_Employe = x.Id_Employe, //Groupe = groupe }; } System.Diagnostics.Debug.WriteLine(membre.EstTutorant); System.Diagnostics.Debug.WriteLine(membre.Id_Employe); System.Diagnostics.Debug.WriteLine(membre.Groupe); db.Membres.Add(membre); } if (tuteur == false) { MessageBoxResult result = MessageBox.Show("Warning : Vous n'avez pas selectionné de tuteur"); } db.SaveChanges(); ListViewCompetence l = new ListViewCompetence(); this.NavigationService.Navigate(new Uri("ListViewGroup.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)); } } }
private void b_Click(object sender, RoutedEventArgs e) { if (C3.SelectedDate == null) { MessageBoxResult result = MessageBox.Show("Error : Aucune date sélectionnée"); } else if (StringCheck(C1.Text) && StringCheck(C2.Text)) { MessageBoxResult result = MessageBox.Show("Error : Aucun Titre sélectionné"); } else { //lier les eux objets using (var db = new BBD_projetEntities()) { BO.Competence t = (BO.Competence)list2.SelectedItem; DAL.Competence objet = null; test2.Content = Actif.ToString(); var objet2 = new DAL.IntituleCompetence(); if (list2.SelectedItem != null) { objet = new DAL.Competence() { Actuel = this.Actuel, Id_CompetenceActuel = t.Id_CompetenceActuel, Annee = C3.SelectedDate.ToString(), Actif = this.Actif }; } else { objet = new DAL.Competence() { Actuel = this.Actuel, Id_CompetenceActuel = null, Annee = C3.SelectedDate.ToString(), Actif = this.Actif }; } if (list.SelectedItem == null) { objet2 = new DAL.IntituleCompetence() { intitule = C1.Text, Description = C2.Text, Id_Langue = 3, Competence = objet }; } else { objet2 = new DAL.IntituleCompetence() { intitule = C1.Text, Description = C2.Text, Id_Langue = ((int)list.SelectedValue), Competence = objet }; } objet.IntituleCompetences.Add(objet2); db.Competences.Add(objet); db.SaveChanges(); ListViewCompetence l = new ListViewCompetence(); this.NavigationService.Navigate(new Uri("ListViewCompetence.xaml", UriKind.Relative)); } } }
private void ToggleButton_Click(object sender, RoutedEventArgs e) { try { var checkError = 0; foreach (var item in listCategorie) { if (NewCategorie.Text == item.Intitule) { checkError = 1; } if (NewCategorie.Text == "") { checkError = 2; } } if (checkError == 0) { using (var db = new BBD_projetEntities()) { var Categorie = NewCategorie.Text; var Langue = ((DAL.Langue)listLangueDal.SelectedItem); var SuperCategorie = ((DAL.Categorie)listCategorieDal.SelectedItem); var idLangue = Langue.Id_Langue; var idSuperCategorie = SuperCategorie.Id_Categorie; var dalCategorie = new DAL.Categorie(); dalCategorie.Id_Super_Categorie = idSuperCategorie; dalCategorie.Intitule = Categorie; db.Categories.Add(dalCategorie); db.SaveChanges(); var req = from c in db.Categories where c.Intitule == Categorie select c; var dalIntituleCategorie = new DAL.IntituleCategorie(); dalIntituleCategorie.Id_Categorie = req.FirstOrDefault().Id_Categorie; dalIntituleCategorie.Id_Langue = idLangue; dalIntituleCategorie.intitule = Categorie; db.IntituleCategories.Add(dalIntituleCategorie); db.SaveChanges(); NavigationService.Navigate(new ListViewCategorie()); } } else if (checkError == 1) { MessageBoxResult resultBeta = MessageBox.Show("Warning : Cette categorie existe deja"); } else { MessageBoxResult resultDelta = MessageBox.Show("Warning : Vous n'avez pas mis de nom"); } } catch (Exception) { MessageBoxResult resultAlpha = MessageBox.Show("Warning : Veuillez saisir des categories ET langues"); } }
private void b_Click(object sender, RoutedEventArgs e) { using (var db = new BBD_projetEntities()) { BO.Competence t = (BO.Competence)list2.SelectedItem; DAL.Competence objet = null; var objet2 = new DAL.IntituleCompetence(); test2.Content = Actif.ToString(); IEnumerable <IntituleCompetence> req = null; if (((int?)list.SelectedValue) != null) { req = (from c in db.IntituleCompetences where c.Id_Competence == Competence.Id_Competence && c.Id_Langue == ((int)list.SelectedValue) select new { Competence = c.Competence, Id_Langue = c.Id_Langue, Id_Competence = c.Id_Competence, Description = c.Description, intitule = c.intitule, Langue = c.Langue }).ToList().Select(c => new DAL.IntituleCompetence { Competence = c.Competence, Id_Langue = c.Id_Langue, Id_Competence = c.Id_Competence, Description = c.Description, intitule = c.intitule, Langue = c.Langue }); } if (!(req == null) || (req != null && req.ToList().Count > 0)) { var o = new BO.IntituleCompetence(req.ToList()[0]); var IcObjet = db.IntituleCompetences.Find(o.Id_Competence, o.Id_Langue); IcObjet.intitule = C1.Text; IcObjet.Description = C2.Text; if (list.SelectedItem == null) { IcObjet.Id_Langue = db.LangueParDefaut(); } else { IcObjet.Id_Langue = ((int)list.SelectedValue); } } else { if (list.SelectedItem == null) { var LangueParDef = db.LangueParDefaut(); if ((from c in db.IntituleCompetences where c.Id_Competence == Competence.Id_Competence && c.Id_Langue == LangueParDef select new { }).Count() > 1) { objet2 = new DAL.IntituleCompetence() { intitule = C1.Text, Description = C2.Text, Id_Langue = db.LangueParDefaut(), Id_Competence = Competence.Id_Competence, Competence = db.Competences.Find(Competence.Id_Competence), Langue = db.Langues.Find(db.LangueParDefaut()) }; System.Diagnostics.Debug.WriteLine(objet2.intitule); System.Diagnostics.Debug.WriteLine(objet2.Description); System.Diagnostics.Debug.WriteLine(objet2.Id_Langue); System.Diagnostics.Debug.WriteLine(objet2.Id_Competence); db.IntituleCompetences.Add(objet2); } else { //work var IcObjet = db.IntituleCompetences.Find(Competence.Id_Competence, db.LangueParDefaut()); IcObjet.intitule = C1.Text; IcObjet.Description = C2.Text; } } else { objet2 = new DAL.IntituleCompetence() { intitule = C1.Text, Description = C2.Text, Id_Langue = ((int)list.SelectedValue), Id_Competence = Competence.Id_Competence }; db.IntituleCompetences.Add(objet2); } } var DALCompetence = db.Competences.Find(Competence.Id_Competence); if (list2.SelectedValue != null) { DALCompetence.Id_CompetenceActuel = t.Id_Competence; } /* System.Diagnostics.Debug.WriteLine(C3.SelectedDate == null); * System.Diagnostics.Debug.WriteLine(C3.SelectedDate != null); * System.Diagnostics.Debug.WriteLine(!(C3.SelectedDate == null));*/ if (C3.SelectedDate != null) { DALCompetence.Annee = C3.SelectedDate.ToString(); } if (DALCompetence.Actif == this.Actif) { DALCompetence.Actif = this.Actif; } System.Diagnostics.Debug.WriteLine(C3.SelectedDate.ToString()); System.Diagnostics.Debug.WriteLine(DALCompetence.Annee); System.Diagnostics.Debug.WriteLine(!(C3.SelectedDate == null)); db.SaveChanges(); ListViewCompetence l = new ListViewCompetence(); this.NavigationService.Navigate(new Uri("ListViewCompetence.xaml", UriKind.Relative)); } }
private void Enregistrement_Click(object sender, RoutedEventArgs e) { using (var db = new BBD_projetEntities()) { if (Date.SelectedDate == null && Groupe.DateReunion == null) { MessageBoxResult result = MessageBox.Show("Error : Aucune date sélectionnée"); } else if (Titre.Text.Count() <= 0) { MessageBoxResult result = MessageBox.Show("Error : Aucun Titre sélectionné"); } else if (Competence == null) { MessageBoxResult result = MessageBox.Show("Error : Veuillez indiqué la compétence enseigné"); } else { System.Diagnostics.Debug.WriteLine(Competence.Id_Competence); //Groupe var DALGroupe = db.Groupes.Find(Groupe.Id_Groupe); System.Diagnostics.Debug.WriteLine(Groupe.Id_Groupe); System.Diagnostics.Debug.WriteLine(DALGroupe); DALGroupe.Id_Competence = Competence.Id_Competence; if (Date.SelectedDate != null && Date.SelectedDate != Groupe.DateReunion) { DALGroupe.DateReunion = Date.SelectedDate.Value; } DALGroupe.Titre = Titre.Text; System.Diagnostics.Debug.WriteLine(DALGroupe.Id_Competence); System.Diagnostics.Debug.WriteLine(DALGroupe.DateReunion); System.Diagnostics.Debug.WriteLine(DALGroupe.Titre); //Membre et tuteur var tuteur = false; if (Groupe.Participant.Count <= 0) { MessageBoxResult result = MessageBox.Show("Warning : Vous n'avez pas de participants"); } var req = (from m in db.Membres where m.Id_Groupe == DALGroupe.Id_Groupe select new { Id_Groupe = m.Id_Groupe, Id_Employe = m.Id_Employe, EstTutorant = m.EstTutorant }).ToList().Select(m => new DAL.Membre { Id_Groupe = m.Id_Groupe, Id_Employe = m.Id_Employe, EstTutorant = m.EstTutorant }); foreach (var x in Groupe.Participant) { if (req.Where(c => c.Id_Employe == x.Id_Employe).Count() == 0) { var membre = new DAL.Membre(); if (ListBoxTuteur.SelectedItem is BO.Employe && x.Id_Employe == Tuteur.Id_Employe) { tuteur = true; membre = new DAL.Membre { EstTutorant = true, Id_Employe = x.Id_Employe, Groupe = DALGroupe }; } else { membre = new DAL.Membre { EstTutorant = false, Id_Employe = x.Id_Employe, Groupe = DALGroupe }; } System.Diagnostics.Debug.WriteLine(membre.EstTutorant); System.Diagnostics.Debug.WriteLine(membre.Id_Employe); System.Diagnostics.Debug.WriteLine(membre.Groupe); db.Membres.Add(membre); } } if (req.Where(c => c.Id_Employe == Tuteur.Id_Employe && c.EstTutorant == true).Count() == 0) { System.Diagnostics.Debug.WriteLine(Tuteur.Id_Employe + " " + Groupe.Id_Groupe); var modif = db.Membres.Find(Groupe.Id_Groupe, Tuteur.Id_Employe); modif.EstTutorant = true; if (!(req.Where(c => c.EstTutorant == true).ToList().First() is null)) { var modif2 = db.Membres.Find(Groupe.Id_Groupe, req.Where(c => c.EstTutorant == true).ToList().First().Id_Employe); modif2.EstTutorant = false; } } foreach (var x in req.ToList()) { if (Groupe.Participant.Where(c => c.Id_Employe == x.Id_Employe).Count() == 0) { db.Membres.Attach(x); db.Membres.Remove(x); } } db.SaveChanges(); ListViewCompetence l = new ListViewCompetence(); this.NavigationService.Navigate(new Uri("ListViewGroup.xaml", UriKind.Relative)); } } }