public Usuario SelecionarLoginSenha(Usuario u) { SqlCommand c = new SqlCommand(); c.CommandType = CommandType.Text; c.CommandText = "select id,senha from tbl_usuario where id = @id and senha = @senha "; c.Parameters.AddWithValue("@id", u.Id); c.Parameters.AddWithValue("@senha", u.Senha); ConexaoDAO con = new ConexaoDAO(); SqlDataReader dr = con.Select(c); Usuario obju = new Usuario(); if (dr.HasRows) { dr.Read(); obju.Id = Convert.ToInt32(dr["id"]); obju.Senha = Convert.ToString(dr["senha"]); } else { return(obju = null); } return(obju); }
public Usuario SelecionarID(string s) { SqlCommand c = new SqlCommand(); c.CommandType = CommandType.Text; c.CommandText = " select id from tbl_usuario where cpf = @cpf "; c.Parameters.AddWithValue("@cpf", s); ConexaoDAO con = new ConexaoDAO(); SqlDataReader dr = con.Select(c); Usuario u = new Usuario(); if (dr.HasRows) { dr.Read(); u.Id = Convert.ToInt32(dr["id"]); } else { return(u = null); } return(u); }