private void Button1_Click(object sender, EventArgs e) { frmPrincipal principal = new frmPrincipal(); frmPrincipal2 principal2 = new frmPrincipal2(); bool resultado = VerificaLogin(); Logado = resultado; if (resultado) { using (SqlConnection cn = new SqlConnection()) { cn.ConnectionString = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=SistemaBibliotecaDB;Integrated Security=True"; SqlCommand cmd = new SqlCommand("select Id from Usuarios where Login = '******' and Senha = '" + tbxSenha.Text + "';", cn); cn.Open(); var userId = (int)cmd.ExecuteScalar(); } tbxLogin.Text = ""; tbxSenha.Text = ""; principal2.ShowDialog(); } else { MessageBox.Show("Usuário ou senha incorreto!"); } }
private void Button1_Click(object sender, EventArgs e) { //frmPrincipal principal1 = new frmPrincipal(); frmPrincipal2 principal2 = new frmPrincipal2(); //bool resultado = VerificaLogin(); var result = this.usuariosTableAdapter1.LoginQuery(tbxLogin.Text, tbxSenha.Text); if (result != null) { Session.user = new Usuario { Id = (int)result, Login = tbxLogin.Text }; tbxLogin.Text = ""; tbxSenha.Text = ""; principal2.ShowDialog(); } else { MessageBox.Show("Usuário ou senha incorreto!"); } }