Exemple #1
0
        private void btnSuaUser_Click(object sender, EventArgs e)
        {
            string username    = this.txtUsername.Text;
            string tenHienThi  = this.txtTenHienThi.Text;
            string passwordcu  = this.txtPassword.Text;
            string passwordMoi = this.txtPasswordMoi.Text;
            string nhapLaiPass = this.txtNhapLaiPassword.Text;

            if (thayDoi)
            {
                if (!string.IsNullOrEmpty(passwordMoi) || !string.IsNullOrEmpty(nhapLaiPass))
                {
                    DoiMatKhau(username, tenHienThi, passwordcu, passwordMoi, nhapLaiPass);
                }
            }
            else
            {
                try
                {
                    if (tenHienThi == "" || passwordcu == "")
                    {
                        MessageBox.Show("Không dược để trống!", "Thông báo");
                    }
                    else
                    {
                        if (KiemTraPass(username, passwordcu) == true)
                        {
                            if (AccountDAL.Instance.SuaTaiKhoan(username, passwordcu, tenHienThi, filename))
                            {
                                MessageBox.Show("Cập nhật tài khoản thành công !", "Thông báo");
                                formTrangChu.fileNameUser = filename;
                                formTrangChu f = new formTrangChu();
                                f.LoadAvatar();
                            }
                            else
                            {
                                MessageBox.Show("Cập nhật tài khoản không thành công! Xin kiểm tra lại.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Password không đúng");
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            //Đổi mật khẩu
        }
Exemple #2
0
        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            string username = txtUsername.Text;
            string password = txtPassword.Text;

            if (DangNhapHienTai(username, password) == true)
            {
                Account accLogin = AccountDAL.Instance.LayTaiKhoanDangNhap(username);
                formHome.thuNgan         = username;
                formUser.TaiKhoanHienTai = accLogin;
                formTrangChu fTrangChu = new formTrangChu(accLogin);
                this.Hide();
                fTrangChu.ShowDialog();
            }
            else
            {
                MessageBox.Show("Username hoặc password không đúng!");
            }
        }