private void BtnDangNhap_Click(object sender, EventArgs e) { DataTable dt = new DangNhapBLL().TimKiem(txtTaiKhoan.Text.Trim(), txtMatKhau.Text.Trim()); try { if (txtTaiKhoan.Text.Trim() == string.Empty) { MessageBox.Show("Bạn chưa nhập tài khoản", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (txtMatKhau.Text.Trim() == string.Empty) { MessageBox.Show("Bạn chưa nhập mật khẩu", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (dt.Rows.Count == 0) { MessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Đăng nhập thành công"); string maNV = dt.Rows[0][0].ToString(); new FormNvPhongDaoTao(maNV).Show(); Hide(); } } catch (Exception ex) { MessageBox.Show("Lỗi: " + ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public frmDangNhap() { dnbll = new DangNhapBLL(); ds = new DataSet(); InitializeComponent(); txtTenDangNhap.Text = Properties.Settings.Default.user; txtMatKhau.Text = Properties.Settings.Default.pass; ckbMatKhau.Checked = Properties.Settings.Default.check; }
void GetThongTinTaiKhoan() { DataTable dt = DangNhapBLL.GetThongTinNguoiDung(tenDangNhap); txtHoTen.Text = dt.Rows[0]["HOTEN"].ToString(); txtSDT.Text = dt.Rows[0]["SDT"].ToString(); txtEmail.Text = dt.Rows[0]["EMAIL"].ToString(); txtDiaChi.Text = dt.Rows[0]["DIACHI"].ToString(); string chucVu = dt.Rows[0]["QUYEN"].ToString(); quyen = chucVu.Trim(); //if (chucVu == "GIAMDOC ") // //txtChucVu.Text = "Giám đốc"; //else if (chucVu == "QUANLI ") // txtChucVu.Text = "Quản lí"; //else if (chucVu == "NHANVIEN ") // txtChucVu.Text = "Nhân viên"; }
void DangNhap() { if (!string.IsNullOrEmpty(txtTaiKhoan.Text) && !string.IsNullOrEmpty(txtMatKhau.Text)) { if (DangNhapBLL.XemDL("*", txtTaiKhoan.Text.Trim(), txtMatKhau.Text.Trim()).Rows.Count != 0) { frmMain formMain = new frmMain(); frmMain.Quyen = (Quyen)Enum.Parse(typeof(Quyen), DangNhapBLL.XemDL("QUYEN", txtTaiKhoan.Text, txtMatKhau.Text).Rows[0][0].ToString()); formMain.username = txtTaiKhoan.Text.Trim(); this.Hide(); formMain.ShowDialog(); this.Close(); } else { labStatus.Visible = true; txtMatKhau.Clear(); } } }
void DangNhap() { if (!string.IsNullOrEmpty(txtTaiKhoan.Text) && !string.IsNullOrEmpty(txtMatKhau.Text)) { if (DangNhapBLL.XemDL("*", txtTaiKhoan.Text, txtMatKhau.Text).Rows.Count != 0) { frmThongTinTaiKhoan.tenDangNhap = txtTaiKhoan.Text; frmThongTinTaiKhoan.matKhau = txtMatKhau.Text; frmThayDoiMatKhau.taiKhoan = txtTaiKhoan.Text; frmMain formMain = new frmMain(); frmMain.quyen = DangNhapBLL.XemDL("QUYEN", txtTaiKhoan.Text, txtMatKhau.Text).Rows[0][0].ToString(); this.Hide(); formMain.ShowDialog(); this.Close(); } else { labStatus.Visible = true; txtMatKhau.Clear(); } } }
private void btn_DangNhap_Click(object sender, EventArgs e) { lblStatus.Text = ""; if (txt_TaiKhoan.Text.Length == 0 || txt_MatKhau.Text.Length == 0)// nếu tài khoản hoặc mật khẩu trống { lblStatus.BackColor = Color.Pink; lblStatus.Text = "Bạn chưa nhập tên hoặc tài khoản"; txt_TaiKhoan.Focus(); } else { if (txt_MatKhau.Text.IndexOf(" ") > 0 || txt_MatKhau.Text.IndexOf("/") > 0 || txt_MatKhau.Text.IndexOf("*") > 0) { lblStatus.Text = "Mật khẩu sai, không được có khoảng trắng, dấu /, dấu *"; txt_MatKhau.Focus(); } else { this.Cursor = Cursors.WaitCursor; DangNhapPublic clsLogin = new DangNhapPublic(); clsLogin.TaiKhoan = txt_TaiKhoan.Text.Trim(); clsLogin.MatKhau = txt_MatKhau.Text.Trim(); DangNhapBLL cls = new DangNhapBLL(); if (cls.BLL_DangNhap_Select(clsLogin))//trùng tài khoản mật khẩu { switch (cls.BLL_PhanQuyen(clsLogin)) { case "MNDHT": frm_Home.quyendangnhap = "MNDHT"; MessageBox.Show("Bạn đăng nhập với quyền của Hiệu trưởng"); break; case "MNDGV": frm_Home.quyendangnhap = "MNDGV"; MessageBox.Show("Bạn đăng nhập với quyền của Giáo viên"); break; case "MNDQT": frm_Home.quyendangnhap = "MNDQT"; MessageBox.Show("Bạn đăng nhập với quyền của Quản trị viên"); break; default: frm_Home.quyendangnhap = "Lỗi quyền đăng nhập!"; MessageBox.Show("Bạn đăng nhập với quyền của Khách"); break; } this.Close(); frm_Home.dadangnhap = true; frm_Home.tendangnhap = txt_TaiKhoan.Text.Trim(); } else { lblStatus.Text = "Tài khoản hoặc mật khẩu sai"; txt_TaiKhoan.Text = ""; txt_MatKhau.Text = ""; txt_TaiKhoan.Focus(); this.Cursor = Cursors.Default; } } } }
public Login() { InitializeComponent(); _dangNhapBLL = new DangNhapBLL(); main = new main(); }