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 static IntituleCompetence DALtoBO(DAL.IntituleCompetence dal)
        {
            IntituleCompetence Bo = new IntituleCompetence(dal);

            return(Bo);
        }