Exemplo n.º 1
0
        public Juridico LeerJuridico(string rif)
        {
            try
            {
                Conexion.Open();

                string Comando = "SELECT * FROM juridico WHERE cl_rif = @rif";
                Script = new NpgsqlCommand(Comando, Conexion);

                Script.Parameters.AddWithValue("rif", rif);
                Reader = Script.ExecuteReader();

                if (Reader.Read())
                {
                    Juridico juridico = new Juridico(ReadString(0), ReadString(1), ReadString(2), ReadFloat(3), ReadString(4),
                                                     ReadInt(5), ReadInt(6));
                    Cliente cliente = new Cliente(juridico.RIF);
                    juridico.Base(cliente);
                    return(juridico);
                }
            }
            finally
            {
                Conexion.Close();
            }

            return(null);
        }
Exemplo n.º 2
0
        public List <Juridico> TodosJuridicos()
        {
            List <Juridico> lista = new List <Juridico>();

            try
            {
                Conexion.Open();

                string        Command = "SELECT * FROM juridico";
                NpgsqlCommand Script  = new NpgsqlCommand(Command, Conexion);

                Reader = Script.ExecuteReader();

                while (Reader.Read())
                {
                    Juridico juridico = new Juridico(ReadString(0), ReadString(1), ReadString(2), ReadFloat(3),
                                                     ReadString(4), ReadInt(5), ReadInt(6));
                    lista.Add(juridico);
                }
            }
            catch (Exception e)
            {
                throw new Exception("Ha ocurrido un error en la base de datos", e);
            }
            finally
            {
                Conexion.Close();

                foreach (Juridico juridico in lista)
                {
                    Cliente cliente = new Cliente(juridico.RIF);
                    juridico.Base(cliente);
                }
            }

            return(lista);
        }