Exemplo n.º 1
0
  private void UpdateTable() {
    String searchItem = inCIdField2.getText();
    String selectedItem = (String) jComboBox4.getSelectedItem();
    System.out.println("SearchItem: " + searchItem);
    tableContent = new Vector<Vector<String>>();

    table = (DefaultTableModel) jTable5.getModel();
    while (table.getRowCount() > 0) table.removeRow(0);

    try {
      System.out.println("testestetsetset");
      result = Search.searchMovies(searchItem, selectedItem);

      System.out.println(result.size());
      for (int i = 0; i < result.size(); i++) // inventory.GeneralMovie movie : result)
      {
        inventory.GeneralMovie singleMovie = (inventory.GeneralMovie) result.get(i);
        System.out.println("result Size: " + singleMovie.getTitle());

        Vector<String> row = new Vector<String>();
        row.add(singleMovie.getTitle());
        row.add("" + singleMovie.getReleaseDate().get(java.util.Calendar.YEAR));
        row.add("" + singleMovie.getDirector());
        System.out.println("Get Director: " + singleMovie.getDirector());
        String actors = "";
        for (String actor : singleMovie.getActors()) {
          actors += actor;
          actors += ", ";
        }
        actors = actors.trim().substring(0, actors.length() - 2);
        row.add("" + actors);
        System.out.println("Get actors: " + actors);
        row.add("" + singleMovie.getRating());
        System.out.println("Get Rating: " + singleMovie.getRating());
        row.add(singleMovie.getFormat());
        if (RentalMovieManagement.getAvailableCopies(singleMovie) > 0)
          row.add("# of Available " + RentalMovieManagement.getAvailableCopies(singleMovie));
        else if (RentalMovieManagement.getAvailableCopies(singleMovie) == 0) row.add("Rented");
        else if (RentalMovieManagement.getAvailableCopies(singleMovie) < 0) row.add("Not in Store");
        table.addRow(row);
      }

    } catch (SQLException ex) {
      Logger.getLogger(CustomerFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (ClassNotFoundException ex) {
      Logger.getLogger(CustomerFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (MovieNotFoundException ex) {
      searchField1.setText("Movie Not Found");
    } catch (Exception ex) {
      System.out.print(ex.getMessage());
      ex.printStackTrace();
    }

    table.fireTableStructureChanged();
  }
Exemplo n.º 2
0
 /**
  * This adds/saves the current transaction to the database.
  *
  * @throws IllegalStateException if the transaction has not been paid for.
  *     <dt><b>Precondition:</b>
  *     <dd>
  *         <ul>
  *           <li>Payment for the transaction has been made.
  *         </ul>
  */
 public void process()
     throws IllegalStateException, SQLException, ClassNotFoundException, MovieNotFoundException,
         Exception {
   if (myTransaction.isPaid() == false) {
     throw new IllegalStateException("The invoice has not been paid, not saving info.");
   }
   // mySQLhelper.insertInvoiceTable(myTransaction);
   RentalMovieManagement rentalManager = new RentalMovieManagement();
   SaleMovieManagement saleManager = new SaleMovieManagement();
   for (int i = 1; i <= myTransaction.getNumberOfItems(); i++) {
     TransactionItem item = myTransaction.getItem(i);
     if (item.getType().equals("for sale")) {
       saleManager.sell(item.getBarcode());
     } else if (item.getType().trim().toLowerCase().equals("new release")
         || item.getType().trim().toLowerCase().equals("7 day")) {
       rentalManager.checkOut(
           myTransaction.getCustomerID(), item.getBarcode(), new JDBCConnection());
     }
   }
 }