Пример #1
0
  public void showDues() {
    try {
      ResultSet rs;
      CallableStatement cstmt =
          DBConnection.returnCallableStatememt("{call show_dues_pkg.show_dues_proc(?, ?, ?, ?)}");
      cstmt.setString(1, userType);
      cstmt.setString(2, userName);
      cstmt.registerOutParameter(3, OracleTypes.CURSOR);
      cstmt.registerOutParameter(4, OracleTypes.VARCHAR);
      ArrayList<Object> arrayList = DBConnection.returnResultSetAndError(cstmt, 3, 4);
      if (!arrayList.get(1).equals(Constant.kBlankString)) {
        System.out.println(arrayList.get(1));
        Utility.callUserDialogueBox(this.userName, this.userType);
        return;
      }
      rs = (ResultSet) arrayList.get(0);
      if (!rs.next()) {
        System.out.println("\nYou don't have any due !!\n");
        Utility.callUserDialogueBox(this.userName, this.userType);
        return;
      } else {
        System.out.println(
            "Resource Type"
                + "\t"
                + "Name"
                + "\t"
                + "Expected due date"
                + "\t"
                + "Total Dues (USD)");
        System.out.println(
            "---------------------------------------------------------------------------------------------------------------------------------------------------------");

        do {
          String resourceType = rs.getString("type");
          String name = rs.getString("name");
          String expectedDueDate = rs.getString("due_start_date");
          String totalDues = rs.getString("due_in_dollars");
          System.out.println(
              resourceType + "\t" + name + "\t\t" + expectedDueDate + "\t" + totalDues);
        } while (rs.next());
      }
    } catch (SQLException e) {
      PrintSQLException.printSQLException(e);
      Utility.badErrorMessage();
    }
    Utility.callUserDialogueBox(userName, userType);
  }
Пример #2
0
  public void showPublicationMenuItems() {
    Utility.setMessage("Please enter a choice:");
    System.out.println(
        "1: Books\t2: Journals\t3: Conferences Papers\t0: Go back to previous menu.");
    boolean flag = true;
    try {
      while (flag) {
        int choice = Integer.parseInt(Utility.enteredConsoleString());
        switch (choice) {
          case 0:
            searchResources();
            flag = false;
            break;
          case 1:
            System.out.println("Books");
            // Call check out method
            Book book = new Book(this.userName, this.userType);
            book.showBooks();
            flag = false;
            break;
          case 2:
            System.out.println("Journals");
            Journal journal = new Journal(this.userName, this.userType);
            journal.showJournals();
            flag = false;
            break;
          case 3:
            System.out.println("Conference Papers");
            // Call check out method
            ConferencePaper confPaper = new ConferencePaper(this.userName, this.userType);
            confPaper.searchConferencePapers();
            flag = false;
            break;

          default:
            System.out.println("Invalid choice: Please enter again.");
            showPublicationMenuItems();
            flag = false;
            break;
        }
      }
    } catch (Exception e) {
      Utility.badErrorMessage();
      searchResources();
    }
  }
Пример #3
0
  public void searchResources() {
    System.out.println("Please enter your choice:");
    System.out.println(
        "1: Publications\t\t2: Conference/Study rooms\t3: Cameras\t0: Go back to previous menu.");

    boolean flag = true;
    try {
      while (flag) {
        int choice = Integer.parseInt(Utility.enteredConsoleString());
        switch (choice) {
          case 0:
            Utility.callUserDialogueBox(userName, userType);
            flag = false;
            break;
          case 1:
            System.out.println("Publications");
            // Call check out method
            showPublicationMenuItems();
            flag = false;
            break;
          case 2:
            Room room = new Room(userName, userType);
            room.showDialogueBox();
            flag = false;
            break;
          case 3:
            // Call check out method
            Camera camera = new Camera(this.userName, this.userType);
            camera.searchCameras();
            flag = false;
            break;

          default:
            System.out.println("Invalid choice: Please enter again.");
            searchResources();
            flag = false;
            break;
        }
      }
    } catch (Exception e) {
      Utility.badErrorMessage();
      searchResources();
    }
  }