Beispiel #1
0
        private void btnChangePassword_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                try
                {
                    int             RowsAffected = 0;
                    BusinessManager bm           = new BusinessManager();
                    BOAddUser       bo           = new BOAddUser();
                    bo.OldPassword = txtOldPassword.Text.Trim();
                    bo.NewPassword = txtNewPassword.Text.Trim();
                    bo.Username    = txtUsername.Text.Trim();

                    RowsAffected = bm.BALChangePassword(bo);
                    if (RowsAffected > 0)
                    {
                        MessageBox.Show("Password successfully changed!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Hide();
                        txtUsername.Text        = "";
                        txtOldPassword.Text     = "";
                        txtNewPassword.Text     = "";
                        txtConfirmPassword.Text = "";
                        frmLogin userlogin = new frmLogin();
                        userlogin.Show();
                        userlogin.txtUsername.Text     = "";
                        userlogin.txtPassword.Text     = "";
                        userlogin.progressBar1.Visible = false;
                        userlogin.txtUsername.Focus();
                    }
                    else
                    {
                        MessageBox.Show("Invalid Username or Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtUsername.Text        = "";
                        txtOldPassword.Text     = "";
                        txtNewPassword.Text     = "";
                        txtConfirmPassword.Text = "";
                        txtOldPassword.Focus();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }