private void txtUsername_TextChanged(object sender, EventArgs e) { if (txtUsername.Text != "") { LoginDAO acc = new LoginDAO(); string qh = dgvNhanVien.SelectedCells[0].OwningRow.Cells["QuyenHan"].Value.ToString(); Account now = acc.GetAccountByUserName(txtUsername.Text); int index = -1; int i = 0; foreach (Account item in cbQH.Items) { if (item.QuyenHan == qh) { index = i; break; } i++; } cbQH.SelectedIndex = index; } }
private void btnLogin_Click(object sender, EventArgs e) { string username, password; username = txtUserName.Text; password = txtPassWord.Text; LoginDAO login = new LoginDAO(); if (login.Login(username, password)) { Account AccountLogin = login.GetAccountByUserName(username); btnLogin.Tag = AccountLogin; fManagement f = new fManagement(AccountLogin); f.Tag = (sender as Button).Tag; this.Hide(); f.ShowDialog(); //this.Show(); } else { MessageBox.Show("Tên đăng nhập hoặc mật khẩu không đúng !"); } }