private void btnDangNhap_Click(object sender, EventArgs e) { nd.TaiKhoan = txtTaiKhoan.Text; nd.MatKhau = txtMatKhau.Text; nd.PhanQuyen = cmbQuyen.Text; if (txtTaiKhoan.Text == "") { lblNoName.Text = "Bạn chưa nhập tài khoản"; } else if (txtMatKhau.Text == "") { lblNoPass.Text = "Bạn chưa nhập mật khẩu"; } else { DataTable dt = new DataTable(); dt = ndbus.DangNhap(nd); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { nd.TaiKhoan = dt.Rows[i].ToString(); nd.MatKhau = dt.Rows[i].ToString(); nd.PhanQuyen = dt.Rows[i].ToString(); } frmMain mainn = new frmMain(); mainn.Show(); } else { MessageBox.Show("Sai tài khoản hoặc mật khẩu!"); } } }
private void btnDoi_Click(object sender, EventArgs e) { string oldpass = "", newpass = ""; foreach (DataRow row in NguoiDungBUS.DangNhap(username).Rows) { oldpass = row["Password"].ToString(); } if (txtMKCu.Text == oldpass) { newpass = txtMKmoi.Text; if (NguoiDungBUS.ChangePassword(username, newpass) == true) { MessageBox.Show("Thay đổi thành công.", "Imformation", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Thay đổi mật khẩu thất bại.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtMKCu.ResetText(); txtMKmoi.ResetText(); } } else { MessageBox.Show("Mật khẩu cũ không đúng.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMKCu.ResetText(); txtMKmoi.ResetText(); } }
private void DangNhap() { NguoiDungDTO nd = new NguoiDungDTO(); string pass = "", username = "", phanquyen = "", hinhanh = ""; username = txtTaiKhoan.Text; if (NguoiDungBUS.DangNhap(username).Rows.Count > 0) { foreach (DataRow row in NguoiDungBUS.DangNhap(username).Rows) { pass = row["Password"].ToString(); phanquyen = row["MaPQ"].ToString(); hinhanh = row["HinhAnh"].ToString(); } if (ch == true && txtMatKhau.Password != pass) { if (txtMatKhau.Password != "") { tbThongbao.Text = "※Sai mật khẩu※"; dispatcherTimer.Start(); } } if (ch == false && txtTaiKhoan.Text == username) { TransitioningContent transitioningContent = new TransitioningContent(); TransitionEffect effect = new TransitionEffect(); effect.Kind = TransitionEffectKind.ExpandIn; transitioningContent.OpeningEffect = effect; object avatarContent; ell.Height = 150; ell.Width = 150; ell.Stroke = Brushes.Transparent; ell.StrokeThickness = 1; ell.Fill = new ImageBrush(new BitmapImage(new Uri(@"..\..\Resources\Images\Avatar\" + hinhanh, UriKind.RelativeOrAbsolute))); avatarContent = ell; transitioningContent.Content = avatarContent; avatarContentControl.Content = transitioningContent; ch = true; transitionerField.SelectedIndex = 1; FocusManager.SetFocusedElement(gridSumary, txtMatKhau); } if (ch == true && txtMatKhau.Password == pass) { Account = username; Avatar = hinhanh; MainWindow mainWindow = new MainWindow(); mainWindow.Show(); this.Close(); } } else { if (txtTaiKhoan.Text != "") { tbThongbao.Text = "※Tài khoản không tồn tại※"; dispatcherTimer.Start(); } } }
private void btnDangNhap_Click(object sender, EventArgs e) { NguoiDungDTO nd = new NguoiDungDTO(); string pass = "", hoten = "", username = "", phanquyen = ""; if (ValidateChildren(ValidationConstraints.Enabled)) { while (true) { username = txtUsername.Text; foreach (DataRow row in NguoiDungBUS.DangNhap(username).Rows) { pass = row["Password"].ToString(); hoten = row["HoTen"].ToString(); phanquyen = row["PhanQuyen"].ToString(); } if (txtPassword.Text == pass) { if (phanquyen == "Admin") { this.Hide(); frmMain frm = new frmMain(hoten, username, phanquyen); frm.ShowDialog(); this.Show(); txtPassword.ResetText(); break; } else if (phanquyen == "User ") { this.Hide(); frmUser frm = new frmUser(hoten, username, phanquyen); frm.ShowDialog(); this.Show(); txtPassword.ResetText(); break; } } else { if (dem == 3) { MessageBox.Show("Bạn nhập sai quá 3 lần cho phép.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); break; } dem++; MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPassword.ResetText(); txtUsername.ResetText(); break; } } } }
private void btnDangNhap_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); dt = ndbus.DangNhap(txtTaiKhoan.Text, txtMatKhau.Text); if (dt.Rows.Count > 0) { this.Hide(); frmMain mainn = new frmMain(); mainn.Show(); } else { MessageBox.Show("Dang nhap that bai"); } }
private void btnDangNhap_Click(object sender, EventArgs e) { DataTable dt = new DataTable(); dt = ndbus.DangNhap(txtTaiKhoan.Text, txtMatKhau.Text); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { nd.TaiKhoan = dt.Rows[i].ToString(); nd.MatKhau = dt.Rows[i].ToString(); } this.Hide(); frmMain main = new frmMain(); main.Show(); } else { MessageBox.Show("Dang nhap that bai"); } }