Exemplo n.º 1
0
        private void btnokdoipass_Click(object sender, EventArgs e)
        {
            string username  = txtsuausename.Text;
            string oldpass   = txtmkcu.Text;
            string password1 = txtmkmoi.Text;
            string password2 = txtNhapLaiMK.Text;

            if (string.IsNullOrEmpty(username))
            {
                MessageBox.Show("Tên tài khoản không được để trống");
                txtsuausename.Focus();
                return;
            }
            if (string.IsNullOrEmpty(oldpass) || string.IsNullOrEmpty(password1) || string.IsNullOrEmpty(password2))
            {
                MessageBox.Show("Password không được để trống");
                txtmkcu.Focus();
                return;
            }
            if (!password1.Equals(password2))
            {
                MessageBox.Show("Password không trùng khớp");
                txtmkmoi.Focus();
                return;
            }

            TaiKhoan old      = new TaiKhoan(username, oldpass, -1);
            TaiKhoan taiKhoan = new TaiKhoan(username, password1, 0);

            if (taiKhoanBUS.DoiPassword(old, taiKhoan))
            {
                MessageBox.Show("Thành công");
                txtmkcu.ResetText();
                txtmkmoi.ResetText();
                txtNhapLaiMK.ResetText();
            }
            else
            {
                MessageBox.Show("Lỗi");
            }
            txtmkcu.Focus();
        }