public Receipt getReceiptDetails(int receiptId) { Receipt receipt = new Receipt(); try { DBConnection receiptSc = (DBConnection) sc.getAttribute("dbConn"); receiptConn = receiptSc.getDBConnection(); receiptStmt = receiptConn.prepareStatement("SELECT * FROM tbl_student_fees_receipt where receipt_id=?"); receiptStmt.setInt(1, receiptId); receiptRs = receiptStmt.executeQuery(); receiptRs.next(); receipt.setReceiptId(receiptRs.getInt("receipt_id")); receipt.setStudentId(receiptRs.getInt("student_id")); receipt.setSemester(receiptRs.getInt("semester")); receipt.setTotalFees(receiptRs.getDouble("total_fees")); receipt.setPendingFees(receiptRs.getDouble("fees_pending")); receipt.setStatus(receiptRs.getInt("status")); } catch (Exception e) { System.out.println("Exception in getting receipt details of Receipt controller" + e); } finally { close(); } return receipt; }
public ArrayList<Receipt> getAllReceiptId(int studentId) { ArrayList<Receipt> receiptIds = new ArrayList<>(); try { DBConnection receiptSc = (DBConnection) sc.getAttribute("dbConn"); receiptConn = receiptSc.getDBConnection(); receiptStmt = receiptConn.prepareStatement( "SELECT receipt_id FROM tbl_student_fees_receipt where student_id=?"); receiptStmt.setInt(1, studentId); receiptRs = receiptStmt.executeQuery(); while (receiptRs.next()) { Receipt receipId = new Receipt(); receipId.setReceiptId(receiptRs.getInt("receipt_id")); receiptIds.add(receipId); } } catch (Exception e) { System.out.println( "Exception in getting all receipt id of student in Receipt controller " + e); } finally { close(); } return receiptIds; }