Package upc.iluminados.modelo

Examples of upc.iluminados.modelo.Cancha


    }

    public Cancha obtener(String nombre, Integer idLocal) throws BaseExcepcion {
        System.out.println("CanchaDAO: obtener(String nombre)");
        Cancha vo = null;
        Connection con = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
        try {
            String query = "select idCancha,nombre,tarifadiurna,tarifanocturna  from tb_cancha where nombre=? and idLocal = ?";
            con = ConexionBD.obtenerConexion();
            stmt = con.prepareStatement(query);
            stmt.setString(1, nombre);
            stmt.setInt(2, idLocal);
            rs = stmt.executeQuery();
            if (rs.next()) {
                vo = new Cancha();
                vo.setId(rs.getInt(1));
                vo.setNombre(rs.getString(2));
                vo.setTarifaDiurna(rs.getDouble(3));
                vo.setTarifaNocturna(rs.getDouble(4));
            }
        } catch (SQLException e) {
            System.err.println(e.getMessage());
            throw new BaseExcepcion(e.getMessage());
        } finally {
View Full Code Here


    public List<HorarioCancha> listar(Integer idCancha, Integer distrito, String dia, String hora) throws BaseExcepcion {
        System.out.println("CanchaDAO: obtener(String nombre)");
        List<HorarioCancha> lista = new ArrayList<HorarioCancha>();
        HorarioCancha vo = null;
        Cancha cancha = null;
        Local local = null;
        Connection con = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
        try {
//            String query = "select b.idHorario, b.dia,b.hora,a.idCancha,a.nombre,a.tarifadiurna,a.tarifanocturna, exists ( select 1 from tb_alquilercancha ac where ac.idhorario = b.idhorario ) as alquilado "
//                    + " from tb_cancha a, tb_horariocancha b, tb_local c where a.idCancha = b.idCancha and a.idLocal = c.idLocal ";

            String query = "select b.idHorario, b.dia,b.hora,a.idCancha,a.nombre,a.tarifadiurna,a.tarifanocturna, exists ( select 1 from tb_alquilercancha ac where ac.idhorario = b.idhorario AND ac.fecha = '" + dia + " ') as alquilado, c.nombre as localNombre "
                    + " from tb_cancha a, tb_horariocancha b, tb_local c where a.idCancha = b.idCancha and a.idLocal = c.idLocal ";

            if (idCancha != null) {
                query = query + " and a.idCancha = " + idCancha;
            }
            if (distrito != null) {
                query = query + " and c.distrito = " + distrito;
            }
            //if (dia != null) {
            query = query + " and b.dia = DATE_FORMAT('" + dia + "','%w')";
            //}
            if (hora != null) {
                query = query + " and b.hora = '" + hora + "'";
            }
            System.out.println("CanchaDAO: query=" + query);
            con = ConexionBD.obtenerConexion();
            stmt = con.prepareStatement(query);
            rs = stmt.executeQuery();
            while (rs.next()) {
                vo = new HorarioCancha();
                vo.setId(rs.getInt(1));
                vo.setDia(rs.getString(2));
                vo.setHora(rs.getString(3));
                vo.setAlquilado(rs.getInt("alquilado") == 1 ? true : false);
                cancha = new Cancha();
                cancha.setId(rs.getInt(4));
                cancha.setNombre(rs.getString(5));
                cancha.setTarifaDiurna(rs.getDouble(6));
                cancha.setTarifaNocturna(rs.getDouble(7));
                local = new Local();
                local.setNombre(rs.getString("localNombre"));
                cancha.setLocal(local);
                vo.setCancha(cancha);

                lista.add(vo);
            }
        } catch (SQLException e) {
View Full Code Here

        System.out.println("AlquilerCanchaDAO: listar(Integer idCliente)");
        Collection<AlquilerCancha> lista = new ArrayList<AlquilerCancha>();
        AlquilerCancha vo = null;
        Usuario cliente = null;
        HorarioCancha horarioCancha = null;
        Cancha cancha = null;
       
       
        Connection con = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
        try {
            String query = "SELECT a.fecha, a.horaInicio, a.horaFin, b.idUsuario, b.nombre, b.apellidoPaterno, b.apellidoMaterno, d.nombre as canchanombre "
                    + " FROM tb_alquilercancha a, tb_usuario b, tb_horariocancha c, tb_cancha d "
                    + " Where a.idUsuario = b.idUsuario and b.tipo = 2 and a.idHorario = c.idHorario and c.idCancha = d.idCancha ";
            if(idCliente!=null){
                query = query + " and idUsuario = " + idCliente;
            }
            con = ConexionBD.obtenerConexion();
            stmt = con.prepareStatement(query);
            rs = stmt.executeQuery();
            while (rs.next()) {
                vo = new AlquilerCancha();
                cliente = new Usuario();
                horarioCancha = new HorarioCancha();
                cancha = new Cancha();
                
                vo.setCliente(cliente);
                vo.setHorarioCancha(horarioCancha);
                horarioCancha.setCancha(cancha);
               
                //AlquilerCancha
                vo.setFecha(rs.getString(1));
                vo.setHoraInicio(rs.getString(2));
                vo.setHoraFin(rs.getString(3));
               
                //Cliente
                cliente.setNombre(rs.getString(5));
               
                //Cancha
                cancha.setNombre(rs.getString("canchanombre"));
            


                lista.add(vo);
            }
View Full Code Here

    @Override
    public List<HorarioCancha> listar(Integer idCancha, Integer distrito, String dia, String hora) {
      List<HorarioCancha> lista = new ArrayList<HorarioCancha>();
      HorarioCancha hc = new HorarioCancha();
      Cancha cancha = new Cancha();
      cancha.setNombre("canchita 1");
      hc.setCancha(cancha);
      hc.setId(Integer.valueOf(1));
      hc.setDia("2012-07-18");
      hc.setHora("18:00");
      lista.add(hc);
View Full Code Here

    }

    public Cancha obtener(String nombre, Integer idLocal) throws BaseExcepcion {
        System.out.println("CanchaDAO: obtener(String nombre)");
        Cancha vo = null;
        Connection con = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
        try {
            String query = "select idCancha,nombre,tarifadiurna,tarifanocturna  from tb_cancha where nombre=? and idLocal = ?";
            con = ConexionBD.obtenerConexion();
            stmt = con.prepareStatement(query);
            stmt.setString(1, nombre);
            stmt.setInt(2, idLocal);
            rs = stmt.executeQuery();
            if (rs.next()) {
                vo = new Cancha();
                vo.setId(rs.getInt(1));
                vo.setNombre(rs.getString(2));
                vo.setTarifaDiurna(rs.getDouble(3));
                vo.setTarifaNocturna(rs.getDouble(4));
            }
        } catch (SQLException e) {
            System.err.println(e.getMessage());
            throw new BaseExcepcion(e.getMessage());
        } finally {
View Full Code Here

    public List<HorarioCancha> listar(Integer idCancha, Integer distrito, String dia, String hora) throws BaseExcepcion {
        System.out.println("CanchaDAO: obtener(String nombre)");
        List<HorarioCancha> lista = new ArrayList<HorarioCancha>();
        HorarioCancha vo = null;
        Cancha cancha = null;
        Local local = null;
        Connection con = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
        try {
//            String query = "select b.idHorario, b.dia,b.hora,a.idCancha,a.nombre,a.tarifadiurna,a.tarifanocturna, exists ( select 1 from tb_alquilercancha ac where ac.idhorario = b.idhorario ) as alquilado "
//                    + " from tb_cancha a, tb_horariocancha b, tb_local c where a.idCancha = b.idCancha and a.idLocal = c.idLocal ";

            String query = "select b.idHorario, b.dia,b.hora,a.idCancha,a.nombre,a.tarifadiurna,a.tarifanocturna, exists ( select 1 from tb_alquilercancha ac where ac.idhorario = b.idhorario AND ac.fecha = '" + dia + "') as alquilado, c.nombre as localNombre "
                    + " from tb_cancha a, tb_horariocancha b, tb_local c where a.idCancha = b.idCancha and a.idLocal = c.idLocal ";

            if (idCancha != null) {
                query = query + " and a.idCancha = " + idCancha;
            }
            if (distrito != null) {
                query = query + " and c.distrito = " + distrito;
            }
            //if (dia != null) {
            query = query + " and b.dia = DATE_FORMAT('" + dia + "','%w')";
            //}
            if (hora != null) {
                query = query + " and b.hora = '" + hora + "'";
            }
            System.out.println("CanchaDAO: query=" + query);
            con = ConexionBD.obtenerConexion();
            stmt = con.prepareStatement(query);
            rs = stmt.executeQuery();
            while (rs.next()) {
                vo = new HorarioCancha();
                vo.setId(rs.getInt(1));
                vo.setDia(rs.getString(2));
                vo.setHora(rs.getString(3));
                vo.setAlquilado(rs.getInt("alquilado") == 1 ? true : false);
                cancha = new Cancha();
                cancha.setId(rs.getInt(4));
                cancha.setNombre(rs.getString(5));
                cancha.setTarifaDiurna(rs.getDouble(6));
                cancha.setTarifaNocturna(rs.getDouble(7));
                local = new Local();
                local.setNombre(rs.getString("localNombre"));
                cancha.setLocal(local);
                vo.setCancha(cancha);

                lista.add(vo);
            }
        } catch (SQLException e) {
View Full Code Here

        System.out.println("AlquilerCanchaDAO: listar(Integer idCliente)");
        Collection<AlquilerCancha> lista = new ArrayList<AlquilerCancha>();
        AlquilerCancha vo = null;
        Usuario cliente = null;
        HorarioCancha horarioCancha = null;
        Cancha cancha = null;
       
       
        Connection con = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
        try {
            String query = "SELECT a.fecha, a.horaInicio, a.horaFin, b.idUsuario, b.nombre, b.apellidoPaterno, b.apellidoMaterno, d.nombre as canchanombre "
                    + " FROM tb_alquilercancha a, tb_usuario b, tb_horariocancha c, tb_cancha d "
                    + " Where a.idUsuario = b.idUsuario and b.tipo = 2 and a.idHorario = c.idHorario and c.idCancha = d.idCancha ";
            if(idCliente!=null){
                query = query + " and idUsuario = " + idCliente;
            }
            con = ConexionBD.obtenerConexion();
            stmt = con.prepareStatement(query);
            rs = stmt.executeQuery();
            while (rs.next()) {
                vo = new AlquilerCancha();
                cliente = new Usuario();
                horarioCancha = new HorarioCancha();
                cancha = new Cancha();
                
                vo.setCliente(cliente);
                vo.setHorarioCancha(horarioCancha);
                horarioCancha.setCancha(cancha);
               
                //AlquilerCancha
                vo.setFecha(rs.getString(1));
                vo.setHoraInicio(rs.getString(2));
                vo.setHoraFin(rs.getString(3));
               
                //Cliente
                cliente.setNombre(rs.getString(5));
               
                //Cancha
                cancha.setNombre(rs.getString("canchanombre"));
            


                lista.add(vo);
            }
View Full Code Here

     
     
        AlquilerCancha vo = null;
        Usuario cliente = null;
        HorarioCancha horarioCancha = null;
        Cancha cancha = null;
       
        Connection con = null;
        PreparedStatement stmt = null;
        ResultSet rs = null;
       
        int codigo=Integer.valueOf(nombre);
       
        try {
            String query = "SELECT t.idUsuario, u.nombre, u.apellidoPaterno,  t.fecha, t.horaInicio, t.horaFin FROM tb_alquilercancha t inner join tb_usuario u  on t.idUsuario=u.idUsuario ";
            if(nombre!=null){
                query = query + " where t.idUsuario = " + codigo;
            }
           
            System.out.println("consulta  : "+query);
            con = ConexionBD.obtenerConexion();
            stmt = con.prepareStatement(query);
            rs = stmt.executeQuery();
            while (rs.next()) {
             
              System.out.println("dentro del query");
                vo = new AlquilerCancha();
                cliente = new Usuario();
                horarioCancha = new HorarioCancha();
                cancha = new Cancha();
                
                //vo.setCliente(cliente.setNombre(rs.getString(1)));
               
                cliente.setId(rs.getInt(1));
                cliente.setNombre(rs.getString(2));
View Full Code Here

  List<AlquilerCancha> lista=new ArrayList<AlquilerCancha>();
 
  AlquilerCancha vo = null;
    Usuario cliente = null;
    HorarioCancha horarioCancha = null;
    Cancha cancha = null;
   
    Connection con = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;
   
   
    try {
        String query = "SELECT t.idUsuario, u.nombre, u.apellidoPaterno,  t.fecha, t.horaInicio, t.horaFin FROM tb_alquilercancha t inner join tb_usuario u  on t.idUsuario=u.idUsuario ";
       
       
        System.out.println("consulta  : "+query);
        con = ConexionBD.obtenerConexion();
        stmt = con.prepareStatement(query);
        rs = stmt.executeQuery();
        while (rs.next()) {
         
          System.out.println("dentro del query");
            vo = new AlquilerCancha();
            cliente = new Usuario();
            horarioCancha = new HorarioCancha();
            cancha = new Cancha();
            
            //vo.setCliente(cliente.setNombre(rs.getString(1)));
           
            cliente.setId(rs.getInt(1));
            cliente.setNombre(rs.getString(2));
View Full Code Here

        }
        if (lista == null || lista.isEmpty()) {
            throw new BaseExcepcion("Horario Requerido");
        }

        Cancha cancha = canchaDAO.obtener(vo.getNombre(), vo.getLocal().getId());
        if (cancha != null) {
            throw new BaseExcepcion("Cancha ya existe");
        }
        canchaDAO.insertar(vo, lista);
    }
View Full Code Here

TOP

Related Classes of upc.iluminados.modelo.Cancha

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.