public ArrayList<SupplierDeliveryReceipt> GetDeliveryReceiptList() throws ParseException { ArrayList<SupplierDeliveryReceipt> DeliveryReceipt = new ArrayList<SupplierDeliveryReceipt>(); try { DBConnectionFactory myFactory = DBConnectionFactory.getInstance(); Connection conn = myFactory.getConnection(); PreparedStatement pstmt = conn.prepareStatement("select * from supplier_delivery_receipt"); ResultSet rs = pstmt.executeQuery(); while (rs.next()) { SupplierDeliveryReceipt temp = new SupplierDeliveryReceipt(); temp.setDrNumber(rs.getInt("drNumber")); temp.setPoNumber(rs.getInt("poNumber")); temp.setItemCode(rs.getInt("itemCode")); temp.setDateReceived(rs.getDate("dateReceived")); temp.setQty(rs.getInt("qty")); temp.setReceivedBy(rs.getInt("receivedBy")); temp.setApprovedBy(rs.getInt("approvedBy")); temp.setStatus(rs.getString("status")); DeliveryReceipt.add(temp); } pstmt.close(); conn.close(); return DeliveryReceipt; } catch (SQLException ex) { Logger.getLogger(SupplierDeliveryReceiptDAO.class.getName()).log(Level.SEVERE, null, ex); } return null; }
public boolean EncodeSupplierDeliveryReceipt(SupplierDeliveryReceipt newSupplierDeliveryReceipt) { try { DBConnectionFactory myFactory = DBConnectionFactory.getInstance(); Connection conn = myFactory.getConnection(); String query = "insert into supplier_delivery_receipt" + "(drNumber,poNumber,itemCode,dateReceived,qty," + "receivedBy,approvedBy,status) " + "values (?,?,?,?,?,?,?,?)"; PreparedStatement pstmt = conn.prepareStatement(query); pstmt.setInt(1, newSupplierDeliveryReceipt.getDrNumber()); pstmt.setInt(2, newSupplierDeliveryReceipt.getPoNumber()); pstmt.setInt(3, newSupplierDeliveryReceipt.getItemCode()); pstmt.setDate(4, newSupplierDeliveryReceipt.getDateReceived()); pstmt.setInt(5, newSupplierDeliveryReceipt.getQty()); pstmt.setInt(6, newSupplierDeliveryReceipt.getReceivedBy()); pstmt.setInt(7, newSupplierDeliveryReceipt.getApprovedBy()); pstmt.setString(8, newSupplierDeliveryReceipt.getStatus()); int rows = pstmt.executeUpdate(); conn.close(); return rows == 1; } catch (SQLException ex) { Logger.getLogger(SupplierDeliveryReceiptDAO.class.getName()).log(Level.SEVERE, null, ex); } return false; }