コード例 #1
0
        private void btnDoiMK_Click(object sender, EventArgs e)
        {
            if (txtMKCu.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mật khẩu cũ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtMKCu.Focus();
                return;
            }
            else if (txtMKMoi.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mật khẩu mới", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtMKMoi.Focus();
                return;
            }
            else if (txtMKNhapLai.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập lại mật khẩu mới", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtMKNhapLai.Focus();
                return;
            }
            else if (txtMKNhapLai.Text.Trim() != txtMKMoi.Text.Trim())
            {
                MessageBox.Show("Bạn phải nhập mật khẩu mới và mật khẩu nhập lại giống nhau", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtMKMoi.Focus();
                return;
            }
            else if (txtMKMoi.Text.Trim() == txtMKCu.Text.Trim())
            {
                MessageBox.Show("Bạn phải nhập mật mới khác mật khẩu cũ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtMKMoi.Focus();
                return;
            }
            else
            {
                if (MessageBox.Show("Bạn có chắc muốn đổi mật khẩu", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string matKhauMoi = busNguoiDung.encryption(txtMKMoi.Text);
                    string matKhauCu  = busNguoiDung.encryption(txtMKCu.Text);
                    if (busNguoiDung.DoiMatKhau(stremail, matKhauCu, matKhauMoi))
                    {
                        SendMail(stremail, txtMKNhapLai.Text);
                        MessageBox.Show("Cập nhật mật khẩu thành công, bạn phải đăng nhập lại");
                        this.Close();
                        Form fc = Application.OpenForms["FrmMain"];

                        if (fc != null)
                        {
                            fc.Hide();
                        }

                        FrmDangNhap dn = new FrmDangNhap();
                        dn.Show();
                    }
                }
            }
        }
コード例 #2
0
        private void btnDangXuat_Click(object sender, EventArgs e)
        {
            tuyChon.Close();

            FrmDangNhap dn = new FrmDangNhap();

            dn.Show();

            this.Hide();
        }