diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 5ff6309..0000000 --- a/.gitignore +++ /dev/null @@ -1,38 +0,0 @@ -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/**/target/ -!**/src/test/**/target/ - -### IntelliJ IDEA ### -.idea/modules.xml -.idea/jarRepositories.xml -.idea/compiler.xml -.idea/libraries/ -*.iws -*.iml -*.ipr - -### Eclipse ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ - -### Mac OS ### -.DS_Store \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 26d3352..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index aa00ffa..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 039a9d1..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.mvn/wrapper/fontawesomefx-8.2.jar b/.mvn/wrapper/fontawesomefx-8.2.jar deleted file mode 100644 index 6606075..0000000 Binary files a/.mvn/wrapper/fontawesomefx-8.2.jar and /dev/null differ diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar deleted file mode 100644 index c1dd12f..0000000 Binary files a/.mvn/wrapper/maven-wrapper.jar and /dev/null differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 40ca015..0000000 --- a/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,2 +0,0 @@ -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar \ No newline at end of file diff --git a/.mvn/wrapper/mysql-connector-j-8.0.33.jar b/.mvn/wrapper/mysql-connector-j-8.0.33.jar deleted file mode 100644 index 3f741f5..0000000 Binary files a/.mvn/wrapper/mysql-connector-j-8.0.33.jar and /dev/null differ diff --git a/Blank diagram.png b/Blank diagram.png deleted file mode 100644 index fda192c..0000000 Binary files a/Blank diagram.png and /dev/null differ diff --git a/Blank_diagram-removebg-preview.png b/Blank_diagram-removebg-preview.png deleted file mode 100644 index 4493d7e..0000000 Binary files a/Blank_diagram-removebg-preview.png and /dev/null differ diff --git a/Description b/Description deleted file mode 100644 index 41740e4..0000000 --- a/Description +++ /dev/null @@ -1,28 +0,0 @@ -This is a DU Cafeteria Management project developed in Java. The system includes a login system with two types of users: - -Teachers & Students: They can log in using their registration ID and password after signing up for the cafeteria. -Admin & Employees: -The admin can log in using a unique ID and password. -Employees require the admin’s permission along with their ID and password to access the system. -For security, users can recover their password using a predefined codeword in case they forget it. - -Features -For Teachers & Students: -✅ View the menu -✅ Add food items to the cart and purchase them -✅ Leave reviews for food items -✅ View purchase history -✅ Update profile - -For Admin & Employees: -✅ Access customer and product charts -✅ Track total and daily income -✅ Update product availability -✅ Add new products and set prices -✅ Admin can approve employee login to prevent unauthorized access -✅ Admin can also add new employees - -Additionally, the system includes a sign-out button, which prompts a confirmation message before logging out. - -Users can learn more about the cafeteria and its services on the "About Us" page. - diff --git a/Normal_ATM b/Normal_ATM new file mode 160000 index 0000000..9743d1c --- /dev/null +++ b/Normal_ATM @@ -0,0 +1 @@ +Subproject commit 9743d1cb67085ef456bd59eba0f6663d9d9cc5f2 diff --git a/Project Images/0e35add0-a1da-4a22-bfae-a47bb68e4ecf.jpeg b/Project Images/0e35add0-a1da-4a22-bfae-a47bb68e4ecf.jpeg deleted file mode 100644 index 0037e8d..0000000 Binary files a/Project Images/0e35add0-a1da-4a22-bfae-a47bb68e4ecf.jpeg and /dev/null differ diff --git a/Project Images/1b1e0700-839a-4f8e-8fea-28a5f1c8b53b.jpeg b/Project Images/1b1e0700-839a-4f8e-8fea-28a5f1c8b53b.jpeg deleted file mode 100644 index 9f7bcf9..0000000 Binary files a/Project Images/1b1e0700-839a-4f8e-8fea-28a5f1c8b53b.jpeg and /dev/null differ diff --git a/Project Images/24c56370-9242-4efa-a4ac-829b2121adcf.jpeg b/Project Images/24c56370-9242-4efa-a4ac-829b2121adcf.jpeg deleted file mode 100644 index 363421f..0000000 Binary files a/Project Images/24c56370-9242-4efa-a4ac-829b2121adcf.jpeg and /dev/null differ diff --git a/Project Images/312f64fe-a827-4451-bd63-ac6e52982ef2.jpeg b/Project Images/312f64fe-a827-4451-bd63-ac6e52982ef2.jpeg deleted file mode 100644 index 4ed0842..0000000 Binary files a/Project Images/312f64fe-a827-4451-bd63-ac6e52982ef2.jpeg and /dev/null differ diff --git a/Project Images/3d762ea2-f3c8-4f63-a9a1-e4aa9eeb27e1.jpeg b/Project Images/3d762ea2-f3c8-4f63-a9a1-e4aa9eeb27e1.jpeg deleted file mode 100644 index b3acf5b..0000000 Binary files a/Project Images/3d762ea2-f3c8-4f63-a9a1-e4aa9eeb27e1.jpeg and /dev/null differ diff --git a/Project Images/418b8dd2-72d0-4cbc-835a-d0970433f7da.jpeg b/Project Images/418b8dd2-72d0-4cbc-835a-d0970433f7da.jpeg deleted file mode 100644 index c842e74..0000000 Binary files a/Project Images/418b8dd2-72d0-4cbc-835a-d0970433f7da.jpeg and /dev/null differ diff --git a/Project Images/46b50d82-94db-4362-9879-572a7fc0a5dc.jpeg b/Project Images/46b50d82-94db-4362-9879-572a7fc0a5dc.jpeg deleted file mode 100644 index ca64b51..0000000 Binary files a/Project Images/46b50d82-94db-4362-9879-572a7fc0a5dc.jpeg and /dev/null differ diff --git a/Project Images/6c1cc7aa-5cf5-4cb5-9e17-b3f93a62449c.jpeg b/Project Images/6c1cc7aa-5cf5-4cb5-9e17-b3f93a62449c.jpeg deleted file mode 100644 index ab357d5..0000000 Binary files a/Project Images/6c1cc7aa-5cf5-4cb5-9e17-b3f93a62449c.jpeg and /dev/null differ diff --git a/Project Images/781a7020-517f-4a6f-8bd3-84db41b8d772.jpeg b/Project Images/781a7020-517f-4a6f-8bd3-84db41b8d772.jpeg deleted file mode 100644 index b15c7ea..0000000 Binary files a/Project Images/781a7020-517f-4a6f-8bd3-84db41b8d772.jpeg and /dev/null differ diff --git a/Project Images/89d48ea2-b30b-4d8c-9fb6-a57acb44d67d.jpeg b/Project Images/89d48ea2-b30b-4d8c-9fb6-a57acb44d67d.jpeg deleted file mode 100644 index 184076f..0000000 Binary files a/Project Images/89d48ea2-b30b-4d8c-9fb6-a57acb44d67d.jpeg and /dev/null differ diff --git a/Project Images/8a7bfa9c-228d-4f5a-b027-27b7aeb6df10.jpeg b/Project Images/8a7bfa9c-228d-4f5a-b027-27b7aeb6df10.jpeg deleted file mode 100644 index 739b541..0000000 Binary files a/Project Images/8a7bfa9c-228d-4f5a-b027-27b7aeb6df10.jpeg and /dev/null differ diff --git a/Project Images/a70b9020-8d4b-46da-8fd3-6465514c20a8.jpeg b/Project Images/a70b9020-8d4b-46da-8fd3-6465514c20a8.jpeg deleted file mode 100644 index 8635e12..0000000 Binary files a/Project Images/a70b9020-8d4b-46da-8fd3-6465514c20a8.jpeg and /dev/null differ diff --git a/Project Images/a7e13c8f-bf9d-4bc2-8549-0361595af428.jpeg b/Project Images/a7e13c8f-bf9d-4bc2-8549-0361595af428.jpeg deleted file mode 100644 index bbf3553..0000000 Binary files a/Project Images/a7e13c8f-bf9d-4bc2-8549-0361595af428.jpeg and /dev/null differ diff --git a/Project Images/b244614c-247c-47a2-b56d-3adf500e97fc.jpeg b/Project Images/b244614c-247c-47a2-b56d-3adf500e97fc.jpeg deleted file mode 100644 index cae5ab8..0000000 Binary files a/Project Images/b244614c-247c-47a2-b56d-3adf500e97fc.jpeg and /dev/null differ diff --git a/Project Images/b54e93a3-0e03-43df-8a57-6f4ddd62c150.jpeg b/Project Images/b54e93a3-0e03-43df-8a57-6f4ddd62c150.jpeg deleted file mode 100644 index de53096..0000000 Binary files a/Project Images/b54e93a3-0e03-43df-8a57-6f4ddd62c150.jpeg and /dev/null differ diff --git a/Project Images/c2dfa87d-2004-4b18-b060-9e532fc7ba80.jpeg b/Project Images/c2dfa87d-2004-4b18-b060-9e532fc7ba80.jpeg deleted file mode 100644 index ad66ce5..0000000 Binary files a/Project Images/c2dfa87d-2004-4b18-b060-9e532fc7ba80.jpeg and /dev/null differ diff --git a/Project Images/cdf33b47-6456-4225-9615-bd677d453f8b.jpeg b/Project Images/cdf33b47-6456-4225-9615-bd677d453f8b.jpeg deleted file mode 100644 index b46cece..0000000 Binary files a/Project Images/cdf33b47-6456-4225-9615-bd677d453f8b.jpeg and /dev/null differ diff --git a/Project Images/d03c1e4f-8208-4435-ab80-838c08632b58.jpeg b/Project Images/d03c1e4f-8208-4435-ab80-838c08632b58.jpeg deleted file mode 100644 index 32e817a..0000000 Binary files a/Project Images/d03c1e4f-8208-4435-ab80-838c08632b58.jpeg and /dev/null differ diff --git a/Project Images/d4bf673a-311b-47ec-9985-8ed9d2e42774.jpeg b/Project Images/d4bf673a-311b-47ec-9985-8ed9d2e42774.jpeg deleted file mode 100644 index a3cc24a..0000000 Binary files a/Project Images/d4bf673a-311b-47ec-9985-8ed9d2e42774.jpeg and /dev/null differ diff --git a/Project Report & Presentation/OOP Project Presentation Slide.pptx b/Project Report & Presentation/OOP Project Presentation Slide.pptx deleted file mode 100644 index dcb5b34..0000000 Binary files a/Project Report & Presentation/OOP Project Presentation Slide.pptx and /dev/null differ diff --git a/Project Report & Presentation/OOP Report (1).docx b/Project Report & Presentation/OOP Report (1).docx deleted file mode 100644 index 08e261a..0000000 Binary files a/Project Report & Presentation/OOP Report (1).docx and /dev/null differ diff --git a/README.md b/README.md deleted file mode 100644 index 292dfd1..0000000 --- a/README.md +++ /dev/null @@ -1,176 +0,0 @@ -# Cafeteria Management, DU -## Overview -The Cafeteria Management, DU, is a Java-based application designed to streamline cafeteria operations at the Science Complex, University of Dhaka. - -It provides a secure and efficient platform for teachers, students, admins, and employees to manage cafeteria services. -The system features user authentication, food ordering, purchase tracking, and administrative controls, ensuring a seamless -experience for both customers and staff. With role-based access, real-time updates, and secure login mechanisms, this system -enhances efficiency, transparency, and user convenience. - -## Tools -- IDE: IntelliJ -- Language: JAVA -- Framework: JavaFX -- Database: MySQL -- Testing: Manual testing for the overall -system functionality - - -## Workflow -![image alt](https://github.com/Clear20-22/Java-Project/blob/5ae01b462834a38334f3274799ee52cdaafe6912/Blank%20diagram.png) - -## Directory Layout - -``` -cafe/ -│ -├── src/ # Source code -│ ├── main/ -│ ├── java/ -| | |── module-info.java -│ │ |── cafe.management.cafe/ -| | ├── AdminController.java -│ │ ├── CafeManagement.java # Main entry point of the application -│ │ ├── cardProduct.java -| | ├── CustomerController.java -| | ├── CustomerOrderHistory.java -│ │ ├── CustomerSummary.java -| | ├── DatabaseUsers.java # Database connection logic cardProduct.java -| | ├── EmployeeData.java -│ │ ├── ManagementControl.java -│ │ ├── ProductData.java -│ │ └── SurfaceLayoutContoller.java -| | ├── data.java -│ └── resources/ -│ ├── cafe.management/ -│ ├── cafe/ # JavaFX FXML & CSS files -| ├────── cardProduct.fxml -| ├────── CustomerLayout.fxml -| ├────── LoginPage.fxml -| ├────── LoginStyle.css -| ├────── mainForm1Design.css -| ├────── SurfaceLayout.fxml -| ├────── test.fxml -│ ├── img/ -├── target/ -├── lib/ -├── out/ -│ ├──── artifacts -| ├───cafe_jar -| ├──── cafe.jar -├── .git/ -├── .idea/ -├── .mvn/ -├── javafx-sdk-23.0.1. -├── README.md -├── pom.xml -├── .gigintore - -``` - -## Key Features - -### For Teachers & Students: -- **Secure Login & Sign-up** – Access the system using a registration ID and password. -- **View Menu** – Browse available food items with prices. -- **Order Food** – Add items to the cart and complete purchases. -- **Purchase History** – View past orders and payments. -- **Leave Reviews & Ratings** – Provide feedback on food quality. -- **Profile Management** – Update personal details. -- **Password Recovery** – Reset password using a predefined codeword. - -### For Admin & Employees: -- **User Management** – Admin can approve new employees and track users. -- **Inventory Management** – Update product availability and pricing. -- **Sales Tracking** – Monitor daily and total income. -- **Order Management** – Process and track customer orders. -- **Employee Access Control** – Admin approves employee logins to prevent unauthorized access. - -## Additional Features: -- **Sign-out Confirmation** – Ensures secure logout. -- **"About Us" Page** – Provides details about the cafeteria and its services. - - - -## Download and Setup Instructions - -### **1. Download the ZIP File:** -Download the project ZIP file from the [repository](#). - -### **2. Extract the Files:** -Extract the contents of the ZIP file to your preferred directory. - -### **3. Environment Setup:** - -Ensure that you have **JavaFX** set up in your IDE. You may need to manually configure JavaFX if it is not bundled with your IDE. Refer to the [JavaFX installation guide](https://openjfx.io/) if necessary. - -- **For IntelliJ IDEA or Eclipse:** - Add the **JavaFX SDK** to your project libraries. - Set the VM options to include JavaFX modules like: - ```bash - --module-path "path-to-javafx-sdk/lib" --add-modules javafx.controls,javafx.fxml - ``` - -### **4. Database Setup:** - -1. **Modify Database Credentials:** - - - Open the `DatabaseUsers.java` file located in your project folder. - - Find the following lines and update them with your **MySQL username** and **password**: - - ```java - String jdbcUsername = "root"; // MySQL username - String jdbcPassword = "root"; // MySQL password - String jdbcURL = "jdbc:mysql://localhost:3306/cafeteria_db"; // Database URL - ``` - - - Replace `"root"` with your actual MySQL username and password. Example: - - ```java - String jdbcUsername = "your_username"; // MySQL username - String jdbcPassword = "your_password"; // MySQL password - String jdbcURL = "jdbc:mysql://localhost:3306/cafeteria_db"; // Database URL - ``` - -2. **Save the file** after modifying the credentials. - -### **5. Run the Application:** - -To run the application, follow these steps: - -1. Open a terminal or command prompt in the directory where `cafe.jar` is located. -2. Use the following command to run the application: - - ```sh - java --module-path "your_lib_file_directory" --add-modules javafx.controls,javafx.fxml -jar cafe.jar - - -1. **Run the server** (for chat functionality or backend processes). -2. **Run the Admin and Client sections** of the application as needed. - ---- - -## Troubleshooting - -- **Database Connection Error?** - Make sure MySQL is running and that the database URL, username, and password are correctly set in the `DatabaseUsers.java` file. - -- **JavaFX Issues?** - Ensure you have added the JavaFX SDK and set the VM options correctly in your IDE. - ---- - -## License - -Feel free to fork, clone, and modify the project. If you encounter any issues, please open an issue on this repository. - ---- - -🚀 **Enjoy using the Cafeteria Management, DU.** - - -## Authors -- Suraya Jannat Mim (Roll: 17)
-- Anisha Tabassum (Roll: 19)
-- Jubayer Ahmed Sojib (Roll: 23)
-- Tamal Kanti Sarker (Roll: 39) diff --git a/UML Diagram.png b/UML Diagram.png deleted file mode 100644 index 6b15b52..0000000 Binary files a/UML Diagram.png and /dev/null differ diff --git a/lib/mysql-connector-j-8.0.33.jar b/lib/mysql-connector-j-8.0.33.jar deleted file mode 100644 index d3f5a12..0000000 --- a/lib/mysql-connector-j-8.0.33.jar +++ /dev/null @@ -1 +0,0 @@ - diff --git a/mvnw b/mvnw deleted file mode 100644 index 8a8fb22..0000000 --- a/mvnw +++ /dev/null @@ -1,316 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /usr/local/etc/mavenrc ] ; then - . /usr/local/etc/mavenrc - fi - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" - fi - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`\\unset -f command; \\command -v java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; -fi - -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi -else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR -fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - $MAVEN_DEBUG_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" \ - "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd deleted file mode 100644 index 1d8ab01..0000000 --- a/mvnw.cmd +++ /dev/null @@ -1,188 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM https://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* -if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" - -FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) -) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% ^ - %JVM_CONFIG_MAVEN_PROPS% ^ - %MAVEN_OPTS% ^ - %MAVEN_DEBUG_OPTS% ^ - -classpath %WRAPPER_JAR% ^ - "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ - %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" -if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%"=="on" pause - -if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% - -cmd /C exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 18b2934..0000000 --- a/pom.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - 4.0.0 - - cafe.Manegment - cafe - 1.0-SNAPSHOT - cafe - - - UTF-8 -5.10.2 - - - - org.openjfx - javafx-controls - 22.0.1 - - - mysql - mysql-connector-java - 8.0.33 - - - - org.openjfx - javafx-fxml - 22.0.1 - - - org.openjfx - javafx-web - 22.0.1 - - - org.openjfx - javafx-swing - 22.0.1 - - - org.openjfx - javafx-media - 22.0.1 - - org.controlsfx - controlsfx - 11.2.1 - - com.dlsc.formsfx - formsfx-core - 11.6.0 - - - org.openjfx - * - - - - net.synedra - validatorfx - 0.5.0 - - - org.openjfx - * - - - - org.kordamp.ikonli - ikonli-javafx - 12.3.1 - - eu.hansolo - tilesfx - 21.0.3 - - - org.openjfx - * - - - - com.github.almasb - fxgl - 17.3 - - - org.openjfx - * - - - - - org.junit.jupiter - junit-jupiter-api - ${junit.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit.version} - test - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.13.0 - - 22 - 22 - - - - org.openjfx - javafx-maven-plugin - 0.0.8 - - - - default-cli - - cafe.manegment.cafe/cafe.management.cafe.CafeManagement - app - app - app - true - true - true - - - - - - - \ No newline at end of file diff --git a/src/lib/mysql-connector-j-9.1.0.jar b/src/lib/mysql-connector-j-9.1.0.jar deleted file mode 100644 index d3f5a12..0000000 --- a/src/lib/mysql-connector-j-9.1.0.jar +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/main/java/cafe/management/cafe/AdminController.java b/src/main/java/cafe/management/cafe/AdminController.java deleted file mode 100644 index 29845f7..0000000 --- a/src/main/java/cafe/management/cafe/AdminController.java +++ /dev/null @@ -1,1532 +0,0 @@ -package cafe.management.cafe; - -import javafx.application.Platform; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import javafx.scene.Node; -import javafx.scene.chart.*; -import javafx.scene.control.*; -import javafx.scene.control.cell.PropertyValueFactory; -import javafx.scene.image.Image; -import javafx.scene.image.ImageView; -import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.GridPane; -import javafx.stage.FileChooser; - -import java.io.File; -import java.io.IOException; -import java.sql.*; -import java.text.DateFormatSymbols; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; - -import static javafx.collections.FXCollections.observableList; - -public class AdminController { - - @FXML - private AnchorPane DashboardMainpage; - - @FXML - private AnchorPane DashboardScroll; - - @FXML - private AnchorPane DashboardChart; - - - @FXML - private Button cutomer_btn; - - @FXML - private Button dashboard_btn; - - @FXML - private Button inventory_addBtn; - - @FXML - private Button inventory_btn; - - @FXML - private Button inventory_clearBtn; - - @FXML - private TableColumn inventory_col_date; - - @FXML - private TableColumn inventory_col_price; - - @FXML - private TableColumn inventory_col_productID; - - @FXML - private TableColumn inventory_col_productName; - - @FXML - private TableColumn inventory_col_status; - - @FXML - private TableColumn inventory_col_stock; - - @FXML - private TableColumn inventory_col_type; - - @FXML - private Button inventory_deleteBtn; - - @FXML - private AnchorPane inventory_form; - - @FXML - private ImageView inventory_imageView; - - @FXML - private Button inventory_importBtn; - - @FXML - private TextField inventory_price; - - @FXML - private TextField inventory_productID; - - @FXML - private TextField inventory_productName; - - @FXML - private ComboBox inventory_status; - - @FXML - private TextField inventory_stock; - - @FXML - private TableView inventory_tableView; - - @FXML - private Button inventory_updateBtn; - - @FXML - private Button logout_btn; - - @FXML - private AnchorPane main_form; - - @FXML - private TextField menu_amount; - - @FXML - private Button menu_btn; - - @FXML - private Label menu_change; - - @FXML - private TableColumn menu_col_price; - - @FXML - private TableColumn menu_col_productName; - - @FXML - private TableColumn menu_col_quantity; - - @FXML - private AnchorPane menu_form; - - @FXML - private GridPane menu_gridPane; - - @FXML - private Button menu_payBtn; - - @FXML - private Button menu_receiptBtn; - - @FXML - private Button menu_removeBtn; - - @FXML - private ScrollPane menu_scrollPane; - - @FXML - private TableView menu_tableView; - - @FXML - private Label menu_total; - - @FXML - private Label username; - - private Image img; - - @FXML - private AnchorPane EmployeePage; - - - @FXML - private ComboBox Inventory_choiceType; - - @FXML - private AnchorPane ProfilePage; - - - @FXML - private AnchorPane ConfirmUpdate_page; - - - @FXML - private ComboBox inventory_choiceStatus; - - @FXML - private Label Today_Income; - - @FXML - private Label Total_Sold; - - @FXML - private Label Total_customer; - - @FXML - private Label Total_income; - - private String[] type_list = {"Meals","Drinks"}; - - private String[] status_list = {"Available","Unavailable"}; - - private Connection connection = null; - - private PreparedStatement preparedStatement = null; - - private ResultSet resultSet = null; - - @FXML - private AnchorPane customer_show; - - public AdminController() { - connection = DatabaseUsers.getConnection(); - } - - @FXML - void LeavePage(ActionEvent event) { - Alert alrt = new Alert(Alert.AlertType.CONFIRMATION); - alrt.setTitle("Confirmation Message"); - alrt.setHeaderText(null); - alrt.setContentText("Are you sure you want to sign out."); - - Optional opt = alrt.showAndWait(); - - if(opt.isPresent() && opt.get() == ButtonType.OK) { - try { - CafeManagement.switchScene("LoginPage.fxml", 800); - } catch (IOException e) { - e.printStackTrace(); - System.err.println("Failed to load LoginPage.fxml"); - } - } else { - System.out.println("Stay loggedin."); - } - } - - @FXML - void Customer(ActionEvent event) { - DashboardMainpage.setVisible(false); - inventory_form.setVisible(false); - menu_form.setVisible(false); - ProfilePage.setVisible(false); - ConfirmUpdate_page.setVisible(false); - EmployeePage.setVisible(false); - customer_show.setVisible(true); - - customercount(); - showCustomerData(); - } - - private HashMap track = new HashMap<>(); - private double tot = 0.0; - private int totsold = 0; - private int totcustomer = 0; - - @FXML - void Dashboard(ActionEvent event) { - DashboardMainpage.setVisible(true); - inventory_form.setVisible(false); - menu_form.setVisible(false); - ProfilePage.setVisible(false); - ConfirmUpdate_page.setVisible(false); - EmployeePage.setVisible(false); - customer_show.setVisible(false); - - loadCustomerChartData(); - initializeCustomerChart(); - initializeIncomeChart(); - - tot = 0.0; - totsold = 0; - track.clear(); - - ArrayList summaries = getCustomerSummaries(); - totcustomer = summaries.size(); - - for (CustomerSummary summary : summaries) { - tot += summary.getTotalPrice(); - totsold += summary.getTotalQuantity(); - String date = summary.getDate(); - track.put(date, track.getOrDefault(date, 0.0) + summary.getTotalPrice()); - } - - String formattedDate = LocalDate.now().format(DateTimeFormatter.ISO_DATE); - double todayIncomeValue = track.getOrDefault(formattedDate, 0.0); - - String todayIncome = String.format("%.2f", todayIncomeValue) + " TK"; - String totalIncome =String.format("%.2f", tot) + " TK"; - String totalCustomer =String.valueOf(totsold); - String totalSold =String.valueOf(totcustomer); - - Today_Income.setText(todayIncome); - Total_income.setText(totalIncome); - Total_Sold.setText(totalCustomer); - Total_customer.setText(totalSold); - } - - void inventory_Type_Status() { - List list = new ArrayList<>(); - - for(String s : type_list){ - list.add(s); - } - ObservableList observableList = FXCollections.observableArrayList(list); - Inventory_choiceType.setItems(observableList); - - List statusList = new ArrayList<>(); - - for(String s:status_list){ - statusList.add(s); - } - - ObservableList sList = FXCollections.observableArrayList(statusList); - - inventory_choiceStatus.setItems(sList); - } - - void ClearFields() { - inventory_imageView.setImage(null); - img = null; - inventory_productName.requestFocus(); - inventory_productID.requestFocus(); - inventory_stock.requestFocus(); - inventory_price.requestFocus(); - inventory_choiceStatus.requestFocus(); - Inventory_choiceType.requestFocus(); - inventory_productName.setText(""); - inventory_productID.setText(""); - inventory_stock.setText(""); - inventory_price.setText(""); - inventory_choiceStatus.setValue(null); - Inventory_choiceType.setValue(null); - } - - ObservableList Inventory_ProductDatalist(){ - ObservableList list = FXCollections.observableArrayList(); - - String query = "SELECT * FROM ProductDetails"; - - try { - preparedStatement = connection.prepareStatement(query); - resultSet = preparedStatement.executeQuery(); - ProductData data = null; - - while(resultSet.next()){ - data = new ProductData(resultSet.getString("ProductID"), - resultSet.getString("ProductName"), - resultSet.getString("Type"), - resultSet.getInt("Stock"), - resultSet.getDouble("Price"), - resultSet.getString("Status"), - resultSet.getDate("DateAdded"), - resultSet.getString("Image") - ); - list.add(data); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - CloseConnection(); - ClearFields(); - } - return list; - } - - ObservableList InventoryListData; - - void InventoryShowData() { - InventoryListData = Inventory_ProductDatalist(); - - inventory_col_productID.setCellValueFactory(new PropertyValueFactory<>("ProductID")); - inventory_col_productName.setCellValueFactory(new PropertyValueFactory<>("ProductName")); - inventory_col_type.setCellValueFactory(new PropertyValueFactory<>("Type")); - inventory_col_stock.setCellValueFactory(new PropertyValueFactory<>("Stock")); - inventory_col_price.setCellValueFactory(new PropertyValueFactory<>("Price")); - inventory_col_status.setCellValueFactory(new PropertyValueFactory<>("Status")); - inventory_col_date.setCellValueFactory(new PropertyValueFactory<>("DateAdded")); - inventory_tableView.setItems(InventoryListData); - } - - @FXML - void InventoryAddBtn(ActionEvent event) { - if(inventory_productName.getText().isEmpty() || - inventory_productID.getText().isEmpty() || - inventory_stock.getText().isEmpty() || - inventory_price.getText().isEmpty() || - inventory_choiceStatus.getSelectionModel().getSelectedItem() == null || - Inventory_choiceType.getSelectionModel().getSelectedItem() == null|| - inventory_imageView.getImage() == null){ - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Please fill all the fields."); - alert.showAndWait(); - } else { - String CheckProductID = "SELECT ProductID FROM ProductDetails WHERE ProductID = '" + inventory_productID.getText() +"'"; - try { - Statement Statement = connection.createStatement(); - ResultSet rs = Statement.executeQuery(CheckProductID); - if(rs.next()){ - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Product ID already exists."); - alert.showAndWait(); - } else { - String query = "INSERT INTO ProductDetails (ProductID, ProductName, Type, Stock, Price, Status, DateAdded, Image) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; - preparedStatement = connection.prepareStatement(query); - preparedStatement.setString(1, inventory_productID.getText()); - preparedStatement.setString(2, inventory_productName.getText()); - preparedStatement.setString(3, Inventory_choiceType.getSelectionModel().getSelectedItem().toString()); - preparedStatement.setInt(4, Integer.parseInt(inventory_stock.getText())); - preparedStatement.setDouble(5, Double.parseDouble(inventory_price.getText())); - preparedStatement.setString(6, inventory_choiceStatus.getSelectionModel().getSelectedItem().toString()); - preparedStatement.setDate(7, new Date(System.currentTimeMillis())); - preparedStatement.setString(8, img.getUrl()); - int rowsInserted = preparedStatement.executeUpdate(); - if(rowsInserted > 0){ - Alert alert = new Alert(Alert.AlertType.INFORMATION); - alert.setTitle("Information Message"); - alert.setHeaderText(null); - alert.setContentText("Product added successfully."); - alert.showAndWait(); - - inventory_productName.requestFocus(); - inventory_productID.requestFocus(); - inventory_stock.requestFocus(); - inventory_price.requestFocus(); - inventory_choiceStatus.requestFocus(); - Inventory_choiceType.requestFocus(); - inventory_productName.setText(""); - inventory_productID.setText(""); - inventory_stock.setText(""); - - } - else{ - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Failed to add product."); - } - } - - } catch (SQLException e) { - throw new RuntimeException(e); - } - finally { - CloseConnection(); - InventoryShowData(); - } - } - } - - @FXML - void InventoryClearBtn(ActionEvent event) { - ClearFields(); - InventoryShowData(); - } - - @FXML - void InventoryDeleteBtn(ActionEvent event) { - if (inventory_productID.getText().isEmpty()) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Please fill the Product ID field."); - alert.showAndWait(); - } else { - String CheckProductID = "SELECT ProductID FROM ProductDetails WHERE ProductID = '" + inventory_productID.getText() + "'"; - - try { - connection = DatabaseUsers.getConnection(); - Statement statement = connection.createStatement(); - ResultSet rs = statement.executeQuery(CheckProductID); - - if (!rs.next()) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Product ID does not exist."); - alert.showAndWait(); - } else { - Alert alert = new Alert(Alert.AlertType.CONFIRMATION); - alert.setTitle("Confirmation Message"); - alert.setHeaderText(null); - alert.setContentText("Are you sure you want to delete this Product ID: " + inventory_productID.getText() + "?"); - - Optional opt = alert.showAndWait(); - - if (opt.isPresent() && opt.get() == ButtonType.OK) { - String query = "DELETE FROM ProductDetails WHERE ProductID = ?"; - preparedStatement = connection.prepareStatement(query); - preparedStatement.setString(1, inventory_productID.getText()); - - int rowsDeleted = preparedStatement.executeUpdate(); - - if (rowsDeleted > 0) { - Alert infoAlert = new Alert(Alert.AlertType.INFORMATION); - infoAlert.setTitle("Information Message"); - infoAlert.setHeaderText(null); - infoAlert.setContentText("Product deleted successfully."); - infoAlert.showAndWait(); - } else { - Alert errorAlert = new Alert(Alert.AlertType.ERROR); - errorAlert.setTitle("Error Message"); - errorAlert.setHeaderText(null); - errorAlert.setContentText("Failed to delete product."); - errorAlert.showAndWait(); - } - } - } - - InventoryShowData(); - - } catch (SQLException e) { - e.printStackTrace(); - } finally { - CloseConnection(); - ClearFields(); - } - } - - } - - @FXML - - void InventoryUpdateBtn(ActionEvent event) { - if (inventory_productID.getText().isEmpty()) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Please fill the Product ID field."); - alert.showAndWait(); - } else { - String CheckProductID = "SELECT ProductID FROM ProductDetails WHERE ProductID = '" + inventory_productID.getText() + "'"; - - try { - Statement statement = connection.createStatement(); - ResultSet rs = statement.executeQuery(CheckProductID); - - if (!rs.next()) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Product ID does not exist."); - alert.showAndWait(); - } else { - - String pdType = null; - int pdStock = 0; - double pdPrice = 0.0; - String pdStatus = null; - String pdImage = null; - String find = "SELECT ProductName, Type, Stock, Price, Status, Image FROM ProductDetails WHERE ProductID = ?"; - String pdName = null; - try { - preparedStatement = connection.prepareStatement(find); - preparedStatement.setString(1, inventory_productID.getText()); - - ResultSet result = preparedStatement.executeQuery(); - - if (result.next()) { - pdName = result.getString("ProductName"); - pdType = result.getString("Type"); - pdStock = result.getInt("Stock"); - pdPrice = result.getDouble("Price"); - pdStatus = result.getString("Status"); - pdImage = result.getString("Image"); - } - } catch (SQLException e) { - e.printStackTrace(); - } - - pdName = (inventory_productName.getText().isEmpty()) ? pdName : inventory_productName.getText(); - pdType = (Inventory_choiceType.getSelectionModel().getSelectedItem() == null) ? pdType : Inventory_choiceType.getSelectionModel().getSelectedItem().toString(); - pdStock = (inventory_stock.getText().isEmpty()) ? pdStock : Integer.parseInt(inventory_stock.getText()); - pdPrice = (inventory_price.getText().isEmpty()) ? pdPrice : Double.parseDouble(inventory_price.getText()); - pdStatus = (inventory_choiceStatus.getSelectionModel().getSelectedItem() == null) ? pdStatus : inventory_choiceStatus.getSelectionModel().getSelectedItem().toString(); - pdImage = (img == null) ? pdImage : img.getUrl(); - - String query = "UPDATE ProductDetails SET ProductName = ?, Type = ?, Stock = ?, Price = ?, Status = ?, DateAdded = ?, Image = ? WHERE ProductID = ?"; - - preparedStatement = connection.prepareStatement(query); - preparedStatement.setString(1, pdName); - preparedStatement.setString(2, pdType); - preparedStatement.setInt(3, pdStock); - preparedStatement.setDouble(4, pdPrice); - preparedStatement.setString(5, pdStatus); - preparedStatement.setDate(6, new Date(System.currentTimeMillis())); - preparedStatement.setString(7, pdImage); - preparedStatement.setString(8, inventory_productID.getText()); - - Alert alrt = new Alert(Alert.AlertType.CONFIRMATION); - alrt.setTitle("Confirmation Message"); - alrt.setHeaderText(null); - alrt.setContentText("Are you sure you want to update this Product ID: " + inventory_productID.getText() + "?"); - - Optional opt = alrt.showAndWait(); - - if (opt.isPresent() && opt.get() == ButtonType.OK) { - - int rowsUpdated = preparedStatement.executeUpdate(); - - if (rowsUpdated > 0) { - Alert alert = new Alert(Alert.AlertType.INFORMATION); - alert.setTitle("Information Message"); - alert.setHeaderText(null); - alert.setContentText("Product updated successfully."); - alert.showAndWait(); - - } else { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Failed to update product."); - alert.showAndWait(); - } - } - - InventoryShowData(); - } - } catch (SQLException e) { - throw new RuntimeException(e); - } finally { - CloseConnection(); - ClearFields(); - } - } - } - - @FXML - void InventoryImortBtn(ActionEvent event) { - FileChooser fileChooser = new FileChooser(); - fileChooser.setTitle("Open Resource File"); - fileChooser.getExtensionFilters().addAll( - new FileChooser.ExtensionFilter("Open Image File", "*.png", "*.jpg") - ); - - File file = fileChooser.showOpenDialog(DashboardMainpage.getScene().getWindow()); - - if(file != null){ - img = new Image(file.toURI().toString(),168,144,false,true); - inventory_imageView.setImage(img); - } - } - - @FXML - void Inventory(ActionEvent event) { - DashboardMainpage.setVisible(false); - inventory_form.setVisible(true); - ProfilePage.setVisible(false); - menu_form.setVisible(false); - ConfirmUpdate_page.setVisible(false); - EmployeePage.setVisible(false); - customer_show.setVisible(false); - inventory_Type_Status(); - InventoryShowData(); - } - - private ObservableList cardProduct = FXCollections.observableArrayList(); - - public ObservableList menuCard(){ - String sql = "SELECT * FROM productdetails"; - ObservableList temp = FXCollections.observableArrayList(); - try{ - preparedStatement = connection.prepareStatement(sql); - resultSet = preparedStatement.executeQuery(); - - while(resultSet.next()){ - ProductData prod; - if ("Available".equalsIgnoreCase(resultSet.getString("Status").trim())) { - prod = new ProductData(resultSet.getString("ProductID"), - resultSet.getString("ProductName"), - resultSet.getDouble("Price"), - resultSet.getString("Image")); - temp.add(prod); - } - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - CloseConnection(); - } - return temp; - } - - public void menuDisplyCard(){ - cardProduct.clear(); - cardProduct.addAll(menuCard()); - - menu_gridPane.getChildren().clear(); - - int col=0; - int row=0; - menu_gridPane.getRowConstraints().clear(); - menu_gridPane.getColumnConstraints().clear(); - -// menu_gridPane.setHgap(15); -// menu_gridPane.setVgap(15); - for(int i = 0;i < cardProduct.size();i++){ - try { - FXMLLoader load = new FXMLLoader(); - load.setLocation(getClass().getResource("CardProduct.fxml")); - AnchorPane pan = load.load(); - - CardProduct controller = load.getController(); - controller.setData(cardProduct.get(i)); - - if(col == 3){ - col = 0; - row++; - } - menu_gridPane.add(pan,col++,row); - GridPane.setMargin(pan, new Insets(10, 10, 10, 10)); - - } catch (Exception e){ - e.printStackTrace(); - } - } - } - - @FXML - void Menu(ActionEvent event) { - DashboardMainpage.setVisible(false); - inventory_form.setVisible(false); - ProfilePage.setVisible(false); - menu_form.setVisible(true); - ConfirmUpdate_page.setVisible(false); - EmployeePage.setVisible(false); - customer_show.setVisible(false); - - menuDisplyCard(); - displayorder(); - } - - @FXML - private Label ProfileCat; - - @FXML - private Label ProfileDept; - - @FXML - private Label ProfileID; - - @FXML - private Label ProfileName; - - private String registration_ID; - - private String fullName; - - - @FXML - private Label updatePhone; - - void showProfileInformation(){ - - String regID = ManagementControl.ID; - - try { - String sql = "SELECT FullName, RegistrationID, Category, PhoneNumber, Department FROM userdetails WHERE RegistrationID = ?"; - - preparedStatement = connection.prepareStatement(sql); - preparedStatement.setString(1, regID); - - resultSet = preparedStatement.executeQuery(); - - if (resultSet.next()) { - String name = resultSet.getString("FullName"); - String registrationId = resultSet.getString("RegistrationID"); - String category = resultSet.getString("Category"); - String phone = resultSet.getString("PhoneNumber"); - String department = resultSet.getString("Department"); - - fullName = name; - registration_ID = registrationId; - - ProfileID.setText(registrationId); - ProfileName.setText(name); - ProfileCat.setText(category); - if(department != null) - ProfileDept.setText(department); - if(phone != null) - updatePhone.setText(phone); - - } else { - System.out.println("No data found for regID: " + regID); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - CloseConnection(); - } - - } - - @FXML - void Profile(ActionEvent event) { - DashboardMainpage.setVisible(false); - inventory_form.setVisible(false); - ProfilePage.setVisible(true); - menu_form.setVisible(false); - ConfirmUpdate_page.setVisible(false); - EmployeePage.setVisible(false); - customer_show.setVisible(false); - - showProfileInformation(); - } - - @FXML - private TextField const_ID; - - @FXML - private TextField updateName; - - @FXML - private TextField update_Department; - - @FXML - private TextField update_phone; - - - - - @FXML - void ProfileUpdate(ActionEvent event) { - Alert alrt = new Alert(Alert.AlertType.CONFIRMATION); - alrt.setTitle("Confirmation Message"); - alrt.setHeaderText(null); - alrt.setContentText("Are you sure you want to update your information."); - - Optional opt = alrt.showAndWait(); - - if(opt.isPresent() && opt.get() == ButtonType.OK){ - ProfilePage.setVisible(false); - ConfirmUpdate_page.setVisible(true); - const_ID.setText(registration_ID); - const_ID.setDisable(true); - updateName.setText(fullName); - updateName.requestFocus(); - } - - } - - - - @FXML - void ConfirmUpdate(ActionEvent event) { - Alert alrt = new Alert(Alert.AlertType.CONFIRMATION); - alrt.setTitle("Confirmation Message"); - alrt.setHeaderText(null); - alrt.setContentText("Are you sure you want to update your information."); - - Optional opt = alrt.showAndWait(); - - if(opt.isPresent() && opt.get() == ButtonType.OK){ - ProfilePage.setVisible(true); - ConfirmUpdate_page.setVisible(false); - confirm_update(); - } - } - - - - void confirm_update(){ - String name = updateName.getText(); - String department = update_Department.getText(); - String phone = update_phone.getText(); - - if (name.isEmpty() || department.isEmpty() || phone.isEmpty()) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error"); - alert.setHeaderText(null); - alert.setContentText("All fields are required. Please fill out all fields."); - alert.showAndWait(); - return; - } - - try { - String updateQuery = "UPDATE userdetails SET FullName = ?, Department = ?, PhoneNumber = ? WHERE RegistrationID = ?"; - PreparedStatement pstmt = connection.prepareStatement(updateQuery); - - pstmt.setString(1, name); - pstmt.setString(2, department); - pstmt.setString(3, phone); - pstmt.setString(4, const_ID.getText()); - - int rowsAffected = pstmt.executeUpdate(); - - if (rowsAffected > 0) { - Alert alert = new Alert(Alert.AlertType.INFORMATION); - alert.setTitle("Success"); - alert.setHeaderText(null); - alert.setContentText("Profile updated successfully!"); - alert.showAndWait(); - showProfileInformation(); - } else { - Alert alert = new Alert(Alert.AlertType.WARNING); - alert.setTitle("Warning"); - alert.setHeaderText(null); - alert.setContentText("No matching record found. Update failed."); - alert.showAndWait(); - } - } catch (SQLException e) { - e.printStackTrace(); - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Database Error"); - alert.setHeaderText(null); - alert.setContentText("An error occurred while updating the profile."); - alert.showAndWait(); - } finally { - CloseConnection(); - } - - } - - - @FXML - void Employee(ActionEvent event) { - DashboardMainpage.setVisible(false); - inventory_form.setVisible(false); - ProfilePage.setVisible(false); - menu_form.setVisible(false); - ConfirmUpdate_page.setVisible(false); - EmployeePage.setVisible(true); - customer_show.setVisible(false); - - employee_Category_Status(); - EmployeeShowData(); - } - - - - private void CloseConnection(){ - try { - if(resultSet != null) resultSet.close(); - if(preparedStatement != null) preparedStatement.close(); - } catch(SQLException e) { - e.printStackTrace(); - } - - } - - - @FXML - private TableColumn Employee_Col_Category; - - @FXML - private TableColumn Employee_Col_Date; - - @FXML - private TableColumn Employee_Col_ID; - - @FXML - private TableColumn Employee_Col_Name; - - @FXML - private TableColumn Employee_Col_Phone; - - @FXML - private TableColumn Employee_Col_Status; - - @FXML - private ComboBox Employee_category; - - @FXML - private ComboBox Employee_Status; - - @FXML - private TableView Employee_tableView; - - ObservableList EmployeeListData; - - ObservableList EmployeeDataList() { - ObservableList list = FXCollections.observableArrayList(); - String query = "SELECT * FROM userdetails"; - - try { - preparedStatement = connection.prepareStatement(query); - resultSet = preparedStatement.executeQuery(); - - while (resultSet.next()) { - if (resultSet.getString("Category").equals("Employee")) { - EmployeeData data = new EmployeeData( - resultSet.getString("RegistrationID"), - resultSet.getString("FullName"), - resultSet.getString("PhoneNumber"), - resultSet.getString("Category"), - resultSet.getDouble("Salery"), - resultSet.getDate("Date"), - resultSet.getString("Status") - ); - list.add(data); - } - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - CloseConnection(); - } - return list; - } - - private void centerAlignColumn(TableColumn column) { - column.setCellFactory(col -> new TableCell<>() { - @Override - protected void updateItem(T item, boolean empty) { - super.updateItem(item, empty); - if (empty || item == null) { - setText(null); - } else { - setText(item.toString()); - setAlignment(Pos.CENTER); - } - } - }); - } - - void EmployeeShowData() { - EmployeeListData = EmployeeDataList(); - - Employee_Col_ID.setCellValueFactory(new PropertyValueFactory<>("RegistrationID")); - Employee_Col_Name.setCellValueFactory(new PropertyValueFactory<>("FullName")); - Employee_Col_Phone.setCellValueFactory(new PropertyValueFactory<>("PhoneNumber")); - Employee_Col_Category.setCellValueFactory(new PropertyValueFactory<>("Category")); - Employee_Col_Date.setCellValueFactory(new PropertyValueFactory<>("Date")); - Employee_Col_Status.setCellValueFactory(new PropertyValueFactory<>("Status")); - - centerAlignColumn(Employee_Col_ID); - centerAlignColumn(Employee_Col_Name); - centerAlignColumn(Employee_Col_Phone); - centerAlignColumn(Employee_Col_Category); - centerAlignColumn(Employee_Col_Status); - - Employee_tableView.setItems(EmployeeListData); - } - - void employee_Category_Status() { - List categoryList = List.of("Employee","Student","Teacher"); - ObservableList categoryObservableList = FXCollections.observableArrayList(categoryList); - Employee_category.setItems(categoryObservableList); - - List statusList = List.of("Active", "Inactive", "On Leave"); - ObservableList statusObservableList = FXCollections.observableArrayList(statusList); - Employee_Status.setItems(statusObservableList); - } - - @FXML - private TextField employeenamefield; - - @FXML - private TextField employeephonefield; - - @FXML - private TextField employeesaleryfield; - - @FXML - private TextField employidfield; - - @FXML - void Employee_Delete(ActionEvent event) { - if (employidfield.getText().isEmpty()) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Please fill the Employee ID field."); - alert.showAndWait(); - } else { - String query = "DELETE FROM userdetails WHERE RegistrationID = ?"; - try { - preparedStatement = connection.prepareStatement(query); - preparedStatement.setString(1, employidfield.getText()); - int rowsDeleted = preparedStatement.executeUpdate(); - if (rowsDeleted > 0) { - Alert alert = new Alert(Alert.AlertType.INFORMATION); - alert.setTitle("Information Message"); - alert.setHeaderText(null); - alert.setContentText("Employee deleted successfully."); - alert.showAndWait(); - EmployeeShowData(); - Employee_clear(event); - } else { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Employee ID not found."); - alert.showAndWait(); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - CloseConnection(); - } - } - } - - @FXML - void Employee_Update(ActionEvent event) { - if (employidfield.getText().isEmpty()) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Please fill the Employee ID field."); - alert.showAndWait(); - } else { - String query = "UPDATE userdetails SET FullName = ?, PhoneNumber = ?, Salery = ? WHERE RegistrationID = ?"; - try { - preparedStatement = connection.prepareStatement(query); - preparedStatement.setString(1, employeenamefield.getText()); - preparedStatement.setString(2, employeephonefield.getText()); - preparedStatement.setDouble(3, Double.parseDouble(employeesaleryfield.getText())); - preparedStatement.setString(4, employidfield.getText()); - - int rowsUpdated = preparedStatement.executeUpdate(); - if (rowsUpdated > 0) { - Alert alert = new Alert(Alert.AlertType.INFORMATION); - alert.setTitle("Information Message"); - alert.setHeaderText(null); - alert.setContentText("Employee updated successfully."); - alert.showAndWait(); - EmployeeShowData(); - Employee_clear(event); - } else { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Employee ID not found."); - alert.showAndWait(); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - CloseConnection(); - } - } - } - - @FXML - void Employee_add(ActionEvent event) { - if (employeenamefield.getText().isEmpty() || - employeephonefield.getText().isEmpty() || - employeesaleryfield.getText().isEmpty() || - employidfield.getText().isEmpty()) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Please fill all the fields."); - alert.showAndWait(); - } else { - String query = "INSERT INTO userdetails (RegistrationID, FullName, PhoneNumber, Salery, Date, Status, Category) VALUES (?, ?, ?, ?, ?, ?, ?)"; - try { - preparedStatement = connection.prepareStatement(query); - preparedStatement.setString(1, employidfield.getText()); - preparedStatement.setString(2, employeenamefield.getText()); - preparedStatement.setString(3, employeephonefield.getText()); - preparedStatement.setDouble(4, Double.parseDouble(employeesaleryfield.getText())); - preparedStatement.setDate(5, new Date(System.currentTimeMillis())); - preparedStatement.setString(6, Employee_Status.getSelectionModel().getSelectedItem().toString()); - preparedStatement.setString(7, Employee_category.getSelectionModel().getSelectedItem().toString()); - - int rowsInserted = preparedStatement.executeUpdate(); - if (rowsInserted > 0) { - Alert alert = new Alert(Alert.AlertType.INFORMATION); - alert.setTitle("Information Message"); - alert.setHeaderText(null); - alert.setContentText("Employee added successfully."); - alert.showAndWait(); - EmployeeShowData(); - Employee_clear(event); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - CloseConnection(); - } - } - } - - @FXML - void Employee_clear(ActionEvent event) { - employeenamefield.setText(""); - employeephonefield.setText(""); - employeesaleryfield.setText(""); - employidfield.setText(""); - employeenamefield.requestFocus(); - } - - private double total_price = 0.0; - - public ObservableList menuDisplayOrder(){ - ObservableList listdata = FXCollections.observableArrayList(); - String sql = "SELECT * FROM customer"; - - try { - // Establishing connection (Make sure your connection logic is correct) - connection = DatabaseUsers.getConnection(); // assuming DatabaseConnection is a class managing DB connection - - // Prepare the SQL statement - preparedStatement = connection.prepareStatement(sql); - - // Execute the query and retrieve the result set - resultSet = preparedStatement.executeQuery(); - - // Iterate through the result set and map the data to ProductData objects - while (resultSet.next()) { - if(resultSet.getString("type").equals("Paid")) - continue; - String productId = "abc"; - String productName = resultSet.getString("prod_name"); - double price = resultSet.getDouble("Price"); - String image = "abc"; - int quantity = resultSet.getInt("quantity"); - - total_price += price; - - // Creating the ProductData object with the constructor - ProductData product = new ProductData(productId, productName, price, image, quantity); - listdata.add(product); - } - } catch (SQLException e) { - e.printStackTrace(); // Handle exceptions appropriately - } finally { - // Close resources to avoid memory leaks - try { - if (resultSet != null) resultSet.close(); - if (preparedStatement != null) preparedStatement.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - } - - return listdata; - } - - private ObservableList menulist; - - public void displayorder(){ - menulist = menuDisplayOrder(); - - menu_col_price.setCellValueFactory(new PropertyValueFactory<>("Price")); - menu_col_productName.setCellValueFactory(new PropertyValueFactory<>("ProductName")); - menu_col_quantity.setCellValueFactory(new PropertyValueFactory<>("quantity")); - menu_tableView.setItems(menulist); - - - String tk = String.valueOf(total_price) + "TK"; - menu_total.setText(tk); - } - - - @FXML - void payBtn(ActionEvent event) { - Alert alert = new Alert(Alert.AlertType.INFORMATION); - alert.setTitle("Payment Confirmation"); - alert.setHeaderText(null); - alert.setContentText("Are you sure you want to proceed with the payment?"); - - // Add OK and Cancel buttons - alert.getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL); - - // Wait for user response - ButtonType result = alert.showAndWait().orElse(ButtonType.CANCEL); - - if (result == ButtonType.CANCEL) { - return; // Cancel payment process if user chooses "Cancel" - } - menu_amount.setText(""); - - menu_total.setText("$0.0 TK"); - total_price = 0.0; - String updateSql = "UPDATE customer SET type = 'Paid' WHERE type = 'Unpaid'"; - - try { - preparedStatement = connection.prepareStatement(updateSql); - - int rowsUpdated = preparedStatement.executeUpdate(); - System.out.println("Updated " + rowsUpdated + " rows to 'Paid'"); - - } catch (SQLException e) { - System.out.println("Error updating 'Paid' status: " + e.getMessage()); - } - - } - - @FXML - void Amount(ActionEvent event) { - - String amountText = menu_amount.getText(); - double given_price = 0.0; - - if (!amountText.isEmpty()) { - try { - given_price = Double.parseDouble(amountText); - } catch (NumberFormatException e) { - System.out.println("Invalid input: " + e.getMessage()); - return; - } - } - - if(given_price < total_price){ - Alert insufficientFundsAlert = new Alert(Alert.AlertType.WARNING); - insufficientFundsAlert.setTitle("Insufficient Funds"); - insufficientFundsAlert.setHeaderText(null); - insufficientFundsAlert.setContentText("The amount given is less than the total price.\nPlease enter a sufficient amount."); - insufficientFundsAlert.showAndWait(); - return; - } - double change = given_price - total_price; - String cng = String.valueOf(change) + "TK"; - - menu_change.setText(cng); - } - - @FXML - private TableView customer_tableview; - - @FXML - private TableColumn pars_col_customerid; - - @FXML - private TableColumn pars_col_customername; - - @FXML - private TableColumn pars_col_date; - - @FXML - private TableColumn pars_col_quantity; - - @FXML - private TableColumn pars_col_price; - - - - - - public ArrayList getCustomerSummaries() { - ArrayList summaries = new ArrayList<>(); - String sql = "SELECT c.customer_id, u.FullName AS customer_name, c.date, " + - "SUM(c.quantity) AS total_quantity, " + - "SUM(c.price * c.quantity) AS total_price " + - "FROM customer c " + - "JOIN userdetails u ON c.customer_id = u.RegistrationID " + - "GROUP BY c.customer_id, c.date " + - "ORDER BY c.customer_id, c.date"; - - try (PreparedStatement preparedStatement = connection.prepareStatement(sql); - ResultSet resultSet = preparedStatement.executeQuery()) { - - while (resultSet.next()) { - String customerId = resultSet.getString("customer_id"); - String name = resultSet.getString("customer_name"); // Directly get the name - String date = resultSet.getString("date"); - int totalQuantity = resultSet.getInt("total_quantity"); - double totalPrice = resultSet.getDouble("total_price"); - - summaries.add(new CustomerSummary(customerId, date, totalQuantity, totalPrice, name)); - } - - } catch (SQLException e) { - System.out.println("Error fetching customer summaries: " + e.getMessage()); - } - - return summaries; - } - - private ArrayList alldata; - - public void customercount(){ - alldata = getCustomerSummaries(); - } - - private void showCustomerData() { - // Link TableColumns to CustomerSummary properties - ObservableList data = FXCollections.observableArrayList(alldata); - - pars_col_customerid.setCellValueFactory(new PropertyValueFactory<>("CustomerId")); - pars_col_customername.setCellValueFactory(new PropertyValueFactory<>("CustomerName")); - pars_col_date.setCellValueFactory(new PropertyValueFactory<>("Date")); - pars_col_quantity.setCellValueFactory(new PropertyValueFactory<>("TotalQuantity")); - pars_col_price.setCellValueFactory(new PropertyValueFactory<>("TotalPrice")); - - - customer_tableview.setItems(data); - - centerAlignColumn2(pars_col_customerid); - centerAlignColumn2(pars_col_customername); - centerAlignColumn2(pars_col_price); - centerAlignColumn2(pars_col_quantity); - centerAlignColumn2(pars_col_date); - - } - - private void centerAlignColumn2(TableColumn column) { - column.setCellFactory(col -> new TableCell<>() { - @Override - protected void updateItem(T item, boolean empty) { - super.updateItem(item, empty); - if (empty || item == null) { - setText(null); - } else { - setText(item.toString()); - setAlignment(Pos.CENTER); - } - } - }); - } - - @FXML - private BarChart Dash_customerChart; // Corrected generics - @FXML - private AreaChart Dash_incomeChart; // Corrected generics - - // Initialize Income Chart - private void initializeIncomeChart() { - // Set up axes - CategoryAxis xAxis = new CategoryAxis(); - NumberAxis yAxis = new NumberAxis(); - xAxis.setLabel("Month"); - yAxis.setLabel("Revenue ($)"); - - Dash_incomeChart.setTitle("Monthly Income Overview"); - Dash_incomeChart.setLegendVisible(false); - - // Sample data (replace with actual database data) - XYChart.Series series = new XYChart.Series<>(); - series.getData().add(new XYChart.Data<>("Jan", 15000)); - series.getData().add(new XYChart.Data<>("Feb", 23000)); - series.getData().add(new XYChart.Data<>("Mar", 18500)); - series.getData().add(new XYChart.Data<>("Apr", 21000)); - - Dash_incomeChart.getData().add(series); - - // Styling the AreaChart - Platform.runLater(() -> { - for (XYChart.Data data : series.getData()) { - Node bar = data.getNode(); - if (bar != null) { - // Make the bars fatter - bar.setStyle("-fx-bar-width: 40px;"); - - // Change the color of the bars with a fancy gradient - bar.setStyle("-fx-bar-fill: linear-gradient(to top, #4caf50, #81c784);"); - - // Optional: Add a border to the bars - bar.setStyle("-fx-border-color: #388e3c; -fx-border-width: 2px;"); - } - } - }); - } - - // Initialize Customer Chart - private void initializeCustomerChart() { - // Set up axes - CategoryAxis xAxis = new CategoryAxis(); - NumberAxis yAxis = new NumberAxis(); - xAxis.setLabel("Month"); - yAxis.setLabel("Number of Customers"); - - Dash_customerChart.setTitle("Monthly Customer Activity"); - Dash_customerChart.setLegendVisible(false); - - // Sample data (replace with database data) - XYChart.Series series = new XYChart.Series<>(); - series.getData().add(new XYChart.Data<>("Jan", 150)); - series.getData().add(new XYChart.Data<>("Feb", 230)); - series.getData().add(new XYChart.Data<>("Mar", 185)); - series.getData().add(new XYChart.Data<>("Apr", 210)); - - Dash_customerChart.getData().add(series); - - // Use Platform.runLater to ensure the chart is fully rendered before applying styling - Platform.runLater(() -> { - for (XYChart.Data data : series.getData()) { - Node bar = data.getNode(); - - // Ensure the node is not null before styling - if (bar != null) { - // Make the bars fatter - bar.setStyle("-fx-bar-width: 40px;"); - - // Change the color of the bars with a fancy gradient - bar.setStyle("-fx-bar-fill: linear-gradient(to top, #ff9800, #ff5722);"); - - // Optional: Add a border to the bars - bar.setStyle("-fx-border-color: #ff5722; -fx-border-width: 2px;"); - } - } - - // Optional: Add a glow effect to the bars - for (XYChart.Data data : series.getData()) { - Node bar = data.getNode(); - if (bar != null) { - bar.setStyle("-fx-effect: dropshadow(gaussian, #ff5722, 10, 0, 0, 2);"); - } - } - }); - } - - - // Load Customer Chart Data from the database - private void loadCustomerChartData() { - // Clear any existing data before adding new data - Dash_customerChart.getData().clear(); - - XYChart.Series series = new XYChart.Series<>(); - - String sql = "SELECT MONTH(date) AS month, COUNT(DISTINCT customer_id) AS count " - + "FROM customer GROUP BY MONTH(date)"; - - try (PreparedStatement ps = connection.prepareStatement(sql); - ResultSet rs = ps.executeQuery()) { - - while (rs.next()) { - String month = getMonthName(rs.getInt("month")); - int count = rs.getInt("count"); - series.getData().add(new XYChart.Data<>(month, count)); - } - - Dash_customerChart.getData().add(series); // Add data to the chart - } catch (SQLException e) { - System.out.println("Error loading chart data: " + e.getMessage()); - } - } - - // Utility method to get the month name - private String getMonthName(int month) { - return new DateFormatSymbols().getMonths()[month - 1]; - } - - - -} - diff --git a/src/main/java/cafe/management/cafe/CafeManagement.java b/src/main/java/cafe/management/cafe/CafeManagement.java deleted file mode 100644 index 5cf664e..0000000 --- a/src/main/java/cafe/management/cafe/CafeManagement.java +++ /dev/null @@ -1,37 +0,0 @@ -package cafe.management.cafe; - -import javafx.application.Application; -import javafx.fxml.FXMLLoader; -import javafx.scene.Scene; -import javafx.stage.Stage; - -import java.io.IOException; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; - -public class CafeManagement extends Application { - - private static Stage Samestage; - - @Override - public void start(Stage stage) throws IOException { - Samestage = stage; - FXMLLoader fxmlLoader = new FXMLLoader(CafeManagement.class.getResource("LoginPage.fxml")); - Scene scene = new Scene(fxmlLoader.load(), 800, 600); - stage.setTitle("Java OOP Project"); - stage.setScene(scene); - stage.show(); - } - - public static void switchScene(String fxmlFile,int width) throws IOException { - FXMLLoader loader = new FXMLLoader(CafeManagement.class.getResource(fxmlFile)); - Scene scene = new Scene(loader.load(), width, 600); - Samestage.setScene(scene); - Samestage.show(); - } - - public static void main(String[] args) { - launch(args); - } -} \ No newline at end of file diff --git a/src/main/java/cafe/management/cafe/CardProduct.java b/src/main/java/cafe/management/cafe/CardProduct.java deleted file mode 100644 index 2fe0744..0000000 --- a/src/main/java/cafe/management/cafe/CardProduct.java +++ /dev/null @@ -1,176 +0,0 @@ -package cafe.management.cafe; - -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.scene.control.*; -import javafx.scene.image.Image; -import javafx.scene.image.ImageView; -import javafx.scene.layout.AnchorPane; - - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; - -public class CardProduct{ - - @FXML - private AnchorPane Card_form; - - @FXML - private Button Product_Add; - - @FXML - private Label Product_Name; - - @FXML - private Label Product_Price; - - @FXML - private Spinner Product_Spinner; - - @FXML - private ImageView Product_image; - - private Connection connection = null; - private PreparedStatement preparedStatement = null; - private ResultSet resultSet = null; - - private ProductData productData; - private Image img; - private String pname; - private SpinnerValueFactory spin; - private int qty; - - public void setData(ProductData prodData) { - this.productData = prodData; - pname = prodData.getProductName(); - String prc = String.valueOf(productData.getPrice()) + " TK"; - Product_Price.setText(prc); - Product_Name.setText(productData.getProductName()); - img = new Image(productData.getImage(), 203, 112, false, true); - Product_image.setImage(img); - setQuantity(); // Initialize the spinner - } - - private void setQuantity() { - spin = new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 100, 0); - Product_Spinner.setValueFactory(spin); - } - - public static boolean click = false; - - @FXML - void addBtn(ActionEvent event){ - qty = Product_Spinner.getValue(); - - // Validate if at least 1 item is selected - if (qty <= 0) { - showAlert(Alert.AlertType.WARNING, "Warning", "Please select at least 1 item!"); - return; - } - - // Query to check product availability and stock - String checkAvailableQuery = "SELECT Status, Stock, price, Type FROM productdetails WHERE ProductName = ?"; - - // Query to update stock after purchase - String updateStockQuery = "UPDATE productdetails SET Stock = Stock - ? WHERE ProductName = ?"; - - // Query to insert customer order - String insertData = "INSERT INTO customer (customer_id, prod_name, type, quantity, price, date, em_username) VALUES (?, ?, ?, ?, ?, ?, ?)"; - - try { - // Establish database connection - connection = DatabaseUsers.getConnection(); - - // Prepare statement to check product availability - preparedStatement = connection.prepareStatement(checkAvailableQuery); - preparedStatement.setString(1, Product_Name.getText()); - - resultSet = preparedStatement.executeQuery(); - - if (resultSet.next()) { - String status = resultSet.getString("Status"); - int availableQuantity = resultSet.getInt("Stock"); - double price = resultSet.getDouble("price"); // Get product price - String type = resultSet.getString("Type"); - - // Check if product is available - if (!"Available".equalsIgnoreCase(status)) { - showAlert(Alert.AlertType.ERROR, "Product Unavailable", "Sorry, this product is currently unavailable."); - return; - } - - // Check if enough stock is available - if (availableQuantity < qty) { - showAlert(Alert.AlertType.ERROR, "Stock Insufficient", "Only " + availableQuantity + " items are available."); - return; - } - - // Reduce stock after purchase - PreparedStatement updateStmt = connection.prepareStatement(updateStockQuery); - updateStmt.setInt(1, qty); - updateStmt.setString(2, Product_Name.getText()); - - int rowsUpdated = updateStmt.executeUpdate(); - type = "Unpaid"; - - if (rowsUpdated > 0) { - // Insert customer order into the database - PreparedStatement insertStmt = connection.prepareStatement(insertData); - insertStmt.setString(1, ManagementControl.ID); // Generate a unique customer ID - insertStmt.setString(2, Product_Name.getText()); - insertStmt.setString(3, type); - insertStmt.setInt(4, qty); - insertStmt.setDouble(5, price * qty); - insertStmt.setDate(6, java.sql.Date.valueOf(java.time.LocalDate.now())); - insertStmt.setString(7, "admin"); - - int rowsInserted = insertStmt.executeUpdate(); - if (rowsInserted > 0) { - showAlert(Alert.AlertType.INFORMATION, "Success", "Product added to cart successfully!"); - click = true; - } else { - showAlert(Alert.AlertType.ERROR, "Error", "Could not add product to cart."); - } - - insertStmt.close(); - } else { - showAlert(Alert.AlertType.ERROR, "Error", "Could not update stock."); - } - - updateStmt.close(); - } else { - showAlert(Alert.AlertType.ERROR, "Error", "Product not found."); - } - - } catch (SQLException e) { - e.printStackTrace(); - } finally { - closeResources(); - } - } - - - private void showAlert(Alert.AlertType type, String title, String message) { - Alert alert = new Alert(type); - alert.setTitle(title); - alert.setHeaderText(null); - alert.setContentText(message); - alert.showAndWait(); - } - - private void closeResources() { - try { - if (resultSet != null) resultSet.close(); - if (preparedStatement != null) preparedStatement.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - } - -// public void addBtn(javafx.event.ActionEvent actionEvent) { -// -// } -} diff --git a/src/main/java/cafe/management/cafe/CustomerController.java b/src/main/java/cafe/management/cafe/CustomerController.java deleted file mode 100644 index e740d59..0000000 --- a/src/main/java/cafe/management/cafe/CustomerController.java +++ /dev/null @@ -1,701 +0,0 @@ -package cafe.management.cafe; - -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import javafx.scene.control.*; -import javafx.scene.control.cell.PropertyValueFactory; -import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.GridPane; - -import java.io.IOException; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Optional; - -public class CustomerController { - - @FXML - private TextField CustomerConstID; - - @FXML - private AnchorPane CustomerMainForm; - - @FXML - private AnchorPane CustomerMenuForm; - - @FXML - private Label CustomerProfileCat; - - @FXML - private Label CustomerProfileDept; - - @FXML - private TextField CustomerProfileEditDept; - - @FXML - private TextField CustomerProfileEditName; - - @FXML - private TextField CustomerProfileEditPhone; - - @FXML - private Label CustomerProfileID; - - @FXML - private Label CustomerProfileName; - - @FXML - private AnchorPane CustomerProfilePage; - - @FXML - private Label CustomerProfilePhone; - - @FXML - private AnchorPane CustomerProfileUpdatePage; - - @FXML - private TableColumn menu_col_price; - - @FXML - private TableColumn menu_col_productName; - - @FXML - private TableColumn menu_col_quantity; - - @FXML - private GridPane menu_gridPane; - - @FXML - private ScrollPane menu_scrollPane; - - @FXML - private TableView menu_tableView; - - @FXML - private AnchorPane AboutUs_Page; - - @FXML - private AnchorPane reviewPage; - - private Connection connection = null; - - private PreparedStatement preparedStatement = null; - - private ResultSet resultSet = null; - - @FXML - private GridPane CustomerMenu_grid; - - public CustomerController(){connection = DatabaseUsers.getConnection();} - - @FXML - void CustomerAboutUs(ActionEvent event) { - AboutUs_Page.setVisible(true); - CustomerMenuForm.setVisible(false); - CustomerProfilePage.setVisible(false); - CustomerProfileUpdatePage.setVisible(false); - reviewPage.setVisible(false); - } - - private ObservableList cardProduct = FXCollections.observableArrayList(); - - public ObservableList menuCard(){ - String sql = "SELECT * FROM productdetails"; - ObservableList temp = FXCollections.observableArrayList(); - try{ - preparedStatement = connection.prepareStatement(sql); - resultSet = preparedStatement.executeQuery(); - - while(resultSet.next()){ - ProductData prod; - if ("Available".equalsIgnoreCase(resultSet.getString("Status").trim())) { - prod = new ProductData(resultSet.getString("ProductID"), - resultSet.getString("ProductName"), - resultSet.getDouble("Price"), - resultSet.getString("Image")); - temp.add(prod); - } - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - CloseConnection(); - } - return temp; - } - - public void menuDisplyCard(){ - cardProduct.clear(); - cardProduct.addAll(menuCard()); - - CustomerMenu_grid.getChildren().clear(); - - int col=0; - int row=0; - CustomerMenu_grid.getRowConstraints().clear(); - CustomerMenu_grid.getColumnConstraints().clear(); - -// menu_gridPane.setHgap(15); -// menu_gridPane.setVgap(15); - for(int i = 0;i < cardProduct.size();i++){ - try { - FXMLLoader load = new FXMLLoader(); - load.setLocation(getClass().getResource("CardProduct.fxml")); - AnchorPane pan = load.load(); - - CardProduct controller = load.getController(); - controller.setData(cardProduct.get(i)); - - if(col == 3){ - col = 0; - row++; - } - CustomerMenu_grid.add(pan,col++,row); - GridPane.setMargin(pan, new Insets(10, 10, 10, 10)); - - } catch (Exception e){ - e.printStackTrace(); - } - } - } - @FXML - void CustomerMenu(ActionEvent event) { - AboutUs_Page.setVisible(false); - CustomerMenuForm.setVisible(true); - CustomerProfilePage.setVisible(false); - CustomerProfileUpdatePage.setVisible(false); - reviewPage.setVisible(false); - menuDisplyCard(); - displayorder(); - } - - private String customerName = null; - - void showProfileInformation(){ - - String regID = ManagementControl.ID; - - try { - String sql = "SELECT FullName, RegistrationID, Category, PhoneNumber, Department FROM userdetails WHERE RegistrationID = ?"; - - preparedStatement = connection.prepareStatement(sql); - preparedStatement.setString(1, regID); - - resultSet = preparedStatement.executeQuery(); - - if (resultSet.next()) { - String name = resultSet.getString("FullName"); - String registrationId = resultSet.getString("RegistrationID"); - String category = resultSet.getString("Category"); - String phone = resultSet.getString("PhoneNumber"); - String department = resultSet.getString("Department"); - - customerName = name; - - CustomerProfileID.setText(registrationId); - CustomerProfileName.setText(name); - CustomerProfileCat.setText(category); - if(department != null) - CustomerProfileDept.setText(department); - if(phone != null) - CustomerProfilePhone.setText(phone); - - } else { - System.out.println("No data found for regID: " + regID); - } - } catch (SQLException e) { - e.printStackTrace(); - } - } - - @FXML - void CustomerProfile(ActionEvent event) { - AboutUs_Page.setVisible(false); - CustomerMenuForm.setVisible(false); - CustomerProfilePage.setVisible(true); - CustomerProfileUpdatePage.setVisible(false); - - showProfileInformation(); - } - - void CustomerEditedInfo(){ - String name = CustomerProfileEditName.getText(); - String department = CustomerProfileEditDept.getText(); - String phone = CustomerProfileEditPhone.getText(); - - if (name.isEmpty() || department.isEmpty() || phone.isEmpty()) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error"); - alert.setHeaderText(null); - alert.setContentText("All fields are required. Please fill out all fields."); - alert.showAndWait(); - return; - } - - try { - String updateQuery = "UPDATE userdetails SET FullName = ?, Department = ?, PhoneNumber = ? WHERE RegistrationID = ?"; - PreparedStatement pstmt = connection.prepareStatement(updateQuery); - - pstmt.setString(1, name); - pstmt.setString(2, department); - pstmt.setString(3, phone); - pstmt.setString(4, CustomerConstID.getText()); - - int rowsAffected = pstmt.executeUpdate(); - - if (rowsAffected > 0) { - Alert alert = new Alert(Alert.AlertType.INFORMATION); - alert.setTitle("Success"); - alert.setHeaderText(null); - alert.setContentText("Profile updated successfully!"); - alert.showAndWait(); - showProfileInformation(); - } else { - Alert alert = new Alert(Alert.AlertType.WARNING); - alert.setTitle("Warning"); - alert.setHeaderText(null); - alert.setContentText("No matching record found. Update failed."); - alert.showAndWait(); - } - } catch (SQLException e) { - e.printStackTrace(); - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Database Error"); - alert.setHeaderText(null); - alert.setContentText("An error occurred while updating the profile."); - alert.showAndWait(); - } finally { - CloseConnection(); - } - } - - @FXML - void CustomerProfileEditConfirm(ActionEvent event) { - AboutUs_Page.setVisible(false); - CustomerMenuForm.setVisible(false); - CustomerProfilePage.setVisible(true); - CustomerProfileUpdatePage.setVisible(false); - - CustomerEditedInfo(); - } - - - - @FXML - void CustomerProfileUpdate(ActionEvent event) { - AboutUs_Page.setVisible(false); - CustomerMenuForm.setVisible(false); - Alert alrt = new Alert(Alert.AlertType.CONFIRMATION); - alrt.setTitle("Confirmation Message"); - alrt.setHeaderText(null); - alrt.setContentText("Are you sure you want to update your information."); - - Optional opt = alrt.showAndWait(); - - if(opt.isPresent() && opt.get() == ButtonType.OK) { - CustomerProfilePage.setVisible(false); - CustomerProfileUpdatePage.setVisible(true); - } - - CustomerConstID.setText(ManagementControl.ID); - CustomerConstID.setDisable(true); - - if(customerName != null) - CustomerProfileEditName.setText(customerName); - - } - - @FXML - void CustomerSignOut(ActionEvent event) { - Alert alrt = new Alert(Alert.AlertType.CONFIRMATION); - alrt.setTitle("Confirmation Message"); - alrt.setHeaderText(null); - alrt.setContentText("Are you sure you want to sign out."); - - Optional opt = alrt.showAndWait(); - - if(opt.isPresent() && opt.get() == ButtonType.OK) { - try { - CafeManagement.switchScene("LoginPage.fxml", 800); - } catch (IOException e) { - e.printStackTrace(); - System.err.println("Failed to load LoginPage.fxml"); - } - } else { - System.out.println("Stay loggedin."); - } - } - - @FXML - void CutomerReview(ActionEvent event) { - AboutUs_Page.setVisible(false); - CustomerMenuForm.setVisible(false); - CustomerProfilePage.setVisible(false); - CustomerProfileUpdatePage.setVisible(false); - reviewPage.setVisible(true); - - customercount(); - showCustomerData(); - } - - private double total_price = 0.0; - - public ObservableList menuDisplayOrder(){ - ObservableList listdata = FXCollections.observableArrayList(); - String sql = "SELECT * FROM customer"; - - try { - // Establishing connection (Make sure your connection logic is correct) - connection = DatabaseUsers.getConnection(); // assuming DatabaseConnection is a class managing DB connection - - // Prepare the SQL statement - preparedStatement = connection.prepareStatement(sql); - - // Execute the query and retrieve the result set - resultSet = preparedStatement.executeQuery(); - - // Iterate through the result set and map the data to ProductData objects - while (resultSet.next()) { - if(resultSet.getString("type").equals("Paid")) - continue; - String productId = "abc"; - String productName = resultSet.getString("prod_name"); - double price = resultSet.getDouble("Price"); - String image = "abc"; - int quantity = resultSet.getInt("quantity"); - - total_price += price; - - // Creating the ProductData object with the constructor - ProductData product = new ProductData(productId, productName, price, image, quantity); - listdata.add(product); - } - } catch (SQLException e) { - e.printStackTrace(); // Handle exceptions appropriately - } finally { - // Close resources to avoid memory leaks - try { - if (resultSet != null) resultSet.close(); - if (preparedStatement != null) preparedStatement.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - } - - return listdata; - } - - private ObservableList menulist; - - @FXML - private TextField menu_amount; - - @FXML - private Label menu_change; - - @FXML - private Label menu_total; - - public void displayorder(){ - menulist = menuDisplayOrder(); - - menu_col_price.setCellValueFactory(new PropertyValueFactory<>("Price")); - menu_col_productName.setCellValueFactory(new PropertyValueFactory<>("ProductName")); - menu_col_quantity.setCellValueFactory(new PropertyValueFactory<>("quantity")); - menu_tableView.setItems(menulist); - - - String tk = String.valueOf(total_price) + "TK"; - menu_total.setText(tk); - } - - - @FXML - void payBtn(ActionEvent event) { - Alert alert = new Alert(Alert.AlertType.INFORMATION); - alert.setTitle("Payment Confirmation"); - alert.setHeaderText(null); - alert.setContentText("Are you sure you want to proceed with the payment?"); - - // Add OK and Cancel buttons - alert.getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL); - - // Wait for user response - ButtonType result = alert.showAndWait().orElse(ButtonType.CANCEL); - - if (result == ButtonType.CANCEL) { - return; // Cancel payment process if user chooses "Cancel" - } - menu_amount.setText(""); - - String amountText = menu_amount.getText(); - double given_price = 0.0; - - if (!amountText.isEmpty()) { - try { - given_price = Double.parseDouble(amountText); - } catch (NumberFormatException e) { - System.out.println("Invalid input: " + e.getMessage()); - return; - } - } - - double change = given_price - total_price; - String cng = String.valueOf(change); - - menu_change.setText("$0.0 TK"); - menu_total.setText("$0.0 TK"); - total_price = 0.0; - String updateSql = "UPDATE customer SET type = 'Paid' WHERE type = 'Unpaid'"; - - try { - preparedStatement = connection.prepareStatement(updateSql); - - int rowsUpdated = preparedStatement.executeUpdate(); - System.out.println("Updated " + rowsUpdated + " rows to 'Paid'"); - - } catch (SQLException e) { - System.out.println("Error updating 'Paid' status: " + e.getMessage()); - } finally { - CloseConnection(); - displayorder(); - } - - } - - @FXML - void Amount(ActionEvent event) { - - String amountText = menu_amount.getText(); - double given_price = 0.0; - - if (!amountText.isEmpty()) { - try { - given_price = Double.parseDouble(amountText); - } catch (NumberFormatException e) { - System.out.println("Invalid input: " + e.getMessage()); - return; - } - } - - if(given_price < total_price){ - Alert insufficientFundsAlert = new Alert(Alert.AlertType.WARNING); - insufficientFundsAlert.setTitle("Insufficient Funds"); - insufficientFundsAlert.setHeaderText(null); - insufficientFundsAlert.setContentText("The amount given is less than the total price.\nPlease enter a sufficient amount."); - insufficientFundsAlert.showAndWait(); - return; - } - double change = given_price - total_price; - String cng = String.valueOf(change) + "TK"; - - menu_change.setText(cng); - } - - - private void CloseConnection(){ - try { - if(resultSet != null) resultSet.close(); - if(preparedStatement != null) preparedStatement.close(); - } catch(SQLException e) { - e.printStackTrace(); - } - - } - - // In your controller class - @FXML - private TableColumn cus_col_prod_id; - @FXML - private TableColumn cus_col_prod_name; - @FXML - private TableColumn cus_col_quantity; - @FXML - private TableColumn cus_col_date; - @FXML - private TableColumn cus_col_price; - - @FXML - private TableView customer_tableview; - - public ArrayList getCustomerPurchases() { - ArrayList purchases = new ArrayList<>(); - String customerQuery = "SELECT prod_name, quantity, price, date " + - "FROM customer " + - "WHERE customer_id = ?"; - - try { - // First get customer name from userdetails - String customerName = getCustomerName(ManagementControl.ID); - - // Then get purchase history - try (PreparedStatement customerStmt = connection.prepareStatement(customerQuery)) { - customerStmt.setString(1, ManagementControl.ID); - - try (ResultSet customerRs = customerStmt.executeQuery()) { - while (customerRs.next()) { - String prodName = customerRs.getString("prod_name"); - int quantity = customerRs.getInt("quantity"); - double price = customerRs.getDouble("price"); - String date = customerRs.getString("date"); - double totalPrice = price * quantity; - - // Get product ID from productdetails - String productId = getProductId(prodName); - - purchases.add(new CustomerOrderHistory( - productId, - prodName, - ManagementControl.ID, // customer_id - customerName, - date, - quantity, - totalPrice - )); - } - } - } - } catch (SQLException e) { - System.out.println("Error fetching purchases: " + e.getMessage()); - } finally { - CloseConnection(); - } - return purchases; - } - - private String getCustomerName(String customerId) throws SQLException { - String nameQuery = "SELECT FullName FROM userdetails WHERE RegistrationID = ?"; - try (PreparedStatement stmt = connection.prepareStatement(nameQuery)) { - stmt.setString(1, customerId); - try (ResultSet rs = stmt.executeQuery()) { - return rs.next() ? rs.getString("FullName") : "Unknown Customer"; - } - } - } - - private String getProductId(String productName) throws SQLException { - String productQuery = "SELECT productid FROM productdetails WHERE productname = ?"; - try (PreparedStatement stmt = connection.prepareStatement(productQuery)) { - stmt.setString(1, productName); - try (ResultSet rs = stmt.executeQuery()) { - return rs.next() ? rs.getString("productid") : "N/A"; - } - } - } - - private ArrayList alldata; - - public void customercount() { - alldata = getCustomerPurchases(); - } - - private void showCustomerData() { - // Set cell value factories - cus_col_prod_id.setCellValueFactory(new PropertyValueFactory<>("productId")); - cus_col_prod_name.setCellValueFactory(new PropertyValueFactory<>("productName")); - cus_col_quantity.setCellValueFactory(new PropertyValueFactory<>("quantity")); - cus_col_date.setCellValueFactory(new PropertyValueFactory<>("date")); - cus_col_price.setCellValueFactory(new PropertyValueFactory<>("totalPrice")); - - // Create observable list - ObservableList data = FXCollections.observableArrayList(alldata); - customer_tableview.setItems(data); - - // Apply alignment - centerAlignColumn(cus_col_prod_id); - centerAlignColumn(cus_col_prod_name); - centerAlignColumn(cus_col_quantity); - centerAlignColumn(cus_col_date); - centerAlignColumn(cus_col_price); - } - - // Updated center alignment method with proper generics - private void centerAlignColumn(TableColumn column) { - column.setCellFactory(col -> new TableCell() { - @Override - protected void updateItem(T item, boolean empty) { - super.updateItem(item, empty); - if (empty || item == null) { - setText(null); - } else { - setText(item.toString()); - setAlignment(Pos.CENTER); - } - } - }); - } - - - @FXML - private TextField rating_bos; - - @FXML - private TextField id_box; - - @FXML - void rating_confirm(ActionEvent event) { - String ratingText = rating_bos.getText(); - String idText = id_box.getText(); - - - if (ratingText.isEmpty() || idText.isEmpty()) { - showAlert(Alert.AlertType.ERROR, "Input Error", "Please fill in all fields."); - return; - } - - try { - - float rating = Float.parseFloat(ratingText); - - - if (rating < 1 || rating > 5) { - showAlert(Alert.AlertType.ERROR, "Invalid Rating", "Please enter a rating between 1 and 5."); - return; - } - - - String query = "INSERT INTO rating (id, rating) VALUES (?, ?)"; - - try (Connection conn = DatabaseUsers.getConnection(); - PreparedStatement stmt = conn.prepareStatement(query)) { - - stmt.setString(1, idText); - stmt.setFloat(2, rating); - - - int rowsAffected = stmt.executeUpdate(); - - if (rowsAffected > 0) { - showAlert(Alert.AlertType.INFORMATION, "Success", "Rating successfully inserted!"); - } else { - showAlert(Alert.AlertType.ERROR, "Error", "Failed to insert the rating."); - } - - } catch (SQLException e) { - - showAlert(Alert.AlertType.ERROR, "Database Error", "Error inserting rating into database: " + e.getMessage()); - } - - } catch (NumberFormatException e) { - showAlert(Alert.AlertType.ERROR, "Invalid Rating", "Please enter a valid numerical rating."); - } - } - - private void showAlert(Alert.AlertType alertType, String title, String message) { - Alert alert = new Alert(alertType); - alert.setTitle(title); - alert.setHeaderText(null); - alert.setContentText(message); - alert.showAndWait(); - } - - -} diff --git a/src/main/java/cafe/management/cafe/CustomerOrderHistory.java b/src/main/java/cafe/management/cafe/CustomerOrderHistory.java deleted file mode 100644 index d18a706..0000000 --- a/src/main/java/cafe/management/cafe/CustomerOrderHistory.java +++ /dev/null @@ -1,32 +0,0 @@ -package cafe.management.cafe; - -public class CustomerOrderHistory { - - private String productId; - private String productName; - private String customerId; - private String customerName; - private String date; - private int quantity; - private double totalPrice; - - public CustomerOrderHistory(String productId, String productName, String customerId, - String customerName, String date, int quantity, double totalPrice) { - this.productId = productId; - this.productName = productName; - this.customerId = customerId; - this.customerName = customerName; - this.date = date; - this.quantity = quantity; - this.totalPrice = totalPrice; - } - - // Getters (must match TableColumn property names!) - public String getProductId() { return productId; } - public String getProductName() { return productName; } - public String getCustomerId() { return customerId; } - public String getCustomerName() { return customerName; } - public String getDate() { return date; } - public int getQuantity() { return quantity; } - public double getTotalPrice() { return totalPrice; } -} diff --git a/src/main/java/cafe/management/cafe/CustomerSummary.java b/src/main/java/cafe/management/cafe/CustomerSummary.java deleted file mode 100644 index a1a0cf7..0000000 --- a/src/main/java/cafe/management/cafe/CustomerSummary.java +++ /dev/null @@ -1,23 +0,0 @@ -package cafe.management.cafe; - -public class CustomerSummary { - private String customerId; - private String date; - private int totalQuantity; - private double totalPrice; - private String customerName; - - public CustomerSummary(String customerId, String date, int totalQuantity, double totalPrice, String customerName) { - this.customerId = customerId; - this.date = date; - this.totalQuantity = totalQuantity; - this.totalPrice = totalPrice; - this.customerName = customerName; - } - public String getCustomerId() { return customerId; } - public String getDate() { return date; } - public int getTotalQuantity() { return totalQuantity; } - public double getTotalPrice() { return totalPrice; } - public String getCustomerName(){ return customerName; } - -} diff --git a/src/main/java/cafe/management/cafe/DatabaseUsers.java b/src/main/java/cafe/management/cafe/DatabaseUsers.java deleted file mode 100644 index 3b6c93c..0000000 --- a/src/main/java/cafe/management/cafe/DatabaseUsers.java +++ /dev/null @@ -1,32 +0,0 @@ -package cafe.management.cafe; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.SQLException; - -public class DatabaseUsers { - private static final String DATABASE_URL = "jdbc:mysql://localhost:3306/cafemanagement"; - private static final String DATABASE_USERNAME = "root"; - private static final String DATABASE_PASSWORD = "2022315898"; - private static Connection connection = null; - - public static Connection getConnection() { - try { - - Class.forName("com.mysql.cj.jdbc.Driver"); - - - connection = DriverManager.getConnection(DATABASE_URL, DATABASE_USERNAME, DATABASE_PASSWORD); -// System.out.println("Connected to the database successfully!"); - - } catch (ClassNotFoundException e) { -// System.err.println("MySQL JDBC Driver not found. Add the library to your project."); - e.printStackTrace(); - } catch (SQLException e) { -// System.err.println("Failed to connect to the database!"); - e.printStackTrace(); - } - - return connection; - } -} diff --git a/src/main/java/cafe/management/cafe/EmployeeData.java b/src/main/java/cafe/management/cafe/EmployeeData.java deleted file mode 100644 index 97f4fad..0000000 --- a/src/main/java/cafe/management/cafe/EmployeeData.java +++ /dev/null @@ -1,33 +0,0 @@ -package cafe.management.cafe; - -import java.sql.Date; - -public class EmployeeData { - private String RegistrationID; - private String FullName; - private String PhoneNumber; - private String Category; - private double Salery; - private Date Date; - private String Status; - - public EmployeeData(String RegistrationID, String FullName, String PhoneNumber, String Category, double Salery, Date Date,String status) { - this.RegistrationID = RegistrationID; - this.FullName = FullName; - this.PhoneNumber = PhoneNumber; - this.Category = Category; - this.Salery = Salery; - this.Date = Date; - this.Status = status; - } - - public String getRegistrationID() { return RegistrationID; } - public String getFullName() { return FullName; } - public String getPhoneNumber() { return PhoneNumber; } - public String getCategory() { return Category; } - public double getSalery() { return Salery; } - public Date getDate() { return Date; } - public String getStatus() { // ✅ Add this getter - return Status; - } -} diff --git a/src/main/java/cafe/management/cafe/ManagementControl.java b/src/main/java/cafe/management/cafe/ManagementControl.java deleted file mode 100644 index 0f82816..0000000 --- a/src/main/java/cafe/management/cafe/ManagementControl.java +++ /dev/null @@ -1,584 +0,0 @@ -package cafe.management.cafe; - -import com.mysql.cj.exceptions.DataReadException; -import javafx.animation.TranslateTransition; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.scene.control.*; -import javafx.scene.layout.*; -import javafx.stage.Stage; -import javafx.util.Duration; -import org.jetbrains.annotations.NotNull; - -import java.io.IOException; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.time.LocalDate; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeParseException; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import javafx.collections.ObservableList; - - -public class ManagementControl { - - @FXML - private TextField passclue; - - @FXML - private AnchorPane ChangePassword; - - @FXML - private PasswordField ConfirmPassword; - - @FXML - private TextField ForgateDate; - - @FXML - private Label ForgateDateError; - - @FXML - private Hyperlink ForgetPassword; - - @FXML - private TextField GiveForgetEmail; - - @FXML - private PasswordField GivePassword; - - @FXML - private TextField Givefullname; - - @FXML - private TextField GiveRegiID; - - @FXML - private Button Login; - - @FXML - private PasswordField LoginPassword; - - @FXML - private TextField LoginRegiID; - - @FXML - private AnchorPane Login_Form; - - @FXML - private PasswordField NewPassword; - - @FXML - private Label PasswordError; - - @FXML - private AnchorPane Proceed_Form; - - @FXML - private Label Regclueerror; - - @FXML - private Label RegIDerror; - - @FXML - private Label RegPasswordError; - - @FXML - private Label Regnamerror; - - @FXML - private Button SignUp; - - @FXML - private Label UsernameError; - - @FXML - private Label blankemail; - - @FXML - private Button cngBack; - - @FXML - private Label confirmpassworderror; - - @FXML - private Button forgetemailback; - - @FXML - private Button forgetproceed; - - @FXML - private Button left; - - @FXML - private Label need; - - @FXML - private Label need1; - - @FXML - private Label newpassworderror; - - @FXML - private Button right; - - @FXML - private AnchorPane side_form; - - - @FXML - private Label RegCategoryError; - - private Connection connection = null; - private PreparedStatement preparedStatement = null; - private ResultSet resultSet = null; - - private String [] category = {"Teacher","Student"}; - - @FXML - private ComboBox Category_Type; - - public ManagementControl() { - connection = DatabaseUsers.getConnection(); - } - - @FXML - void Switch(ActionEvent e){ - TranslateTransition slide = new TranslateTransition(); - - if(e.getSource() == right){ - slide.setNode(side_form); - slide.setToX(375); - slide.setDuration(Duration.seconds(.7)); - slide.setOnFinished(event -> { - right.setVisible(false); - left.setVisible(true); - need.setVisible(false); - need1.setVisible(true); - Login_Form.setVisible(true); - Proceed_Form.setVisible(false); - ChangePassword.setVisible(false); - }); - slide.play(); - } - else if(e.getSource() == left){ - slide.setNode(side_form); - slide.setToX(0); - slide.setDuration(Duration.seconds(1)); - slide.setOnFinished(event -> { - right.setVisible(true); - left.setVisible(false); - need.setVisible(true); - need1.setVisible(false); - Login_Form.setVisible(true); - Proceed_Form.setVisible(false); - ChangePassword.setVisible(false); - }); - slide.play(); - } - Regnamerror.setText(""); - RegPasswordError.setText(""); - RegIDerror.setText(""); - Regclueerror.setText(""); - UsernameError.setText(""); - PasswordError.setText(""); - RegCategoryError.setText(""); - Givefullname.setText(""); - GivePassword.setText(""); - GiveRegiID.setText(""); - passclue.setText(""); - LoginRegiID.setText(""); - LoginPassword.setText(""); - - List list = new ArrayList<>(); - - for(String s : category){ - list.add(s); - } - ObservableList observableList = FXCollections.observableArrayList(list); - Category_Type.setItems(observableList); - } - - protected static String ID = ""; - - @FXML - void LoginPage(ActionEvent event) { - UsernameError.setText(""); - PasswordError.setText(""); - - String username = LoginRegiID.getText(); - String password = LoginPassword.getText(); - - boolean loginerror = false; - - if (username.isEmpty()) { - UsernameError.setText("Registration ID is required."); - loginerror = true; - } - - if (password.isEmpty()) { - PasswordError.setText("Password is required."); - loginerror = true; - } - - if(loginerror == true) - return; - - try { - String query = "SELECT * FROM userdetails WHERE RegistrationID = ? AND password = ?"; - preparedStatement = connection.prepareStatement(query); - preparedStatement.setString(1, username); - preparedStatement.setString(2, password); - - resultSet = preparedStatement.executeQuery(); - - if (resultSet.next()) { - System.out.println("Login successful! Welcome " + username); - ID = username; - String sql = "SELECT Category FROM userdetails WHERE RegistrationID = ?"; - try { - preparedStatement = connection.prepareStatement(sql); - preparedStatement.setString(1, ID); - resultSet = preparedStatement.executeQuery(); - - String category; - - if (resultSet.next()) { - category = resultSet.getString("Category"); - if(username.equals("admin")){ - CafeManagement.switchScene("Admin.fxml", 1100); - } else if (category.equals("Employee")) { - CafeManagement.switchScene("SurfaceLayout.fxml", 1100); - } else { - CafeManagement.switchScene("CurtomerLayout.fxml", 1100); - } - } else { - System.out.println("ID not found."); - } - } catch (SQLException e){ - e.printStackTrace(); - } - } else { - System.out.println("Invalid ID or password!"); - UsernameError.setText("Invalid ID."); - PasswordError.setText("Invalide Password."); - } - } catch (SQLException e) { - e.printStackTrace(); - System.err.println("Database query failed!"); - } catch (IOException e) { - throw new RuntimeException(e); - } finally { - closeResources(); - } - } - - - - @FXML - void SignUp(ActionEvent event) { - Regnamerror.setText(""); - RegPasswordError.setText(""); - RegIDerror.setText(""); - Regclueerror.setText(""); - RegCategoryError.setText(""); - - - String username = Givefullname.getText(); - String password = GivePassword.getText(); - String Regid = GiveRegiID.getText(); - String clue= passclue.getText(); - - - boolean error = false; - - if (username.isEmpty()) { - Regnamerror.setText("Name is required."); - error = true; - } - - if (password.isEmpty()) { - RegPasswordError.setText("Password is required."); - error = true; - } - - if (Regid.isEmpty()) { - RegIDerror.setText("Registration ID is required."); - error = true; - } - - if (clue.isEmpty()) { - Regclueerror.setText("Password Clue is required."); - error = true; - } - - if(Category_Type.getSelectionModel().getSelectedItem() == null){ - RegCategoryError.setText("Please Choose category."); - error = true; - } - - if(error == true) - return; - try { - String usernameQuery = "SELECT COUNT(*) FROM userdetails WHERE FullName = ?"; - preparedStatement = connection.prepareStatement(usernameQuery); - preparedStatement.setString(1, username); - resultSet = preparedStatement.executeQuery(); - - boolean check = false; - if (resultSet.next() && resultSet.getInt(1) > 0) { - Regnamerror.setText("Name is already taken."); - check = true; - } - - String emailQuery = "SELECT COUNT(*) FROM userdetails WHERE RegistrationID = ?"; - preparedStatement = connection.prepareStatement(emailQuery); - preparedStatement.setString(1, Regid); - resultSet = preparedStatement.executeQuery(); - if (resultSet.next() && resultSet.getInt(1) > 0) { - RegIDerror.setText("Registration ID is already registered."); - check = true; - } - - if(check == true) - return ; - - Alert alert = new Alert(Alert.AlertType.CONFIRMATION); - alert.setTitle("Confirmation Message"); - alert.setHeaderText(null); - alert.setContentText("Registration successfull."); - - Optional opt = alert.showAndWait(); - - if(opt.isPresent() && opt.get() == ButtonType.OK) { - String insertQuery = "INSERT INTO userdetails (FullName, RegistrationID, PasswordClue, password, Category) VALUES (?, ?, ?, ?, ?)"; - - preparedStatement = connection.prepareStatement(insertQuery); - preparedStatement.setString(1, username); - preparedStatement.setString(2, Regid); - preparedStatement.setString(3, clue); - preparedStatement.setString(4, password); - preparedStatement.setString(5, Category_Type.getSelectionModel().getSelectedItem().toString()); - - int rowsInserted = preparedStatement.executeUpdate(); - if (rowsInserted > 0) { - System.out.println("User registered successfully!"); - - ActionEvent mock = new ActionEvent(left, null); - Switch(mock); - - } else { - System.err.println("User registration failed!"); - } - - } else { - Alert errorAlert = new Alert(Alert.AlertType.ERROR); - errorAlert.setTitle("Error Message"); - errorAlert.setHeaderText(null); - errorAlert.setContentText("Please try again."); - errorAlert.showAndWait(); - } - - } catch (SQLException e) { - e.printStackTrace(); - System.err.println("SQL Error: " + e.getMessage()); - } finally { - closeResources(); - } - - } - - - @FXML - void switchForm(ActionEvent event) { - if(event.getSource()==ForgetPassword){ - Login_Form.setVisible(false); - Proceed_Form.setVisible(true); - } - } - - - @FXML - void ChangeBack(ActionEvent event) { - if(event.getSource() == cngBack){ - Proceed_Form.setVisible(true); - ChangePassword.setVisible(false); - NewPassword.setText(""); - ConfirmPassword.setText(""); - confirmpassworderror.setText(""); - newpassworderror.setText(""); - } - } - - @FXML - void ChangePassword(ActionEvent event) { - newpassworderror.setText(""); - confirmpassworderror.setText(""); - - String nwpassword = NewPassword.getText(); - String confmpassword = ConfirmPassword.getText(); - if(nwpassword.isEmpty()){ - newpassworderror.setText("New password is required."); - return; - } - - if(confmpassword.isEmpty()){ - confirmpassworderror.setText("Confirm password is required."); - return; - } - - if(!nwpassword.equals(confmpassword)){ - confirmpassworderror.setText("Please give the same password."); - return; - } - if(nwpassword.equals(confmpassword)){ - try{ - String email = GiveForgetEmail.getText(); - String date = ForgateDate.getText(); -// date = convertDate(date,"dd-MM-yyyy"); - String query = "UPDATE userdetails SET password = ? WHERE RegistrationID = ? AND PasswordClue = ?"; - - preparedStatement = connection.prepareStatement(query); - - preparedStatement.setString(1,nwpassword); - preparedStatement.setString(2,email); - preparedStatement.setString(3, date); - - Alert alert = new Alert(Alert.AlertType.INFORMATION); - alert.setTitle("Success"); - alert.setHeaderText(null); - alert.setContentText("User details updated successfully!"); - - // Show the alert and wait for OK click - alert.showAndWait().ifPresent(response -> { - if (response == ButtonType.OK) { - int rowsAffected = 0; - try { - rowsAffected = preparedStatement.executeUpdate(); - } catch (SQLException e) { - throw new RuntimeException(e); - } - if (rowsAffected > 0) { - System.out.println("User details updated successfully."); - Login_Form.setVisible(true); - ChangePassword.setVisible(false); - - } else { - System.out.println("No user found with the specified ID."); - } - } - }); - - }catch (SQLException e){ - - e.printStackTrace(); - System.out.println(e.getMessage()); - } - finally { - closeResources(); - } - - } - } - - @FXML - void ForgetEmailBack(@NotNull ActionEvent event) { - if(event.getSource() == forgetemailback){ - Proceed_Form.setVisible(false); - Login_Form.setVisible(true); - ForgateDate.setText(""); - GiveForgetEmail.setText(""); - blankemail.setText(""); - ForgateDateError.setText(""); - } - - } - - - @FXML - void ForgetProceed(ActionEvent event) { - - blankemail.setText(""); - ForgateDateError.setText(""); - - String email = GiveForgetEmail.getText(); - String date = ForgateDate.getText(); - if(email.isEmpty()){ - blankemail.setText("ID is required."); - return; - } - - if(date.isEmpty()){ - ForgateDateError.setText("Password Clue is required."); - return; - } - - try{ -// date = convertDate(date,"dd-MM-yyyy"); - String query = "SELECT * FROM userdetails WHERE RegistrationID = ? AND PasswordClue = ?"; - preparedStatement = connection.prepareStatement(query); - preparedStatement.setString(1,email); - preparedStatement.setString(2,date); - - resultSet = preparedStatement.executeQuery(); - if(resultSet.next()){ - Proceed_Form.setVisible(false); - ChangePassword.setVisible(true); - blankemail.setText(""); - ForgateDateError.setText(""); - }else{ - blankemail.setText("Use Valid ID."); - ForgateDateError.setText("Use Valid Clue."); - GiveForgetEmail.setText(""); - ForgateDate.setText(""); - } - }catch (SQLException e){ - e.printStackTrace(); - } - finally { - closeResources(); - } - } - - @NotNull - private String convertDate(String inputDate, String inputFormat) { - try { - DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern(inputFormat); - LocalDate date = LocalDate.parse(inputDate, inputFormatter); - - - DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); - return date.format(outputFormatter); - } catch (DateTimeParseException e) { - return "Invalid date or format: " + e.getMessage(); - } - } - - private void closeResources() { - try { - if (resultSet != null) { - resultSet.close(); - resultSet = null; - } - if (preparedStatement != null) { - preparedStatement.close(); - preparedStatement = null; - } -// if (connection != null) { -// connection.close(); -// connection = null; -// } - } catch (SQLException e) { - e.printStackTrace(); - } - } -} diff --git a/src/main/java/cafe/management/cafe/ProductData.java b/src/main/java/cafe/management/cafe/ProductData.java deleted file mode 100644 index 703395a..0000000 --- a/src/main/java/cafe/management/cafe/ProductData.java +++ /dev/null @@ -1,68 +0,0 @@ -package cafe.management.cafe; - -import java.sql.Date; - -public class ProductData { - private final String Image; - private String ProductId; - private String ProductName; - private String Type; - private int Stock; - private double Price; - private String Status; - private Date DateAdded; - private int quantity; - - public ProductData(String ProductId, String ProductName, String Type, int Stock, double Price, String Status, Date DateAdded, String Image) { - this.ProductId = ProductId; - this.ProductName = ProductName; - this.Type = Type; - this.Stock = Stock; - this.Price = Price; - this.Status = Status; - this.DateAdded = DateAdded; - this.Image = Image; - } - - public ProductData(String ProductId, String ProductName, double Price, String Image) { - this.ProductId = ProductId; - this.ProductName = ProductName; - this.Price = Price; - this.Image = Image; - } - - public ProductData(String ProductId, String ProductName, double Price, String Image,int quantity) { - this.ProductId = ProductId; - this.ProductName = ProductName; - this.Price = Price; - this.Image = Image; - this.quantity = quantity; - } - - - public String getProductID() { - return ProductId; - } - public String getProductName() { - return ProductName; - } - public int getStock() { - return Stock; - } - public double getPrice() { - return Price; - } - public String getType() { - return Type; - } - public String getStatus() { - return Status; - } - public Date getDateAdded() { - return DateAdded; - } - public String getImage() { - return Image; - } - public int getQuantity(){return quantity;} -} diff --git a/src/main/java/cafe/management/cafe/SurfaceLayoutContoller.java b/src/main/java/cafe/management/cafe/SurfaceLayoutContoller.java deleted file mode 100644 index 1d9b202..0000000 --- a/src/main/java/cafe/management/cafe/SurfaceLayoutContoller.java +++ /dev/null @@ -1,1337 +0,0 @@ -package cafe.management.cafe; - -import javafx.application.Platform; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import javafx.scene.Node; -import javafx.scene.chart.*; -import javafx.scene.control.*; -import javafx.scene.control.cell.PropertyValueFactory; -import javafx.scene.image.Image; -import javafx.scene.image.ImageView; -import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.GridPane; -import javafx.stage.FileChooser; - -import java.io.File; -import java.io.IOException; -import java.sql.*; -import java.text.DateFormatSymbols; -import java.time.Instant; -import java.time.LocalDate; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; - -import static javafx.collections.FXCollections.observableList; - -public class SurfaceLayoutContoller { - - @FXML - private AnchorPane DashboardMainpage; - - @FXML - private AnchorPane DashboardScroll; - - @FXML - private AnchorPane DashboardChart; - - - @FXML - private Button cutomer_btn; - - @FXML - private Button dashboard_btn; - - @FXML - private Button inventory_addBtn; - - @FXML - private Button inventory_btn; - - @FXML - private Button inventory_clearBtn; - - @FXML - private TableColumn inventory_col_date; - - @FXML - private TableColumn inventory_col_price; - - @FXML - private TableColumn inventory_col_productID; - - @FXML - private TableColumn inventory_col_productName; - - @FXML - private TableColumn inventory_col_status; - - @FXML - private TableColumn inventory_col_stock; - - @FXML - private TableColumn inventory_col_type; - - @FXML - private Button inventory_deleteBtn; - - @FXML - private AnchorPane inventory_form; - - @FXML - private ImageView inventory_imageView; - - @FXML - private Button inventory_importBtn; - - @FXML - private TextField inventory_price; - - @FXML - private TextField inventory_productID; - - @FXML - private TextField inventory_productName; - - @FXML - private ComboBox inventory_status; - - @FXML - private TextField inventory_stock; - - @FXML - private TableView inventory_tableView; - - @FXML - private Button inventory_updateBtn; - - @FXML - private Button logout_btn; - - @FXML - private AnchorPane main_form; - - @FXML - private TextField menu_amount; - - @FXML - private Button menu_btn; - - @FXML - private Label menu_change; - - @FXML - private TableColumn menu_col_price; - - @FXML - private TableColumn menu_col_productName; - - @FXML - private TableColumn menu_col_quantity; - - @FXML - private AnchorPane menu_form; - - @FXML - private GridPane menu_gridPane; - - @FXML - private Button menu_payBtn; - - @FXML - private Button menu_receiptBtn; - - @FXML - private Button menu_removeBtn; - - @FXML - private ScrollPane menu_scrollPane; - - @FXML - private TableView menu_tableView; - - @FXML - private Label menu_total; - - @FXML - private Label username; - - private Image img; - - - @FXML - private ComboBox Inventory_choiceType; - - @FXML - private AnchorPane ProfilePage; - - - @FXML - private AnchorPane ConfirmUpdate_page; - - - @FXML - private Label Today_Income; - - @FXML - private Label Total_Sold; - - @FXML - private Label Total_customer; - - @FXML - private Label Total_income; - - - @FXML - private ComboBox inventory_choiceStatus; - - private String[] type_list = {"Meals","Drinks"}; - - private String[] status_list = {"Available","Unavailable"}; - - private Connection connection = null; - - private PreparedStatement preparedStatement = null; - - private ResultSet resultSet = null; - - public SurfaceLayoutContoller() { - connection = DatabaseUsers.getConnection(); - } - - @FXML - void LeavePage(ActionEvent event) { - Alert alrt = new Alert(Alert.AlertType.CONFIRMATION); - alrt.setTitle("Confirmation Message"); - alrt.setHeaderText(null); - alrt.setContentText("Are you sure you want to sign out."); - - Optional opt = alrt.showAndWait(); - - if(opt.isPresent() && opt.get() == ButtonType.OK) { - try { - CafeManagement.switchScene("LoginPage.fxml", 800); - } catch (IOException e) { - e.printStackTrace(); - System.err.println("Failed to load LoginPage.fxml"); - } - } else { - System.out.println("Stay loggedin."); - } - } - - @FXML - private AnchorPane customer_page; - - @FXML - void Customer(ActionEvent event) { - DashboardMainpage.setVisible(false); - inventory_form.setVisible(false); - menu_form.setVisible(false); - ProfilePage.setVisible(false); - ConfirmUpdate_page.setVisible(false); - customer_page.setVisible(true); - - customercount(); - showCustomerData(); - } - - - - private HashMap track = new HashMap<>(); - private double tot = 0.0; - private int totsold = 0; - private int totcustomer = 0; - - @FXML - void Dashboard(ActionEvent event) { - DashboardMainpage.setVisible(true); - inventory_form.setVisible(false); - menu_form.setVisible(false); - ProfilePage.setVisible(false); - ConfirmUpdate_page.setVisible(false); - customer_page.setVisible(false); - - loadCustomerChartData(); - initializeCustomerChart(); - initializeIncomeChart(); - - tot = 0.0; - totsold = 0; - track.clear(); - - ArrayList summaries = getCustomerSummaries(); - totcustomer = summaries.size(); - - for (CustomerSummary summary : summaries) { - tot += summary.getTotalPrice(); - totsold += summary.getTotalQuantity(); - String date = summary.getDate(); - track.put(date, track.getOrDefault(date, 0.0) + summary.getTotalPrice()); - } - - String formattedDate = LocalDate.now().format(DateTimeFormatter.ISO_DATE); - double todayIncomeValue = track.getOrDefault(formattedDate, 0.0); - - String todayIncome = String.format("%.2f", todayIncomeValue) + " TK"; - String totalIncome =String.format("%.2f", tot) + " TK"; - String totalCustomer =String.valueOf(totsold); - String totalSold =String.valueOf(totcustomer); - - Today_Income.setText(todayIncome); - Total_income.setText(totalIncome); - Total_Sold.setText(totalCustomer); - Total_customer.setText(totalSold); - } - - void inventory_Type_Status() { - List list = new ArrayList<>(); - - for(String s : type_list){ - list.add(s); - } - ObservableList observableList = FXCollections.observableArrayList(list); - Inventory_choiceType.setItems(observableList); - - List statusList = new ArrayList<>(); - - for(String s:status_list){ - statusList.add(s); - } - - ObservableList sList = FXCollections.observableArrayList(statusList); - - inventory_choiceStatus.setItems(sList); - } - - void ClearFields() { - inventory_imageView.setImage(null); - img = null; - inventory_productName.requestFocus(); - inventory_productID.requestFocus(); - inventory_stock.requestFocus(); - inventory_price.requestFocus(); - inventory_choiceStatus.requestFocus(); - Inventory_choiceType.requestFocus(); - inventory_productName.setText(""); - inventory_productID.setText(""); - inventory_stock.setText(""); - inventory_price.setText(""); - inventory_choiceStatus.setValue(null); - Inventory_choiceType.setValue(null); - } - - ObservableList Inventory_ProductDatalist(){ - ObservableList list = FXCollections.observableArrayList(); - - String query = "SELECT * FROM ProductDetails"; - - try { - preparedStatement = connection.prepareStatement(query); - resultSet = preparedStatement.executeQuery(); - ProductData data = null; - - while(resultSet.next()){ - data = new ProductData(resultSet.getString("ProductID"), - resultSet.getString("ProductName"), - resultSet.getString("Type"), - resultSet.getInt("Stock"), - resultSet.getDouble("Price"), - resultSet.getString("Status"), - resultSet.getDate("DateAdded"), - resultSet.getString("Image") - ); - list.add(data); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - CloseConnection(); - ClearFields(); - } - return list; - } - - ObservableList InventoryListData; - - void InventoryShowData() { - InventoryListData = Inventory_ProductDatalist(); - - inventory_col_productID.setCellValueFactory(new PropertyValueFactory<>("ProductID")); - inventory_col_productName.setCellValueFactory(new PropertyValueFactory<>("ProductName")); - inventory_col_type.setCellValueFactory(new PropertyValueFactory<>("Type")); - inventory_col_stock.setCellValueFactory(new PropertyValueFactory<>("Stock")); - inventory_col_price.setCellValueFactory(new PropertyValueFactory<>("Price")); - inventory_col_status.setCellValueFactory(new PropertyValueFactory<>("Status")); - inventory_col_date.setCellValueFactory(new PropertyValueFactory<>("DateAdded")); - inventory_tableView.setItems(InventoryListData); - } - - @FXML - void InventoryAddBtn(ActionEvent event) { - if(inventory_productName.getText().isEmpty() || - inventory_productID.getText().isEmpty() || - inventory_stock.getText().isEmpty() || - inventory_price.getText().isEmpty() || - inventory_choiceStatus.getSelectionModel().getSelectedItem() == null || - Inventory_choiceType.getSelectionModel().getSelectedItem() == null|| - inventory_imageView.getImage() == null){ - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Please fill all the fields."); - alert.showAndWait(); - } else { - String CheckProductID = "SELECT ProductID FROM ProductDetails WHERE ProductID = '" + inventory_productID.getText() +"'"; - try { - Statement Statement = connection.createStatement(); - ResultSet rs = Statement.executeQuery(CheckProductID); - if(rs.next()){ - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Product ID already exists."); - alert.showAndWait(); - } else { - String query = "INSERT INTO ProductDetails (ProductID, ProductName, Type, Stock, Price, Status, DateAdded, Image) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"; - preparedStatement = connection.prepareStatement(query); - preparedStatement.setString(1, inventory_productID.getText()); - preparedStatement.setString(2, inventory_productName.getText()); - preparedStatement.setString(3, Inventory_choiceType.getSelectionModel().getSelectedItem().toString()); - preparedStatement.setInt(4, Integer.parseInt(inventory_stock.getText())); - preparedStatement.setDouble(5, Double.parseDouble(inventory_price.getText())); - preparedStatement.setString(6, inventory_choiceStatus.getSelectionModel().getSelectedItem().toString()); - preparedStatement.setDate(7, new Date(System.currentTimeMillis())); - preparedStatement.setString(8, img.getUrl()); - int rowsInserted = preparedStatement.executeUpdate(); - if(rowsInserted > 0){ - Alert alert = new Alert(Alert.AlertType.INFORMATION); - alert.setTitle("Information Message"); - alert.setHeaderText(null); - alert.setContentText("Product added successfully."); - alert.showAndWait(); - - inventory_productName.requestFocus(); - inventory_productID.requestFocus(); - inventory_stock.requestFocus(); - inventory_price.requestFocus(); - inventory_choiceStatus.requestFocus(); - Inventory_choiceType.requestFocus(); - inventory_productName.setText(""); - inventory_productID.setText(""); - inventory_stock.setText(""); - - } - else{ - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Failed to add product."); - } - } - - } catch (SQLException e) { - throw new RuntimeException(e); - } - finally { - CloseConnection(); - InventoryShowData(); - } - } - } - - @FXML - void InventoryClearBtn(ActionEvent event) { - ClearFields(); - InventoryShowData(); - } - - @FXML - void InventoryDeleteBtn(ActionEvent event) { - if (inventory_productID.getText().isEmpty()) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Please fill the Product ID field."); - alert.showAndWait(); - } else { - String CheckProductID = "SELECT ProductID FROM ProductDetails WHERE ProductID = '" + inventory_productID.getText() + "'"; - - try { - connection = DatabaseUsers.getConnection(); - Statement statement = connection.createStatement(); - ResultSet rs = statement.executeQuery(CheckProductID); - - if (!rs.next()) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Product ID does not exist."); - alert.showAndWait(); - } else { - Alert alert = new Alert(Alert.AlertType.CONFIRMATION); - alert.setTitle("Confirmation Message"); - alert.setHeaderText(null); - alert.setContentText("Are you sure you want to delete this Product ID: " + inventory_productID.getText() + "?"); - - Optional opt = alert.showAndWait(); - - if (opt.isPresent() && opt.get() == ButtonType.OK) { - String query = "DELETE FROM ProductDetails WHERE ProductID = ?"; - preparedStatement = connection.prepareStatement(query); - preparedStatement.setString(1, inventory_productID.getText()); - - int rowsDeleted = preparedStatement.executeUpdate(); - - if (rowsDeleted > 0) { - Alert infoAlert = new Alert(Alert.AlertType.INFORMATION); - infoAlert.setTitle("Information Message"); - infoAlert.setHeaderText(null); - infoAlert.setContentText("Product deleted successfully."); - infoAlert.showAndWait(); - } else { - Alert errorAlert = new Alert(Alert.AlertType.ERROR); - errorAlert.setTitle("Error Message"); - errorAlert.setHeaderText(null); - errorAlert.setContentText("Failed to delete product."); - errorAlert.showAndWait(); - } - } - } - - InventoryShowData(); - - } catch (SQLException e) { - e.printStackTrace(); - } finally { - CloseConnection(); - ClearFields(); - } - } - - } - - @FXML - - void InventoryUpdateBtn(ActionEvent event) { - if (inventory_productID.getText().isEmpty()) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Please fill the Product ID field."); - alert.showAndWait(); - } else { - String CheckProductID = "SELECT ProductID FROM ProductDetails WHERE ProductID = '" + inventory_productID.getText() + "'"; - - try { - Statement statement = connection.createStatement(); - ResultSet rs = statement.executeQuery(CheckProductID); - - if (!rs.next()) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Product ID does not exist."); - alert.showAndWait(); - } else { - - String pdType = null; - int pdStock = 0; - double pdPrice = 0.0; - String pdStatus = null; - String pdImage = null; - String find = "SELECT ProductName, Type, Stock, Price, Status, Image FROM ProductDetails WHERE ProductID = ?"; - String pdName = null; - try { - preparedStatement = connection.prepareStatement(find); - preparedStatement.setString(1, inventory_productID.getText()); - - ResultSet result = preparedStatement.executeQuery(); - - if (result.next()) { - pdName = result.getString("ProductName"); - pdType = result.getString("Type"); - pdStock = result.getInt("Stock"); - pdPrice = result.getDouble("Price"); - pdStatus = result.getString("Status"); - pdImage = result.getString("Image"); - } - } catch (SQLException e) { - e.printStackTrace(); - } - - pdName = (inventory_productName.getText().isEmpty()) ? pdName : inventory_productName.getText(); - pdType = (Inventory_choiceType.getSelectionModel().getSelectedItem() == null) ? pdType : Inventory_choiceType.getSelectionModel().getSelectedItem().toString(); - pdStock = (inventory_stock.getText().isEmpty()) ? pdStock : Integer.parseInt(inventory_stock.getText()); - pdPrice = (inventory_price.getText().isEmpty()) ? pdPrice : Double.parseDouble(inventory_price.getText()); - pdStatus = (inventory_choiceStatus.getSelectionModel().getSelectedItem() == null) ? pdStatus : inventory_choiceStatus.getSelectionModel().getSelectedItem().toString(); - pdImage = (img == null) ? pdImage : img.getUrl(); - - String query = "UPDATE ProductDetails SET ProductName = ?, Type = ?, Stock = ?, Price = ?, Status = ?, DateAdded = ?, Image = ? WHERE ProductID = ?"; - - preparedStatement = connection.prepareStatement(query); - preparedStatement.setString(1, pdName); - preparedStatement.setString(2, pdType); - preparedStatement.setInt(3, pdStock); - preparedStatement.setDouble(4, pdPrice); - preparedStatement.setString(5, pdStatus); - preparedStatement.setDate(6, new Date(System.currentTimeMillis())); - preparedStatement.setString(7, pdImage); - preparedStatement.setString(8, inventory_productID.getText()); - - Alert alrt = new Alert(Alert.AlertType.CONFIRMATION); - alrt.setTitle("Confirmation Message"); - alrt.setHeaderText(null); - alrt.setContentText("Are you sure you want to update this Product ID: " + inventory_productID.getText() + "?"); - - Optional opt = alrt.showAndWait(); - - if (opt.isPresent() && opt.get() == ButtonType.OK) { - - int rowsUpdated = preparedStatement.executeUpdate(); - - if (rowsUpdated > 0) { - Alert alert = new Alert(Alert.AlertType.INFORMATION); - alert.setTitle("Information Message"); - alert.setHeaderText(null); - alert.setContentText("Product updated successfully."); - alert.showAndWait(); - - } else { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error Message"); - alert.setHeaderText(null); - alert.setContentText("Failed to update product."); - alert.showAndWait(); - } - } - - InventoryShowData(); - } - } catch (SQLException e) { - throw new RuntimeException(e); - } finally { - CloseConnection(); - ClearFields(); - } - } - } - - @FXML - void InventoryImortBtn(ActionEvent event) { - FileChooser fileChooser = new FileChooser(); - fileChooser.setTitle("Open Resource File"); - fileChooser.getExtensionFilters().addAll( - new FileChooser.ExtensionFilter("Open Image File", "*.png", "*.jpg") - ); - - File file = fileChooser.showOpenDialog(DashboardMainpage.getScene().getWindow()); - - if(file != null){ - img = new Image(file.toURI().toString(),168,144,false,true); - inventory_imageView.setImage(img); - } - } - - @FXML - void Inventory(ActionEvent event) { - DashboardMainpage.setVisible(false); - inventory_form.setVisible(true); - ProfilePage.setVisible(false); - menu_form.setVisible(false); - ConfirmUpdate_page.setVisible(false); - customer_page.setVisible(false); - inventory_Type_Status(); - InventoryShowData(); - } - - private ObservableList cardProduct = FXCollections.observableArrayList(); - - public ObservableList menuCard(){ - String sql = "SELECT * FROM productdetails"; - ObservableList temp = FXCollections.observableArrayList(); - try{ - preparedStatement = connection.prepareStatement(sql); - resultSet = preparedStatement.executeQuery(); - - while(resultSet.next()){ - ProductData prod; - if ("Available".equalsIgnoreCase(resultSet.getString("Status").trim())) { - prod = new ProductData(resultSet.getString("ProductID"), - resultSet.getString("ProductName"), - resultSet.getDouble("Price"), - resultSet.getString("Image")); - temp.add(prod); - } - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - CloseConnection(); - } - return temp; - } - - public void menuDisplyCard(){ - cardProduct.clear(); - cardProduct.addAll(menuCard()); - - menu_gridPane.getChildren().clear(); - - int col=0; - int row=0; - menu_gridPane.getRowConstraints().clear(); - menu_gridPane.getColumnConstraints().clear(); - -// menu_gridPane.setHgap(15); -// menu_gridPane.setVgap(15); - for(int i = 0;i < cardProduct.size();i++){ - try { - FXMLLoader load = new FXMLLoader(); - load.setLocation(getClass().getResource("CardProduct.fxml")); - AnchorPane pan = load.load(); - - CardProduct controller = load.getController(); - controller.setData(cardProduct.get(i)); - - if(col == 3){ - col = 0; - row++; - } - menu_gridPane.add(pan,col++,row); - GridPane.setMargin(pan, new Insets(10, 10, 10, 10)); - - } catch (Exception e){ - e.printStackTrace(); - } - } - } - - @FXML - void Menu(ActionEvent event) { - DashboardMainpage.setVisible(false); - inventory_form.setVisible(false); - ProfilePage.setVisible(false); - menu_form.setVisible(true); - ConfirmUpdate_page.setVisible(false); - customer_page.setVisible(false); - - menuDisplyCard(); - displayorder(); - } - - @FXML - private Label ProfileCat; - - @FXML - private Label ProfileDept; - - @FXML - private Label ProfileID; - - @FXML - private Label ProfileName; - - private String registration_ID; - - private String fullName; - - private String pass; - - private String clue; - - private String num; - - - @FXML - private Label updatePhone; - - void showProfileInformation(){ - - String regID = ManagementControl.ID; - - try { - String sql = "SELECT FullName, RegistrationID, Category, PhoneNumber, Department, Password, PasswordClue FROM userdetails WHERE RegistrationID = ?"; - - preparedStatement = connection.prepareStatement(sql); - preparedStatement.setString(1, regID); - - resultSet = preparedStatement.executeQuery(); - - if (resultSet.next()) { - String name = resultSet.getString("FullName"); - String registrationId = resultSet.getString("RegistrationID"); - String category = resultSet.getString("Category"); - String phone = resultSet.getString("PhoneNumber"); - String department = resultSet.getString("Department"); - - fullName = name; - registration_ID = registrationId; - pass = resultSet.getString("Password"); - clue = resultSet.getString("PasswordClue"); - num = phone; - - ProfileID.setText(registrationId); - ProfileName.setText(name); - ProfileCat.setText(category); - if(department != null) - ProfileDept.setText(department); - if(phone != null) - updatePhone.setText(phone); - - } else { - System.out.println("No data found for regID: " + regID); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - CloseConnection(); - } - - } - - @FXML - void Profile(ActionEvent event) { - DashboardMainpage.setVisible(false); - inventory_form.setVisible(false); - ProfilePage.setVisible(true); - menu_form.setVisible(false); - ConfirmUpdate_page.setVisible(false); - customer_page.setVisible(false); - - showProfileInformation(); - } - - @FXML - private TextField const_ID; - - @FXML - private TextField updateName; - - @FXML - private TextField update_Department; - - @FXML - private TextField update_phone; - - - @FXML - void ProfileUpdate(ActionEvent event) { - Alert alrt = new Alert(Alert.AlertType.CONFIRMATION); - alrt.setTitle("Confirmation Message"); - alrt.setHeaderText(null); - alrt.setContentText("Are you sure you want to update your information."); - - Optional opt = alrt.showAndWait(); - - if(opt.isPresent() && opt.get() == ButtonType.OK){ - ProfilePage.setVisible(false); - ConfirmUpdate_page.setVisible(true); - const_ID.setText(registration_ID); - const_ID.setDisable(true); - updateName.setText(fullName); - updateName.requestFocus(); - update_passclue.setText(clue); - update_password.setText(pass); - if(num != null){ - updatePhone.setText(num); - } - } - - } - - - - @FXML - void ConfirmUpdate(ActionEvent event) { - Alert alrt = new Alert(Alert.AlertType.CONFIRMATION); - alrt.setTitle("Confirmation Message"); - alrt.setHeaderText(null); - alrt.setContentText("Are you sure you want to update your information."); - - Optional opt = alrt.showAndWait(); - - if(opt.isPresent() && opt.get() == ButtonType.OK){ - ProfilePage.setVisible(true); - ConfirmUpdate_page.setVisible(false); - confirm_update(); - } - } - - @FXML - private TextField update_passclue; - - @FXML - private TextField update_password; - - void confirm_update(){ - String name = updateName.getText(); - String department = update_Department.getText(); - String phone = update_phone.getText(); - String password = update_password.getText(); - String passclue = update_passclue.getText(); - - if (name.isEmpty() || department.isEmpty() || phone.isEmpty() || passclue.isEmpty() || password.isEmpty()) { - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Error"); - alert.setHeaderText(null); - alert.setContentText("All fields are required. Please fill out all fields."); - alert.showAndWait(); - return; - } - - try { - String updateQuery = "UPDATE userdetails SET FullName = ?, Department = ?, PhoneNumber = ?, Password = ?, PasswordClue = ? WHERE RegistrationID = ?"; - PreparedStatement pstmt = connection.prepareStatement(updateQuery); - - pstmt.setString(1, name); - pstmt.setString(2, department); - pstmt.setString(3, phone); - pstmt.setString(4, password); - pstmt.setString(5, passclue); - pstmt.setString(6, const_ID.getText()); - - int rowsAffected = pstmt.executeUpdate(); - - if (rowsAffected > 0) { - Alert alert = new Alert(Alert.AlertType.INFORMATION); - alert.setTitle("Success"); - alert.setHeaderText(null); - alert.setContentText("Profile updated successfully!"); - alert.showAndWait(); - showProfileInformation(); - } else { - Alert alert = new Alert(Alert.AlertType.WARNING); - alert.setTitle("Warning"); - alert.setHeaderText(null); - alert.setContentText("No matching record found. Update failed."); - alert.showAndWait(); - } - } catch (SQLException e) { - e.printStackTrace(); - Alert alert = new Alert(Alert.AlertType.ERROR); - alert.setTitle("Database Error"); - alert.setHeaderText(null); - alert.setContentText("An error occurred while updating the profile."); - alert.showAndWait(); - } finally { - CloseConnection(); - } - - } - - - private int Cid; - - public void customer_id() { - String sql = "SELECT MAX(customer_id) FROM customer"; - - try { - connection = DatabaseUsers.getConnection(); - preparedStatement = connection.prepareStatement(sql); - resultSet = preparedStatement.executeQuery(); - - if(resultSet.next()){ - Cid = resultSet.getInt("MAX(customer_id)"); - } - String checkcid = "SELECT MAX(customer_id) FROM receipt"; - preparedStatement = connection.prepareStatement(checkcid); - resultSet = preparedStatement.executeQuery(); - int checkID = 0; - if (resultSet.next()) { - checkID = resultSet.getInt("MAX(customer_id)"); - } - - if(Cid == 0){ - Cid += 1; - } else if(Cid == checkID){ - Cid += 1; - } - - data.cid = Cid; - - } catch (SQLException e) { - e.printStackTrace(); - } finally { - CloseConnection(); - } - } - - private double total_price = 0.0; - - public ObservableList menuDisplayOrder(){ - ObservableList listdata = FXCollections.observableArrayList(); - String sql = "SELECT * FROM customer"; - - try { - // Establishing connection (Make sure your connection logic is correct) - connection = DatabaseUsers.getConnection(); // assuming DatabaseConnection is a class managing DB connection - - // Prepare the SQL statement - preparedStatement = connection.prepareStatement(sql); - - // Execute the query and retrieve the result set - resultSet = preparedStatement.executeQuery(); - - // Iterate through the result set and map the data to ProductData objects - while (resultSet.next()) { - if(resultSet.getString("type").equals("Paid")) - continue; - String productId = "abc"; - String productName = resultSet.getString("prod_name"); - double price = resultSet.getDouble("Price"); - String image = "abc"; - int quantity = resultSet.getInt("quantity"); - - total_price += price; - - // Creating the ProductData object with the constructor - ProductData product = new ProductData(productId, productName, price, image, quantity); - listdata.add(product); - } - } catch (SQLException e) { - e.printStackTrace(); // Handle exceptions appropriately - } finally { - // Close resources to avoid memory leaks - try { - if (resultSet != null) resultSet.close(); - if (preparedStatement != null) preparedStatement.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - } - - return listdata; - } - - private ObservableList menulist; - - public void displayorder(){ - menulist = menuDisplayOrder(); - - menu_col_price.setCellValueFactory(new PropertyValueFactory<>("Price")); - menu_col_productName.setCellValueFactory(new PropertyValueFactory<>("ProductName")); - menu_col_quantity.setCellValueFactory(new PropertyValueFactory<>("quantity")); - menu_tableView.setItems(menulist); - - String tk = String.valueOf(total_price) + "TK"; - menu_total.setText(tk); - } - - - @FXML - void payBtn(ActionEvent event) { - - Alert alert = new Alert(Alert.AlertType.INFORMATION); - alert.setTitle("Payment Confirmation"); - alert.setHeaderText(null); - alert.setContentText("Are you sure you want to proceed with the payment?"); - - alert.getButtonTypes().setAll(ButtonType.OK, ButtonType.CANCEL); - - ButtonType result = alert.showAndWait().orElse(ButtonType.CANCEL); - - if (result == ButtonType.CANCEL) { - return; - } - - menu_amount.setText(""); - - String amountText = menu_amount.getText(); - double given_price = 0.0; - - if (!amountText.isEmpty()) { - try { - given_price = Double.parseDouble(amountText); - } catch (NumberFormatException e) { - System.out.println("Invalid input: " + e.getMessage()); - return; - } - } - - double change = given_price - total_price; - String cng = String.valueOf(change); - - menu_change.setText("$0.0 TK"); - menu_total.setText("$0.0 TK"); - total_price = 0.0; - String updateSql = "UPDATE customer SET type = 'Paid' WHERE type = 'Unpaid'"; - - try { - preparedStatement = connection.prepareStatement(updateSql); - - int rowsUpdated = preparedStatement.executeUpdate(); - System.out.println("Updated " + rowsUpdated + " rows to 'Paid'"); - - } catch (SQLException e) { - System.out.println("Error updating 'Paid' status: " + e.getMessage()); - } finally { - CloseConnection(); - displayorder(); - } - } - - @FXML - void Amount(ActionEvent event) { - - String amountText = menu_amount.getText(); - double given_price = 0.0; - - if (!amountText.isEmpty()) { - try { - given_price = Double.parseDouble(amountText); - } catch (NumberFormatException e) { - System.out.println("Invalid input: " + e.getMessage()); - return; - } - } - - if(given_price < total_price){ - Alert insufficientFundsAlert = new Alert(Alert.AlertType.WARNING); - insufficientFundsAlert.setTitle("Insufficient Funds"); - insufficientFundsAlert.setHeaderText(null); - insufficientFundsAlert.setContentText("The amount given is less than the total price.\nPlease enter a sufficient amount."); - insufficientFundsAlert.showAndWait(); - return; - } - double change = given_price - total_price; - String cng = String.valueOf(change) + "TK"; - - menu_change.setText(cng); - } - - @FXML - private TableView customer_tableview; - - @FXML - private TableColumn pars_col_customerid; - - @FXML - private TableColumn pars_col_customername; - - @FXML - private TableColumn pars_col_date; - - @FXML - private TableColumn pars_col_quantity; - - @FXML - private TableColumn pars_col_price; - - - - public ArrayList getCustomerSummaries() { - ArrayList summaries = new ArrayList<>(); - String sql = "SELECT c.customer_id, u.FullName AS customer_name, c.date, " + - "SUM(c.quantity) AS total_quantity, " + - "SUM(c.price * c.quantity) AS total_price " + - "FROM customer c " + - "JOIN userdetails u ON c.customer_id = u.RegistrationID " + - "GROUP BY c.customer_id, c.date " + - "ORDER BY c.customer_id, c.date"; - - try (PreparedStatement preparedStatement = connection.prepareStatement(sql); - ResultSet resultSet = preparedStatement.executeQuery()) { - - while (resultSet.next()) { - String customerId = resultSet.getString("customer_id"); - String name = resultSet.getString("customer_name"); - String date = resultSet.getString("date"); - int totalQuantity = resultSet.getInt("total_quantity"); - double totalPrice = resultSet.getDouble("total_price"); - - summaries.add(new CustomerSummary(customerId, date, totalQuantity, totalPrice, name)); - } - - } catch (SQLException e) { - System.out.println("Error fetching customer summaries: " + e.getMessage()); - } - - return summaries; - } - - private ArrayList alldata; - - public void customercount(){ - alldata = getCustomerSummaries(); - } - - private void showCustomerData() { - // Link TableColumns to CustomerSummary properties - ObservableList data = FXCollections.observableArrayList(alldata); - - pars_col_customerid.setCellValueFactory(new PropertyValueFactory<>("CustomerId")); - pars_col_customername.setCellValueFactory(new PropertyValueFactory<>("CustomerName")); - pars_col_date.setCellValueFactory(new PropertyValueFactory<>("Date")); - pars_col_quantity.setCellValueFactory(new PropertyValueFactory<>("TotalQuantity")); - pars_col_price.setCellValueFactory(new PropertyValueFactory<>("TotalPrice")); - - - customer_tableview.setItems(data); - - centerAlignColumn(pars_col_customerid); - centerAlignColumn(pars_col_customername); - centerAlignColumn(pars_col_price); - centerAlignColumn(pars_col_quantity); - centerAlignColumn(pars_col_date); - } - - private void centerAlignColumn(TableColumn column) { - column.setCellFactory(col -> new TableCell<>() { - @Override - protected void updateItem(T item, boolean empty) { - super.updateItem(item, empty); - if (empty || item == null) { - setText(null); - } else { - setText(item.toString()); - setAlignment(Pos.CENTER); - } - } - }); - } - - @FXML - private BarChart Dash_customerChart; // Corrected generics - @FXML - private AreaChart Dash_incomeChart; // Corrected generics - - // Initialize Income Chart - private void initializeIncomeChart() { - // Set up axes - CategoryAxis xAxis = new CategoryAxis(); - NumberAxis yAxis = new NumberAxis(); - xAxis.setLabel("Month"); - yAxis.setLabel("Revenue ($)"); - - Dash_incomeChart.setTitle("Monthly Income Overview"); - Dash_incomeChart.setLegendVisible(false); - - // Sample data (replace with actual database data) - XYChart.Series series = new XYChart.Series<>(); - series.getData().add(new XYChart.Data<>("Jan", 15000)); - series.getData().add(new XYChart.Data<>("Feb", 23000)); - series.getData().add(new XYChart.Data<>("Mar", 18500)); - series.getData().add(new XYChart.Data<>("Apr", 21000)); - - Dash_incomeChart.getData().add(series); - - // Styling (adjust if needed) - Platform.runLater(() -> { - for (XYChart.Data data : series.getData()) { - Node bar = data.getNode(); - if (bar != null) { - // Make the bars fatter - bar.setStyle("-fx-bar-width: 40px;"); - - // Change the color of the bars with a fancy gradient - bar.setStyle("-fx-bar-fill: linear-gradient(to top, #4caf50, #81c784);"); - - // Optional: Add a border to the bars - bar.setStyle("-fx-border-color: #388e3c; -fx-border-width: 2px;"); - } - } - }); - } - - // Initialize Customer Chart - private void initializeCustomerChart() { - // Set up axes - CategoryAxis xAxis = new CategoryAxis(); - NumberAxis yAxis = new NumberAxis(); - xAxis.setLabel("Month"); - yAxis.setLabel("Number of Customers"); - - Dash_customerChart.setTitle("Monthly Customer Activity"); - Dash_customerChart.setLegendVisible(false); - - // Sample data (replace with database data) - XYChart.Series series = new XYChart.Series<>(); - series.getData().add(new XYChart.Data<>("Jan", 150)); - series.getData().add(new XYChart.Data<>("Feb", 230)); - series.getData().add(new XYChart.Data<>("Mar", 185)); - series.getData().add(new XYChart.Data<>("Apr", 210)); - - Dash_customerChart.getData().add(series); - - // Use Platform.runLater to ensure the chart is fully rendered before applying styling - Platform.runLater(() -> { - for (XYChart.Data data : series.getData()) { - Node bar = data.getNode(); - - // Ensure the node is not null before styling - if (bar != null) { - // Make the bars fatter - bar.setStyle("-fx-bar-width: 40px;"); - - // Change the color of the bars with a fancy gradient - bar.setStyle("-fx-bar-fill: linear-gradient(to top, #ff9800, #ff5722);"); - - // Optional: Add a border to the bars - bar.setStyle("-fx-border-color: #ff5722; -fx-border-width: 2px;"); - } - } - - // Optional: Add a glow effect to the bars - for (XYChart.Data data : series.getData()) { - Node bar = data.getNode(); - if (bar != null) { - bar.setStyle("-fx-effect: dropshadow(gaussian, #ff5722, 10, 0, 0, 2);"); - } - } - }); - } - - - // Load Customer Chart Data from the database - private void loadCustomerChartData() { - // Clear any existing data before adding new data - Dash_customerChart.getData().clear(); - - XYChart.Series series = new XYChart.Series<>(); - - String sql = "SELECT MONTH(date) AS month, COUNT(DISTINCT customer_id) AS count " - + "FROM customer GROUP BY MONTH(date)"; - - try (PreparedStatement ps = connection.prepareStatement(sql); - ResultSet rs = ps.executeQuery()) { - - while (rs.next()) { - String month = getMonthName(rs.getInt("month")); - int count = rs.getInt("count"); - series.getData().add(new XYChart.Data<>(month, count)); - } - - Dash_customerChart.getData().add(series); - } catch (SQLException e) { - System.out.println("Error loading chart data: " + e.getMessage()); - } - } - - private String getMonthName(int month) { - return new DateFormatSymbols().getMonths()[month - 1]; - } - - - - private void CloseConnection(){ - try { - if(resultSet != null) resultSet.close(); - if(preparedStatement != null) preparedStatement.close(); - } catch(SQLException e) { - e.printStackTrace(); - } - - } -} - diff --git a/src/main/java/cafe/management/cafe/data.java b/src/main/java/cafe/management/cafe/data.java deleted file mode 100644 index d385044..0000000 --- a/src/main/java/cafe/management/cafe/data.java +++ /dev/null @@ -1,10 +0,0 @@ -package cafe.management.cafe; - -public class data { - - public static String username; - public static String path; - public static String date; - public static int id; - public static int cid; -} diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java deleted file mode 100644 index 827cd48..0000000 --- a/src/main/java/module-info.java +++ /dev/null @@ -1,19 +0,0 @@ -module cafe.manegment.cafe { - requires javafx.controls; - requires javafx.fxml; - requires javafx.web; - requires java.sql; - - requires org.controlsfx.controls; - requires com.dlsc.formsfx; - requires net.synedra.validatorfx; - requires org.kordamp.ikonli.javafx; - requires eu.hansolo.tilesfx; - requires com.almasb.fxgl.all; - requires annotations; - requires java.desktop; - requires mysql.connector.j; - - opens cafe.management.cafe to javafx.fxml; - exports cafe.management.cafe; -} \ No newline at end of file diff --git a/src/main/resources/cafe/management/cafe/Admin.fxml b/src/main/resources/cafe/management/cafe/Admin.fxml deleted file mode 100644 index 7be953a..0000000 --- a/src/main/resources/cafe/management/cafe/Admin.fxml +++ /dev/null @@ -1,805 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
-
-
diff --git a/src/main/resources/cafe/management/cafe/CardProduct.fxml b/src/main/resources/cafe/management/cafe/CardProduct.fxml deleted file mode 100644 index cb86112..0000000 --- a/src/main/resources/cafe/management/cafe/CardProduct.fxml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - diff --git a/src/main/resources/cafe/management/cafe/LoginPage.fxml b/src/main/resources/cafe/management/cafe/LoginPage.fxml deleted file mode 100644 index a4cc960..0000000 --- a/src/main/resources/cafe/management/cafe/LoginPage.fxml +++ /dev/null @@ -1,267 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/resources/cafe/management/cafe/LoginStyle.css b/src/main/resources/cafe/management/cafe/LoginStyle.css deleted file mode 100644 index cfe6530..0000000 --- a/src/main/resources/cafe/management/cafe/LoginStyle.css +++ /dev/null @@ -1,160 +0,0 @@ -/* Button box with gradient and hover effect */ -.button_box { - -fx-background-color: linear-gradient(to bottom, #b3cde0, #f0ffff); - -fx-background-radius: 30px; - -fx-border-radius: 30px; - -fx-border-color: rgba(200, 200, 200, 0.5); - -fx-border-width: 2px; - -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.2), 12, 0, 3, 3); - -fx-padding: 10px 15px; - -fx-font-size: 14px; - -fx-font-weight: bold; - -fx-text-fill: linear-gradient(to right, #333333, #555555); - -fx-cursor: hand; - -fx-transition: all 0.4s ease-in-out; -} - -/* Hover effect */ -.button_box:hover { - -fx-background-color: linear-gradient(to bottom, #e0f7fa, #b3e5fc); - -fx-border-color: rgba(100, 150, 200, 0.5); - -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.3), 12, 0, 4, 4); -} - - -.button_box:pressed { - -fx-background-color: linear-gradient(to bottom, #e0e0e0, #cfcfcf); - -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.15), 8, 0, 2, 2); - -fx-border-color: rgba(150, 150, 150, 0.5); - -fx-transform: scale(0.98); -} -/* Transparent glass effect with hover */ -/* Transparent container with a vanishing box effect */ -.transparent { - -fx-background-color: rgba(255, 255, 255, 0); - -fx-border-color: rgba(255, 255, 255, 0); - -fx-border-width: 0; - -fx-background-radius: 15px; - -fx-border-radius: 15px; - -fx-effect: none; - -fx-transition: all 0.3s ease-in-out; -} - -.transparent:hover { - -fx-background-color: rgba(255, 255, 255, 0.2); - -fx-border-color: rgba(255, 255, 255, 0.3); - -fx-border-width: 1px; - -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.15), 10, 0, 3, 3); -} - -/* TextField with underline effect */ -.textfield-underline { - -fx-background-color: transparent; - -fx-alignment: center; - -fx-border-color: transparent; - -fx-border-width: 0; - -fx-border-style: none; - -fx-border-width: 0 0 1px 0; - -fx-border-color: #286155; - -fx-padding: 5px 0; - -fx-font-size: 12px; - -fx-transition: all 0.3s ease-in-out; -} - -.textfield-underline:focused { - -fx-border-color: #0f6789; - -fx-border-width: 0 0 1.5px 0; - -fx-background-color: transparent; -} - - -.transparent:hover { - -fx-background-color: rgba(255, 255, 255, 0.3); - -fx-border-color: rgba(255, 255, 255, 0.5); - -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.25), 12, 0, 4, 4); - -fx-cursor: hand; -} - -/* Gradient background with hover effect */ -.gradient { - -fx-background-color: linear-gradient(to bottom right, #2a3d6d, #3c6e8f); - -fx-background-radius: 10px; - -fx-border-radius: 10px; - -fx-border-color: rgba(255, 255, 255, 0.2); - -fx-border-width: 1px; - -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.3), 15, 0, 4, 4); - -fx-padding: 15px; - -fx-transition: all 0.3s ease-in-out; -} - -.gradient:hover { - -fx-background-color: linear-gradient(to bottom right, #3c6e8f, #2a3d6d); /* Inverted deep blue gradient */ - -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.4), 18, 0, 5, 5); - -fx-cursor: hand; -} - - - -.Registration { - -fx-text-fill: linear-gradient(to right, #0000FF, #00FFFF);/* Light blue gradient text */ - -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.3), 3, 0, 1, 1); - -fx-font-size: 16px; - -fx-font-weight: bold; - -fx-transition: all 0.3s ease-in-out; -} - -.Registration:hover { - -fx-text-fill: linear-gradient(to right, #FFD700, #FF8C00); /* Gradient from gold to dark orange on hover */ - -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.7), 4, 0, 2, 2); -} - -.ForgetPassword { - -fx-text-fill: linear-gradient(to right, #4682B4, #87CEFA); /* Light blue gradient text */ - -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.3), 3, 0, 1, 1); - -fx-font-size: 13px; - -fx-font-weight: bold; - -fx-transition: all 0.3s ease-in-out; -} - -.ForgetPassword:hover { - -fx-text-fill: linear-gradient(to right, #FFD700, #FF8C00); /* Gradient from gold to dark orange on hover */ - -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.7), 4, 0, 2, 2); -} - - - -/* Text color hover effect */ -.text_color { - -fx-text-fill: #ffffff; /* White text */ - -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.5), 3, 0, 1, 1); - -fx-font-size: 16px; - -fx-font-weight: bold; - -fx-transition: all 0.3s ease-in-out; -} - -.text_color:hover { - -fx-text-fill: #ffcc00; /* Gold text on hover */ - -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.7), 4, 0, 2, 2); -} - -/* Label with hover gradient effect */ -.head_label { - -fx-border-color: linear-gradient(to right, #286155, #0f6789); - -fx-border-width: 0 0 0 5px; - -fx-padding: 0 0 0 10px; - -fx-background-color: linear-gradient(to right, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0)); - -fx-background-radius: 5px; - -fx-transition: all 0.3s ease-in-out; -} - -.head_label:hover { - -fx-border-color: linear-gradient(to right, #0f6789, #286155); - -fx-background-color: linear-gradient(to right, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1)); -} - -.error-message { - -fx-text-fill: #ff4d4d; /* Red text color */ - -fx-font-size: 12px; - -fx-font-style: italic; - -fx-padding: 5px 0 0 0; -} diff --git a/src/main/resources/cafe/management/cafe/SurfaceLayout.fxml b/src/main/resources/cafe/management/cafe/SurfaceLayout.fxml deleted file mode 100644 index 28a7fb4..0000000 --- a/src/main/resources/cafe/management/cafe/SurfaceLayout.fxml +++ /dev/null @@ -1,695 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
-
-
diff --git a/src/main/resources/cafe/management/cafe/mainForm1Design.css b/src/main/resources/cafe/management/cafe/mainForm1Design.css deleted file mode 100644 index af3ff00..0000000 --- a/src/main/resources/cafe/management/cafe/mainForm1Design.css +++ /dev/null @@ -1,177 +0,0 @@ -.header { - -fx-background-color: linear-gradient(to bottom right, rgba(9, 140, 83, 0.7), rgba(36, 104, 97, 0.7)); - -fx-border-color: #fff; - -fx-border-width: 0 0 0.8px 0; - -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.5), 10, 0, 0, 0); - -fx-backdrop-filter: blur(10px); -} - -.nav-form { - -fx-background-color: linear-gradient(to bottom right, - rgba(42, 61, 109, 0.6), - rgba(60, 110, 143, 0.6) - ); - -fx-backdrop-filter: blur(8px); -} - -.nav-btn { - -fx-background-color: rgba(173, 216, 230, 0.3); - -fx-background-radius: 20px; - -fx-border-radius: 20px; - -fx-border-color: rgba(173, 216, 230, 0.6); - -fx-border-width: 1px; - -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.2), 10, 0, 0, 2); - -fx-padding: 10px 20px; - -fx-font-size: 14px; - -fx-text-fill: #333; - -fx-cursor: hand; - -fx-transition: all 0.4s ease-in-out; - -fx-transform: perspective(1px) translateZ(0); -} - -/* Hover effect */ -.nav-btn:hover { - -fx-background-color: rgba(173, 216, 230, 0.4); - -fx-border-color: rgba(135, 206, 235, 0.6); - -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.3), 12, 0, 0, 3); - -fx-text-fill: #222; -} - -/* Press effect */ -.nav-btn:pressed { - -fx-background-color: rgba(135, 206, 235, 0.5); - -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.15), 8, 0, 0, 1); - -fx-border-color: rgba(100, 149, 237, 0.5); - -fx-transform: scale(0.98); -} - - - - - - -.shadow { - -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.6), 10, 0, 0, 0); -} - -.white-bg { - -fx-background-color: rgba(255, 255, 255, 0.8); - -fx-backdrop-filter: blur(10px); - -fx-background-radius: 4px; - -fx-background-padding: 2px; -} - -.radius { - -fx-background-radius: 8px; -} - -.transparent { - -fx-background-color: transparent; -} - - -.gradiented { - -fx-background-color: linear-gradient(to bottom right, #2a3d6d, #3c6e8f); /* Deep blue gradient */ - -fx-background-radius: 8px; - -fx-border-radius: 8px; - -fx-border-color: rgba(255, 255, 255, 0.2); - -fx-border-width: 1px; - -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.3), 10, 0, 2, 2); - -fx-padding: 10px; - -fx-min-width: 230px; - -fx-min-height: 160px; - -fx-max-width: 230px; - -fx-max-height: 160px; - -fx-transition: all 0.3s ease-in-out; -} - -.gradiented:hover { - -fx-background-color: linear-gradient(to bottom right, #3c6e8f, #2a3d6d); /* Inverted deep blue */ - -fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.4), 12, 0, 3, 3); - -fx-cursor: hand; -} -.import-btn { - -fx-background-color: rgba(173, 216, 230, 0.3); /* Light pastel blue for a calming effect */ - -fx-background-radius: 20px; - -fx-border-radius: 20px; - -fx-border-color: rgba(173, 216, 230, 0.6); - -fx-border-width: 0.7px; - -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.2), 10, 0, 0, 2); - -fx-padding: 10px 20px; - -fx-font-size: 14px; - -fx-text-fill: #333; - -fx-cursor: hand; - -fx-transition: all 0.4s ease-in-out; - -fx-transform: perspective(1px) translateZ(0); -} - -/* Hover effect */ -.import-btn:hover { - -fx-background-color: rgba(173, 216, 230, 0.4); - -fx-border-color: rgba(135, 206, 235, 0.6); - -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.3), 12, 0, 0, 3); - -fx-text-fill: #222; -} - -/* Press effect */ -.import-btn:pressed { - -fx-background-color: rgba(135, 206, 235, 0.5); - -fx-effect: dropshadow(three-pass-box, rgba(0, 0, 0, 0.15), 8, 0, 0, 1); - -fx-border-color: rgba(100, 149, 237, 0.5); - -fx-transform: scale(0.98); -} - -/* Anchor Panel Container */ -.anchor-panel { - position: relative; - display: flex; - align-items: center; - justify-content: center; - width: 200px; - height: 250px; - border-radius: 10px; - background-color: #f9f9f9; - box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); - overflow: hidden; - transition: transform 0.3s, box-shadow 0.3s; -} - -.anchor-panel:hover { - transform: scale(1.05); - box-shadow: 0 8px 12px rgba(0, 0, 0, 0.2); -} - -/* ImageView (Profile Picture) */ -.image-view { - width: 80px; - height: 80px; - border-radius: 50%; - overflow: hidden; - margin-bottom: 10px; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); -} - -.image-view img { - width: 100%; - height: 100%; - object-fit: cover; -} - -/* Profile Info Section */ -.profile-info { - text-align: center; - color: #333; -} - -.profile-info h3 { - font-size: 1.2rem; - margin: 5px 0; - font-weight: 600; -} - -.profile-info p { - font-size: 0.9rem; - color: #666; - margin: 0; -} - diff --git a/src/main/resources/cafe/management/cafe/surfaceLayoutContoller.java b/src/main/resources/cafe/management/cafe/surfaceLayoutContoller.java deleted file mode 100644 index 41238ab..0000000 --- a/src/main/resources/cafe/management/cafe/surfaceLayoutContoller.java +++ /dev/null @@ -1,5 +0,0 @@ -package cafe.management.cafe; - -public class surfaceLayoutContoller { - -} diff --git a/src/main/resources/cafe/management/cafe/test.fxml b/src/main/resources/cafe/management/cafe/test.fxml deleted file mode 100644 index aabe07d..0000000 --- a/src/main/resources/cafe/management/cafe/test.fxml +++ /dev/null @@ -1,296 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -