Introduction to software Engineering

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 23

1, Use Case Documentation - Login

Use Case: User Login

1. Use Case Name:


-User Login

2. Description:
-This use case describes the process by which a user logs into the application using their email and
password.

3. Actors:
- Primary Actor:User(Super Admin , Admin)

4. Preconditions:
- The user must have a valid email and password.
- The user must be registered in the system and their account status must be active.

5. Postconditions:
- On successful login, the user will be redirected to the home page corresponding to their role.
- On unsuccessful login, the user will receive an error message indicating that the email or password is
incorrect.

6. Basic Flow:
1. The use case begins when the user opens the login form.
2. The user enters their email in the Username field.
3. The user enters their password in the Password field.
4. The user clicks the `Login` button.
5. The system validates the email and password against the database.
6. If the credentials are correct and the account status is 'Active':
- The system hides the login form.
- The system opens the home page corresponding to the user's role.
7. If the credentials are incorrect or the account status is not 'Active':
- The system displays an error message indicating "Incorrect Email or Password".

7. Alternative Flows:
Alternative Flow 1: User Exits Application
- 3a. The user clicks the `Exit` button.
- 3b. The system prompts the user with a confirmation dialog.
- 3c. If the user confirms, the system closes the application.

8. Exceptions:
Exception 1: Database Connection Error
- If there is an error connecting to the database, the system displays an error message indicating the
issue.

9. Assumptions:
- The database connection and querying mechanisms are correctly implemented and functional.
- User roles are predefined in the system and associated with user accounts.

10. Detailed Flow of Events:

Main Flow:
1. User opens the login form:
- The system displays the login form centered on the screen.

2. User enters email:


- The user types their email address into the Username text field.

3. User enters password:


- The user types their password into the Password password field.

4. User clicks 'Login' button:


- The user clicks on the login.

5. System validates credentials:


- The system retrieves the entered email and password.
- The system queries the database to find a matching record where email, password, and status are as
specified.
- The system checks if a record is found.

6. System handles login result:


- If a matching record is found and status is 'Active':
- The system hides the login form.
- The system opens the home page for the user, passing the user role from the database.
- If no matching record is found:
- The system shows an error message "Incorrect Email or Password".

Alternative Flow:
1. User clicks 'Exit' button:
- The user clicks on the `Exit button`.
- The system prompts the user with a confirmation dialog "Are you sure you want to Exit?" with
Yes/No options.
- If the user confirms (Yes), the system closes the application.

3. Database Query Example:


```sql
SELECT * FROM appuser1
WHERE email = 'user@example.com'
AND password = 'userpassword'
AND status = 'Active';
```

14. Code Integration Points:


