// bouton pour supprimer une voiture sélectionnée

        private void btn_remv_etu_Click(object sender, EventArgs e)
        {
            //int ind = DG_Student.CurrentRow.Index;

            //string mypath = "imgStudent/" + DG_Student[0, ind].Value.ToString() + ".jpg";
            //if (File.Exists(mypath))
            //{
            //    File.Delete(mypath);
            //}
            EtudientADO.Supprimer(Id_Etud.Text);
            Affiche_Etud();
        }
        // Bouton Recherche de voiture par Immatriculation ou par Marque

        private void btn_srch_etud_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Id_Etud.Text))
            {
                Etudient E = EtudientADO.Recherche_Code(Id_Etud.Text);
                if (E != null)
                {
                    Id_Etud.Text      = E.num_Etud;
                    nom_etud.Text     = E.nom;
                    pren_etud.Text    = E.prenom;
                    group_etud.Text   = E.Groupe;
                    tel_etud.Text     = E.tel;
                    genre_etud.Text   = E.Genre;
                    dt_insc_etud.Text = E.date_insc;
                    dt_Fin_Etud.Text  = E.date_PFE;

                    int ind = DG_Student.CurrentRow.Index;

                    string mypath = "imgStudent/" + DG_Student[0, ind].Value.ToString() + ".jpg";
                    if (File.Exists(mypath))
                    {
                        img_etud.Image = Image.FromFile(mypath);
                    }

                    DG_Student.Rows.Clear();

                    DG_Student.Rows.Add(E.num_Etud, E.nom, E.prenom, E.Groupe, E.tel, E.Genre, E.date_insc, E.date_PFE);
                }
                else
                {
                    MessageBox.Show("Aucune Etudient trouvée", "attention");
                }
            }
            else
            if (!string.IsNullOrEmpty(nom_etud.Text))
            {
                List <Etudient> l = EtudientADO.Recherche_Nom(nom_etud.Text);
                if (l.Count > 0)
                {
                    DG_Student.Rows.Clear();
                    foreach (var E in l)
                    {
                        DG_Student.Rows.Add(E.num_Etud, E.nom, E.prenom, E.Groupe, E.tel, E.Genre, E.date_insc, E.date_PFE);
                    }
                }
                else
                {
                    MessageBox.Show("Aucune Etudient trouvée");
                }
            }
        }
        private void Affiche_Etud()
        {
            LE = EtudientADO.List_Etudient();
            DG_Student.Rows.Clear();


            if (LE != null)
            {
                foreach (Etudient E in LE)
                {
                    DG_Student.Rows.Add(E.num_Etud, E.nom, E.prenom, E.Groupe, E.tel, E.Genre, E.date_insc, E.date_PFE);
                }
            }
        }
示例#4
0
        // bouton pour modifier un enseignant sélectionnée
        // Bouton Recherche d'un enseignant par code

        private void btn_srch_ens_Click_1(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Id_Ens.Text))
            {
                Enseignant E = EnseignantADO.Recherche_Code(Id_Ens.Text);
                if (E != null)
                {
                    Id_Ens.Text      = E.num_Ens;
                    nom_ens.Text     = E.nom;
                    pren_ens.Text    = E.prenom;
                    email_ens.Text   = E.email;
                    special_ens.Text = E.speciality;
                    tel_ens.Text     = E.telephone;
                    grade.Text       = E.grade;
                    dep.Text         = E.department;

                    DG_Prof.Rows.Clear();

                    DG_Prof.Rows.Add(E.num_Ens, E.nom, E.prenom, E.email, E.speciality, E.telephone, E.grade, E.department);
                }
                else
                {
                    MessageBox.Show("Aucune Enseignant trouvée", "attention");
                }
            }
            else
            if (!string.IsNullOrEmpty(nom_ens.Text))
            {
                List <Etudient> l = EtudientADO.Recherche_Nom(nom_ens.Text);
                if (l.Count > 0)
                {
                    DG_Prof.Rows.Clear();
                    foreach (var E in l)
                    {
                        DG_Prof.Rows.Add(E.num_Etud, E.nom, E.prenom, E.Groupe, E.tel, E.Genre, E.date_insc, E.date_PFE);
                    }
                }
                else
                {
                    MessageBox.Show("Aucune Enseignant trouvée");
                }
            }
        }
        // Bouton pour Enregistrer une nouvel Etudient dans la base de données

        private void btn_add_etu_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Id_Etud.Text))
            {
                MessageBox.Show("saisir L'Identifient de l'Etudient !");
            }

            else
            {
                Etudient E = new Etudient
                {
                    num_Etud  = Id_Etud.Text,
                    nom       = nom_etud.Text,
                    prenom    = pren_etud.Text,
                    Groupe    = group_etud.Text,
                    tel       = tel_etud.Text,
                    Genre     = genre_etud.Text,
                    date_insc = dt_insc_etud.Text,
                    date_PFE  = dt_Fin_Etud.Text,
                };
                Etudient E1 = EtudientADO.Recherche_Code(Id_Etud.Text);

                if (E1 == null)
                {
                    if (!Directory.Exists("imgStudent"))
                    {
                        Directory.CreateDirectory("imgStudent");
                    }
                    img_etud.Image.Save("imgStudent/" + Id_Etud.Text + ".jpg");



                    EtudientADO.Ajouter(E);
                    Affiche_Etud();
                    img_etud.Image = new PictureBox().Image;
                }
                else
                {
                    MessageBox.Show("Cet étudient existe dejà");
                }
            }
        }
        // bouton pour modifier une voiture sélectionnée

        private void btn_edit_etu_Click(object sender, EventArgs e)
        {
            Etudient E = new Etudient
            {
                num_Etud  = Id_Etud.Text,
                nom       = nom_etud.Text,
                prenom    = pren_etud.Text,
                Groupe    = group_etud.Text,
                tel       = tel_etud.Text,
                Genre     = genre_etud.Text,
                date_insc = dt_insc_etud.Text,
                date_PFE  = dt_Fin_Etud.Text,
            };



            EtudientADO.Modifier(E);
            Affiche_Etud();
            img_etud.Image = new PictureBox().Image;
        }