コード例 #1
0
        public static UsuarioModel BuscaUsuario(string usuario)
        {
            var ret = new UsuarioModel();

            using (var comando = new SqlCommand())
            {
                comando.Connection = Conexao.connection;

                comando.CommandText = string.Format(
                    "select * from UserSys where Login = '******' or Email = '{1}'", usuario, usuario); Conexao.Desconectar();
                Conexao.Desconectar();
                Conexao.Conectar();
                var reader = comando.ExecuteReader();
                while (reader.Read())
                {
                    ret.Id         = (int)reader["Id"];
                    ret.Login      = (string)reader["Login"];
                    ret.Email      = (string)reader["Email"];
                    ret.UserRoleId = (int)reader["UserRoleId"];
                }
                Conexao.Desconectar();
            }

            return(ret);
        }