- Database Connection:`ConnectionProvider.getCon()`
- Login Action:`btnLoginActionPerformed()`
- Exit Action:’btnExitActionPerformed()`

2, Use Case Documentation: Home page


Actors
- Admin

Use Cases

1. Launch Home Interface

Description:
-The admin opens the home management application.

Primary Actor:
- Admin

Preconditions:
-The admin has the application installed and launched.
Postconditions:
-The main interface of the application is displayed.

Main Flow:

1. The admin launches the application.


2. The `Home` form is displayed with buttons for various management actions.

2.1 Manage Users

Description:
- The admin manages user accounts.

Primary Actor: Admin

Preconditions:
-The admin is logged into the application.

Postconditions:
- The `ManageUser` interface is displayed for managing user accounts.

Main Flow:

1. The admin clicks the "USER" button.


2. The system displays the `ManageUser` interface.

2.2 Manage Categories

Description:
-The admin manages product categories.
Primary Actor:
-Admin

Preconditions:
- The admin is logged into the application.

Postconditions:
- The `ManageCategory` interface is displayed for managing categories.

Main Flow:

1. The admin clicks the "CATEGORY" button.


2. The system displays the `ManageCategory` interface.

2.3 Manage Products

Description:
- The admin manages products.

Primary Actor:
-Admin

Preconditions:
-The admin is logged into the application.

Postconditions:
-The `ManageProduct` interface is displayed for managing products.

Main Flow:
1. The admin clicks the "PRODUCT" button.
2. The system displays the `ManageProduct` interface.

2.4 Manage Customers


Description:
- The admin manages customer accounts.

Primary Actor:
- Admin

Preconditions:
- The admin is logged into the application.

Postconditions:
- The `ManageCustomer` interface is displayed for managing customers.

Main Flow:

1. The admin clicks the "CUSTOMER" button.


2. The system displays the `ManageCustomer` interface.

2.5 Manage Orders

Description:
-The admin manages orders.

Primary Actor:
- Admin
Preconditions:
- The admin is logged into the application.

Postconditions:
The `ManageOrder` interface is displayed for managing orders.

Main Flow:
1. The admin clicks the "ORDER" button.
2. The system displays the `ManageOrder` interface.

2.6 Logout

Description:
- The admin logs out of the application.

Primary Actor:
- Admin

Preconditions:
- The admin is logged into the application.

Postconditions:
- The admin is logged out and the login interface is displayed.

Main Flow:
1. The admin clicks the "LOGOUT" button.
2. The system prompts the admin to confirm the logout action.
3. The admin confirms the logout action.
4. The system logs out the admin and displays the login interface.
User Interface Components

- **Buttons:**
- `btnUser`: Opens the `ManageUser` interface.
- `btnCategory`: Opens the `ManageCategory` interface.
- `btnProduct`: Opens the `ManageProduct` interface.
- `btnCustomer`: Opens the `ManageCustomer` interface.
- `btnOrder`: Opens the `ManageOrder` interface.
- `btnLogout`: Logs out the admin.
- `JOptionPane`: Used for logout confirmation dialog.

3 , Use Case Documentation for User


Management System
#### Use Case Name: User Management

#### Primary Actor: Admin

#### Goal:
To manage user accounts in the system including creating, updating, and displaying user details.

### Stakeholders and Interests


- **Admin:** Needs to manage user accounts efficiently.
- **System:** Needs to maintain accurate user data.

### Preconditions
- The admin must be logged into the system.
- The database and connection provider must be properly set up and functioning.
### Postconditions
- The user account details are accurately reflected in the system's database.
- The user interface displays the updated user list.

### Main Success Scenario (Basic Flow)


1. **Admin opens the User Management interface.**
- The system initializes the components and displays the form centered on the screen.

2. **System loads existing user data.**


- Upon showing the form, the system fetches and displays all admin users from the database in a table.

3. **Admin creates a new user.**


- Admin enters user details (name, email, password, address, status) and clicks the "Save" button.
- The system validates the fields to ensure no fields are empty.
- If validation passes, the system inserts the new user record into the database.
- The system displays a success message and refreshes the form to show the updated user list.

4. Admin updates an existing user.**


- Admin selects a user from the table, which populates the form fields with the user's current details.
- Admin modifies the necessary fields and clicks the "Update" button.
- The system validates the fields to ensure no fields are empty (except the password).
- If validation passes, the system updates the user record in the database with the new details.
- The system displays a success message and refreshes the form to show the updated user list.

5. **Admin resets the form.**


- Admin clicks the "Reset" button.
- The system clears all input fields and refreshes the user list in the table.

6. **Admin closes the User Management interface.**


- Admin clicks the "Close" button.
- The system closes the form.

### Extensions (Alternate Flows)


3a. **Validation fails when creating a new user.**
- The system displays an error message indicating that all fields are required.

4a. **Validation fails when updating a user.**


- The system displays an error message indicating that all fields are required (except the password).

4b. **Admin changes the status of a user.**


- When a user with a certain status is selected, the status combo box adjusts to show the current status as
the default and provides the option to change it to the other status.

### Special Requirements


- The UI should be user-friendly and responsive.
- Error messages should be clear and specific.
- Password field should be editable only when creating a new user, not when updating.

### Technology and Data Variations List


- **Database Connection:** Uses `ConnectionProvider` for database connection.
- **UI Framework:** Java Swing for the graphical user interface.

### Frequency of Use


- This functionality will be used whenever an admin needs to manage user accounts, which can vary
depending on the size and dynamics of the organization.

### Assumptions
- The admin has sufficient permissions to manage user accounts.
- The database schema is set up correctly with the necessary tables and columns.

### Open Issues


- Potential handling of large datasets (pagination or lazy loading for the user table).
- Enhanced validation for email and password formats.
- Encryption and security measures for storing and handling passwords.

4,Use Case Documentation: ManageCategory


#### 1. Overview

The `ManageCategory` application is a Java Swing-based GUI that allows users to manage categories in a
database. It provides functionalities to add, update, view, and reset categories. The application interacts
with a backend database to perform CRUD (Create, Read, Update, Delete) operations on the category
data.

#### 2. Actors

- **User**: The primary actor who interacts with the application to manage categories.

#### 3. Pre-conditions

- The application must be connected to a database.


- The `category` table must exist in the database with at least two columns: `category_pk` (primary key)
and `name` (category name).

#### 4. Post-conditions

- Changes made to the categories (additions, updates) are persisted in the database.
- The user receives feedback on the success or failure of their actions.

#### 5. Use Cases


##### 5.1. Add a New Category

**Primary Actor**: User

**Description**: Allows the user to add a new category to the database.

**Pre-condition**: The application is running, and the user has entered a category name in the `txtName`
field.

**Post-condition**: A new category is added to the database, and the table is updated to reflect this
addition.

**Main Flow**:
1. The user enters a category name in the `txtName` field.
2. The user clicks the "Save" button.
3. The system validates the input.
4. If validation passes, the system inserts the new category into the database.
5. The system displays a success message and refreshes the category table.

**Alternative Flow**:
- If validation fails, the system displays an error message indicating that all fields are required.

##### 5.2. Update an Existing Category

**Primary Actor**: User

**Description**: Allows the user to update the name of an existing category.

**Pre-condition**: The application is running, and the user has selected a category from the table and
entered a new name in the `txtName` field.
**Post-condition**: The selected category is updated in the database, and the table is updated to reflect
this change.

**Main Flow**:
1. The user selects a category from the `tableCategory`.
2. The user enters a new name in the `txtName` field.
3. The user clicks the "Update" button.
4. The system validates the input.
5. If validation passes, the system updates the category in the database.
6. The system displays a success message and refreshes the category table.

**Alternative Flow**:
- If validation fails, the system displays an error message indicating that all fields are required.

##### 5.3. Reset the Form

**Primary Actor**: User

**Description**: Allows the user to reset the form to its initial state.

**Pre-condition**: The application is running.

**Post-condition**: The form is reset to its initial state, and the category table is reloaded.

**Main Flow**:
1. The user clicks the "Reset" button.
2. The system resets the form fields and reloads the category table.

##### 5.4. Close the Application


**Primary Actor**: User

**Description**: Allows the user to close the application.

**Pre-condition**: The application is running.

**Post-condition**: The application window is closed.

**Main Flow**:
1. The user clicks the "Close" button.
2. The system closes the application window.

##### 5.5. View Categories

**Primary Actor**: User

**Description**: Automatically loads and displays all categories in the table when the application starts.

**Pre-condition**: The application is running.

**Post-condition**: All categories are displayed in the `tableCategory`.

**Main Flow**:
1. The application starts and triggers the `formComponentShown` event.
2. The system retrieves all categories from the database.
3. The system populates the `tableCategory` with the retrieved data.

#### 6. GUI Components

- **Labels**:
- `jLabel1`: Title label displaying "Manage Category".
- `jLabel2`: Label for the `txtName` field, displaying "Name".

- **Text Field**:
- `txtName`: Input field for entering the category name.

- **Buttons**:
- `btnSave`: Saves a new category.
- `btnUpdate`: Updates the selected category.
- `btnReset`: Resets the form.
- `btnClose`: Closes the application.

- **Table**:
- `tableCategory`: Displays the list of categories with columns "ID" and "Name".

- **Scroll Pane**:
- `jScrollPane1`: Encapsulates `tableCategory` to provide scrolling functionality.

#### 7. Database Interaction

- **ConnectionProvider**: Utility class that provides a connection to the database.


- **SQL Queries**:
- Insert new category: `INSERT INTO category (name) VALUES (?)`
- Update existing category: `UPDATE category SET name = ? WHERE category_pk = ?`
- Select all categories: `SELECT * FROM category`

#### 8. Error Handling

- Validation errors (e.g., missing category name) are communicated to the user via `JOptionPane` dialog
boxes.
- Database errors (e.g., connection issues, SQL exceptions) are caught and displayed to the user via
`JOptionPane` dialog boxes.

5, Use Case Documentation for ManageProduct


Description

The `ManageProduct` application is a Java-based GUI application for managing product records in a
database. It allows users to add, update, and view product details. The application integrates with a
database to store and retrieve product information and uses Java Swing components for the user interface.

Actors

1. User: The primary actor who interacts with the application to manage product records.

Functional Requirements

1. Display Product Management Interface


The application should display the product management interface when it starts.

Precondition:
-The application is launched.

Postcondition:
- The product management interface is displayed.

2. Retrieve and Display Categories

Description:
-The application should retrieve all categories from the database and display them in a combo box.
Precondition:
- The application is launched.
Postcondition:
-Categories are displayed in the `comboBoxCategory`.

3. Retrieve and Display Products

Description:
- The application should retrieve all products from the database and display them in a table.
Precondition:
-The application is launched.
Postcondition:
-Products are displayed in the `tableProduct`.

4. Add New Product

Description:
-The user can add a new product by entering the product details and clicking the "Save" button.
Precondition:
-The user has entered all required product details and clicked the "Save" button.
Postcondition:
-The new product is added to the database and displayed in the product table.
Validation: All fields must be filled in to save a new product.

5. Edit Existing Product

Description:
- The user can edit an existing product by selecting it from the table, modifying the details, and clicking
the "Update" button.
Precondition:
- The user has selected a product from the table and made changes to the product details.
Postcondition:
-The product details are updated in the database and the updated information is displayed in the product
table.
Validation:
- All fields must be filled in to update an existing product.

6. Reset Form

Description: The user can reset the form by clicking the "Reset" button.
Precondition: The user has clicked the "Reset" button.
Postcondition: The form fields are cleared and reset to their default states.

7. Close Application

Description: The user can close the application by clicking the "Close" button.
Precondition: The user has clicked the "Close" button.
Postcondition: The application window is closed.

Non-Functional Requirements

1. Usability: The application should have an intuitive user interface to allow users to easily manage
product records.
2. Performance: The application should retrieve and display data from the database promptly.
3. Reliability: The application should handle database errors gracefully and provide appropriate error
messages.
4. Scalability: The application should be able to handle a large number of product records efficiently.

Database Interaction
- ConnectionProvider: Utility class to manage database connections.
- SQL Queries:
- Retrieve categories: `select * from category`
- Retrieve products: `select * from product inner join category on product.category_fk =
category.category_pk’
- Insert product: `insert into product(name, quantity, price, description, category_fk) values (?, ?, ?, ?, ?)`
- Update product: `update product set name =?, quantity=?, price=?, description=?, category_fk=? where
product_pk=?`

