1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| try
{
MySqlDataReader reader_verify_user = verify_user.ExecuteReader();
if (reader_verify_user.HasRows)
{
while (reader_verify_user.Read())
{
//u.ID = reader_verify_user.GetInt32(0);
//MessageBox.Show(u.ID.ToString());
//u.Pseudo = reader_verify_user.GetString(1);
//u.Email = reader_verify_user.GetString(3);
ID = reader_verify_user.GetInt32(0);
username = reader_verify_user.GetString(1);
email = reader_verify_user.GetString(3);
date_inscrit = reader_verify_user.GetString(4);
IP = reader_verify_user.GetString(5);
}
reader_verify_user.Close();
conn.Close();
conn.Open();
ip_user.ExecuteNonQuery();
conn.Close();
conn.Open();
MySqlCommand verify_user_connexion = new MySqlCommand("SELECT userid FROM Connexion WHERE userid = '" + ID + "'", conn);
MySqlDataReader reader_user_connexion = verify_user_connexion.ExecuteReader();
if (reader_user_connexion.HasRows)
{
reader_user_connexion.Close();
if (MessageBox.Show("Vous êtes déjà connecter!\nSe reconnecter?", "Server", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
{
MySqlCommand delete_connexion = new MySqlCommand("DELETE FROM Connexion WHERE userid = '" + ID + "'", conn);
try
{
delete_connexion.ExecuteNonQuery();
conn.Close();
}
catch (Exception)
{
throw;
}
}
}
else
{
reader_user_connexion.Close();
conn.Close();
conn.Open();
MySqlCommand insert_connexion = new MySqlCommand("INSERT INTO Connexion(IP, userid, last_connexion) VALUE('" + GetComputer_InternetIP.ToString() + "', '" + ID + "', '" + DateTime.Now.ToString() + "')", conn);
insert_connexion.ExecuteNonQuery();
conn.Close();
this.Hide();
Accueil a = new Accueil(ID, username, email);
a.Show();
}
}
else
{
MessageBox.Show("L'identifiant ou le mot de passe est incorrect!", "Connexion", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
conn.Close();
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
throw;
} |
Partager