Exemplo n.º 1
0
        private void button4_Click(object sender, EventArgs e) // Supprimer [DONE]
        {
            string code;

            code = textBox1.Text;
            if (code == "")
            {
                MessageBox.Show("Entrez le code étudiant pour supprimer un étudiant !");
                return;
            }
            if (!_Getudiant.EtudiantExiste(code))
            {
                MessageBox.Show("cet étudiant n'existe pas !! ");
                return;
            }
            // Supprimer l'étudiant ,
            var selectedoption = MessageBox.Show("Etes vous sure de vouloir supprimer cet étudiant ?", "Confirmation", MessageBoxButtons.YesNo);

            if (selectedoption == DialogResult.No)
            {
                return;
            }
            eleves ee = _Getudiant.RechercherUnEtudiant(code);

            _Getudiant.SupprimerEtudiant(code);
            MessageBox.Show("Étudiant Supprimé ! ");
            InitialiserGrid();
            DeletingInXML dl = new DeletingInXML("D:\\ensat.xml");

            dl.AjouterEleveSupprimerAuFichierXML(ee);
        }
Exemplo n.º 2
0
        public void AjouterEleveSupprimerAuFichierXML(eleves e)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(pathToXmlFile);

            XmlElement ParentNode = doc.CreateElement("Eleve");


            XmlElement codeElev = doc.CreateElement("CodeEleve");

            codeElev.InnerText = e.codeElev;
            XmlElement Nom = doc.CreateElement("Nom");

            Nom.InnerText = e.nom;
            XmlElement Prenom = doc.CreateElement("Prenom");

            Prenom.InnerText = e.prenom;
            XmlElement CodeFilière = doc.CreateElement("CodeFilière");

            CodeFilière.InnerText = e.code_Fil;
            XmlElement niveau = doc.CreateElement("niveau");

            niveau.InnerText = e.niveau;

            ParentNode.AppendChild(codeElev);
            ParentNode.AppendChild(Nom);
            ParentNode.AppendChild(Prenom);
            ParentNode.AppendChild(CodeFilière);
            ParentNode.AppendChild(niveau);

            doc.LastChild.AppendChild(ParentNode);

            doc.Save(pathToXmlFile);
        }
        public List <matieres> RechercheMs(eleves Etu)
        {
            var query = from e in myEntity.matieres
                        where  e.code_Fil == Etu.code_Fil && e.niveau == Etu.niveau
                        select e;

            return(query.ToList <matieres>());
        }
        /*    public static Etudiant RechercheE(string code)
         *  {
         *      using (MySqlConnection cnx = gestionConnection.getConnection())
         *      {
         *
         *          Etudiant E = new Etudiant();
         *          // the state of my connection was closed sometimes so i added this line
         *          if (cnx.State == System.Data.ConnectionState.Closed)
         *          {
         *              cnx.Open();
         *          }
         *          MySqlCommand cmd = new MySqlCommand();
         *          cmd.CommandText = "select * from eleves where codeElev='" + code + "';";
         *
         *          cmd.Connection = cnx;
         *          Console.WriteLine(cnx.State);
         *          if (cnx.State == System.Data.ConnectionState.Closed)
         *          {
         *              cnx.Open();
         *          }
         *          MySqlDataReader rd = cmd.ExecuteReader();
         *          E.Code = code;
         *          while (rd.Read())
         *          {
         *              E.Nom = rd[1].ToString();
         *              E.Prenom = rd[2].ToString();
         *              E.Niveau = rd[3].ToString();
         *              E.Code_Fil = rd[4].ToString();
         *          }
         *
         *
         *          return E;
         *      }
         *  }*/
        public List <eleves> RechercheE(eleves Etu)
        {
            var query = from e in myEntity.eleves
                        where e.codeElev.Contains(Etu.codeElev) && e.nom.Contains(Etu.nom) &&
                        e.prenom.Contains(Etu.prenom) && e.code_Fil.Contains(Etu.code_Fil) &&
                        e.niveau.Contains(Etu.niveau)
                        select e;

            return(query.ToList <eleves>());
        }
        public void SupprimerEtudiant(string code)
        {
            var query = from e in myEntity.eleves
                        where e.codeElev == code
                        select e;
            eleves elevesup = query.FirstOrDefault <eleves>();

            myEntity.eleves.Remove(elevesup);
            myEntity.SaveChanges();
        }
 public ComboBoxModif(eleves e)
 {
     InitializeComponent();
     _Getudiant = new GererEtudiant();
     this.codeE=label2.Text = e.codeElev;
     textBox1.Text = e.nom;
     textBox2.Text = e.prenom;
     comboBox1.Text = e.code_Fil;
     textBox3.Text = e.niveau;
 }
        public void UpdateE(eleves e)
        {
            var eleveToUpdate = from elv in myEntity.eleves
                                where elv.codeElev == e.codeElev
                                select elv;

            eleveToUpdate.FirstOrDefault().code_Fil = e.code_Fil;
            eleveToUpdate.FirstOrDefault().nom      = e.nom;
            eleveToUpdate.FirstOrDefault().prenom   = e.prenom;
            eleveToUpdate.FirstOrDefault().niveau   = e.niveau;

            myEntity.SaveChanges();
        }
