Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
1.3 kB
2
Indexable
Never
  private void BsearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BsearchActionPerformed
        Date from = (Date) Sfrom.getValue();
        Date till = (Date) Still.getValue();
        long timeDiff = till.getTime() - from.getTime();
        int duration = (int) (timeDiff / (1000 * 60 * 60* 24));

        if (till.before(from) || duration == 0)
        {LOGGER.log(Level.WARNING, "An attempt to break data (reservation duration) rules.");
        JOptionPane.showMessageDialog(this, "Minimum stay is 1 day. Please, change the dates.", "ERROR",JOptionPane.ERROR_MESSAGE);}
        else
        {
            ArrayList<Room> availableRooms = new ArrayList<Room> ();
            
            for(Hotel h: hotels) 
            {
            	h.seeAvailableRooms(availableRooms, reservations, from, till);
            	System.out.println("Hotel "+String.valueOf(h.getRooms().size()));
            }
            System.out.println(hotels.size());
            System.out.println(availableRooms.size());
           ((DefaultListModel)LavailableRooms.getModel()).removeAllElements();
           LtotalSum.setText("");
           ((DefaultListModel)LavailableRooms.getModel()).addAll(availableRooms);
        }
    }//GEN-LAST:event_BsearchActionPerformed