Error Handling

- Display error messages using `JOptionPane` for any exceptions encountered during database operations.

Future Enhancements

1. Delete Product: Add functionality to delete a product.


2. Search Product: Add functionality to search for products by name or category.
3. Advanced Validation: Implement more advanced validation checks for input fields.
4. Responsive UI: Enhance the user interface to be more responsive and user-friendly.

This documentation provides a detailed overview of the `ManageProduct` application's functionality,


components, and interactions.

Certainly! Below is the use case documentation for the "Manage Order" functionality in a Java Swing
application:

6, Use Case: Manage Order


1. Use Case Name: Manage Order

2. Description:
This use case allows the user to manage orders by selecting customers, adding products to a cart, and
saving the order. It includes functionality for displaying customer and product lists, adding products to a
cart, calculating total amounts, and generating order invoices in PDF format.

3. Actors:
- User: Typically a sales representative or cashier who manages customer orders.

4. Precondition:
- The application is running, and the user has access to the "Manage Order" functionality.
- Customer and product data are preloaded into the system.

5. Trigger:
The user initiates the "Manage Order" functionality from the main menu or another part of the
application.

6. Main Flow:
6.1. Display Initial Screen:
- The system displays the "Manage Order" screen with lists of customers and products.

6.2. Select Customer:


