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;
  }
  public ArrayList<RefSupplier> MonitorRefSupplier() {
    ArrayList<RefSupplier> refSupplier = new ArrayList<RefSupplier>();

    try {
      DBConnectionFactory myFactory = DBConnectionFactory.getInstance();
      Connection conn = myFactory.getConnection();
      PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM `ref_supplier`");

      ResultSet rs = pstmt.executeQuery();
      while (rs.next()) {
        RefSupplier newRefSupplier = new RefSupplier();

        newRefSupplier.setSupplierID(rs.getInt("supplierID"));
        newRefSupplier.setItemCode(rs.getInt("itemCode"));
        newRefSupplier.setItemName(rs.getString("itemName"));
        newRefSupplier.setCompanyName(rs.getString("companyName"));
        newRefSupplier.setCompanyAddress(rs.getString("companyAddress"));
        newRefSupplier.setContactPerson(rs.getString("contactPerson"));
        newRefSupplier.setContactNumber(rs.getInt("contactNumber"));

        refSupplier.add(newRefSupplier);
        System.out.println(refSupplier.get(0).getCompanyName());
      }

      pstmt.close();
      rs.close();
      conn.close();

      return refSupplier;

    } catch (SQLException ex) {
      Logger.getLogger(RefSupplierDAO.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
  }
  public boolean EncodeRefSupplier(RefSupplier newRefSupplier) {
    try {
      DBConnectionFactory myFactory = DBConnectionFactory.getInstance();
      Connection conn = myFactory.getConnection();
      String query =
          "insert into `ref_supplier`"
              + "(supplierID,itemCode,itemName,companyName,companyAddress,contactPerson,contactNumber) "
              + "values (?,?,?,?,?,?,?)";
      PreparedStatement pstmt = conn.prepareStatement(query);
      pstmt.setInt(1, newRefSupplier.getSupplierID());
      pstmt.setInt(2, newRefSupplier.getItemCode());
      pstmt.setString(3, newRefSupplier.getItemName());
      pstmt.setString(4, newRefSupplier.getCompanyName());
      pstmt.setString(5, newRefSupplier.getCompanyAddress());
      pstmt.setString(6, newRefSupplier.getContactPerson());
      pstmt.setFloat(7, newRefSupplier.getContactNumber());

      int rows = pstmt.executeUpdate();
      conn.close();
      return rows == 1;
    } catch (SQLException ex) {
      Logger.getLogger(RefSupplierDAO.class.getName()).log(Level.SEVERE, null, ex);
    }
    return false;
  }
  public ArrayList<RefSupplier> searchSupplier(String itemName) throws SQLException {
    DBConnectionFactory myFactory = DBConnectionFactory.getInstance();
    Connection conn = myFactory.getConnection();

    String query = "SELECT * FROM `ref_supplier` WHERE itemName LIKE '%" + itemName + "%'";
    PreparedStatement ps = conn.prepareStatement(query);
    ArrayList<RefSupplier> RefSupplierList = new ArrayList();
    ResultSet rs = ps.executeQuery();
    while (rs.next()) {
      RefSupplier RefSupplierN = new RefSupplier();
      RefSupplierN.setSupplierID(rs.getInt("supplierID"));
      RefSupplierN.setItemCode(rs.getInt("itemCode"));
      RefSupplierN.setItemName(rs.getString("itemName"));
      RefSupplierN.setCompanyName(rs.getString("companyName"));
      RefSupplierN.setCompanyAddress(rs.getString("companyAddress"));
      RefSupplierN.setContactPerson(rs.getString("contactPerson"));
      RefSupplierN.setContactNumber(rs.getInt("contactNumber"));
      RefSupplierList.add(RefSupplierN);
    }
    rs.close();
    return RefSupplierList;
  }
Esempio n. 6
0
  public void actionPerformed(ActionEvent e) {
    String s = new String(e.getActionCommand());

    if ((s).equals("Login")) {
      try {
        if (factory.authenticate(username.getText(), password.getText())) {
          loginFrame.dispose();
          new HomeScreen(factory);
        } else {
          JOptionPane.showMessageDialog(loginFrame, "Username or Password is incorrect.");
        }
      } catch (SQLException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }

    } else if ((s).equals("Cancel")) {
      loginFrame.dispose();
      new ExitListener();
    }
  }