Exemplo n.º 1
0
        public ClasseEtudiant convertEtudiant(etudiant e)
        {
            ClasseEtudiant etu = new ClasseEtudiant();

            etu.Cne     = e.cne;
            etu.Nom     = e.nom;
            etu.Prenom  = e.prenom;
            etu.Filiere = e.Filiere.Nom_filiere;
            try
            {
                etu.Date_naiss = (DateTime)e.date_naiss;
            } catch (Exception ex)
            {
                etu.Date_naiss = new DateTime();
            }

            if (e.sexe.Equals('H'))
            {
                etu.Sexe = Gender.Homme;
            }
            else
            {
                etu.Sexe = Gender.Femme;
            }
            return(etu);
        }
Exemplo n.º 2
0
        private etudiant getEtudiant()
        {
            ClasseEtudiant student = radDataForm1.CurrentItem as ClasseEtudiant;
            var            et      = (from etudiant in db.etudiant
                                      where etudiant.cne == student.Cne
                                      select etudiant).SingleOrDefault();

            return(et);
        }
Exemplo n.º 3
0
        private void Data_DeletingItem(object sender, System.ComponentModel.CancelEventArgs e)
        {
            ClasseEtudiant et = radDataForm1.CurrentItem as ClasseEtudiant;
            var            x  = (from c in db.etudiant
                                 where c.cne == et.Cne
                                 select c).SingleOrDefault();

            db.etudiant.DeleteOnSubmit(x);
            db.SubmitChanges();
        }
Exemplo n.º 4
0
        private ObservableCollection <ClasseEtudiant> CreateEtudiants()
        {
            ProjetDataContext bd = new ProjetDataContext();

            var data = from etudiant in bd.etudiant
                       join filiere in bd.Filiere
                       on etudiant.id_fil equals filiere.Id_filiere
                       select etudiant;

            List <etudiant>       list      = data.ToList();
            List <ClasseEtudiant> etudiants = new List <ClasseEtudiant>();

            foreach (etudiant e in data)
            {
                ClasseEtudiant etu = convertEtudiant(e);
                etudiants.Add(etu);
            }

            ObservableCollection <ClasseEtudiant> etudiantList = new ObservableCollection <ClasseEtudiant>(etudiants);

            return(etudiantList);
        }
Exemplo n.º 5
0
        private void RadDataForm1_AutoGeneratingField(object sender, Telerik.Windows.Controls.Data.DataForm.AutoGeneratingFieldEventArgs e)
        {
            ClasseEtudiant etudiant = this.radDataForm1.CurrentItem as ClasseEtudiant;

            if (e.PropertyName == "Cne")
            {
                e.DataField.Label     = "CNE";
                e.DataField.IsEnabled = false;
            }
            if (e.PropertyName == "Filiere")
            {
                e.DataField.Description = "This is the initial salary!";
                //e.DataField.MouseDoubleClick += new MouseButtonEventHandler(changeFiliere);
                e.DataField.PreviewMouseDoubleClick += new MouseButtonEventHandler(changeFiliere);
            }
            if (etudiant.Sexe == Gender.Femme)
            {
                e.DataField.Foreground = new SolidColorBrush(Colors.Purple);
            }
            else
            {
                e.DataField.Foreground = new SolidColorBrush(Colors.Blue);
            }
        }
Exemplo n.º 6
0
        private void Data_EditEnding(object sender, Telerik.Windows.Controls.Data.DataForm.EditEndingEventArgs e)
        {
            ClasseEtudiant student = radDataForm1.CurrentItem as ClasseEtudiant;

            var x = (from etudiant in db.etudiant
                     join filiere in db.Filiere
                     on etudiant.id_fil equals filiere.Id_filiere
                     where etudiant.cne == student.Cne
                     select etudiant).SingleOrDefault();

            if (x != null)
            {
                x.nom        = student.Nom;
                x.prenom     = student.Prenom;
                x.date_naiss = student.Date_naiss;
                if (student.Sexe == Gender.Femme)
                {
                    x.sexe = 'F';
                }
                else if (student.Sexe == Gender.Homme)
                {
                    x.sexe = 'H';
                }
                else
                {
                    x.sexe = 'X';
                }

                db.SubmitChanges();
            }
            else
            {
                bool           erreur = false;
                ClasseEtudiant item   = radDataForm1.CurrentItem as ClasseEtudiant;
                etudiant       et     = new etudiant();
                et.cne        = item.Cne;
                et.nom        = item.Nom;
                et.prenom     = item.Prenom;
                et.date_naiss = item.Date_naiss;
                if (et.image == null)
                {
                    et.image = "default.png";
                }
                if (student.Sexe == Gender.Femme)
                {
                    et.sexe = 'F';
                }
                else if (student.Sexe == Gender.Homme)
                {
                    et.sexe = 'H';
                }
                else
                {
                    et.sexe = 'X';
                }

                bool find = false;
                int  id   = 0;

                var fil = from f in db.Filiere
                          select f;
                foreach (Filiere f in fil)
                {
                    if (f.Nom_filiere.Equals(item.Filiere))
                    {
                        find = true;
                        id   = f.Id_filiere;
                    }
                }

                if (find)
                {
                    et.id_fil = id;
                }

                else
                {
                    MessageBox.Show("Veuillez Entrer une filiere valide !");
                    erreur = true;
                }

                if (!erreur)
                {
                    db.etudiant.InsertOnSubmit(et);
                    db.SubmitChanges();
                }
            }
        }