- The user selects a customer from the customer list.
- The system displays the selected customer's details in the appropriate fields.

6.3. Select Product:


- The user selects a product from the product list.
- The system displays the selected product's details in the appropriate fields.

6.4. Add Product to Cart:


- The user specifies the order quantity.
- The user clicks the "Add to Cart" button.
- The system checks the product stock.
- If sufficient stock is available:
- The system adds the product to the cart with the specified quantity.
- The system updates the cart table and recalculates the total price.
- If insufficient stock is available:
- The system displays an error message indicating the available stock.

6.5. Save Order:


- The user clicks the "Save Order" button.
- The system validates that the cart is not empty and a customer is selected.
- The system generates a unique order ID.
- The system saves the order details to the database.
- The system generates an invoice in PDF format and opens it for the user.
- The system displays a success message.

6.6. Reset Form:


- The user clicks the "Reset" button.
- The system clears all fields and resets the form to its initial state.

6.7. Close Form:


- The user clicks the "Close" button.
- The system closes the "Manage Order" screen.

7. Alternate Flows:
- A1: Insufficient Stock:
- If the product stock is insufficient during the "Add Product to Cart" step, the system displays an error
message indicating the available stock, and the product is not added to the cart.

- A2: Cart is Empty or Customer Not Selected:


- If the user attempts to save an order without any products in the cart or without selecting a customer,
the system displays an error message prompting the user to add products to the cart or select a customer.
8. Postcondition:
- The order is saved in the database.
- An invoice is generated in PDF format and displayed to the user.

9. Assumptions:
- The database is available and operational.
- The customer and product data are accurate and up-to-date.
- The PDF generation library (iText) is correctly configured and functioning.

---

You might also like