示例#1
0
        private void openDB()
        {
            using (MySqlConnection connection = new MySqlConnection(DatabaseConnection.connectionString))
            {
                connection.Open();
                try
                {
                    string query = "SELECT password, MD5(tempopw) AS hashedTempo FROM " + DatabaseConnection.UsersTable + " WHERE loginid = @id;";
                    command = new MySqlCommand(query, connection);
                    command.Parameters.AddWithValue("@id", loginid);
                    reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        password    = reader["password"].ToString();
                        hashedTempo = reader["hashedTempo"].ToString();
                    }

                    reader.Close();
                    command.Dispose();

                    if (password == hashedTempo)
                    {
                        MessageBox.Show("It seems you haven't changed your password yet. Please change your password first.", "Temporary Password Detected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        frmChangePassword frmChangePassword = new frmChangePassword();
                        frmChangePassword.ShowDialog();
                    }
                    else
                    {
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                connection.Close();
            }
        }
示例#2
0
        private void btnChangePassword_Click(object sender, EventArgs e)
        {
            frmChangePassword frmChangePassword = new frmChangePassword();

            frmChangePassword.ShowDialog();
        }