예제 #1
0
        public void MoveToRegister()
        {
            BLRegister register = new BLRegister();

            App.Current.MainWindow = register;
            register.Show();
        }
        public static void UpdatePassword(string sqlString, string username, string password)
        {
            MySqlConnection conn = new MySqlConnection(connStr);

            try {
                conn.Open();
                string       sql   = sqlString;
                string       passW = BLRegister.EncryptPassword(password);
                MySqlCommand cmd   = new MySqlCommand(sql, conn);
                cmd.Prepare();
                cmd.Parameters.AddWithValue("@USERNAME", username);
                cmd.Parameters.AddWithValue("@PASSWORD", passW);
                cmd.ExecuteNonQuery();
            } catch (Exception ex) {
                throw ex;
            }
        }
예제 #3
0
        private void btnRegister_Click(object sender, RoutedEventArgs e)
        {
            string username   = txtUsername.Text;
            string password   = txtPassword.Password;
            string repassword = txtReEnterPassword.Password;
            string message    = "";

            validator = new Validator();

            try {
                if (validator.ValidateRegister(username, password, repassword))
                {
                    BLRegister register = new BLRegister(username, password);
                    if (register.RegisterUser(out message))
                    {
                        shutdown = false;
                        handler.MoveToLogin();
                        this.Close();
                        MessageBox.Show("Registration was successful!", "Registration Music Database");
                    }
                    else
                    {
                        txtUsername.Text            = "";
                        txtPassword.Password        = "";
                        txtReEnterPassword.Password = "";
                        txtUsername.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("Valid username: 5-20 characters.\nValid password: 8-20 characters.\nNo special characters.\nPasswords must match.", "Registration Music Database");
                    txtUsername.Text            = "";
                    txtPassword.Password        = "";
                    txtReEnterPassword.Password = "";
                    txtUsername.Focus();
                }
            } catch (Exception ex) {
                message = ex.Message;
            } finally {
                if (message != "")
                {
                    MessageBox.Show(message, "Registration Music Database");
                }
            }
        }