Ejemplo n.º 1
0
        public Tb_ClienteEstructura Consultar_Cliente_X_Id(long Id)
        {
            Tb_ClienteEstructura ObjCliente = new Tb_ClienteEstructura();

            try
            {
                String comando_sql = "Pq_Cliente.Consultar_Cliente_Id";
                using (_Connection = new OracleConnection(_ConnetionString))
                {
                    _Connection.Open();
                    OracleCommand _command = new OracleCommand(comando_sql, _Connection);
                    _command.CommandType = System.Data.CommandType.StoredProcedure;
                    _command.Parameters.Add("p_Id", OracleDbType.Int64).Value             = Id;
                    _command.Parameters.Add("p_cursor", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
                    OracleParameter  _parameter = new OracleParameter();
                    OracleDataReader reader     = _command.ExecuteReader();

                    if (reader != null)
                    {
                        while (reader.Read())
                        {
                            ObjCliente.Cliente_Id         = reader.GetInt32(0);
                            ObjCliente.Cliente_Dni        = reader.GetString(1);
                            ObjCliente.Cliente_Nombre_1   = reader.GetString(2);
                            ObjCliente.Cliente_Nombre_2   = reader.GetString(3);
                            ObjCliente.Cliente_Apellido_1 = reader.GetString(4);
                            ObjCliente.Cliente_Apellido_2 = reader.GetString(5);
                            ObjCliente.Cliente_Tpo_Dni    = reader.GetInt64(6);
                            ObjCliente.Cliente_Telefono   = reader.GetString(7);
                            ObjCliente.Cliente_Direccion  = reader.GetString(8);
                            ObjCliente.Cliente_Email      = reader.GetString(9);
                        }
                    }
                    _command.Dispose();
                    _Connection.Close();
                }
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(ex);
            }

            return(ObjCliente);
        }
Ejemplo n.º 2
0
        public List <Tb_ClienteEstructura> Consultar_Clientes()

        {
            List <Tb_ClienteEstructura> ListaClientes = new List <Tb_ClienteEstructura>();

            try
            {
                String comando_sql = "Pq_Cliente.Consultar_Cliente";
                using (_Connection = new OracleConnection(_ConnetionString))
                {
                    _Connection.Open();
                    OracleCommand _command = new OracleCommand(comando_sql, _Connection);
                    _command.CommandType = System.Data.CommandType.StoredProcedure;
                    _command.Parameters.Add("p_cursor", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
                    OracleParameter  _parameter = new OracleParameter();
                    OracleDataReader reader     = _command.ExecuteReader();
                    if (reader != null)
                    {
                        while (reader.Read())
                        {
                            Tb_ClienteEstructura estructura = new Tb_ClienteEstructura();
                            estructura.Cliente_Id         = reader.GetInt32(0);
                            estructura.Cliente_Dni        = reader.GetString(1);
                            estructura.Cliente_Nombre_1   = reader.GetString(2);
                            estructura.Cliente_Nombre_2   = !reader.IsDBNull(3)? reader.GetString(3):null;
                            estructura.Cliente_Apellido_1 = reader.GetString(4);
                            estructura.Cliente_Apellido_2 = reader.GetString(5);
                            estructura.Cliente_Tpo_Dni    = reader.GetInt64(6);
                            estructura.Cliente_Telefono   = reader.GetString(7);
                            estructura.Cliente_Direccion  = reader.GetString(8);
                            estructura.Cliente_Email      = reader.GetString(9);
                            ListaClientes.Add(estructura);
                        }
                    }
                    _command.Dispose();
                    _Connection.Close();
                }
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(ex);
            }
            return(ListaClientes);
        }