Fix Check stock availability Issue and Add error message
- Added "Check Stock Availability" header in AdminMenu::checkStockAvailability for clarity. - Updated prompt text to "Enter the Item ID" for consistency. - Added util::clear() after reading Item ID to refresh the screen before displaying results. - Implemented validation to show "Item not Found" message when the entered ID does not exist in inventory. Fix #1741
This commit is contained in:
@@ -298,8 +298,10 @@ void AdminMenu::checkStockAvailability()
|
||||
{
|
||||
util::clear();
|
||||
std::string itemId;
|
||||
std::cout << "Enter the Item Id : ";
|
||||
std::cout << "Check Stock Availability \n";
|
||||
std::cout << "Enter the Item ID : ";
|
||||
util::read(itemId);
|
||||
util::clear();
|
||||
const InventoryItem* selectedItem = m_controller.getInventoryItem(itemId);
|
||||
if (selectedItem != nullptr)
|
||||
{
|
||||
@@ -312,6 +314,10 @@ void AdminMenu::checkStockAvailability()
|
||||
std::cout << "Quantity : " << selectedItem->getQuantity() << "\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Item not Found" << std::endl;
|
||||
}
|
||||
util::pressEnter();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user