Exemplo n.º 8
0
        private void button2_Click(object sender, EventArgs e) //Ajouter Etudiant
        {
            string nom, prenom, code, niveau, fili;
            eleves E = new eleves();

            code   = textBox1.Text;
            nom    = textBox2.Text;
            prenom = textBox3.Text;
            fili   = comboBox1.Text;
            niveau = comboBox2.Text;

            //I need to check if all textboxes are full
            foreach (Control x in this.Controls)
            {
                if (x is TextBox)
                {
                    if (((TextBox)x).Text == String.Empty)
                    {
                        MessageBox.Show("Tous les champs doivent être remplies");
                        return;
                    }
                }
                if (x is ComboBox)
                {
                    if (((ComboBox)x).Text == String.Empty)
                    {
                        MessageBox.Show("Tous les champs doivent être remplies");
                        return;
                    }
                }
            }

            // i still need to check if the primary key exist
            if (_service.EtudiantExiste(code))
            {
                MessageBox.Show("Ce code etudiant existe déjà , impossible d'ajouter");
                return;
            }
            E.codeElev = code;
            E.niveau   = niveau;
            E.nom      = nom;
            E.prenom   = prenom;
            E.code_Fil = fili;

            // GererEtudiant.AjouterEtudiant(E);
            _service.AddEtudiant(E);
            MessageBox.Show("Etudiant Insérer");
            SupprimerTtChamps();
            InitialiserGrid();
        }
Exemplo n.º 9
0
        public Form2(eleves E)
        {
            InitializeComponent();
            this.E      = E;
            _Gmatières  = new GererMatieres();
            _Gnotes     = new GererNotes();
            label4.Text = E.codeElev;
            List <matieres> Listmat = _Gmatières.RechercheMs(E);

            foreach (matieres dr in Listmat)
            {
                comboBox1.Items.Add(dr.codeMat);
            }
            InitialiserGrid();
        }
Exemplo n.º 10
0
        private void button3_Click(object sender, EventArgs e) // Modifier
        {
            DataGridViewCell d    = dataGridView1.SelectedCells[0];
            string           code = d.Value.ToString();

            if (code == "")
            {
                MessageBox.Show("Sélectionnez un étudiant pour le modifier");
                return;
            }
            eleves        eleve = _Getudiant.RechercherUnEtudiant(code);
            ComboBoxModif frm   = new ComboBoxModif(eleve);

            frm.Show();
        }
Exemplo n.º 11
0
        private void button5_Click(object sender, EventArgs e) // Rechercher
        {
            string code   = "";
            string nom    = "";
            string prenom = "";
            string fili   = "";
            string niveau = "";

            if (!checkBox5.Checked && !checkBox4.Checked && !checkBox3.Checked && !checkBox2.Checked && !checkBox1.Checked)
            {
                MessageBox.Show("Choisissez un critère de recherche et entrez sa valeur !");
                return;
            }
            if (checkBox1.Checked)
            {
                code = textBox1.Text;
            }
            if (checkBox2.Checked)
            {
                nom = textBox2.Text;
            }
            if (checkBox3.Checked)
            {
                prenom = textBox3.Text;
            }
            if (checkBox4.Checked)
            {
                fili = comboBox1.Text;
            }
            if (checkBox5.Checked)
            {
                niveau = comboBox2.Text;
            }


            eleves E = new eleves();

            E.codeElev = code;
            E.nom      = nom;
            E.prenom   = prenom;
            E.code_Fil = fili;
            E.niveau   = niveau;
            List <eleves> listE = _Getudiant.RechercheE(E);


            dataGridView1.DataSource = listE;
        }
Exemplo n.º 12
0
        private void button6_Click(object sender, EventArgs e) // gestion des notes
        {
            DataGridViewCell d0 = dataGridView1.SelectedCells[0];


            string code = d0.Value.ToString();

            if (code == "")
            {
                MessageBox.Show("Sélectionnez un étudiant pour le modifier");
                return;
            }
            eleves Eleve = _Getudiant.RechercherUnEtudiant(code);// we need etudiant with that code
            Form2  frm2  = new Form2(Eleve);

            frm2.Show();
        }
Exemplo n.º 13
0
        private void button3_Click(object sender, EventArgs e)
        {
            //I need to check if all textboxes are full 
            foreach (Control x in this.Controls)
            {
                if (x is TextBox)
                {
                    if (((TextBox)x).Text == String.Empty)
                    {
                        MessageBox.Show("Tous les champs doivent être remplies");
                        return;
                    }

                }
                if (x is ComboBox)
                {
                    if (((ComboBox)x).Text == String.Empty)
                    {
                        MessageBox.Show("Tous les champs doivent être remplies");
                        return;
                    }

                }
            }

            // Now i need to update 
            eleves et1 = new eleves();
            et1.codeElev = this.codeE;
            et1.nom = textBox1.Text;
            et1.prenom = textBox2.Text;
            et1.code_Fil = comboBox1.Text;
            et1.niveau = textBox3.Text;
            _Getudiant.UpdateE(et1);
            MessageBox.Show("Etudiant Modifié");
            this.Close();
            

        }
Exemplo n.º 14
0
 public void AddEtudiant(eleves E)
 {
     _context.eleves.Add(E);
     _context.SaveChanges();
 }
Exemplo n.º 15
0
 public void AjouterEtudiant(eleves e)
 {
     myEntity.eleves.Add(e);
     myEntity.SaveChanges();
 }