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(); } }
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(); } }
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(); } }