Ejemplo n.º 1
0
        private void btthaydoi_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtMatKhaucu.Text.Trim() != DangNhap.strMatKhau.Trim())
                {
                    throw new Exception("Mật khẩu hiện tại không đúng!!!");
                }

                if (txtMatKhaumoi.Text != txtnhaplai.Text)
                {
                    throw new Exception("Mật khẩu nhập lại không khớp với mật khẩu mới");
                }

                if (NhanVien.DoiMatKhau(DangNhap.idNhanVien, txtMatKhaumoi.Text) == true)
                {
                    MessageBox.Show("Đã hoàn thành việc thay đôi mật khẩu", "Thông báo");
                    btnThoat_Click(this, e);
                }

                else
                {
                    MessageBox.Show("Việc thay đổi đã bị lỗi hãy thử lại sau", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Question);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        private void btnDoiMatKhau_Click(object sender, EventArgs e)
        {
            string oldpassword = tboxOldPassword.Text.Trim().ToString();
            string newpassword = tBoxNewPassword.Text.Trim().ToString();
            string confirmpass = tboxConfirmPassword.Text.Trim().ToString();
            string errors      = "Có 1 số lỗi sau :";
            int    noError     = 0;

            if (oldpassword == "" || newpassword == "" || confirmpass == "")
            {
                errors += "\r\n Có trường nào bạn đã để trống";
                noError++;
            }
            if (oldpassword != Access.PASSWORD)
            {
                errors += "\r\n Mật khẩu cũ bạn nhập không chính xác";
                noError++;
            }
            if (newpassword != confirmpass)
            {
                errors += "\r\n Mật khẩu mới và mật khẩu xác nhận không giống nhau";
                noError++;
            }

            if (noError > 0)
            {
                MessageBox.Show(errors);
                return;
            }
            else
            {
                NhanVien nvien = new NhanVien();
                string[] param = { oldpassword, newpassword, Access.USERNAME };

                int a = nvien.DoiMatKhau(param);
                if (a == 0)
                {
                    MessageBox.Show("Đổi mật khẩu thành công");
                    Access.PASSWORD          = newpassword;
                    tboxOldPassword.Text     = "";
                    tBoxNewPassword.Text     = "";
                    tboxConfirmPassword.Text = "";
                }
                else
                {
                    MessageBox.Show("Đổi mật khẩu thất bại");
                }
            }
        }