Ejemplo n.º 1
0
        public static Etudiant RechercheE(string code)
        {
            using (MySqlConnection cnx = gestionConnection.getConnection())
            {
                Console.WriteLine("wssalt l hna 1 ");
                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();
                }
                Console.WriteLine("wssalt l hna 2 ");

                return(E);
            }
        }
Ejemplo n.º 2
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
            Etudiant et1 = new Etudiant();

            et1.Code     = this.codeE;
            et1.Nom      = textBox1.Text;
            et1.Prenom   = textBox2.Text;
            et1.Code_Fil = comboBox1.Text;
            et1.Niveau   = textBox3.Text;
            GererEtudiant.UpdateE(et1);
            MessageBox.Show("Etudiant Modifié");
            this.Close();
        }
Ejemplo n.º 3
0
 public ComboBoxModif(Etudiant e)
 {
     InitializeComponent();
     this.codeE     = label2.Text = e.Code;
     textBox1.Text  = e.Nom;
     textBox2.Text  = e.Prenom;
     comboBox1.Text = e.Code_Fil;
     textBox3.Text  = e.Niveau;
 }
Ejemplo n.º 4
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;
            }
            Etudiant      et  = GererEtudiant.RechercheE(code);
            ComboBoxModif frm = new ComboBoxModif(et);

            frm.Show();
        }
Ejemplo n.º 5
0
        public Form2(Etudiant E)
        {
            InitializeComponent();
            this.E      = E;
            label4.Text = E.Code;
            MySqlDataAdapter sqlDa    = GererMatieres.RechercheMs(E);
            DataTable        Matières = new DataTable("Matières");

            sqlDa.Fill(Matières);
            foreach (DataRow dr in Matières.Rows)
            {
                comboBox1.Items.Add(dr[0].ToString());
            }
            InitialiserGrid();
        }
Ejemplo n.º 6
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;
            }
            Etudiant E    = GererEtudiant.RechercheE(code);// we need etudiant with that code
            Form2    frm2 = new Form2(E);

            frm2.Show();
        }
Ejemplo n.º 7
0
        private void button5_Click(object sender, EventArgs e) // Rechercher
        {
            MySqlDataAdapter sqlDa  = null;
            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;
            }


            Etudiant E = new Etudiant(code, nom, prenom, niveau, fili);

            sqlDa = GererEtudiant.RechercheE(E);

            DataTable tbl = new DataTable();

            sqlDa.Fill(tbl);

            dataGridView1.DataSource = tbl;
        }
Ejemplo n.º 8
0
        public static void AjouterEtudiant(Etudiant e)
        {
            using (MySqlConnection cnx = gestionConnection.getConnection())
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "insert into eleves values('" + e.Code + "','" + e.Nom + "','" + e.Prenom + "','" + e.Niveau + "','" + e.Code_Fil + "');";

                cmd.Connection = cnx;
                Console.WriteLine(cnx.State);
                if (cnx.State == System.Data.ConnectionState.Closed)
                {
                    cnx.Open();
                }

                cmd.ExecuteNonQuery();
            }
        }
Ejemplo n.º 9
0
        public static void UpdateE(Etudiant e)
        {
            using (MySqlConnection cnx = gestionConnection.getConnection())
            {
                // 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 = "update eleves set nom='" + e.Nom + "',prenom='" + e.Prenom + "',niveau='" + e.Niveau + "'" +
                                  ",code_Fil='" + e.Code_Fil + "' where codeElev='" + e.Code + "';";

                cmd.Connection = cnx;
                Console.WriteLine(cnx.State);
                if (cnx.State == System.Data.ConnectionState.Closed)
                {
                    cnx.Open();
                }
                cmd.ExecuteNonQuery();
            }
        }
Ejemplo n.º 10
0
        public static MySqlDataAdapter RechercheE(Etudiant Etu)
        {
            using (MySqlConnection cnx = gestionConnection.getConnection())
            {
                string codE = Etu.Code;
                string NomE = Etu.Nom;
                //  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 like '%" + Etu.Code + "%'" +
                                  " and nom like '%" + Etu.Nom + "%' and prenom like '%" + Etu.Prenom +
                                  "%' and code_Fil like '%" + Etu.Code_Fil + "%' and niveau like '%" + Etu.Niveau + "%'; ";

                cmd.Connection = cnx;
                Console.WriteLine(cnx.State);
                if (cnx.State == System.Data.ConnectionState.Closed)
                {
                    cnx.Open();
                }
                MySqlDataAdapter dtadapter = new MySqlDataAdapter(cmd.CommandText, cnx);
                //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(dtadapter);
            }
        }
        public static MySqlDataAdapter RechercheMs(Etudiant Etu)
        {
            using (MySqlConnection cnx = gestionConnection.getConnection())
            {
                // 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 matieres where niveau like '%" + Etu.Niveau + "%'" +
                                  " and code_Fil like '%" + Etu.Code_Fil + "%' ; ";

                cmd.Connection = cnx;
                Console.WriteLine(cnx.State);
                if (cnx.State == System.Data.ConnectionState.Closed)
                {
                    cnx.Open();
                }
                MySqlDataAdapter dtadapter = new MySqlDataAdapter(cmd.CommandText, cnx);

                return(dtadapter);
            }
        }