private void btnDangnhap_Click(object sender, EventArgs e) { string userName = txtAccount.Text; string passWord = txtPassword.Text; //UserDTO user = new UserDTO(userName, passWord); //session = user; int a = int.Parse(B_User.getRole("select dbo.loginWithRole('" + userName + "','" + passWord + "')")); if (a == 1) { DataTable kq = B_User.getInfoAccount(userName); List <UserDTO> listUs = Handling.InstanceHandling.ConvertDataTable <UserDTO>(kq); var dto = listUs.First(); session = dto; Hide(); frmMain frm = new frmMain(); frm.Show(); Visible = false; } else if (a == 2) { DataTable kq = B_User.getInfoAccount(userName); List <UserDTO> listUs = Handling.InstanceHandling.ConvertDataTable <UserDTO>(kq); var dto = listUs.First(); session = dto; Hide(); frmMain frm = new frmMain(); frm.Show(); Visible = false; } else if (a == -1) { MessageBox.Show("Sai Mật Khẩu", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtPassword.Focus(); return; } else { MessageBox.Show("Chưa Có Tài Khoản", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information); txtAccount.Focus(); return; } #region TTT code /*this.Hide(); * frmMain frm = new frmMain(); * frm.Show();*/ #endregion }
private void btnDangNhap_Click(object sender, EventArgs e) { bool check = false; foreach (CanBoGiaoVien cb in bulCBGV.layTatCBGV()) { if (cb.TaiKhoan == txtTaiKhoan.Text && cb.MatKhau == txtMatKhau.Text) { check = true; frmMain frm = new frmMain(cb); frm.Show(); Visible = false; break; } } if (!check) { MessageBox.Show("Sai tài khoản hoặc mật khẩu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }