Class ProductsDAO

java.lang.Object
br.com.pethub.dao.ProductsDAO

public class ProductsDAO extends Object
This class is responsible for managing the data access for the Products in the application. It provides methods to add, edit, delete, list, and search products in the database. It also provides methods to search products by code, update stock, return stock, and generate a products report.
  • Constructor Details

    • ProductsDAO

      public ProductsDAO()
      The constructor method of the ProductsDAO class.
  • Method Details

    • addProducts

      public void addProducts(Products obj)
      This method is used to add a new product to the database.
      Parameters:
      obj - The product to be added.
    • editProducts

      public void editProducts(Products obj)
      This method is used to edit the details of an existing product in the database.
      Parameters:
      obj - The product with the updated details.
    • deleteProducts

      public void deleteProducts(Products obj)
      This method is used to delete a product from the database.
      Parameters:
      obj - The product to be deleted.
    • listProducts

      public List<Products> listProducts()
      This method is used to retrieve a list of all products from the database.
      Returns:
      A list of all products.
    • searchProducts

      public List<Products> searchProducts(String name)
      This method is used to search for products by name.
      Parameters:
      name - The name of the product to search for.
      Returns:
      A list of products that match the provided name.
    • searchProductsByCode

      public Products searchProductsByCode(int id)
      This method is used to search for a product by code.
      Parameters:
      id - The code of the product to search for.
      Returns:
      The product that matches the provided code, or null if no match is found.
    • updateStock

      public void updateStock(int id, int stock_new)
      This method is used to update the stock of a product.
      Parameters:
      id - The id of the product to update the stock for.
      stock_new - The new stock quantity.
    • returnStock

      public int returnStock(int id)
      This method is used to return the stock of a product.
      Parameters:
      id - The id of the product to return the stock for.
      Returns:
      The stock quantity of the product.
    • productsReport

      public void productsReport()
      This method is used to generate a products report.