예제 #1
0
        public IActionResult BuscaAcervo(string Pesquisa)
        {
            //Buscar no Acervo e opção de Reserva de Livro
            string sql = "";
            int    ID;

            try
            {
                Connect.Abrir();
                if (Pesquisa == null)
                {
                    sql = "Select * from livro";
                }
                else
                {
                    bool IDTest = Int32.TryParse(Pesquisa, out ID);
                    if (IDTest)
                    {
                        sql = "Select * from livro where liv_id=" + ID.ToString();
                    }
                    else
                    {
                        sql = "Select * from livro where liv_nome='" + Pesquisa + "'";
                    }
                }
                MySqlDataReader Selecao = Connect.ExecutarSelect(sql);
                ViewBag.Livros = Selecao;
            }
            catch (Exception)
            {
                throw;
            }

            return(View());
        }
        public IActionResult CentralAssinantes(string Pesquisa)
        {
            //Controle Adicionar,Verificar,Alterar,Deletar
            string sql = "";
            int    ID;

            try
            {
                Connect.Abrir();
                if (Pesquisa == null)
                {
                    sql = "SELECT * FROM assinante inner join endereco where ass_ativo=1 and endereco_end_id=end_id";
                }
                else
                {
                    bool IDTest = Int32.TryParse(Pesquisa, out ID);
                    if (IDTest)
                    {
                        sql = "SELECT * FROM assinante inner join endereco where ass_ativo=1 and endereco_end_id=end_id and ass_id=" + ID.ToString();
                    }
                    else
                    {
                        sql = "SELECT * FROM assinante inner join endereco where ass_ativo=1 and endereco_end_id=end_id and ass_nome='" + Pesquisa + "'";
                    }
                }

                MySqlDataReader Selecao = Connect.ExecutarSelect(sql);
                ViewBag.Assinantes = Selecao;
            }
            catch (Exception)
            {
                throw;
            }
            return(View());
        }
예제 #3
0
        /*--------------------------------USUARIOS------------------------------------------*/

        //CARGO LA LISTA DE USUARIOS CON LOS USUARIOS QUE HAY EN LA BD
        public void leerUsuarios()
        {
            bd.Abrir();
            NpgsqlDataReader datosRecibidos = bd.EjecutarSelect("select * from usuarios;");

            while (datosRecibidos.Read())
            {
                listaUsuarios.Add(new Usuario(
                                      datosRecibidos.GetString(0),
                                      datosRecibidos.GetString(1)));
            }

            bd.Cerrar();
        }