Exemplo n.º 1
0
        public void updateAgent(ClassAgent ag)
        {
            InitializeConnection();
            try
            {
                string q = "update agent set nom=@nom,postnom=@postnom,prenom=@prenom,adresse=@adresse,email=@email,tel=@tel,solde=@solde,password=@password where matricule=@matricule";
                cmd = new MySqlCommand(q, con);
                cmd.Parameters.Add(new MySqlParameter("@matricule", ag.Matricule));
                cmd.Parameters.Add(new MySqlParameter("@nom", ag.Nom));
                cmd.Parameters.Add(new MySqlParameter("@postnom", ag.Postnom));
                cmd.Parameters.Add(new MySqlParameter("@prenom", ag.Prenom));
                cmd.Parameters.Add(new MySqlParameter("@adresse", ag.Adresse));
                cmd.Parameters.Add(new MySqlParameter("@email", ag.Email));
                cmd.Parameters.Add(new MySqlParameter("@tel", ag.Tel));
                cmd.Parameters.Add(new MySqlParameter("@solde", ag.Solde));
                cmd.Parameters.Add(new MySqlParameter("@password", ag.Password));

                if (cmd.ExecuteNonQuery() == 1)
                {
                    //MessageBox.Show("Modification effectuee avec succes!!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                cmd.Dispose();
                con.Close();
            }
        }
Exemplo n.º 2
0
        public void deleteAgent(ClassAgent ag)
        {
            InitializeConnection();
            try
            {
                string q = "delete from agent where matricule=@matricule";
                cmd = new MySqlCommand(q, con);
                cmd.Parameters.Add(new MySqlParameter("@matricule", ag.Matricule));


                DialogResult result = MessageBox.Show("Voulez-vous vraiment excuter cette operation ?", "Suppression", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result == DialogResult.Yes)
                {
                    if (cmd.ExecuteNonQuery() == 1)
                    {
                        MessageBox.Show("Suppression avec succes!!");
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }
            finally
            {
                cmd.Dispose();
                con.Close();
            }
        }
Exemplo n.º 3
0
 public void insertAgent(ClassAgent ag)
 {
     InitializeConnection();
     try
     {
         string q = "insert into agent(matricule,nom,postnom,prenom,adresse,email,tel,solde,password) values(@matricule,@nom,@postnom,@prenom,@adresse,@email,@tel,@solde,@password)";
         cmd = new MySqlCommand(q, con);
         cmd.Parameters.Add(new MySqlParameter("@matricule", ag.Matricule));
         cmd.Parameters.Add(new MySqlParameter("@nom", ag.Nom));
         cmd.Parameters.Add(new MySqlParameter("@postnom", ag.Postnom));
         cmd.Parameters.Add(new MySqlParameter("@prenom", ag.Prenom));
         cmd.Parameters.Add(new MySqlParameter("@adresse", ag.Adresse));
         cmd.Parameters.Add(new MySqlParameter("@email", ag.Email));
         cmd.Parameters.Add(new MySqlParameter("@tel", ag.Tel));
         cmd.Parameters.Add(new MySqlParameter("@solde", ag.Solde));
         cmd.Parameters.Add(new MySqlParameter("@password", ag.Password));
         if (cmd.ExecuteNonQuery() == 1)
         {
             MessageBox.Show("Insertion effectuee avec succes!!");
         }
     }
     catch (Exception ex)
     {
         //MessageBox.Show(ex.Message);
     }
     finally
     {
         cmd.Dispose();
         con.Close();
     }
 }