0% found this document useful (0 votes)
13 views2 pages

Inventaory Explain

Uploaded by

misushil55
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Inventaory Explain

Uploaded by

misushil55
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

This code is an implementation of an Inventory Management System in C++.

The
program allows an admin to manage an inventory of items by performing actions like
adding items, viewing items, editing items, selling items, and viewing purchase and
sales records. Below is a detailed explanation of the code:

### Global Constants


- `const string ADMIN_USERNAME = "admin";`
- `const string ADMIN_PASSWORD = "admin123";`

These constants define the admin's username and password for login.

### Helper Functions


- **`void clearScreen()`**: Clears the console screen. It uses `system("cls")` for
Windows and `system("clear")` for other systems.

### Classes
- **`class Item`**: Represents an item in the inventory.
- **Attributes**:
- `int id`: Item ID.
- `string name`: Item name.
- `double price`: Item price.
- `int quantity`: Item quantity.
- `double totalPrice`: Total price (price * quantity).
- `string supplierName`: Supplier name.
- **Methods**:
- `void inputItemDetails()`: Prompts user to input item details and calculates
the total price.
- `void displayItem()`: Displays item details (excluding `totalPrice`).
- `void displayItemWithTotal()`: Displays item details including `totalPrice`.

- **`class Sale`**: Represents a sale record.


- **Attributes**:
- `int id`: Item ID.
- `string name`: Item name.
- `double price`: Item price.
- `int quantity`: Sold quantity.
- `double totalPrice`: Total price of the sale.
- `string customerName`: Customer name.
- **Methods**:
- `void displaySale()`: Displays sale details.

### Functions
- **`bool login()`**: Prompts the user to enter a username and password, returns
`true` if they match the admin credentials.
- **`void addItem()`**: Clears the screen, prompts the user to enter item details,
and saves the item to both `Inventorydashboard.txt` and `Purchasebook.txt`.
- **`void viewItems()`**: Clears the screen, reads and displays all items from
`Inventorydashboard.txt`.
- **`void displayAvailableItems()`**: Displays available items (without supplier
details) from `Inventorydashboard.txt`.
- **`void editItem()`**: Allows the user to edit an existing item's details by its
ID and updates `Inventorydashboard.txt`.
- **`void sellItem()`**: Handles the sale of an item by updating its quantity in
`Inventorydashboard.txt` and recording the sale in `Salesbook.txt`.
- **`void viewPurchaseBook()`**: Clears the screen, reads and displays all purchase
records from `Purchasebook.txt`.
- **`void viewSalesBook()`**: Clears the screen, reads and displays all sale
records from `Salesbook.txt`.
- **`void resetInventory()`**: Prompts for confirmation and, if confirmed, clears
the contents of `Inventorydashboard.txt`, `Purchasebook.txt`, and `Salesbook.txt`.

### Main Function


The `main()` function handles the program's flow:
1. **Login Loop**: Continuously prompts for login until successful or exit.
2. **Main Menu**: Displays a menu with options to add, view, edit, and sell items,
view purchase and sales books, reset the inventory, and exit the program.
3. **Choice Handling**: Based on the user's choice, the appropriate function is
called.

### Program Flow


1. **Login**: The user is prompted to log in. If the login fails, they can try
again or exit.
2. **Main Menu**: After a successful login, the user is presented with options to
manage the inventory.
3. **Perform Actions**: The user can add, view, edit, or sell items, and view
purchase and sales records. They can also reset the inventory.
4. **Exit**: The user can choose to exit the program, ending the main loop.

The use of file I/O operations (`ifstream` for reading, `ofstream` for writing)
ensures data persistence across sessions. The program relies on formatted input and
output operations (`cin` and `cout`), and the `<iomanip>` library for aligned table
display. The inclusion of error handling (e.g., `cin.clear()` and `cin.ignore()`)
ensures robust input validation.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy