Class ProductsDAO
java.lang.Object
br.com.pethub.dao.ProductsDAO
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addProducts
(Products obj) This method is used to add a new product to the database.void
deleteProducts
(Products obj) This method is used to delete a product from the database.void
editProducts
(Products obj) This method is used to edit the details of an existing product in the database.This method is used to retrieve a list of all products from the database.void
This method is used to generate a products report.int
returnStock
(int id) This method is used to return the stock of a product.searchProducts
(String name) This method is used to search for products by name.searchProductsByCode
(int id) This method is used to search for a product by code.void
updateStock
(int id, int stock_new) This method is used to update the stock of a product.
-
Constructor Details
-
ProductsDAO
public ProductsDAO()The constructor method of the ProductsDAO class.
-
-
Method Details
-
addProducts
This method is used to add a new product to the database.- Parameters:
obj
- The product to be added.
-
editProducts
This method is used to edit the details of an existing product in the database.- Parameters:
obj
- The product with the updated details.
-
deleteProducts
This method is used to delete a product from the database.- Parameters:
obj
- The product to be deleted.
-
listProducts
-
searchProducts
-
searchProductsByCode
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.
-