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 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 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)); } }
public MainWindow() { InitializeComponent(); /*this.DataContext = this; * using (var db = new BBD_projetEntities()) * { * var val = db.LangueParDefaut(); * var req = from c in db.OffrantParCompetenceAvecLangueEtIntituleActu(8,3) * select c; * foreach (var v in req) * { * this.DataContext = v.Description; * } * var req2 = from c in db.Langues * select c; * * for (int i = 0; i < req2.ToList().Count; i++) * { * list.Items.Add(req2.ToList().ElementAt(i).Nom); * } * var req3 = from c in db.Competences * where c.Actuel == true && c.Actif == true * select new BO.Competence { Actuel = c.Actuel, * IntituleCompetence = c.IntituleCompetences.Where(b => b.Id_Langue == val).Select(b => b.intitule).FirstOrDefault(), * Annee = c.Annee, * Id_Competence = c.Id_Competence, * Id_CompetenceActuel = c.Id_CompetenceActuel}; * * list2.ItemsSource = req3.ToList(); * * } * } * private void b_Click(object sender, RoutedEventArgs e) * { * using (var db = new BBD_projetEntities()) * { * BO.Competence t = (BO.Competence)list2.SelectedItem; * Competence objet = null; * test2.Content = Actif.ToString(); * var objet2 = new IntituleCompetence() * { * intitule = C1.Text, * Description = C2.Text, * Id_Langue = 3 * }; * if (list2.SelectedItem != null) * { * objet = new Competence() * { * Actuel = this.Actuel, * Id_CompetenceActuel = t.Id_CompetenceActuel, * Annee = C3.SelectedDate.ToString(), * Actif = this.Actif * * }; * } * else * { * objet = new Competence() * { * Actuel = this.Actuel, * Id_CompetenceActuel =null, * Annee = C3.SelectedDate.ToString(), * Actif = this.Actif * * }; * } * objet.IntituleCompetences.Add(objet2); * //db.Competences.Add(objet); * //db.SaveChanges();*/ using (var db = new BBD_projetEntities()) { var req3 = from c in db.Competences where c.Actuel == true && c.Actif == true select new BO.Competence { Actuel = c.Actuel, IntituleCompetence = c.IntituleCompetences.Where(b => b.Id_Langue == 3 && b.Id_Competence == c.Id_Competence).Select(b => b.intitule).FirstOrDefault(), Annee = c.Annee, Id_Competence = c.Id_Competence, Id_CompetenceActuel = c.Id_CompetenceActuel }; var list = req3.ToList(); foreach (var x in list) { var req = db.IntituleCompetences.Where(b => b.Id_Competence == x.Id_Competence); x.IntituleCompetences = BO.IntituleCompetence.ListDALtoBO(req.ToList()); foreach (var y in x.IntituleCompetences) { System.Diagnostics.Debug.WriteLine("C: " + y.Id_Competence + " L: " + y.Id_Langue); System.Diagnostics.Debug.WriteLine("I: " + y.Intitule + " D: " + y.Description); } } System.Diagnostics.Debug.WriteLine(list[3].IntituleCompetences[0].Intitule); NavigationService nav = Frame.NavigationService; ListViewCompetence l = new ListViewCompetence(); nav.Navigate(new PageConnexion()); } }
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)); } } }