Ejemplo n.º 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);
  }
Ejemplo n.º 2
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();
    }
  }