Exemple #1
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            if (tbPseudo.Text == "" || tbPassword.Text == "")
            {
                MessageBox.Show("Veuillez compléter tous les champs !");
                return;
            }
            else
            {
                try
                {
                    string pseudo     = tbPseudo.Text;
                    string motdepasse = (SHA.petitsha(tbPassword.Text));

                    MySqlConnection conn = new MySqlConnection(connectBDD);
                    conn.Open();

                    string sql = $"SELECT id, pseudo, motdepasse, lvl FROM utilisateurs WHERE pseudo = '{pseudo}' AND motdepasse = '{motdepasse}'";

                    MySqlCommand    cmd = new MySqlCommand(sql, conn);
                    MySqlDataReader rdr = cmd.ExecuteReader();

                    if (rdr.Read())
                    {
                        lvl = int.Parse(rdr[0].ToString());
                        this.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        MessageBox.Show("Identifians incorrects !");
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemple #2
0
        private void buttonSubmit_Click(object sender, EventArgs e)
        {
            if (tbID.Text == "" || tbNom.Text == "" || tbPrenom.Text == "" || tbPseudo.Text == "" || tbEmail.Text == "" || tbMdp.Text == "")
            {
                MessageBox.Show("Les champs ne doivent pas être vides !");
            }
            else
            {
                try
                {
                    string id         = tbID.Text;
                    string nom        = tbNom.Text;
                    string prenom     = tbPrenom.Text;
                    string pseudo     = tbPseudo.Text;
                    string email      = tbEmail.Text;
                    string motdepasse = (SHA.petitsha(tbMdp.Text));

                    MySqlConnection conn = new MySqlConnection(connectBDD);
                    conn.Open();

                    string sql = $"UPDATE utilisateurs SET nom = '{nom}', prenom  = '{prenom}', pseudo = '{pseudo}', email = '{email}', motdepasse = '{motdepasse}' WHERE id = '{id}' ";

                    MySqlCommand cmd = new MySqlCommand(sql, conn);

                    if (cmd.ExecuteNonQuery() > 0)
                    {
                        MessageBox.Show("Mise à jour de l'utilisateur réussi !");
                        this.DialogResult = DialogResult.Cancel;
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    return;
                }
            }
        }
Exemple #3
0
        private void buttonSubmit_Click(object sender, EventArgs e)
        {
            if (tbNom.Text == "" || tbPrenom.Text == "" || tbPseudo.Text == "" || tbEmail.Text == "" || tbMdp.Text == "")
            {
                MessageBox.Show("Veuillez compléter tous les champs !");
            }
            else
            {
                try
                {
                    string nom        = tbNom.Text;
                    string prenom     = tbPrenom.Text;
                    string pseudo     = tbPseudo.Text;
                    string email      = tbEmail.Text;
                    string motdepasse = (SHA.petitsha(tbMdp.Text));

                    MySqlConnection conn = new MySqlConnection(connectBDD);
                    conn.Open();

                    string sql = $"INSERT INTO utilisateurs (nom, prenom, pseudo, email, motdepasse, date_inscription, heure_inscription, numero_confirmation, confirme, lvl) VALUES ('{nom}', '{prenom}', '{pseudo}', '{email}', '{motdepasse}', CURDATE(), CURTIME(), null, 1, 1) ";

                    MySqlCommand cmd = new MySqlCommand(sql, conn);

                    if (cmd.ExecuteNonQuery() > 0)
                    {
                        MessageBox.Show("Insertion de l'utilisateur réussi !");
                        this.DialogResult = DialogResult.Cancel;
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    return;
                }
            }
        }