public void insert(Eleve eleve) { using (MySqlConnection cnx = DaoConnectionSingleton.GetMySqlConnection()) { cnx.Open(); using (MySqlCommand cmd = new MySqlCommand("insert into eleve(nom,prenom,login) values(@nom,@prenom,@login)", cnx)) { cmd.Parameters.Add(new MySqlParameter("@nom", MySqlDbType.VarChar)); cmd.Parameters["@nom"].Value = eleve.GetNom(); cmd.Parameters.Add(new MySqlParameter("@prenom", MySqlDbType.VarChar)); cmd.Parameters["@prenom"].Value = eleve.GetPrenom(); cmd.Parameters.Add(new MySqlParameter("@login", MySqlDbType.VarChar)); cmd.Parameters["@login"].Value = eleve.GetLogin(); cmd.ExecuteNonQuery(); } using (MySqlCommand cmd = new MySqlCommand("insert into aauth_users(email,pass,username) values(@email,@pass,@username)", cnx)) { Hash a = new Hash(); cmd.Parameters.Add(new MySqlParameter("@email", MySqlDbType.VarChar)); cmd.Parameters["@email"].Value = eleve.GetNom() + eleve.GetPrenom().Substring(0, 1) + "@sio.jjr.fr"; cmd.Parameters.Add(new MySqlParameter("@pass", MySqlDbType.VarChar)); cmd.Parameters["@pass"].Value = a.GetHashPassword(/*IdUser(eleve)+*/ eleve.GetPassWord()); cmd.Parameters.Add(new MySqlParameter("@username", MySqlDbType.VarChar)); cmd.Parameters["@username"].Value = eleve.GetPrenom().Substring(0, 1) + eleve.GetNom(); cmd.ExecuteNonQuery(); } cnx.Close(); } }
public static MySqlConnection GetMySqlConnection() { if (DaoConnectionSingleton.mySqlConnection == null) { DaoConnectionSingleton.mySqlConnection = new MySqlConnection(DaoConnectionSingleton.GetStringConnection()); } return(DaoConnectionSingleton.mySqlConnection); }
public int select(Eleve eleve) { using (MySqlConnection cnx = DaoConnectionSingleton.GetMySqlConnection()) { cnx.Open(); using (MySqlCommand requeteRecup = new MySqlCommand("select idAuth from eleve where login = @ans", cnx)) { requeteRecup.Parameters.Add(new MySqlParameter("@ans", MySqlDbType.VarChar)); requeteRecup.Parameters["@ans"].Value = eleve.GetLogin(); MySqlDataReader reader = requeteRecup.ExecuteReader(); return((int)reader["id"]); } } }
public void insert(Classe classe) { using (MySqlConnection cnx = DaoConnectionSingleton.GetMySqlConnection()) { cnx.Open(); using (MySqlCommand cmd = new MySqlCommand("insert into classe(anneeScolaire,idNiveau) values(@annéeScolaire,@idNiveau)", cnx)) { //cmd.Parameters.Add(new MySqlParameter("@idEnseignant", MySqlDbType.Int32)); //cmd.Parameters["@idEnseignant"].Value = classe.GetIdEnseignant(); cmd.Parameters.Add(new MySqlParameter("@annéeScolaire", MySqlDbType.VarChar)); cmd.Parameters["@annéeScolaire"].Value = classe.GetAnneeScolaire(); cmd.Parameters.Add(new MySqlParameter("@idNiveau", MySqlDbType.Int32)); cmd.Parameters["@idNiveau"].Value = classe.GetIdNiveau(); cmd.ExecuteNonQuery(); } } }
public List <Niveau> GetAll() { List <Niveau> niveau = new List <Niveau>(); using (MySqlConnection cnx = DaoConnectionSingleton.GetMySqlConnection()) { cnx.Open(); using (MySqlCommand cmd = new MySqlCommand("select id,niveauScolaire from niveau", cnx)) { using (MySqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { niveau.Add(new Niveau(Convert.ToInt32(rdr["id"]), rdr["niveauScolaire"].ToString())); } } } } return(niveau); }
public List <Enseignant> GetAll() { List <Enseignant> login = new List <Enseignant>(); using (MySqlConnection cnx = DaoConnectionSingleton.GetMySqlConnection()) { cnx.Open(); using (MySqlCommand cmd = new MySqlCommand("select * from enseignant", cnx)) { using (MySqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { login.Add(new Enseignant(rdr["nom"].ToString(), rdr["prenom"].ToString(), rdr["login"].ToString(), Convert.ToInt32(rdr["idAuth"]))); } } } } return(login); }