A brief description of what this project does and who it's for
CampusPay is a Java application that provides a platform for students, vendors, and administrators to manage payments and orders within a campus.
- Java: The application is written in Java, making use of its robust OOP features.
- SQL: The application interacts with a database using SQL stored procedures.
- Java Swing framework:is a platform independent framework,built on top of the AWT package.
- JDBC:is a connector, is an API for the Java programming language. Its primary purpose is to define how a client (Java application) can access a database.
- Download the CampusPay-master.zip file from the Google drive.
- Locate the compressed file containing the project code.
- Right-click on the file and select "Extract" or use a suitable extraction tool.
- Choose a destination folder where you want to extract the contents of the compressed file.
- Once extracted, you should have a folder containing your project files and directories.
- Now open the folder in an editor with Java Runtime available preferably INTELLIJ.
- Open your MySQL database management tool (e.g., MySQL Workbench).
- Connect to your root MySQL server using appropriate credentials.
- Locate the
MySQLscript.sql
script within the extracted project folder. - Open the
MySQLscript.sql
script in your MySQL management tool. - Execute the script to create a new schema/database for CampusPay.
- Right-click on This PC or My Computer and select Properties.
- Click on Advanced system settings on the left side.
- In the System Properties window, click on the Environment Variables button.
- Under System variables, click New.
- Set the Variable Name to
MYSQL_ROOT_PASSWORD
and the Variable Value to your MySQL root password. - Click OK to save the variable.
- Open a terminal window.
- Edit the .bashrc or .bash_profile file in your home directory using a text editor (e.g., nano ~/.bashrc or nano ~/.bash_profile).
- Add the following line at the end of the file: export MYSQL_ROOT_PASSWORD=your_password
- Save the file and close the text editor.
- Run source ~/.bashrc or source ~/.bash_profile to apply the changes.
- Download the JDBC driver for MySQL from the official MySQL website or a trusted source.
- Follow the installation instructions provided with the JDBC driver for your specific operating system.
- Extract the file and locate the location where the JDBC driver JAR file is installed on your system.
- Open your project in IntelliJ IDEA.
- In the Project Explorer or Project view, locate the directory where you want to store external libraries (e.g., a lib folder within your project).
- Right-click on the directory and select New > Directory to create a new directory if needed.
- Once the directory is created or located, right-click on it and select "Paste" to paste the copied JDBC driver JAR file into the directory.
- Alternatively, you can directly add the JDBC driver JAR file to your project's classpath:
- In IntelliJ IDEA, go to File > Project Structure.
- In the Project Structure dialog, select Modules from the left sidebar.
- Click on the Dependencies tab.
- Click on the "+" button and select JARs or directories...
- Navigate to the location where you saved the JDBC driver JAR file, select it, and click OK to add it to your project's dependencies. 6.Ensure that the JDBC driver JAR file is successfully added to your project's dependencies. Please refer to [https://www.jetbrains.com/help/idea/jdbc-drivers.html]
- Navigate to the directory within your project where the AdminRegistration class is located.
- Run
AdminRegistration
Class using the Run option in the Upper Right Corner of the INTELLIJ window. - Register Admin Application will open.
- Create an Admin to handle admin operations.
- Navigate to the directory within your project where the
LoginSystem
class is located. - Run
LoginSystem
Class using the Run option in the Upper Right Corner of the INTELLIJ window. - The Project is now running.
The AddItem
class in the AddItem.java
file is used to create a form that allows a vendor to add a new item to the database. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the add item form. It creates aJFrame
and adds several components to it, including labels, text fields for the item name and price, and buttons for submitting the form and going back to the previous page. -
Submit Button: The "Submit" button has an
ActionListener
attached to it. When the button is clicked, it retrieves the item name and price from the text fields, connects to the database, and calls a stored procedureadd_item_to_menu
to add the item to the database. If the item is added successfully, it displays a success message. If there's an error, it displays an error message. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofVendorItems
, calls theshow
method to display the vendor items page, and disposes of the current frame.
The AdminAddTransaction.java
file is a part of a Java application that provides an interface for an admin to add a transaction. Here's a breakdown of the key components:
-
Class Declaration: The class
AdminAddTransaction
is declared. -
Method Declaration: The
show()
method is declared. This method is responsible for setting up the GUI for the transaction addition interface. -
Frame Setup: A
JFrame
is created and its properties are set. This includes setting the default close operation, size, and layout. -
Container Setup: A
Container
is created and its layout and background color are set. -
Labels and Fields: Various
JLabel
andJTextField
objects are created for the transaction details. This includes fields for the student ID, vendor ID, and transaction amount. -
Dropdown Lists: Two
JComboBox
objects are created to list all students and vendors. These lists are populated by querying the respective tables in the database. -
Add Transaction Button: A
JButton
is created for adding the transaction. AnActionListener
is added to this button which retrieves the selected student and vendor IDs, and the entered transaction amount. It then calls a stored proceduremake_transaction
in the database to add the transaction. If the transaction is successful, it shows a success message and redirects to the transaction list. If the transaction fails, it shows an error message. -
Back Button: A
JButton
is created for going back to the previous screen. AnActionListener
is added to this button which redirect
The AdminEditTransaction
class in the AdminEditTransaction.java
file is used to create a form that allows an admin to edit an existing transaction in the database. Here's a breakdown of its functionality:
-
Constructor: The constructor takes five parameters:
transaction_id
,vendor_id
,student_id
,total_amount
, anddate_time
. It initializes aJFrame
and several GUI components including labels, text fields for the vendor ID, student ID, total amount, and date time, and buttons for editing the transaction and going back to the previous page. The text fields are pre-filled with the current values of the transaction. -
Edit Button: The "Edit" button has an
ActionListener
attached to it. When the button is clicked, it retrieves the values from the text fields, connects to the database, and calls a stored procedureupdate_transaction
to update the transaction in the database. If the transaction is updated successfully, it displays a success message, disposes of the current frame, and displays the transactions page. If there's an error, it displays an error message. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofShowTransactions
, calls theshow
method to display the transactions page, and disposes of the current frame. -
show Method: The
show
method is used to make the form visible.
Please note that the actual functionality might vary based on the rest of your codebase and the implementation of other classes like Conn
, ShowTransactions
, etc.
The AdminHome
class in the AdminHome.java
file is used to create the home page for the admin user. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the admin home page. It creates aJFrame
and adds several components to it, including a title label and buttons for viewing vendors, viewing students, showing transactions, showing orders, and logging out. -
View Vendors Button: The "View Vendors" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofViewVendors
, calls theshow
method to display the vendors page, and disposes of the current frame. -
View Students Button: The "View Students" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofViewStudents
, calls theshow
method to display the students page, and disposes of the current frame. -
Show Transactions Button: The "Show Transactions" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofShowTransactions
, calls theshow
method to display the transactions page, and disposes of the current frame. -
Show Orders Button: The "Show Orders" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofShowOrders
, calls theshow
method to display the orders page, and disposes of the current frame. -
Logout Button: The "Logout" button has an
ActionListener
attached to it. When the button is clicked, it clears the current user instance, creates an instance ofLoginSystem
, calls theshow
method to display the login page, and disposes of the current frame.
The AdminRegistration
class in the AdminRegistration.java
file is used to create a form that allows the registration of a new admin. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the admin registration form. It creates aJFrame
and adds several components to it, including labels, text fields for the admin ID and password, and buttons for submitting the form and resetting the form. -
Submit Button: The "Submit" button has an
ActionListener
attached to it. When the button is clicked, it retrieves the admin ID and password from the text fields, hashes the password, connects to the database, and calls a stored procedureregister_admin
to register the admin in the database. If the admin is registered successfully, it displays a success message, disposes of the current frame, and displays the login page. If there's an error, it displays an error message. -
Reset Button: The "Reset" button has an
ActionListener
attached to it. When the button is clicked, it clears the text fields.
The AdminViewStudentTransaction
class in the AdminViewStudentTransaction.java
file is likely used to create a form that allows an admin to view transactions associated with a specific student. Here's a hypothetical breakdown of its functionality based on the naming convention and the pattern observed in your codebase:
-
show Method: The
show
method is used to set up and display the GUI for the student transaction view form. It creates aJFrame
and adds several components to it, including aJTable
to display the transactions. -
Student Transactions Table: The
JTable
is populated by querying the database for transactions associated with the selected student. This might be done using a stored procedure or a SQL query. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofViewStudents
, calls theshow
method to display the students page, and disposes of the current frame.
The AdminViewVendorItems
class in the AdminViewVendorItems.java
file is used to create a form that allows an admin to view items sold by a specific vendor. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the vendor items view form. It creates aJFrame
and adds several components to it, including aJTable
to display the items. -
Vendor Items Table: The
JTable
is populated by querying the database for items sold by the selected vendor. This is done using a stored procedureget_all_items_sold_by_vendor
. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofViewVendors
, calls theshow
method to display the vendors page, and disposes of the current frame.
The AdminViewVendorTransaction
class in the AdminViewVendorTransaction.java
file is likely used to create a form that allows an admin to view transactions associated with a specific vendor. Here's a hypothetical breakdown of its functionality based on the code snippet you provided:
-
show Method: The
show
method is used to set up and display the GUI for the vendor transaction view form. It creates aJFrame
and adds several components to it, including aJTable
to display the transactions. -
Vendor Transactions Table: The
JTable
is populated by querying the database for transactions associated with the selected vendor. This might be done using a stored procedure or a SQL query. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofViewVendors
, calls theshow
method to display the vendors page, and disposes of the current frame.
The EditItem.java
file contains a class named EditItem
which is used to edit the details of an item sold by a vendor in the CampusPay application. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the edit item form. It creates aJFrame
and adds several components to it, including labels, text fields, a drop-down menu for selecting the item to edit, and buttons. -
Drop-down Menu: The drop-down menu is populated with the items sold by the vendor. This is done by connecting to the database and calling the stored procedure
get_all_items_sold_by_vendor
, passing the vendor's ID as a parameter. -
Form Fields: The form includes fields for the item name and price. The item name and price are set to the current name and price of the selected item by calling the stored procedure
get_item_details
, passing the item's ID as a parameter. -
Submit Button: The "Submit" button has an
ActionListener
attached to it. When the button is clicked, it connects to the database and calls the stored procedureupdate_item_details
to update the details of the item. The item's ID, the new name, and the new price are passed as parameters to the stored procedure. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofVendorItems
, calls theshow
method to display the vendor items page, and disposes of the current frame.
The EditStudent.java
file contains a class named EditStudent
which is used to edit the details of a student in the CampusPay application. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the edit student form. It creates aJFrame
and adds several components to it, including labels, text fields, a drop-down menu for selecting the student to edit, and buttons. -
Drop-down Menu: The drop-down menu is populated with the students. If the user is an admin, it gets all students from the database. If the user is a student, the drop-down list is uneditable and shows only the student's details.
-
Form Fields: The form includes fields for the student's name, account number, contact, and password. The fields are set to the current details of the selected student by calling the stored procedure
get_student_details
, passing the student's ID as a parameter. -
Edit Button: The "Edit" button has an
ActionListener
attached to it. When the button is clicked, it connects to the database and calls the stored procedureupdate_student_details
to update the details of the student. The student's ID, the new name, account number, contact, and hashed password are passed as parameters to the stored procedure. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofViewStudents
orStudentHome
(based on the user's role), calls theshow
method to display the respective page, and disposes of the current frame.
The EditVendor.java
file likely contains a class named EditVendor
which is used to edit the details of a vendor in the CampusPay application. Here's a hypothetical breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the edit vendor form. It creates aJFrame
and adds several components to it, including labels, text fields, a drop-down menu for selecting the vendor to edit, and buttons. -
Drop-down Menu: The drop-down menu is populated with the vendors. This is done by connecting to the database and calling a stored procedure or SQL query to get all vendors.
-
Form Fields: The form includes fields for the vendor's name, contact, and password. The fields are set to the current details of the selected vendor by calling a stored procedure or SQL query
get_vendor_details
, passing the vendor's ID as a parameter. -
Edit Button: The "Edit" button has an
ActionListener
attached to it. When the button is clicked, it connects to the database and calls the stored procedure or SQL queryupdate_vendor_details
to update the details of the vendor. The vendor's ID, the new name, contact, and hashed password are passed as parameters to the stored procedure. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofViewVendors
, calls theshow
method to display the vendors page, and disposes of the current frame.
The LoginSystem.java
file contains a class named LoginSystem
which is used to handle the login functionality of the CampusPay application. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the login form. It creates aJFrame
and adds several components to it, including labels, text fields, and buttons. -
User Verification: If a user is already logged in (checked by
User.getInstance().getId() != null
), the method will redirect the user to their respective home page based on their role (student, vendor, or admin). -
Form Fields: The form includes fields for the user's ID, role, and password. The role is entered as a string and converted to an integer representation (0 for student, 1 for vendor, 2 for admin).
-
Submit Button: The "Submit" button has an
ActionListener
attached to it. When the button is clicked, it connects to the database and calls the stored procedureverify_login
to verify the user's credentials. If the credentials are valid, the user is redirected to their respective home page. -
Reset Button: The "Reset" button has an
ActionListener
attached to it. When the button is clicked, it clears the text fields. -
Registration Buttons: There are two buttons for registration - one for students and one for vendors. When clicked, they open the respective registration forms.
-
Password Hashing: The password entered by the user is hashed using the
Hash
class before it is sent to theverify_login
stored procedure. This is done to protect the user's password.
The Hash.java
file contains a utility class named Hash
which is used to hash a password using the SHA-256 algorithm in the CampusPay application. Here's a breakdown of its functionality:
-
hash Method: The
hash
method is a static method that takes a password as a string and returns the hashed version of the password. It uses the SHA-256 hashing algorithm to create a hash of the password. -
MessageDigest: The
MessageDigest
class is used to create a MessageDigest instance for the SHA-256 algorithm. This instance is used to calculate the hash of the password. -
hashInBytes: The
digest
method of theMessageDigest
instance is used to hash the password. The password is converted to bytes using the UTF-8 character set, and these bytes are hashed. Thedigest
method returns the hash as a byte array. -
StringBuilder: A
StringBuilder
is used to build the final hashed password string. Each byte in the hashed byte array is converted to a hexadecimal string and appended to theStringBuilder
. -
NoSuchAlgorithmException: This exception is caught if the algorithm specified when creating the
MessageDigest
instance is not found. In this case, thehash
method returns null.
The Payment.java
file is a part of a Java application that provides an interface for making a payment. Here's a breakdown of the key components:
-
Class Declaration: The class
Payment
is declared. -
Method Declaration: The
show()
method is declared. This method is responsible for setting up the GUI for the payment interface. -
Frame Setup: A
JFrame
is created and its properties are set. This includes setting the default close operation, size, layout, and background color. -
Labels and Fields: Various
JLabel
andJTextField
objects are created for the payment details. This includes fields for the amount and a dropdown list for vendors. -
Dropdown Lists: A
JComboBox
object is created to list all vendors. This list is populated by querying theget_all_vendors()
stored procedure in the database. -
Pay Button: A
JButton
is created for making the payment. AnActionListener
is added to this button which retrieves the entered amount and selected vendor ID. It then calls a stored proceduremake_transaction
in the database to make the payment. If the payment is successful, it shows a success message. If the payment fails, it shows an error message. -
Back Button: A
JButton
is created for going back to the previous screen. AnActionListener
is added to this button which redirects to the student home page. -
Frame Visibility and Position: The frame is made visible and its position is set to the center of the screen.
-
Main Method: The
main
method is declared which creates an instance ofPayment
and calls theshow()
method. This is the entry point of the program.
The RefundTransaction.java
file is a part of a Java application that provides an interface for refunding a transaction. Here's a breakdown of the key components:
-
Class Declaration: The class
RefundTransaction
is declared. -
Method Declaration: The
show()
method is declared. This method is responsible for setting up the GUI for the refund transaction interface. -
Frame Setup: A
JFrame
is created and its properties are set. This includes setting the default close operation, size, layout, and background color. -
Labels: Two
JLabel
objects are created. One for the title which includes the transaction ID and another for a confirmatory message. -
Refund Button: A
JButton
is created for confirming the refund. AnActionListener
is added to this button which calls a stored proceduredelete_transaction
in the database to refund the transaction. If the operation is successful, it shows a success message. If the operation fails, it shows an error message. -
Cancel Button: A
JButton
is created for canceling the refund. AnActionListener
is added to this button which disposes the frame, effectively closing the refund transaction interface. -
Frame Visibility and Position: The frame is made visible and its position is set to the center of the screen.
-
Main Method: The
main
method is declared which creates an instance ofRefundTransaction
and calls theshow()
method with a transaction ID. This is the entry point of the program.
The SetBudget.java
file is a part of a Java application that provides an interface for setting a budget for a student. Here's a breakdown of the key components:
-
Class Declaration: The class
SetBudget
is declared. -
Method Declaration: The
show()
method is declared. This method is responsible for setting up the GUI for the budget setting interface. -
Frame Setup: A
JFrame
is created and its properties are set. This includes setting the default close operation, size, layout, and background color. -
Labels and Fields: A
JLabel
and aJTextField
are created for the budget amount. -
Get Current Budget: The current budget is retrieved by calling the
get_monthly_budget
stored procedure in the database and the result is set as the text of the amount field. -
Set Budget Button: A
JButton
is created for setting the budget. AnActionListener
is added to this button which retrieves the entered amount and calls a stored procedureset_monthly_budget
in the database to set the budget. If the operation is successful, it shows a success message. If the operation fails, it shows an error message. -
Back Button: A
JButton
is created for going back to the previous screen. AnActionListener
is added to this button which redirects to the student home page. -
Frame Visibility and Position: The frame is made visible and its position is set to the center of the screen.
The ShowOrders.java
file contains a class named ShowOrders
which is used to display the orders made by a user in the CampusPay application. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the orders page. It creates aJFrame
and adds several components to it, including labels, a drop-down menu for selecting the transaction, a table to display the orders, and buttons. -
Transaction Selection: A drop-down menu is populated with the transactions made by the current user. If the user is an admin, it gets all transactions. If the user is a vendor, it gets all transactions made by the vendor. If the user is a student, it gets all payments made by the student.
-
Orders Table: A
JTable
is used to display the orders of the selected transaction. The table has columns for the item ID, item name, quantity, and price. -
Show Orders Button: The "Show Orders" button has an
ActionListener
attached to it. When the button is clicked, it connects to the database and calls the stored procedureget_all_orders_of_transaction
to get the orders of the selected transaction. The orders are then displayed in the table. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofAdminHome
,VendorHome
, orStudentHome
(based on the user's role), calls theshow
method to display the respective home page, and disposes of the current frame.
The ShowTransactions.java
file contains a class named ShowTransactions
which is used to display all transactions in the CampusPay application. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the transactions page. It creates aJFrame
and adds several components to it, including labels, a table to display the transactions, and buttons. -
Transactions Table: A
JTable
is used to display the transactions. The table has columns for the transaction ID, vendor ID, student ID, total amount, and date/time. -
Database Connection: It connects to the database and calls the stored procedure
get_all_transactions
to get all transactions. The transactions are then displayed in the table. -
Add Button: The "Add Transaction" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofAdminAddTransaction
, calls theshow
method to display the add transaction page, and disposes of the current frame. -
Edit Button: The "Edit Transaction" button has an
ActionListener
attached to it. When the button is clicked, it gets the selected transaction from the table, creates an instance ofAdminEditTransaction
with the transaction details as parameters, calls theshow
method to display the edit transaction page, and disposes of the current frame. -
Back Button: The "Back" button has a
MouseListener
attached to it. When the button is clicked, it creates an instance ofAdminHome
, calls theshow
method to display the admin home page, and disposes of the current frame.
The StudentHome.java
file is a part of a Java application that provides the home interface for a student. Here's a breakdown of the key components:
-
Class Declaration: The class
StudentHome
is declared. -
Method Declaration: The
show()
method is declared. This method is responsible for setting up the GUI for the student home interface. -
Frame Setup: A
JFrame
is created and its properties are set. This includes setting the default close operation, size, layout, and background color. -
Labels and Fields: Various
JLabel
objects are created for displaying the total amount spent and the most bought item by the student. The total amount spent and the most bought item are retrieved by calling theget_total_amount_spent_by_student
andget_most_bought_item_by_student
stored procedures in the database respectively. -
Buttons: Various
JButton
objects are created for different functionalities. Each button has anActionListener
added to it which redirects to the respective interface when clicked. The buttons include:-
Vendors Button: Redirects to the vendors menu when clicked.
-
Payment Button: Redirects to the payment interface when clicked.
-
Payment History Button: Redirects to the payment history interface when clicked.
-
Update Details Button: Redirects to the student details editing interface when clicked.
-
Show Orders Button: Redirects to the orders interface when clicked.
-
Set Budget Button: Redirects to the budget setting interface when clicked.
-
Logout Button: Logs out the user and redirects to the login interface when clicked.
-
-
Frame Visibility and Position: The frame is made visible and its position is set to the center of the screen.
-
Main Method: The
main
method is declared which creates an instance ofStudentHome
and calls theshow()
method. This is the entry point of the program.
The StudentRegistration.java
file contains a class named StudentRegistration
which is used to handle the student registration functionality in the CampusPay application. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the student registration page. It creates aJFrame
and adds several components to it, including labels, text fields for name, ID, contact, and password, and buttons. -
Form Fields: The form includes fields for the student's name, ID, contact, and password. The ID is used as the BITS account as well.
-
Submit Button: The "Submit" button has an
ActionListener
attached to it. When the button is clicked, it connects to the database and calls the stored procedureregister_student
to register the student. The student's ID, BITS account (which is the same as the ID), name, contact, and hashed password are included in the student record. After successful registration, it shows a success message and redirects to the login page. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofLoginSystem
, calls theshow
method to display the login page, and disposes of the current frame.
The StudentRegistration.java
file contains a class named StudentRegistration
which is used to handle the student registration functionality in the CampusPay application. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the student registration page. It creates aJFrame
and adds several components to it, including labels, text fields for name, ID, contact, and password, and buttons. -
Form Fields: The form includes fields for the student's name, ID, contact, and password. The ID is used as the BITS account as well.
-
Submit Button: The "Submit" button has an
ActionListener
attached to it. When the button is clicked, it connects to the database and calls the stored procedureregister_student
to register the student. The student's ID, BITS account (which is the same as the ID), name, contact, and hashed password are included in the student record. After successful registration, it shows a success message and redirects to the login page. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofLoginSystem
, calls theshow
method to display the login page, and disposes of the current frame.
The User.java
file contains a class named User
which is used to store and manage user information in the CampusPay application. This class is implemented as a singleton, meaning that only one instance of this class can exist at any given time. Here's a breakdown of its functionality:
-
Private Constructor: The constructor of the
User
class is private to prevent the creation of new instances of theUser
class from outside the class. -
getInstance Method: This static method returns the single instance of the
User
class. If the instance doesn't exist, it creates one. -
setId, getId Methods: These methods are used to set and get the ID of the user.
-
setRole, getRole Methods: These methods are used to set and get the role of the user. The role could be an integer representing different user types (like admin, vendor, student, etc.).
-
setPassword, getPassword Methods: These methods are used to set and get the password of the user.
-
clear Method: This method is used to clear the user information. It sets the ID, role, and password to their default values
The VendorHome.java
file contains a class named VendorHome
which is used to handle the home page functionality for a vendor user in the CampusPay application. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the vendor home page. It creates aJFrame
and adds several components to it, including labels, buttons, and a total amount earned label. -
Total Amount Earned: The total amount earned by the vendor is retrieved from the database using the
get_total_amount_earned_by_vendor
stored procedure and displayed on the home page. -
Transaction History Button: The "Transaction History" button, when clicked, creates an instance of
VendorTransactionHistory
, calls theshow
method to display the transaction history page, and disposes of the current frame. -
Items Sold Button: The "My Items" button, when clicked, creates an instance of
VendorItems
, calls theshow
method to display the items page, and disposes of the current frame. -
New Transaction Button: The "New Transaction" button, when clicked, creates an instance of
VendorTransactionProcess
, calls theshow
method to display the new transaction page, and disposes of the current frame. -
Edit Details Button: The "Edit Details" button, when clicked, creates an instance of
EditVendor
, calls theshow
method to display the vendor details editing page, and disposes of the current frame. -
Show Orders Button: The "Show Orders" button, when clicked, creates an instance of
ShowOrders
, calls theshow
method to display the orders page, and disposes of the current frame. -
Logout Button: The "Logout" button, when clicked, clears the user information, creates an instance of
LoginSystem
, calls theshow
method to display the login page, and disposes of the current frame.
The VendorItems.java
file contains a class named VendorItems
which is used to display the items sold by a vendor in the CampusPay application. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the vendor items page. It creates aJFrame
and adds several components to it, including labels, a text area to display the items, and buttons. -
Items Text Area: A
JTextArea
is used to display the items sold by the vendor. The text area is populated by calling the stored procedureget_all_items_sold_by_vendor
with the current user's ID as a parameter. Each item's ID, name, and price are appended to the text area. -
Add Item Button: The "Add Item" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofAddItem
, calls theshow
method to display the add item page, and disposes of the current frame. -
Edit Item Button: The "Edit Item" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofEditItem
, calls theshow
method to display the edit item page, and disposes of the current frame. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofVendorHome
, calls theshow
method to display the vendor home page, and disposes of the current frame.
The VendorRegistration.java
file contains a class named VendorRegistration
which is used to handle the vendor registration functionality in the CampusPay application. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the vendor registration page. It creates aJFrame
and adds several components to it, including labels, text fields for name, account number, contact, and password, and buttons. -
Form Fields: The form includes fields for the vendor's name, account number, contact, and password. The account number is used as the vendor's ID as well.
-
Register Button: The "Register" button has an
ActionListener
attached to it. When the button is clicked, it connects to the database and calls the stored procedureregister_vendor
to register the vendor. The vendor's ID, name, account number, contact, and hashed password are included in the vendor record. After successful registration, it shows a success message with the vendor's ID and redirects to the login page. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofLoginSystem
, calls theshow
method to display the login page, and disposes of the current frame.
The VendorMenu.java
file contains a class named VendorMenu
which is used to display the list of vendors in the CampusPay application. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the vendor menu page. It creates aJFrame
and adds several components to it, including a title label, a scrollable text area to display the list of vendors, and a back button. -
Vendors Text Area: A
JTextArea
is used to display the list of vendors. The text area is populated by executing the SQL querySELECT * FROM vendors
and appending each vendor's name and contact information to the text area. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofStudentHome
, calls theshow
method to display the student home page, and disposes of the current frame.
The VendorTransactionHistory.java
file contains a class named VendorTransactionHistory
which is used to display the transaction history of a vendor in the CampusPay application. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the vendor transaction history page. It creates aJFrame
and adds several components to it, including a title label, a scrollable text area to display the transactions, and a back button. -
Transactions Text Area: A
JTextArea
is used to display the transactions made by the vendor. The text area is populated by calling the stored procedureget_all_transactions_made_by_vendor
with the current user's ID as a parameter. Each transaction's ID, student ID, total amount, and date and time are appended to the text area. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofVendorHome
, calls theshow
method to display the vendor home page, and disposes of the current frame.
The VendorTransactionProcess.java
file is a part of a Java application that provides an interface for a vendor to process a transaction. Here's a detailed breakdown of the key components:
-
Class Declaration: The class
VendorTransactionProcess
is declared. -
Method Declaration: The
show()
method is declared. This method is responsible for setting up the GUI for the vendor transaction process interface. -
Frame Setup: A
JFrame
is created and its properties are set. This includes setting the default close operation, size, layout, and background color. -
Labels and Fields: Various
JLabel
andJTextField
objects are created for displaying and inputting the amount, student ID, product, and quantity. The product list is retrieved by calling theget_all_items_sold_by_vendor
stored procedure in the database. -
Table Setup: A
JTable
is created to display the products, quantities, and prices. ADefaultTableModel
is used to manage the data in the table. -
Buttons: Various
JButton
objects are created for different functionalities. This includes buttons for:-
Adding a Product: Adds the selected product and its quantity to the table and updates the total amount.
-
Removing a Product: Removes the selected product from the table and updates the total amount.
-
Confirming the Transaction: Confirms the transaction by calling the
make_transaction
andmake_order
stored procedures in the database. If the transaction is successful, it shows a success message and redirects to the vendor home interface. If the transaction fails, it shows an error message. -
Going Back: Redirects to the vendor home interface.
-
-
Frame Visibility and Position: The frame is made visible and its position is set to the center of the screen.
-
Main Method: The
main
method is declared which creates an instance ofVendorTransactionProcess
and calls theshow()
method. This is the entry point of the program. -
Helper Method: The
configureButton
method is a helper method used to configure the properties of a button. This includes setting the font, size, location, background color, and border color of the button.
The ViewStudents.java
file contains a class named ViewStudents
which is used to display a list of students in the application. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the student list page. It creates aJFrame
and adds several components to it, including a title label, a scrollable table to display the list of students, and several buttons. -
Students Table: A
JTable
is used to display the list of students. The table is populated by executing the SQL querySELECT * FROM students
and appending each student's ID, BITS_account, s_name, and Contact to the table. -
Add Button: The "Add" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofStudentRegistration
, calls theshow
method to display the student registration page, and disposes of the current frame. -
Edit Button: The "Edit" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofEditStudent
, calls theshow
method to display the edit student page, and disposes of the current frame. -
View Payments Button: The "View Payments" button has an
ActionListener
attached to it. When the button is clicked, it retrieves the selected student's ID from the table, creates an instance ofAdminViewStudentTransactions
, calls theshow
method with the student's ID as a parameter to display the student's payment history, and disposes of the current frame. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofAdminHome
, calls theshow
method to display the admin home page, and disposes of the current frame.
The ViewVendors.java
file contains a class named ViewVendors
which is used to display a list of vendors in the application. Here's a breakdown of its functionality:
-
show Method: The
show
method is used to set up and display the GUI for the vendor list page. It creates aJFrame
and adds several components to it, including a title label, a scrollable table to display the list of vendors, and several buttons. -
Vendors Table: A
JTable
is used to display the list of vendors. The table is populated by executing the stored procedureget_all_vendors
and appending each vendor's ID, name, account number, and contact to the table. -
Add Button: The "Add Vendor" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofVendorRegistration
, calls theshow
method to display the vendor registration page, and disposes of the current frame. -
Edit Button: The "Edit Vendor" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofEditVendor
, calls theshow
method to display the edit vendor page, and disposes of the current frame. -
View Transactions Button: The "View Transactions" button has an
ActionListener
attached to it. When the button is clicked, it retrieves the selected vendor's ID from the table, creates an instance ofAdminViewVendorTransaction
, calls theshow
method with the vendor's ID as a parameter to display the vendor's transaction history, and disposes of the current frame. -
View Items Button: The "View Items" button has an
ActionListener
attached to it. When the button is clicked, it retrieves the selected vendor's ID from the table, creates an instance ofAdminViewVendorItems
, calls theshow
method with the vendor's ID as a parameter to display the vendor's items, and disposes of the current frame. -
Back Button: The "Back" button has an
ActionListener
attached to it. When the button is clicked, it creates an instance ofAdminHome
, calls theshow
method to display the admin home page, and disposes of the current frame.