private void btnDoiMatKhau_Click_1(object sender, EventArgs e) { if (txtmkcu.Text.Length < 1 || txtmkmoi.Text.Length < 1 || txtnhaplai.Text.Length < 1) { Class.App.InputNotAccess(); return; } if (txtmkmoi.Text != txtnhaplai.Text) { MessageBox.Show("Mật khẩu mới và nhập lại mật khẩu chưa trùng nhau !"); return; } Class.S_TaiKhoan tk = new Class.S_TaiKhoan(); tk.UserName = _tk; tk.Password = Class.S_TaiKhoan.md5(txtmkcu.Text); DataTable ktpasscu = tk.CheckLogin(); if (ktpasscu.Rows.Count > 0) { tk.Password = Class.S_TaiKhoan.md5(txtmkmoi.Text); if (tk.ChangePassword()) { MessageBox.Show("Bạn đã thay đổi Mật khẩu thành công "); this.Close(); } else { MessageBox.Show(" Thay đổi mật khẩu thất bại."); } } else { MessageBox.Show("Mật khẩu cũ không đúng"); } }
private void btnDangNhap_KeyPress(object sender, KeyPressEventArgs e) { if (txtTaiKhoan.Text.Length < 1 || txtMatkhau.Text.Length < 1) { MessageBox.Show("Bạn chưa nhập tài khoản hoặc mật khẩu "); return; } Class.S_TaiKhoan tk = new Class.S_TaiKhoan(); tk.UserName = txtTaiKhoan.Text; tk.Password = Class.S_TaiKhoan.md5(txtMatkhau.Text); try { DataTable dt = tk.CheckLogin(); if (dt.Rows.Count > 0) { // MessageBox.Show(" Đăng nhập thành công !"); if (checkLuuPass.Checked) { Class.RegistryWriter rg = new Class.RegistryWriter(); rg.WriteKey("user_client", txtTaiKhoan.Text); } else { Class.RegistryWriter rg = new Class.RegistryWriter(); rg.WriteKey("user_client", ""); } (this.Owner as frmMain)._taiKhoan = txtTaiKhoan.Text; this.Close(); } else { MessageBox.Show(" Tài khoản hoặc mật khẩu không đúng !"); (this.Owner as frmMain)._taiKhoan = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }