public form_add(form_origin F1) { InitializeComponent(); motherWindow = F1; MySqlConnection cnx; string sCnx; sCnx = String.Format("server=172.16.0.148;uid=AdminRl;database=rallyeLecture;port=3306;pwd=siojjr"); cnx = new MySqlConnection(sCnx); cnx.Open(); string requete = "select id, niveauScolaire from niveau"; MySqlCommand cmd = new MySqlCommand(); cmd.Connection = cnx; cmd.CommandText = requete; cmd.CommandType = System.Data.CommandType.Text; MySqlDataReader rdr; rdr = cmd.ExecuteReader(); while (rdr.Read()) { cb_sclrlvl.Items.Add(rdr.GetString(1)); cb_sclrlvl.ItemHeight = rdr.GetInt32(0); } cb_sclrlvl.DropDownStyle = ComboBoxStyle.DropDownList; cb_sclrlvl.SelectedIndex = 0; cb_csvf.DropDownStyle = ComboBoxStyle.DropDownList; }
private void connexionRL(string usr, string wpa, form_origin motherWindow) { MySqlConnection cnx; string sCnx; sCnx = String.Format("server=172.16.0.148;uid=AdminRl;database=rallyeLecture;port=3306;pwd=siojjr"); cnx = new MySqlConnection(sCnx); try { cnx.Open(); } catch (Exception) { messageError.Text = "Connexion échouée: ne pas rentrer d'identifiant."; } string requete = "select pass from aauth_users inner join aauth_user_to_group on aauth_users.id = aauth_user_to_group.user_id where email ='" + usr + "' and group_id = 5;"; MySqlCommand cmd = new MySqlCommand(); cmd.Connection = cnx; cmd.CommandText = requete; cmd.CommandType = System.Data.CommandType.Text; string hashFromBdd = (string)cmd.ExecuteScalar(); messageError.Text = hashFromBdd; requete = "select id from aauth_users where email ='" + usr + "';"; MySqlCommand cmd2 = new MySqlCommand(); cmd2.Connection = cnx; cmd2.CommandText = requete; cmd2.CommandType = System.Data.CommandType.Text; string idUser = Convert.ToString(cmd2.ExecuteScalar()); if ((idUser != null) && (Hash.GetSha256FromString(wpa, idUser) == hashFromBdd)) { motherWindow.displayTheThing(); this.Hide(); } else { messageError.Text = "Indentifiants invalides"; }; }
public form_auth(form_origin F1) { InitializeComponent(); motherWindow = F1; motherWindow.Hide(); }