Parking System CRUD Application
Parking System CRUD Application
The application handles user registrations through a separate interface where users input a username and password. During registration, it checks that no fields are empty. If the inputs are valid, it inserts the new user record into the 'admin' table using a parameterized query to prevent SQL injection, and on success, confirms with a success message; otherwise, it informs the user of the error .
The 'populate_fields' function updates the input fields in the GUI with the details of the selected parking record from the table view. When a user selects a tree item, the function retrieves the item's values and sets the corresponding StringVars for slot number, vehicle type, plate number, and vehicle brand, enabling the user to view and modify existing records .
After completing database operations like add, update, or delete, the system calls `refresh_parking`, which fetches all current database records and repopulates the tree view. This ensures that the data displayed is consistent with the latest database state, providing accurate and up-to-date information to the user .
The document implements try-except blocks for error handling in all database operations involving parking records. For operations like `add_parking`, `update_parking`, and `delete_parking`, if an error occurs during the execution of SQL queries, an error message is displayed with the error details, ensuring the user is informed of the failure and the operations do not terminate abruptly .
The document uses a login system where the user's credentials are checked against the 'users' table in the database. Using the query `SELECT * FROM users WHERE username = %s AND password = %s`, it fetches the record that matches the provided credentials. If a match is found (`result` is true), the CRUD interface is launched; otherwise, an error message is displayed .
To successfully add a new parking slot in the GUI application, the user must first ensure all required fields (slot number, vehicle type, plate number, and vehicle brand) are filled. The 'add_parking' function validates these fields and uses an SQL 'INSERT INTO' command to add the data into the database. If the insertion is successful, the system displays a success message and refreshes the parking display using `refresh_parking` to show the updated list .
When deleting a parking slot, the system first checks if an item is selected in the tree view. If not, it displays an error. If a selection exists, it retrieves the selected item's ID and executes a SQL DELETE command to remove the record from the database. Upon successful deletion, a confirmation message is shown, and the `refresh_parking` function updates the displayed records. Errors during deletion trigger an error message detailing the issue .
The document outlines multiple functionalities for the GUI: adding a parking slot, updating existing parking information, deleting a parking record, and refreshing the table view of parking slots. The GUI also includes features for navigating and manipulating data like buttons to trigger these actions and input fields for user data entry .
The GUI application utilizes parameterized SQL queries during login operations to mitigate SQL injection. By using placeholders %s and passing user inputs as tuple arguments to the `execute` function, it separates user inputs from the SQL logic, thereby preventing malicious input from altering query structure .
The current user authentication method is limited by its reliance on storing passwords in a simple table without obvious hashing or salting techniques, making passwords vulnerable to database breaches. Additionally, the system seems to lack advanced security mechanisms such as multi-factor authentication, and the credentials are checked directly against possibly unencrypted database entries, which could be a security risk .