From 5f42633350ca8891d44cab4f6e9a55ffedfb0a94 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 28 Jan 2026 18:48:36 -0700 Subject: [PATCH 001/127] Added UI --- .gitignore | 39 +++ .mvn/wrapper/maven-wrapper.jar | Bin 0 -> 58727 bytes .mvn/wrapper/maven-wrapper.properties | 2 + mvnw | 316 ++++++++++++++++++ mvnw.cmd | 188 +++++++++++ pom.xml | 77 +++++ src/main/java/module-info.java | 10 + .../org/example/petshopdesktop/Launcher.java | 9 + .../petshopdesktop/PetShopApplication.java | 19 ++ .../controllers/AdoptionController.java | 60 ++++ .../controllers/AppointmentController.java | 63 ++++ .../controllers/InventoryController.java | 54 +++ .../controllers/MainLayoutController.java | 140 ++++++++ .../controllers/PetController.java | 63 ++++ .../controllers/ProductController.java | 60 ++++ .../ProductSupplierController.java | 57 ++++ .../controllers/SaleController.java | 50 +++ .../controllers/ServiceController.java | 57 ++++ .../controllers/SupplierController.java | 57 ++++ .../petshopdesktop/main-layout-view.fxml | 115 +++++++ .../modelviews/adoption-view.fxml | 79 +++++ .../modelviews/appointment-view.fxml | 80 +++++ .../modelviews/inventory-view.fxml | 77 +++++ .../petshopdesktop/modelviews/pet-view.fxml | 80 +++++ .../modelviews/product-supplier-view.fxml | 78 +++++ .../modelviews/product-view.fxml | 79 +++++ .../petshopdesktop/modelviews/sale-view.fxml | 73 ++++ .../modelviews/service-view.fxml | 78 +++++ .../modelviews/supplier-view.fxml | 78 +++++ 29 files changed, 2138 insertions(+) create mode 100644 .gitignore create mode 100644 .mvn/wrapper/maven-wrapper.jar create mode 100644 .mvn/wrapper/maven-wrapper.properties create mode 100644 mvnw create mode 100644 mvnw.cmd create mode 100644 pom.xml create mode 100644 src/main/java/module-info.java create mode 100644 src/main/java/org/example/petshopdesktop/Launcher.java create mode 100644 src/main/java/org/example/petshopdesktop/PetShopApplication.java create mode 100644 src/main/java/org/example/petshopdesktop/controllers/AdoptionController.java create mode 100644 src/main/java/org/example/petshopdesktop/controllers/AppointmentController.java create mode 100644 src/main/java/org/example/petshopdesktop/controllers/InventoryController.java create mode 100644 src/main/java/org/example/petshopdesktop/controllers/MainLayoutController.java create mode 100644 src/main/java/org/example/petshopdesktop/controllers/PetController.java create mode 100644 src/main/java/org/example/petshopdesktop/controllers/ProductController.java create mode 100644 src/main/java/org/example/petshopdesktop/controllers/ProductSupplierController.java create mode 100644 src/main/java/org/example/petshopdesktop/controllers/SaleController.java create mode 100644 src/main/java/org/example/petshopdesktop/controllers/ServiceController.java create mode 100644 src/main/java/org/example/petshopdesktop/controllers/SupplierController.java create mode 100644 src/main/resources/org/example/petshopdesktop/main-layout-view.fxml create mode 100644 src/main/resources/org/example/petshopdesktop/modelviews/adoption-view.fxml create mode 100644 src/main/resources/org/example/petshopdesktop/modelviews/appointment-view.fxml create mode 100644 src/main/resources/org/example/petshopdesktop/modelviews/inventory-view.fxml create mode 100644 src/main/resources/org/example/petshopdesktop/modelviews/pet-view.fxml create mode 100644 src/main/resources/org/example/petshopdesktop/modelviews/product-supplier-view.fxml create mode 100644 src/main/resources/org/example/petshopdesktop/modelviews/product-view.fxml create mode 100644 src/main/resources/org/example/petshopdesktop/modelviews/sale-view.fxml create mode 100644 src/main/resources/org/example/petshopdesktop/modelviews/service-view.fxml create mode 100644 src/main/resources/org/example/petshopdesktop/modelviews/supplier-view.fxml diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..480bdf52 --- /dev/null +++ b/.gitignore @@ -0,0 +1,39 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ +.kotlin + +### 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/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..c1dd12f17644411d6e840bd5a10c6ecda0175f18 GIT binary patch literal 58727 zcmb5W18`>1vNjyPv28mO+cqb*Z6_1kwr$(?#I}=(ZGUs`Jr}3`|DLbDUA3!L?dtC8 zUiH*ktDo+@6r@4HP=SCTA%WmZqm^Ro`Ls)bfPkcdfq?#g1(Fq27W^S8Cq^$TC?_c< zs-#ROD;6C)1wFuk7<3)nGuR^#!H;n&3*IjzXg+s8Z_S!!E0jUq(`}Itt=YdYa5Z_s z&e>2={87knpF*PKNzU;lsbk#P(l^WBvb$yEz)z+nYH43pKodrDkMp@h?;n{;K}hl>Fb^ zqx}C0|D7kg|Cj~3f7hn_zkAE}|6t|cZT|S5Hvb#3nc~C14u5UI{6#F<|FkJ0svs&S zA}S{=DXLT*BM1$`2rK%`D@vEw9l9%*=92X_2g?Fwfi=6Zfpr7+<~sgP#Bav+Df2ts zwtu~70zhqV?mrzM)}r7mMS`Hk_)NrI5K%CTtQtDxqw5iv5F0!ksIon{qqpPVnU?ds zN$|Vm{MHKEReUy>1kVfT-$3))Js0p2W_LFy3cjjZ7za0R zPdBH>y&pb0vr1|ckDpt2p$IQhwnPs5G*^b-y}sg4W!ALn}a`pY0JIa$H0$eV2T8WjWD= zWaENacQhlTyK4O!+aOXBurVR2k$eb8HVTCxy-bcHlZ4Xr!`juLAL#?t6|Ba!g9G4I zSwIt2Lla>C?C4wAZ8cKsZl9-Yd3kqE`%!5HlGdJJaFw0mu#--&**L-i|BcIdc3B$;0FC;FbE-dunVZ; zdIQ=tPKH4iJQQ=$5BeEMLov_Hn>gXib|9nOr}>eZt@B4W^m~>Zp#xhn1dax+?hS!AchWJ4makWZs@dQUeXQ zsI2+425_{X@t2KN zIbqec#)Jg5==VY3^YBeJ2B+%~^Y8|;F!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_(tg^x{$STYM_WKLtrh-_-Hq-M%Ubpt6$mCHY!B{ISD zz}grIo^bNVDw4={SA2*nDNq5`e@ZO5r4TbQpHM)~qfD9!s0h(Jf>vYd;I~j<2fD4)_>ctbwNX6S*8>i^*4 zYKI5<4}d;hM!!N|A$@eg09J|HV;!UUVIau_I~dxZp#?a3u0G)pts6GKdCNk>FKxdh_`Xu!>zO3Kv?u+W6cYJPy!@=PuY868>3|Zg} z$7galV~M`d!q(`I{;CJsq6G9>W0}H6gVY`q7S@9s8ak1r{>}*Q0JyH&f!f8(NZxhC zkn|KS64r^A1fniFel2KkxYByk%erCx9UgFLI)`yuA)X z8SU?6kj!numPNCAj}>1ipax(t{%rxU;6`(Nqt$~Z4~76TQ$9d8l`yJ}rniII%HbH= zlS_7o!qB{55at^>N!Voer%)`KMh9Yd@Z?~nc19*hs)NGN954`O9zA&&vJHbm&|D@E za(&z6A=3NfC;>I)hlI@ulP8E@W-ziGe{iCf_mHvWGldxw8{ng-hI({EtOdALnD9zG ze)fU?I(DNt)Bzdd9Cs^>!|+2!xv1SK=I zJ+y_;=Sq-zqD~GKy@{5(my&aPgFfGY&_mayR_)?dF_^Fwc-n!UAG+fQQGfjWE-1MF YM{}PByk10KD_nuQ4E7Du?}+~TKh4V)`~Uy| literal 0 HcmV?d00001 diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 00000000..e077837e --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +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.3.2/maven-wrapper-3.3.2.jar \ No newline at end of file diff --git a/mvnw b/mvnw new file mode 100644 index 00000000..8a8fb228 --- /dev/null +++ b/mvnw @@ -0,0 +1,316 @@ +#!/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 new file mode 100644 index 00000000..1d8ab018 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,188 @@ +@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 new file mode 100644 index 00000000..f068b382 --- /dev/null +++ b/pom.xml @@ -0,0 +1,77 @@ + + + 4.0.0 + + org.example + PetShopDesktop + 1.0-SNAPSHOT + PetShopDesktop + + + UTF-8 + 5.12.1 + + + + + org.openjfx + javafx-controls + 21.0.6 + + + org.openjfx + javafx-fxml + 21.0.6 + + + + 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 + + 23 + 23 + + + + org.openjfx + javafx-maven-plugin + 0.0.8 + + + + default-cli + + org.example.petshopdesktop/org.example.petshopdesktop.PetShopApplication + + app + app + app + true + true + true + + + + + + + \ No newline at end of file diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 00000000..88acaa41 --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,10 @@ +module org.example.petshopdesktop { + requires javafx.controls; + requires javafx.fxml; + + + opens org.example.petshopdesktop to javafx.fxml; + exports org.example.petshopdesktop; + exports org.example.petshopdesktop.controllers; + opens org.example.petshopdesktop.controllers to javafx.fxml; +} \ No newline at end of file diff --git a/src/main/java/org/example/petshopdesktop/Launcher.java b/src/main/java/org/example/petshopdesktop/Launcher.java new file mode 100644 index 00000000..70456482 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/Launcher.java @@ -0,0 +1,9 @@ +package org.example.petshopdesktop; + +import javafx.application.Application; + +public class Launcher { + public static void main(String[] args) { + Application.launch(PetShopApplication.class, args); + } +} diff --git a/src/main/java/org/example/petshopdesktop/PetShopApplication.java b/src/main/java/org/example/petshopdesktop/PetShopApplication.java new file mode 100644 index 00000000..8a8fcd65 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/PetShopApplication.java @@ -0,0 +1,19 @@ +package org.example.petshopdesktop; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.stage.Stage; + +import java.io.IOException; + +public class PetShopApplication extends Application { + @Override + public void start(Stage stage) throws IOException { + FXMLLoader fxmlLoader = new FXMLLoader(PetShopApplication.class.getResource("main-layout-view.fxml")); + Scene scene = new Scene(fxmlLoader.load()); + stage.setTitle("Pet Shop Manager"); + stage.setScene(scene); + stage.show(); + } +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/AdoptionController.java b/src/main/java/org/example/petshopdesktop/controllers/AdoptionController.java new file mode 100644 index 00000000..f59c8e8d --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/controllers/AdoptionController.java @@ -0,0 +1,60 @@ +package org.example.petshopdesktop.controllers; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; + +public class AdoptionController { + + @FXML + private Button btnAdd; + + @FXML + private Button btnDelete; + + @FXML + private Button btnEdit; + + @FXML + private TableColumn colAdoptionDate; + + @FXML + private TableColumn colAdoptionFee; + + @FXML + private TableColumn colAdoptionId; + + @FXML + private TableColumn colAdoptionStatus; + + @FXML + private TableColumn colCustomerName; + + @FXML + private TableColumn colPetId; + + @FXML + private TableView tvAdoptions; + + @FXML + private TextField txtSearch; + + @FXML + void btnAddClicked(ActionEvent event) { + + } + + @FXML + void btnDeleteClicked(ActionEvent event) { + + } + + @FXML + void btnEditClicked(ActionEvent event) { + + } + +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/AppointmentController.java b/src/main/java/org/example/petshopdesktop/controllers/AppointmentController.java new file mode 100644 index 00000000..9eb6dfce --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/controllers/AppointmentController.java @@ -0,0 +1,63 @@ +package org.example.petshopdesktop.controllers; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; + +public class AppointmentController { + + @FXML + private Button btnAdd; + + @FXML + private Button btnDelete; + + @FXML + private Button btnEdit; + + @FXML + private TableColumn colAppointmentDate; + + @FXML + private TableColumn colAppointmentId; + + @FXML + private TableColumn colAppointmentStatus; + + @FXML + private TableColumn colAppointmentTime; + + @FXML + private TableColumn colCustomerName; + + @FXML + private TableColumn colPetName; + + @FXML + private TableColumn colServiceName; + + @FXML + private TableView tvAppointments; + + @FXML + private TextField txtSearch; + + @FXML + void btnAddClicked(ActionEvent event) { + + } + + @FXML + void btnDeleteClicked(ActionEvent event) { + + } + + @FXML + void btnEditClicked(ActionEvent event) { + + } + +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/InventoryController.java b/src/main/java/org/example/petshopdesktop/controllers/InventoryController.java new file mode 100644 index 00000000..18dbd6a4 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/controllers/InventoryController.java @@ -0,0 +1,54 @@ +package org.example.petshopdesktop.controllers; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; + +public class InventoryController { + + @FXML + private Button btnAdd; + + @FXML + private Button btnDelete; + + @FXML + private Button btnEdit; + + @FXML + private TableColumn colInventoryId; + + @FXML + private TableColumn colProductId; + + @FXML + private TableColumn colProductName; + + @FXML + private TableColumn colQuantity; + + @FXML + private TableView tvInventory; + + @FXML + private TextField txtSearch; + + @FXML + void btnAddClicked(ActionEvent event) { + + } + + @FXML + void btnDeleteClicked(ActionEvent event) { + + } + + @FXML + void btnEditClicked(ActionEvent event) { + + } + +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/MainLayoutController.java b/src/main/java/org/example/petshopdesktop/controllers/MainLayoutController.java new file mode 100644 index 00000000..a5a3060d --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/controllers/MainLayoutController.java @@ -0,0 +1,140 @@ +package org.example.petshopdesktop.controllers; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.control.Button; +import javafx.scene.layout.StackPane; + +public class MainLayoutController { + + @FXML + private Button btnAdoptions; + + @FXML + private Button btnAppointments; + + @FXML + private Button btnInventory; + + @FXML + private Button btnPets; + + @FXML + private Button btnProductSuppliers; + + @FXML + private Button btnProducts; + + @FXML + private Button btnSalesHistory; + + @FXML + private Button btnServices; + + @FXML + private Button btnSuppliers; + + @FXML + private StackPane spContentArea; + + @FXML + void btnAdoptionsClicked(ActionEvent event) { + loadView("adoption-view.fxml"); + updateButtons(btnAdoptions); + } + + @FXML + void btnAppointmentsClicked(ActionEvent event) { + loadView("appointment-view.fxml"); + updateButtons(btnAppointments); + } + + @FXML + void btnInventoryClicked(ActionEvent event) { + loadView("inventory-view.fxml"); + updateButtons(btnInventory); + } + + @FXML + void btnPetsClicked(ActionEvent event) { + loadView("pet-view.fxml"); + updateButtons(btnPets); + } + + @FXML + void btnProductSuppliersClicked(ActionEvent event) { + loadView("product-supplier-view.fxml"); + updateButtons(btnProductSuppliers); + } + + @FXML + void btnProductsClicked(ActionEvent event) { + loadView("product-view.fxml"); + updateButtons(btnProducts); + } + + @FXML + void btnSalesHistoryClicked(ActionEvent event) { + loadView("sale-view.fxml"); + updateButtons(btnSalesHistory); + } + + @FXML + void btnServicesClicked(ActionEvent event) { + loadView("service-view.fxml"); + updateButtons(btnServices); + } + + @FXML + void btnSuppliersClicked(ActionEvent event) { + loadView("supplier-view.fxml"); + updateButtons(btnSuppliers); + } + + @FXML + public void initialize() { + loadView("pet-view.fxml"); + } + + /** + * Load a view when a button is clicked on the navigation + * @param fxmlFile the fxmlFile name to be loaded + */ + private void loadView(String fxmlFile) { + try { + //Get the location of the fxml for view + FXMLLoader loader = new FXMLLoader(getClass().getResource("/org/example/petshopdesktop/modelviews/" + fxmlFile)); + Parent view = loader.load(); + //Clear any content that is in the stack pane and add the new view to display + spContentArea.getChildren().clear(); + spContentArea.getChildren().add(view); + } catch (Exception e) { + System.out.println("Error loading view: " + fxmlFile); + } + } + + /** + * update the button visuals when a button is clicked on the navigation + * @param activeButton the button to be set active + */ + private void updateButtons(Button activeButton) { + //reset all buttons + Button[] BUTTONS = {btnAdoptions, btnPets, btnAppointments, btnInventory, + btnSalesHistory, btnServices, btnSuppliers, btnProductSuppliers, btnProducts}; + for (Button button : BUTTONS) { + //set all buttons to inactive + button.setStyle("-fx-background-color: transparent; " + + "-fx-text-fill: #CCCCCC; " + + "-fx-cursor: hand"); + } + + //set active button + activeButton.setStyle("-fx-background-color: #FF6B6B; " + + "-fx-text-fill: white; " + + "-fx-cursor: hand; " + + "-fx-background-radius: 8"); + } + +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/PetController.java b/src/main/java/org/example/petshopdesktop/controllers/PetController.java new file mode 100644 index 00000000..26834d72 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/controllers/PetController.java @@ -0,0 +1,63 @@ +package org.example.petshopdesktop.controllers; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; + +public class PetController { + + @FXML + private Button btnAdd; + + @FXML + private Button btnDelete; + + @FXML + private Button btnEdit; + + @FXML + private TableColumn colPetAge; + + @FXML + private TableColumn colPetBreed; + + @FXML + private TableColumn colPetId; + + @FXML + private TableColumn colPetName; + + @FXML + private TableColumn colPetPrice; + + @FXML + private TableColumn colPetSpecies; + + @FXML + private TableColumn colPetStatus; + + @FXML + private TableView tvPets; + + @FXML + private TextField txtSearch; + + @FXML + void btnAddClicked(ActionEvent event) { + + } + + @FXML + void btnDeleteClicked(ActionEvent event) { + + } + + @FXML + void btnEditClicked(ActionEvent event) { + + } + +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/ProductController.java b/src/main/java/org/example/petshopdesktop/controllers/ProductController.java new file mode 100644 index 00000000..27d038e0 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/controllers/ProductController.java @@ -0,0 +1,60 @@ +package org.example.petshopdesktop.controllers; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; + +public class ProductController { + + @FXML + private Button btnAdd; + + @FXML + private Button btnDelete; + + @FXML + private Button btnEdit; + + @FXML + private TableColumn colProductCategory; + + @FXML + private TableColumn colProductDesc; + + @FXML + private TableColumn colProductId; + + @FXML + private TableColumn colProductName; + + @FXML + private TableColumn colProductPrice; + + @FXML + private TableColumn colProductSKU; + + @FXML + private TableView tvProducts; + + @FXML + private TextField txtSearch; + + @FXML + void btnAddClicked(ActionEvent event) { + + } + + @FXML + void btnDeleteClicked(ActionEvent event) { + + } + + @FXML + void btnEditClicked(ActionEvent event) { + + } + +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/ProductSupplierController.java b/src/main/java/org/example/petshopdesktop/controllers/ProductSupplierController.java new file mode 100644 index 00000000..d8a6e90a --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/controllers/ProductSupplierController.java @@ -0,0 +1,57 @@ +package org.example.petshopdesktop.controllers; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; + +public class ProductSupplierController { + + @FXML + private Button btnAdd; + + @FXML + private Button btnDelete; + + @FXML + private Button btnEdit; + + @FXML + private TableColumn colCost; + + @FXML + private TableColumn colProductId; + + @FXML + private TableColumn colProductName; + + @FXML + private TableColumn colSupplierId; + + @FXML + private TableColumn colSupplierName; + + @FXML + private TableView tvProductSuppliers; + + @FXML + private TextField txtSearch; + + @FXML + void btnAddClicked(ActionEvent event) { + + } + + @FXML + void btnDeleteClicked(ActionEvent event) { + + } + + @FXML + void btnEditClicked(ActionEvent event) { + + } + +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/SaleController.java b/src/main/java/org/example/petshopdesktop/controllers/SaleController.java new file mode 100644 index 00000000..a54139a2 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/controllers/SaleController.java @@ -0,0 +1,50 @@ +package org.example.petshopdesktop.controllers; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; + +public class SaleController { + + @FXML + private Button btnRefresh; + + @FXML + private TableColumn colCustomerName; + + @FXML + private TableColumn colSaleDate; + + @FXML + private TableColumn colSaleId; + + @FXML + private TableColumn colSalePaymentType; + + @FXML + private TableColumn colSaleQuantity; + + @FXML + private TableColumn colSaleTotal; + + @FXML + private TableColumn colSaleUnitPrice; + + @FXML + private TableColumn colServiceProduct; + + @FXML + private TableView tvSales; + + @FXML + private TextField txtSearch; + + @FXML + void btnRefresh(ActionEvent event) { + + } + +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/ServiceController.java b/src/main/java/org/example/petshopdesktop/controllers/ServiceController.java new file mode 100644 index 00000000..65f73c7d --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/controllers/ServiceController.java @@ -0,0 +1,57 @@ +package org.example.petshopdesktop.controllers; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; + +public class ServiceController { + + @FXML + private Button btnAdd; + + @FXML + private Button btnDelete; + + @FXML + private Button btnEdit; + + @FXML + private TableColumn colServiceDesc; + + @FXML + private TableColumn colServiceDuration; + + @FXML + private TableColumn colServiceId; + + @FXML + private TableColumn colServiceName; + + @FXML + private TableColumn colServicePrice; + + @FXML + private TableView tvServices; + + @FXML + private TextField txtSearch; + + @FXML + void btnAddClicked(ActionEvent event) { + + } + + @FXML + void btnDeleteClicked(ActionEvent event) { + + } + + @FXML + void btnEditClicked(ActionEvent event) { + + } + +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java b/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java new file mode 100644 index 00000000..409cde3b --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java @@ -0,0 +1,57 @@ +package org.example.petshopdesktop.controllers; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; + +public class SupplierController { + + @FXML + private Button btnAdd; + + @FXML + private Button btnDelete; + + @FXML + private Button btnEdit; + + @FXML + private TableColumn colContactPerson; + + @FXML + private TableColumn colSupplierEmail; + + @FXML + private TableColumn colSupplierId; + + @FXML + private TableColumn colSupplierName; + + @FXML + private TableColumn colSupplierPhone; + + @FXML + private TableView tvSuppliers; + + @FXML + private TextField txtSearch; + + @FXML + void btnAddClicked(ActionEvent event) { + + } + + @FXML + void btnDeleteClicked(ActionEvent event) { + + } + + @FXML + void btnEditClicked(ActionEvent event) { + + } + +} diff --git a/src/main/resources/org/example/petshopdesktop/main-layout-view.fxml b/src/main/resources/org/example/petshopdesktop/main-layout-view.fxml new file mode 100644 index 00000000..9579dff6 --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/main-layout-view.fxml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
diff --git a/src/main/resources/org/example/petshopdesktop/modelviews/adoption-view.fxml b/src/main/resources/org/example/petshopdesktop/modelviews/adoption-view.fxml new file mode 100644 index 00000000..c1ec6564 --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/modelviews/adoption-view.fxml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/example/petshopdesktop/modelviews/appointment-view.fxml b/src/main/resources/org/example/petshopdesktop/modelviews/appointment-view.fxml new file mode 100644 index 00000000..ec7e6cce --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/modelviews/appointment-view.fxml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/example/petshopdesktop/modelviews/inventory-view.fxml b/src/main/resources/org/example/petshopdesktop/modelviews/inventory-view.fxml new file mode 100644 index 00000000..dea27d1b --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/modelviews/inventory-view.fxml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/example/petshopdesktop/modelviews/pet-view.fxml b/src/main/resources/org/example/petshopdesktop/modelviews/pet-view.fxml new file mode 100644 index 00000000..a9ab6772 --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/modelviews/pet-view.fxml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/example/petshopdesktop/modelviews/product-supplier-view.fxml b/src/main/resources/org/example/petshopdesktop/modelviews/product-supplier-view.fxml new file mode 100644 index 00000000..6ef50d13 --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/modelviews/product-supplier-view.fxml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/example/petshopdesktop/modelviews/product-view.fxml b/src/main/resources/org/example/petshopdesktop/modelviews/product-view.fxml new file mode 100644 index 00000000..68f15d78 --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/modelviews/product-view.fxml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/example/petshopdesktop/modelviews/sale-view.fxml b/src/main/resources/org/example/petshopdesktop/modelviews/sale-view.fxml new file mode 100644 index 00000000..26b24418 --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/modelviews/sale-view.fxml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/example/petshopdesktop/modelviews/service-view.fxml b/src/main/resources/org/example/petshopdesktop/modelviews/service-view.fxml new file mode 100644 index 00000000..c3398855 --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/modelviews/service-view.fxml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/example/petshopdesktop/modelviews/supplier-view.fxml b/src/main/resources/org/example/petshopdesktop/modelviews/supplier-view.fxml new file mode 100644 index 00000000..423ae2bf --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/modelviews/supplier-view.fxml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From cb6a389a6a14f73ab66aba0905dfab740afcab08 Mon Sep 17 00:00:00 2001 From: augmentedpotato Date: Fri, 30 Jan 2026 18:54:57 -0700 Subject: [PATCH 002/127] initial commit --- src/main/java/org/example/petshopdesktop/Launcher.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/example/petshopdesktop/Launcher.java b/src/main/java/org/example/petshopdesktop/Launcher.java index 70456482..8b91cd9c 100644 --- a/src/main/java/org/example/petshopdesktop/Launcher.java +++ b/src/main/java/org/example/petshopdesktop/Launcher.java @@ -1,3 +1,5 @@ +//Initial commmit + package org.example.petshopdesktop; import javafx.application.Application; From 2f90757229c66c16e5145e17eb452704d75176b7 Mon Sep 17 00:00:00 2001 From: NikithaKommidi89 Date: Fri, 30 Jan 2026 19:02:19 -0700 Subject: [PATCH 003/127] Database --- Petstoredata.sql | 85 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Petstoredata.sql diff --git a/Petstoredata.sql b/Petstoredata.sql new file mode 100644 index 00000000..5eb101be --- /dev/null +++ b/Petstoredata.sql @@ -0,0 +1,85 @@ + +DROP DATABASE IF EXISTS Petstoredb; +CREATE DATABASE Petstoredb; +USE Petstoredb; + +INSERT INTO store_location (store_name, address, phone, email) +VALUES +('Downtown Branch', '123 Main St', '123-456-7890', 'downtown@petshop.com'), +('North Branch', '456 North Ave', '987-654-3210', 'north@petshop.com'); + + + +INSERT INTO employee (first_name, last_name, email, phone, role, is_active) +VALUES +('John', 'Doe', 'john@petshop.com', '111-222-3333', 'Manager', TRUE), +('Sara', 'Smith', 'sara@petshop.com', '444-555-6666', 'Staff', TRUE); + +INSERT INTO employee_store (employee_id, store_id) +VALUES +(1, 1), +(2, 1), +(2, 2); + +INSERT INTO customer (first_name, last_name, email, phone) +VALUES +('Alex', 'Brown', 'alex@gmail.com', '777-888-9999'), +('Emily', 'Clark', 'emily@gmail.com', '666-555-4444'); + +INSERT INTO pet (pet_name, pet_species, pet_breed, pet_age, pet_status, pet_price) +VALUES +('Buddy', 'Dog', 'Labrador', 2, 'Available', 500.00), +('Milo', 'Cat', 'Persian', 1, 'Available', 300.00); + +INSERT INTO adoption (pet_id, customer_id, adoption_date, adoption_status) +VALUES +(1, 1, '2026-01-15', 'Completed'); + +INSERT INTO supplier (sup_company, sup_contact_first_name, sup_contact_last_name, sup_email, sup_phone) +VALUES +('PetFood Inc', 'Robert', 'King', 'contact@petfood.com', '888-111-2222'); + +INSERT INTO category (category_name, category_type) +VALUES +('Dog Food', 'Product'), +('Cat Toys', 'Product'); + +INSERT INTO product (prod_name, prod_sku, prod_price, category_id, prod_desc) +VALUES +('Premium Dog Food', 'DF001', 50.00, 1, 'High quality dog food'), +('Cat Toy Ball', 'CT001', 10.00, 2, 'Colorful toy for cats'); + +INSERT INTO product_supplier (sup_id, prod_id) +VALUES +(1, 1), +(1, 2); + +INSERT INTO inventory (prod_id, quantity) +VALUES +(1, 100), +(2, 200); + +INSERT INTO service (service_name, service_desc, service_duration, service_price) +VALUES +('Pet Grooming', 'Full grooming service', 60, 40.00); + +INSERT INTO appointment (service_id, customer_id, appointment_date, appointment_time, appointment_status) +VALUES +(1, 2, '2026-02-01', '10:30:00', 'Booked'); + +INSERT INTO appointment_pet (appointment_id, pet_id) +VALUES +(1, 2); + +INSERT INTO sale (sale_date, total_amount, payment_method, employee_id, store_id) +VALUES +(NOW(), 60.00, 'Card', 2, 1); + +INSERT INTO sale_item (sale_id, prod_id, quantity, unit_price) +VALUES +(1, 2, 2, 10.00); + +INSERT INTO activity_log (employee_id, activity) +VALUES +(1, 'Created new sale'), +(2, 'Booked appointment'); From 47fe06a5c3d02b0fcd4567f501d5daba9026b56e Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 31 Jan 2026 17:52:30 -0700 Subject: [PATCH 004/127] Added connection to database - displayed products and suppliers to table but still incomplete --- Petstoredata.sql | 191 ++++++++++++++++-- pom.xml | 6 + src/main/java/module-info.java | 3 +- .../controllers/ProductController.java | 63 +++++- .../controllers/SupplierController.java | 47 ++++- .../petshopdesktop/database/ConnectionDB.java | 45 +++++ .../petshopdesktop/database/ProductDB.java | 42 ++++ .../petshopdesktop/database/SupplierDB.java | 38 ++++ .../petshopdesktop/models/Product.java | 97 +++++++++ .../petshopdesktop/models/Supplier.java | 96 +++++++++ 10 files changed, 594 insertions(+), 34 deletions(-) create mode 100644 src/main/java/org/example/petshopdesktop/database/ConnectionDB.java create mode 100644 src/main/java/org/example/petshopdesktop/database/ProductDB.java create mode 100644 src/main/java/org/example/petshopdesktop/database/SupplierDB.java create mode 100644 src/main/java/org/example/petshopdesktop/models/Product.java create mode 100644 src/main/java/org/example/petshopdesktop/models/Supplier.java diff --git a/Petstoredata.sql b/Petstoredata.sql index 5eb101be..763c21cf 100644 --- a/Petstoredata.sql +++ b/Petstoredata.sql @@ -1,85 +1,236 @@ - DROP DATABASE IF EXISTS Petstoredb; CREATE DATABASE Petstoredb; USE Petstoredb; -INSERT INTO store_location (store_name, address, phone, email) +-- Create Tables + +CREATE TABLE storeLocation ( + storeId INT AUTO_INCREMENT PRIMARY KEY, + storeName VARCHAR(100) NOT NULL, + address VARCHAR(255), + phone VARCHAR(20), + email VARCHAR(100) +); + +CREATE TABLE employee ( + employeeId INT AUTO_INCREMENT PRIMARY KEY, + firstName VARCHAR(50) NOT NULL, + lastName VARCHAR(50) NOT NULL, + email VARCHAR(100), + phone VARCHAR(20), + role VARCHAR(50), + isActive BOOLEAN DEFAULT TRUE +); + +CREATE TABLE employeeStore ( + employeeId INT, + storeId INT, + PRIMARY KEY (employeeId, storeId), + FOREIGN KEY (employeeId) REFERENCES employee(employeeId), + FOREIGN KEY (storeId) REFERENCES storeLocation(storeId) +); + +CREATE TABLE customer ( + customerId INT AUTO_INCREMENT PRIMARY KEY, + firstName VARCHAR(50) NOT NULL, + lastName VARCHAR(50) NOT NULL, + email VARCHAR(100), + phone VARCHAR(20) +); + +CREATE TABLE pet ( + petId INT AUTO_INCREMENT PRIMARY KEY, + petName VARCHAR(50), + petSpecies VARCHAR(50), + petBreed VARCHAR(50), + petAge INT, + petStatus VARCHAR(20), + petPrice DECIMAL(10, 2) +); + +CREATE TABLE adoption ( + adoptionId INT AUTO_INCREMENT PRIMARY KEY, + petId INT, + customerId INT, + adoptionDate DATE, + adoptionStatus VARCHAR(20), + FOREIGN KEY (petId) REFERENCES pet(petId), + FOREIGN KEY (customerId) REFERENCES customer(customerId) +); + +CREATE TABLE supplier ( + supId INT AUTO_INCREMENT PRIMARY KEY, + supCompany VARCHAR(100) NOT NULL, + supContactFirstName VARCHAR(50), + supContactLastName VARCHAR(50), + supEmail VARCHAR(100), + supPhone VARCHAR(20) +); + +CREATE TABLE category ( + categoryId INT AUTO_INCREMENT PRIMARY KEY, + categoryName VARCHAR(100) NOT NULL, + categoryType VARCHAR(50) +); + +CREATE TABLE product ( + prodId INT AUTO_INCREMENT PRIMARY KEY, + prodName VARCHAR(100) NOT NULL, + prodSku VARCHAR(50) UNIQUE, + prodPrice DECIMAL(10, 2), + categoryId INT, + prodDesc TEXT, + FOREIGN KEY (categoryId) REFERENCES category(categoryId) +); + +CREATE TABLE productSupplier ( + supId INT, + prodId INT, + PRIMARY KEY (supId, prodId), + FOREIGN KEY (supId) REFERENCES supplier(supId), + FOREIGN KEY (prodId) REFERENCES product(prodId) +); + +CREATE TABLE inventory ( + inventoryId INT AUTO_INCREMENT PRIMARY KEY, + prodId INT, + quantity INT DEFAULT 0, + FOREIGN KEY (prodId) REFERENCES product(prodId) +); + +CREATE TABLE service ( + serviceId INT AUTO_INCREMENT PRIMARY KEY, + serviceName VARCHAR(100) NOT NULL, + serviceDesc TEXT, + serviceDuration INT, + servicePrice DECIMAL(10, 2) +); + +CREATE TABLE appointment ( + appointmentId INT AUTO_INCREMENT PRIMARY KEY, + serviceId INT, + customerId INT, + appointmentDate DATE, + appointmentTime TIME, + appointmentStatus VARCHAR(20), + FOREIGN KEY (serviceId) REFERENCES service(serviceId), + FOREIGN KEY (customerId) REFERENCES customer(customerId) +); + +CREATE TABLE appointmentPet ( + appointmentId INT, + petId INT, + PRIMARY KEY (appointmentId, petId), + FOREIGN KEY (appointmentId) REFERENCES appointment(appointmentId), + FOREIGN KEY (petId) REFERENCES pet(petId) +); + +CREATE TABLE sale ( + saleId INT AUTO_INCREMENT PRIMARY KEY, + saleDate DATETIME, + totalAmount DECIMAL(10, 2), + paymentMethod VARCHAR(50), + employeeId INT, + storeId INT, + FOREIGN KEY (employeeId) REFERENCES employee(employeeId), + FOREIGN KEY (storeId) REFERENCES storeLocation(storeId) +); + +CREATE TABLE saleItem ( + saleItemId INT AUTO_INCREMENT PRIMARY KEY, + saleId INT, + prodId INT, + quantity INT, + unitPrice DECIMAL(10, 2), + FOREIGN KEY (saleId) REFERENCES sale(saleId), + FOREIGN KEY (prodId) REFERENCES product(prodId) +); + +CREATE TABLE activityLog ( + logId INT AUTO_INCREMENT PRIMARY KEY, + employeeId INT, + activity TEXT, + logTimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (employeeId) REFERENCES employee(employeeId) +); + +-- Insert Sample Data + +INSERT INTO storeLocation (storeName, address, phone, email) VALUES ('Downtown Branch', '123 Main St', '123-456-7890', 'downtown@petshop.com'), ('North Branch', '456 North Ave', '987-654-3210', 'north@petshop.com'); - - -INSERT INTO employee (first_name, last_name, email, phone, role, is_active) +INSERT INTO employee (firstName, lastName, email, phone, role, isActive) VALUES ('John', 'Doe', 'john@petshop.com', '111-222-3333', 'Manager', TRUE), ('Sara', 'Smith', 'sara@petshop.com', '444-555-6666', 'Staff', TRUE); -INSERT INTO employee_store (employee_id, store_id) +INSERT INTO employeeStore (employeeId, storeId) VALUES (1, 1), (2, 1), (2, 2); -INSERT INTO customer (first_name, last_name, email, phone) +INSERT INTO customer (firstName, lastName, email, phone) VALUES ('Alex', 'Brown', 'alex@gmail.com', '777-888-9999'), ('Emily', 'Clark', 'emily@gmail.com', '666-555-4444'); -INSERT INTO pet (pet_name, pet_species, pet_breed, pet_age, pet_status, pet_price) +INSERT INTO pet (petName, petSpecies, petBreed, petAge, petStatus, petPrice) VALUES ('Buddy', 'Dog', 'Labrador', 2, 'Available', 500.00), ('Milo', 'Cat', 'Persian', 1, 'Available', 300.00); -INSERT INTO adoption (pet_id, customer_id, adoption_date, adoption_status) +INSERT INTO adoption (petId, customerId, adoptionDate, adoptionStatus) VALUES (1, 1, '2026-01-15', 'Completed'); -INSERT INTO supplier (sup_company, sup_contact_first_name, sup_contact_last_name, sup_email, sup_phone) +INSERT INTO supplier (supCompany, supContactFirstName, supContactLastName, supEmail, supPhone) VALUES ('PetFood Inc', 'Robert', 'King', 'contact@petfood.com', '888-111-2222'); -INSERT INTO category (category_name, category_type) +INSERT INTO category (categoryName, categoryType) VALUES ('Dog Food', 'Product'), ('Cat Toys', 'Product'); -INSERT INTO product (prod_name, prod_sku, prod_price, category_id, prod_desc) +INSERT INTO product (prodName, prodSku, prodPrice, categoryId, prodDesc) VALUES ('Premium Dog Food', 'DF001', 50.00, 1, 'High quality dog food'), ('Cat Toy Ball', 'CT001', 10.00, 2, 'Colorful toy for cats'); -INSERT INTO product_supplier (sup_id, prod_id) +INSERT INTO productSupplier (supId, prodId) VALUES (1, 1), (1, 2); -INSERT INTO inventory (prod_id, quantity) +INSERT INTO inventory (prodId, quantity) VALUES (1, 100), (2, 200); -INSERT INTO service (service_name, service_desc, service_duration, service_price) +INSERT INTO service (serviceName, serviceDesc, serviceDuration, servicePrice) VALUES ('Pet Grooming', 'Full grooming service', 60, 40.00); -INSERT INTO appointment (service_id, customer_id, appointment_date, appointment_time, appointment_status) +INSERT INTO appointment (serviceId, customerId, appointmentDate, appointmentTime, appointmentStatus) VALUES (1, 2, '2026-02-01', '10:30:00', 'Booked'); -INSERT INTO appointment_pet (appointment_id, pet_id) +INSERT INTO appointmentPet (appointmentId, petId) VALUES (1, 2); -INSERT INTO sale (sale_date, total_amount, payment_method, employee_id, store_id) +INSERT INTO sale (saleDate, totalAmount, paymentMethod, employeeId, storeId) VALUES (NOW(), 60.00, 'Card', 2, 1); -INSERT INTO sale_item (sale_id, prod_id, quantity, unit_price) +INSERT INTO saleItem (saleId, prodId, quantity, unitPrice) VALUES (1, 2, 2, 10.00); -INSERT INTO activity_log (employee_id, activity) +INSERT INTO activityLog (employeeId, activity) VALUES (1, 'Created new sale'), (2, 'Booked appointment'); diff --git a/pom.xml b/pom.xml index f068b382..8cb9a1ba 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,12 @@ ${junit.version} test + + + com.mysql + mysql-connector-j + 9.3.0 + diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 88acaa41..4dcea055 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,8 +1,9 @@ module org.example.petshopdesktop { requires javafx.controls; requires javafx.fxml; + requires java.sql; - + opens org.example.petshopdesktop.models to javafx.base; opens org.example.petshopdesktop to javafx.fxml; exports org.example.petshopdesktop; exports org.example.petshopdesktop.controllers; diff --git a/src/main/java/org/example/petshopdesktop/controllers/ProductController.java b/src/main/java/org/example/petshopdesktop/controllers/ProductController.java index 27d038e0..3b71614f 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/ProductController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/ProductController.java @@ -1,11 +1,18 @@ package org.example.petshopdesktop.controllers; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.TextField; +import javafx.scene.control.cell.PropertyValueFactory; +import org.example.petshopdesktop.database.ProductDB; +import org.example.petshopdesktop.models.Product; + +import java.sql.SQLException; public class ProductController { @@ -19,29 +26,71 @@ public class ProductController { private Button btnEdit; @FXML - private TableColumn colProductCategory; + private TableColumn colProductCategory; @FXML - private TableColumn colProductDesc; + private TableColumn colProductDesc; @FXML - private TableColumn colProductId; + private TableColumn colProductId; @FXML - private TableColumn colProductName; + private TableColumn colProductName; @FXML - private TableColumn colProductPrice; + private TableColumn colProductPrice; @FXML - private TableColumn colProductSKU; + private TableColumn colProductSKU; @FXML - private TableView tvProducts; + private TableView tvProducts; @FXML private TextField txtSearch; + //data declaration + private ObservableList data = FXCollections.observableArrayList(); //empty + + /** + * Set up the table view for fees and display it when starting up + */ + @FXML + void initialize() { + //set up table columns + colProductId.setCellValueFactory(new PropertyValueFactory("prodId")); + colProductName.setCellValueFactory(new PropertyValueFactory("prodName")); + colProductSKU.setCellValueFactory(new PropertyValueFactory("prodSku")); + colProductPrice.setCellValueFactory(new PropertyValueFactory("prodPrice")); + colProductCategory.setCellValueFactory(new PropertyValueFactory("categoryId")); + colProductDesc.setCellValueFactory(new PropertyValueFactory("prodDesc")); + + displayProducts(); + + //TODO MUST DISPLAY CATEGORY NAME INSTEAD OF ID + + + } + + /** + * Display the products to table view + */ + private void displayProducts(){ + //Erase old content + data.clear(); + + //get Products from database + try{ + data = ProductDB.getProducts(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + + //put data in the table + tvProducts.setItems(data); + } + + @FXML void btnAddClicked(ActionEvent event) { diff --git a/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java b/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java index 409cde3b..07730787 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java @@ -1,11 +1,18 @@ package org.example.petshopdesktop.controllers; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.TextField; +import javafx.scene.control.cell.PropertyValueFactory; +import org.example.petshopdesktop.database.SupplierDB; +import org.example.petshopdesktop.models.Supplier; + +import java.sql.SQLException; public class SupplierController { @@ -19,26 +26,54 @@ public class SupplierController { private Button btnEdit; @FXML - private TableColumn colContactPerson; + private TableColumn colContactPerson; @FXML - private TableColumn colSupplierEmail; + private TableColumn colSupplierEmail; @FXML - private TableColumn colSupplierId; + private TableColumn colSupplierId; @FXML - private TableColumn colSupplierName; + private TableColumn colSupplierName; @FXML - private TableColumn colSupplierPhone; + private TableColumn colSupplierPhone; @FXML - private TableView tvSuppliers; + private TableView tvSuppliers; @FXML private TextField txtSearch; + private ObservableList data = FXCollections.observableArrayList(); + + @FXML + void initialize(){ + colSupplierId.setCellValueFactory(new PropertyValueFactory("supId")); + colSupplierName.setCellValueFactory(new PropertyValueFactory("supCompany")); + colContactPerson.setCellValueFactory(new PropertyValueFactory("supContactFirstName")); + colSupplierEmail.setCellValueFactory(new PropertyValueFactory("supEmail")); + colSupplierPhone.setCellValueFactory(new PropertyValueFactory("supPhone")); + + displaySupplier(); + + //TODO MUST DISPLAY FULL NAME INSTEAD OF FIRST NAME ALSO ADD COMMENTS LATER + } + + private void displaySupplier(){ + data.clear(); + + try{ + data = SupplierDB.getSuppliers(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + + tvSuppliers.setItems(data); + } + + @FXML void btnAddClicked(ActionEvent event) { diff --git a/src/main/java/org/example/petshopdesktop/database/ConnectionDB.java b/src/main/java/org/example/petshopdesktop/database/ConnectionDB.java new file mode 100644 index 00000000..2b0bad1d --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/database/ConnectionDB.java @@ -0,0 +1,45 @@ +package org.example.petshopdesktop.database; + +import java.io.FileInputStream; +import java.io.IOException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.Properties; + +public class ConnectionDB { + /** + * Method to try and connect to the database sing cnnection.properties located in the + * root of C drive + * @return Connection to the database + */ + public static Connection getConnection(){ + String url = ""; + String user = ""; + String password = ""; + + try{ + //Read connection.properties file + FileInputStream fis = new FileInputStream("c:\\connectionpetstore.properties"); //location of connection can be changed here + Properties prop = new Properties(); + prop.load(fis); + url = prop.getProperty("url"); + user = prop.getProperty("user"); + password = prop.getProperty("password"); + } + catch(IOException e){ + throw new RuntimeException("Problem with reading connection info: "+e.getMessage()); + } + + Connection conn = null; + + try{ + //try to get connection with the data taken from connection.properties + conn = DriverManager.getConnection(url,user,password); + return conn; + } + catch (SQLException e) { + throw new RuntimeException("Problem with database connection: "+e.getMessage()); + } + } +} diff --git a/src/main/java/org/example/petshopdesktop/database/ProductDB.java b/src/main/java/org/example/petshopdesktop/database/ProductDB.java new file mode 100644 index 00000000..d113d679 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/database/ProductDB.java @@ -0,0 +1,42 @@ +package org.example.petshopdesktop.database; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import org.example.petshopdesktop.models.Product; + +import java.io.FileInputStream; +import java.io.IOException; +import java.sql.*; +import java.util.Properties; + +/** + * A class containing all the methods relating to CRUD on Products table + */ +public class ProductDB { + + public static ObservableList getProducts() throws SQLException{ + //Connect to the database + ObservableList products = FXCollections.observableArrayList(); + Connection conn = ConnectionDB.getConnection(); + + //Execute Query + Statement stmt = conn.createStatement(); + ResultSet rs = stmt.executeQuery("SELECT * FROM product"); + + //While there is still data add products to the list + while(rs.next()){ + Product product = new Product( + rs.getInt(1), + rs.getString(2), + rs.getString(3), + rs.getDouble(4), + rs.getInt(5), + rs.getString(6)); + products.add(product); + } + + //close connection and return products + conn.close(); + return products; + } +} diff --git a/src/main/java/org/example/petshopdesktop/database/SupplierDB.java b/src/main/java/org/example/petshopdesktop/database/SupplierDB.java new file mode 100644 index 00000000..55426d3d --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/database/SupplierDB.java @@ -0,0 +1,38 @@ +package org.example.petshopdesktop.database; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import org.example.petshopdesktop.models.Product; +import org.example.petshopdesktop.models.Supplier; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +public class SupplierDB { + public static ObservableList getSuppliers() throws SQLException { + //Connect to the database + ObservableList suppliers = FXCollections.observableArrayList(); + Connection conn = ConnectionDB.getConnection(); + + //Execute Query + Statement stmt = conn.createStatement(); + ResultSet rs = stmt.executeQuery("SELECT * FROM supplier"); + + //While there is still data add products to the list + while(rs.next()){ + Supplier supplier = new Supplier( + rs.getInt(1), + rs.getString(2), + rs.getString(3), + rs.getString(4), + rs.getString(5), + rs.getString(6)); + suppliers.add(supplier); + } + + conn.close(); + return suppliers; + } +} diff --git a/src/main/java/org/example/petshopdesktop/models/Product.java b/src/main/java/org/example/petshopdesktop/models/Product.java new file mode 100644 index 00000000..62217315 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/models/Product.java @@ -0,0 +1,97 @@ +package org.example.petshopdesktop.models; + +import javafx.beans.property.SimpleDoubleProperty; +import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.property.SimpleStringProperty; + +public class Product { + public SimpleIntegerProperty prodId; + public SimpleStringProperty prodName; + public SimpleStringProperty prodSku; + public SimpleDoubleProperty prodPrice; + public SimpleIntegerProperty categoryId; + public SimpleStringProperty prodDesc; + + //constructor + public Product(int prodId, String prodName, String prodSku, double prodPrice, int categoryId, String prodDesc) { + this.prodId = new SimpleIntegerProperty(prodId); + this.prodName = new SimpleStringProperty(prodName); + this.prodSku = new SimpleStringProperty(prodSku); + this.prodPrice = new SimpleDoubleProperty(prodPrice); + this.categoryId = new SimpleIntegerProperty(categoryId); + this.prodDesc = new SimpleStringProperty(prodDesc); + } + + //getter and setters + public int getProdId() { + return prodId.get(); + } + + public SimpleIntegerProperty prodIdProperty() { + return prodId; + } + + public void setProdId(int prodId) { + this.prodId.set(prodId); + } + + public String getProdName() { + return prodName.get(); + } + + public SimpleStringProperty prodNameProperty() { + return prodName; + } + + public void setProdName(String prodName) { + this.prodName.set(prodName); + } + + public String getProdSku() { + return prodSku.get(); + } + + public SimpleStringProperty prodSkuProperty() { + return prodSku; + } + + public void setProdSku(String prodSku) { + this.prodSku.set(prodSku); + } + + public double getProdPrice() { + return prodPrice.get(); + } + + public SimpleDoubleProperty prodPriceProperty() { + return prodPrice; + } + + public void setProdPrice(double prodPrice) { + this.prodPrice.set(prodPrice); + } + + public int getCategoryId() { + return categoryId.get(); + } + + public SimpleIntegerProperty categoryIdProperty() { + return categoryId; + } + + public void setCategoryId(int categoryId) { + this.categoryId.set(categoryId); + } + + public String getProdDesc() { + return prodDesc.get(); + } + + public SimpleStringProperty prodDescProperty() { + return prodDesc; + } + + public void setProdDesc(String prodDesc) { + this.prodDesc.set(prodDesc); + } +} diff --git a/src/main/java/org/example/petshopdesktop/models/Supplier.java b/src/main/java/org/example/petshopdesktop/models/Supplier.java new file mode 100644 index 00000000..5822a977 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/models/Supplier.java @@ -0,0 +1,96 @@ +package org.example.petshopdesktop.models; + +import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.property.SimpleStringProperty; + +public class Supplier { + SimpleIntegerProperty supId; + SimpleStringProperty supCompany; + SimpleStringProperty supContactFirstName; + SimpleStringProperty supContactLastName; + SimpleStringProperty supEmail; + SimpleStringProperty supPhone; + + //constructor + public Supplier(int supId, String supCompany, String supContactFirstName, String supContactLastName, String supEmail, String supPhone) { + this.supId = new SimpleIntegerProperty(supId); + this.supCompany = new SimpleStringProperty(supCompany); + this.supContactFirstName = new SimpleStringProperty(supContactFirstName); + this.supContactLastName = new SimpleStringProperty(supContactLastName); + this.supEmail = new SimpleStringProperty(supEmail); + this.supPhone = new SimpleStringProperty(supPhone); + } + + //getter and setter + public int getSupId() { + return supId.get(); + } + + public SimpleIntegerProperty supIdProperty() { + return supId; + } + + public void setSupId(int supId) { + this.supId.set(supId); + } + + public String getSupCompany() { + return supCompany.get(); + } + + public SimpleStringProperty supCompanyProperty() { + return supCompany; + } + + public void setSupCompany(String supCompany) { + this.supCompany.set(supCompany); + } + + public String getSupContactFirstName() { + return supContactFirstName.get(); + } + + public SimpleStringProperty supContactFirstNameProperty() { + return supContactFirstName; + } + + public void setSupContactFirstName(String supContactFirstName) { + this.supContactFirstName.set(supContactFirstName); + } + + public String getSupContactLastName() { + return supContactLastName.get(); + } + + public SimpleStringProperty supContactLastNameProperty() { + return supContactLastName; + } + + public void setSupContactLastName(String supContactLastName) { + this.supContactLastName.set(supContactLastName); + } + + public String getSupEmail() { + return supEmail.get(); + } + + public SimpleStringProperty supEmailProperty() { + return supEmail; + } + + public void setSupEmail(String supEmail) { + this.supEmail.set(supEmail); + } + + public String getSupPhone() { + return supPhone.get(); + } + + public SimpleStringProperty supPhoneProperty() { + return supPhone; + } + + public void setSupPhone(String supPhone) { + this.supPhone.set(supPhone); + } +} From d11f8070cac02fca3a040289add3bb69bae2791d Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 1 Feb 2026 14:56:00 -0700 Subject: [PATCH 005/127] Fixed Views for Product and Suppliers --- src/main/java/module-info.java | 1 + .../petshopdesktop/DTOs/ProductDTO.java | 131 ++++++++++++++++++ .../controllers/ProductController.java | 44 +++--- .../controllers/SupplierController.java | 12 +- .../SupplierDialogController.java | 5 + .../petshopdesktop/database/ProductDB.java | 41 ++++++ .../petshopdesktop/database/SupplierDB.java | 9 ++ .../petshopdesktop/models/Product.java | 15 +- .../petshopdesktop/models/Supplier.java | 13 ++ 9 files changed, 242 insertions(+), 29 deletions(-) create mode 100644 src/main/java/org/example/petshopdesktop/DTOs/ProductDTO.java create mode 100644 src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/SupplierDialogController.java diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 4dcea055..0c7ee955 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -3,6 +3,7 @@ module org.example.petshopdesktop { requires javafx.fxml; requires java.sql; + opens org.example.petshopdesktop.DTOs to javafx.base; opens org.example.petshopdesktop.models to javafx.base; opens org.example.petshopdesktop to javafx.fxml; exports org.example.petshopdesktop; diff --git a/src/main/java/org/example/petshopdesktop/DTOs/ProductDTO.java b/src/main/java/org/example/petshopdesktop/DTOs/ProductDTO.java new file mode 100644 index 00000000..865af1de --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/DTOs/ProductDTO.java @@ -0,0 +1,131 @@ +package org.example.petshopdesktop.DTOs; + +import javafx.beans.property.SimpleDoubleProperty; +import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.property.SimpleStringProperty; +import org.example.petshopdesktop.models.Product; + +/** + * The class for productDTO, all product data is store here but also gets categoryName + */ +public class ProductDTO { + private SimpleIntegerProperty prodId; + private SimpleStringProperty prodName; + private SimpleStringProperty prodSku; + private SimpleDoubleProperty prodPrice; + private SimpleIntegerProperty categoryId; //used for edit and delete + private SimpleStringProperty categoryName; + private SimpleStringProperty prodDesc; + + //constructor + public ProductDTO(int prodId, String prodName, String prodSku, double prodPrice, int categoryId, String categoryName, String prodDesc) { + this.prodId = new SimpleIntegerProperty(prodId); + this.prodName = new SimpleStringProperty(prodName); + this.prodSku = new SimpleStringProperty(prodSku); + this.prodPrice = new SimpleDoubleProperty(prodPrice); + this.categoryId = new SimpleIntegerProperty(categoryId); + this.categoryName = new SimpleStringProperty(categoryName); + this.prodDesc = new SimpleStringProperty(prodDesc); + } + + //getter and setters + public int getProdId() { + return prodId.get(); + } + + public SimpleIntegerProperty prodIdProperty() { + return prodId; + } + + public void setProdId(int prodId) { + this.prodId.set(prodId); + } + + public String getProdName() { + return prodName.get(); + } + + public SimpleStringProperty prodNameProperty() { + return prodName; + } + + public void setProdName(String prodName) { + this.prodName.set(prodName); + } + + public String getProdSku() { + return prodSku.get(); + } + + public SimpleStringProperty prodSkuProperty() { + return prodSku; + } + + public void setProdSku(String prodSku) { + this.prodSku.set(prodSku); + } + + public double getProdPrice() { + return prodPrice.get(); + } + + public SimpleDoubleProperty prodPriceProperty() { + return prodPrice; + } + + public void setProdPrice(double prodPrice) { + this.prodPrice.set(prodPrice); + } + + public String getCategoryName() { + return categoryName.get(); + } + + public SimpleStringProperty categoryNameProperty() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName.set(categoryName); + } + + public String getProdDesc() { + return prodDesc.get(); + } + + public SimpleStringProperty prodDescProperty() { + return prodDesc; + } + + public void setProdDesc(String prodDesc) { + this.prodDesc.set(prodDesc); + } + + public int getCategoryId() { + return categoryId.get(); + } + + public SimpleIntegerProperty categoryIdProperty() { + return categoryId; + } + + public void setCategoryId(int categoryId) { + this.categoryId.set(categoryId); + } + + /** + * Converts DTO into product for editing and deleting + * @return + */ + public Product toProduct(){ + Product product = new Product( + getProdId(), + getProdName(), + getProdSku(), + getProdPrice(), + getCategoryId(), + getProdDesc() + ); + return product; + } +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/ProductController.java b/src/main/java/org/example/petshopdesktop/controllers/ProductController.java index 3b71614f..c79110fd 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/ProductController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/ProductController.java @@ -9,11 +9,15 @@ import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.TextField; import javafx.scene.control.cell.PropertyValueFactory; +import org.example.petshopdesktop.DTOs.ProductDTO; import org.example.petshopdesktop.database.ProductDB; import org.example.petshopdesktop.models.Product; import java.sql.SQLException; +/** + * The controller for any operations in the products view + */ public class ProductController { @FXML @@ -26,54 +30,52 @@ public class ProductController { private Button btnEdit; @FXML - private TableColumn colProductCategory; + private TableColumn colProductCategory; @FXML - private TableColumn colProductDesc; + private TableColumn colProductDesc; @FXML - private TableColumn colProductId; + private TableColumn colProductId; @FXML - private TableColumn colProductName; + private TableColumn colProductName; @FXML - private TableColumn colProductPrice; + private TableColumn colProductPrice; @FXML - private TableColumn colProductSKU; + private TableColumn colProductSKU; @FXML - private TableView tvProducts; + private TableView tvProducts; @FXML private TextField txtSearch; //data declaration - private ObservableList data = FXCollections.observableArrayList(); //empty + private ObservableList data = FXCollections.observableArrayList(); //empty + private String mode = null; /** - * Set up the table view for fees and display it when starting up + * Set up the table view for products and display it when starting up */ @FXML void initialize() { //set up table columns - colProductId.setCellValueFactory(new PropertyValueFactory("prodId")); - colProductName.setCellValueFactory(new PropertyValueFactory("prodName")); - colProductSKU.setCellValueFactory(new PropertyValueFactory("prodSku")); - colProductPrice.setCellValueFactory(new PropertyValueFactory("prodPrice")); - colProductCategory.setCellValueFactory(new PropertyValueFactory("categoryId")); - colProductDesc.setCellValueFactory(new PropertyValueFactory("prodDesc")); + colProductId.setCellValueFactory(new PropertyValueFactory("prodId")); + colProductName.setCellValueFactory(new PropertyValueFactory("prodName")); + colProductSKU.setCellValueFactory(new PropertyValueFactory("prodSku")); + colProductPrice.setCellValueFactory(new PropertyValueFactory("prodPrice")); + colProductCategory.setCellValueFactory(new PropertyValueFactory("categoryName")); + colProductDesc.setCellValueFactory(new PropertyValueFactory("prodDesc")); displayProducts(); - //TODO MUST DISPLAY CATEGORY NAME INSTEAD OF ID - - } /** - * Display the products to table view + * Display the productDTO to table view */ private void displayProducts(){ //Erase old content @@ -81,9 +83,9 @@ public class ProductController { //get Products from database try{ - data = ProductDB.getProducts(); + data = ProductDB.getProductDTO(); } catch (SQLException e) { - throw new RuntimeException(e); + System.out.println(e.getMessage()); } //put data in the table diff --git a/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java b/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java index 07730787..6ac02698 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java @@ -14,6 +14,9 @@ import org.example.petshopdesktop.models.Supplier; import java.sql.SQLException; +/** + * The controller for any operations in the supplier view + */ public class SupplierController { @FXML @@ -48,19 +51,24 @@ public class SupplierController { private ObservableList data = FXCollections.observableArrayList(); + /** + * Set up the table view for suppliers and display it when starting up + */ @FXML void initialize(){ colSupplierId.setCellValueFactory(new PropertyValueFactory("supId")); colSupplierName.setCellValueFactory(new PropertyValueFactory("supCompany")); - colContactPerson.setCellValueFactory(new PropertyValueFactory("supContactFirstName")); + colContactPerson.setCellValueFactory(new PropertyValueFactory("supFullName")); colSupplierEmail.setCellValueFactory(new PropertyValueFactory("supEmail")); colSupplierPhone.setCellValueFactory(new PropertyValueFactory("supPhone")); displaySupplier(); - //TODO MUST DISPLAY FULL NAME INSTEAD OF FIRST NAME ALSO ADD COMMENTS LATER } + /** + * Display the suppliers to table view + */ private void displaySupplier(){ data.clear(); diff --git a/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/SupplierDialogController.java b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/SupplierDialogController.java new file mode 100644 index 00000000..de8c1f6d --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/SupplierDialogController.java @@ -0,0 +1,5 @@ +package org.example.petshopdesktop.controllers.dialogcontrollers; + +public class SupplierDialogController { + +} diff --git a/src/main/java/org/example/petshopdesktop/database/ProductDB.java b/src/main/java/org/example/petshopdesktop/database/ProductDB.java index d113d679..5eaf1e89 100644 --- a/src/main/java/org/example/petshopdesktop/database/ProductDB.java +++ b/src/main/java/org/example/petshopdesktop/database/ProductDB.java @@ -2,6 +2,7 @@ package org.example.petshopdesktop.database; import javafx.collections.FXCollections; import javafx.collections.ObservableList; +import org.example.petshopdesktop.DTOs.ProductDTO; import org.example.petshopdesktop.models.Product; import java.io.FileInputStream; @@ -14,6 +15,11 @@ import java.util.Properties; */ public class ProductDB { + /** + * gets all the products into an observable list + * @return a list of all the products + * @throws SQLException if failed to find products in the database + */ public static ObservableList getProducts() throws SQLException{ //Connect to the database ObservableList products = FXCollections.observableArrayList(); @@ -39,4 +45,39 @@ public class ProductDB { conn.close(); return products; } + + /** + * gets all the ProductDTOs into an observable list for display (displays categoryName instead of categoryId) + * @return the list of all the ProductDTOs + * @throws SQLException if failed to find products in the database + */ + public static ObservableList getProductDTO() throws SQLException{ + //Connect to the database + ObservableList products = FXCollections.observableArrayList(); + Connection conn = ConnectionDB.getConnection(); + + //Execute Query + Statement stmt = conn.createStatement(); + String sql = "SELECT p.prodId, p.prodName, p.prodSku, p.prodPrice, p.categoryId, c.categoryName, p.prodDesc " + + "FROM product p " + + "LEFT JOIN category c ON p.categoryId = c.categoryId"; + ResultSet rs = stmt.executeQuery(sql); + + //While there is still data add products to the list + while(rs.next()){ + ProductDTO product = new ProductDTO( + rs.getInt(1), + rs.getString(2), + rs.getString(3), + rs.getDouble(4), + rs.getInt(5), + rs.getString(6), + rs.getString(7)); + products.add(product); + } + + //close connection and return products + conn.close(); + return products; + } } diff --git a/src/main/java/org/example/petshopdesktop/database/SupplierDB.java b/src/main/java/org/example/petshopdesktop/database/SupplierDB.java index 55426d3d..ca41bc30 100644 --- a/src/main/java/org/example/petshopdesktop/database/SupplierDB.java +++ b/src/main/java/org/example/petshopdesktop/database/SupplierDB.java @@ -10,7 +10,16 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +/** + * A class containing all the methods relating to CRUD on Suppliers table + */ public class SupplierDB { + + /** + * gets all the suppliers into an observable list + * @return a list of all the suppliers + * @throws SQLException if failed to find suppliers in the database + */ public static ObservableList getSuppliers() throws SQLException { //Connect to the database ObservableList suppliers = FXCollections.observableArrayList(); diff --git a/src/main/java/org/example/petshopdesktop/models/Product.java b/src/main/java/org/example/petshopdesktop/models/Product.java index 62217315..1a7333b3 100644 --- a/src/main/java/org/example/petshopdesktop/models/Product.java +++ b/src/main/java/org/example/petshopdesktop/models/Product.java @@ -4,13 +4,16 @@ import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; +/** + * The class for the entity of products (contains all data relating to products) + */ public class Product { - public SimpleIntegerProperty prodId; - public SimpleStringProperty prodName; - public SimpleStringProperty prodSku; - public SimpleDoubleProperty prodPrice; - public SimpleIntegerProperty categoryId; - public SimpleStringProperty prodDesc; + private SimpleIntegerProperty prodId; + private SimpleStringProperty prodName; + private SimpleStringProperty prodSku; + private SimpleDoubleProperty prodPrice; + private SimpleIntegerProperty categoryId; + private SimpleStringProperty prodDesc; //constructor public Product(int prodId, String prodName, String prodSku, double prodPrice, int categoryId, String prodDesc) { diff --git a/src/main/java/org/example/petshopdesktop/models/Supplier.java b/src/main/java/org/example/petshopdesktop/models/Supplier.java index 5822a977..36f05094 100644 --- a/src/main/java/org/example/petshopdesktop/models/Supplier.java +++ b/src/main/java/org/example/petshopdesktop/models/Supplier.java @@ -3,6 +3,9 @@ package org.example.petshopdesktop.models; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; +/** + * The class for the entity of supplier (contains all data relating to suppliers) + */ public class Supplier { SimpleIntegerProperty supId; SimpleStringProperty supCompany; @@ -93,4 +96,14 @@ public class Supplier { public void setSupPhone(String supPhone) { this.supPhone.set(supPhone); } + + //custom methods + + /** + * Get the full name of supplier contact to display in a single cell + * @return full name of supplier contact + */ + public String getSupFullName() { + return getSupContactFirstName() + " " + getSupContactLastName(); + } } From 310b66329f3184eb66f87056f9ad748736a1b097 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 1 Feb 2026 18:43:35 -0700 Subject: [PATCH 006/127] Added CRUD to Suppliers --- src/main/java/module-info.java | 4 +- .../controllers/ProductController.java | 3 + .../controllers/SupplierController.java | 134 +++++++++++++- .../SupplierDialogController.java | 173 ++++++++++++++++++ .../petshopdesktop/database/SupplierDB.java | 91 ++++++++- .../dialogviews/supplier-dialog-view.fxml | 161 ++++++++++++++++ 6 files changed, 556 insertions(+), 10 deletions(-) create mode 100644 src/main/resources/org/example/petshopdesktop/dialogviews/supplier-dialog-view.fxml diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 0c7ee955..7459e876 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -6,7 +6,9 @@ module org.example.petshopdesktop { opens org.example.petshopdesktop.DTOs to javafx.base; opens org.example.petshopdesktop.models to javafx.base; opens org.example.petshopdesktop to javafx.fxml; + opens org.example.petshopdesktop.controllers.dialogcontrollers to javafx.fxml; + opens org.example.petshopdesktop.controllers to javafx.fxml; + exports org.example.petshopdesktop; exports org.example.petshopdesktop.controllers; - opens org.example.petshopdesktop.controllers to javafx.fxml; } \ No newline at end of file diff --git a/src/main/java/org/example/petshopdesktop/controllers/ProductController.java b/src/main/java/org/example/petshopdesktop/controllers/ProductController.java index c79110fd..d8811cc0 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/ProductController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/ProductController.java @@ -62,6 +62,9 @@ public class ProductController { */ @FXML void initialize() { + //Disable buttons until a row is selected + btnEdit.setDisable(true); + btnDelete.setDisable(true); //set up table columns colProductId.setCellValueFactory(new PropertyValueFactory("prodId")); colProductName.setCellValueFactory(new PropertyValueFactory("prodName")); diff --git a/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java b/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java index 6ac02698..c64eff6c 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java @@ -4,15 +4,20 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; -import javafx.scene.control.Button; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableView; -import javafx.scene.control.TextField; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.control.*; import javafx.scene.control.cell.PropertyValueFactory; +import javafx.stage.Modality; +import javafx.stage.Stage; +import org.example.petshopdesktop.controllers.dialogcontrollers.SupplierDialogController; import org.example.petshopdesktop.database.SupplierDB; import org.example.petshopdesktop.models.Supplier; +import java.io.IOException; import java.sql.SQLException; +import java.sql.SQLIntegrityConstraintViolationException; +import java.util.Optional; /** * The controller for any operations in the supplier view @@ -50,12 +55,17 @@ public class SupplierController { private TextField txtSearch; private ObservableList data = FXCollections.observableArrayList(); + private String mode = null; /** * Set up the table view for suppliers and display it when starting up */ @FXML void initialize(){ + //Disable buttons until a row is selected + btnEdit.setDisable(true); + btnDelete.setDisable(true); + //set columns for table view colSupplierId.setCellValueFactory(new PropertyValueFactory("supId")); colSupplierName.setCellValueFactory(new PropertyValueFactory("supCompany")); colContactPerson.setCellValueFactory(new PropertyValueFactory("supFullName")); @@ -64,6 +74,15 @@ public class SupplierController { displaySupplier(); + // Enable buttons when a row is selected + tvSuppliers.getSelectionModel().selectedItemProperty().addListener( + (observable, oldValue, newValue) -> { + btnEdit.setDisable(false); + btnDelete.setDisable(false); + } + ); + + } /** @@ -82,19 +101,124 @@ public class SupplierController { } + /** + * open a new dialog for adding a supplier + * @param event + */ @FXML void btnAddClicked(ActionEvent event) { - + mode = "Add"; + openDialog(null,mode); } + /** + * + * @param event + */ @FXML void btnDeleteClicked(ActionEvent event) { + int numRows = 0; + //set selected supplier + Supplier selectedSupplier = tvSuppliers.getSelectionModel().getSelectedItem(); + //ask user to confirm + Alert question = new Alert(Alert.AlertType.CONFIRMATION); + question.setHeaderText("Please confirm delete"); + question.setContentText("Are you sure you want to delete this supplier?"); + Optional result = question.showAndWait(); //show alert and wait for response + + //if confirmed, start deletion + if (result.isPresent() && result.get() == ButtonType.OK){ + int supId = selectedSupplier.getSupId(); + + //Try deleting supplier + try{ + numRows = SupplierDB.deleteSupplier(supId); + } + catch (SQLIntegrityConstraintViolationException e){ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Database Operation Error"); + alert.setContentText("Delete failed\n" + + "the selected supplier is being referred in another table"); + alert.showAndWait(); + return; + } + catch (SQLException e) { + throw new RuntimeException(e); + } + + //prompt user of any errors + if (numRows == 0){ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Database Operation Error"); + alert.setContentText("Delete failed"); + alert.showAndWait(); + } + else{ + //prompt user of delete conformation + Alert alert = new Alert(Alert.AlertType.CONFIRMATION); + alert.setHeaderText("Database Operation Confirmed"); + alert.setContentText("Delete successful"); + alert.showAndWait(); + //refresh display + displaySupplier(); + } + } } + /** + * Open a new dialog for editing a supplier + * @param event click event + */ @FXML void btnEditClicked(ActionEvent event) { + //set selected supplier + Supplier selectedSupplier = tvSuppliers.getSelectionModel().getSelectedItem(); + if (selectedSupplier != null) { + mode = "Edit"; + openDialog(selectedSupplier, mode); + } + } + + /** + * Function to open the new Dialog for edit or adding + * depending on the mode given + * @param supplier the supplier entity fo editing, null if adding + * @param mode the mode the dialog should be in + */ + private void openDialog(Supplier supplier, String mode){ + //Get new view + FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/org/example/petshopdesktop/dialogviews/supplier-dialog-view.fxml")); //CHECK + Scene scene = null; + try{ + scene = new Scene(fxmlLoader.load()); + } catch (IOException e) { + throw new RuntimeException(e); + } + SupplierDialogController dialogController = fxmlLoader.getController(); //controller associated with this view + dialogController.setMode(mode); + + //Open the dialog depending on the mode + if(mode.equals("Edit")){ + //Make it display suppliers details in dialog + dialogController.displaySupplierDetails(supplier); + } + Stage dialogStage = new Stage(); + dialogStage.initModality(Modality.APPLICATION_MODAL); //make it modal + if(mode.equals("Add")){ + dialogStage.setTitle("Add Supplier"); + } + else { + dialogStage.setTitle("Edit Supplier"); + } + dialogStage.setScene(scene); + dialogStage.showAndWait(); + + //When dialog closes update table view and disable edit and delete buttons + displaySupplier(); + btnDelete.setDisable(true); + btnEdit.setDisable(true); } } diff --git a/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/SupplierDialogController.java b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/SupplierDialogController.java index de8c1f6d..fe6e06c2 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/SupplierDialogController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/SupplierDialogController.java @@ -1,5 +1,178 @@ package org.example.petshopdesktop.controllers.dialogcontrollers; +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.scene.Node; +import javafx.scene.control.Alert; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.input.MouseEvent; +import javafx.stage.Stage; +import org.example.petshopdesktop.database.SupplierDB; +import org.example.petshopdesktop.models.Supplier; + +import java.sql.SQLException; + public class SupplierDialogController { + @FXML + private Button btnCancel; + + @FXML + private Button btnSave; + + @FXML + private Label lblMode; + + @FXML + private Label lblSupId; + + @FXML + private TextField txtCompanyName; + + @FXML + private TextField txtContactFirstName; + + @FXML + private TextField txtContactLastName; + + @FXML + private TextField txtEmail; + + @FXML + private TextField txtPhone; + + private String mode = null; + + @FXML + void initialize() { + //Set up mouse handlers for buttons + btnSave.setOnMouseClicked(new EventHandler() { + @Override + public void handle(MouseEvent mouseEvent) { + buttonSaveClicked(mouseEvent); + } + }); + + btnCancel.setOnMouseClicked(new EventHandler() { + @Override + public void handle(MouseEvent mouseEvent) { + closeStage(mouseEvent); + } + }); + } + + private void buttonSaveClicked(MouseEvent mouseEvent) { + int numRow = 0; //how many rows affected + String errorMsg = ""; //error message for validation + + //TODO: Import validation class and validate text fields here + + if(errorMsg.isEmpty()){ //no validation errors detected + Supplier supplier = collectSupplier(); //get supplier info + if (mode.equals("Add")) { //add mode + try{ + numRow = SupplierDB.insertSupplier(supplier); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + else{ //edit mode + try{ + numRow = SupplierDB.updateSupplier(supplier.getSupId(),supplier); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + + //if no rows were affected then there was an error (prompt user of error) + if (numRow == 0){ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Database Operation Error"); + alert.setContentText(mode + " failed"); + alert.showAndWait(); + closeStage(mouseEvent); + } + else { + //tell the user operation was successful + Alert alert = new Alert(Alert.AlertType.CONFIRMATION); + alert.setHeaderText("Database Operation Confirmed"); + alert.setContentText(mode + " succeeded"); + alert.showAndWait(); + closeStage(mouseEvent); + } + } + else{ //Display validation errors + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Input Error"); + alert.setContentText(errorMsg); + alert.showAndWait(); + } + } + + /** + * Close the window + * @param mouseEvent mouse event to close + */ + private void closeStage(MouseEvent mouseEvent) { + Node node = (Node) mouseEvent.getSource(); + Stage stage = (Stage) node.getScene().getWindow(); + stage.close(); + } + + /** + * Collect the supplier info + * @return supplier info with the id or the new supplier + */ + private Supplier collectSupplier(){ + int supId = 0; + Supplier supplier = null; + + if(lblSupId.isVisible()){ //Edit mode + //get supplier id from lblId (split the string so we only get the int) + supId = Integer.parseInt(lblSupId.getText().split(": ")[1]); + } + supplier = new Supplier( + supId, + txtCompanyName.getText(), + txtContactFirstName.getText(), + txtContactLastName.getText(), + txtEmail.getText(), + txtPhone.getText() + ); + return supplier; + } + + /** + * Display the supplier data in text fields + * @param supplier the supplier entity containing data to display + */ + public void displaySupplierDetails(Supplier supplier){ + if (supplier!=null){ + lblSupId.setText("ID: " + supplier.getSupId()); + txtCompanyName.setText(supplier.getSupCompany()); + txtContactFirstName.setText(supplier.getSupContactFirstName()); + txtContactLastName.setText(supplier.getSupContactLastName()); + txtEmail.setText(supplier.getSupEmail()); + txtPhone.setText(supplier.getSupPhone()); + } + } + + + /** + * Set the mode of the dialog + * @param mode the mode to for the dialog + */ + public void setMode(String mode) { + this.mode = mode; + lblMode.setText(mode + " Supplier"); + if(mode.equals("Add")) { + lblSupId.setVisible(false); + } + else if(mode.equals("Edit")) { + lblSupId.setVisible(true); + } + } + } diff --git a/src/main/java/org/example/petshopdesktop/database/SupplierDB.java b/src/main/java/org/example/petshopdesktop/database/SupplierDB.java index ca41bc30..cc186081 100644 --- a/src/main/java/org/example/petshopdesktop/database/SupplierDB.java +++ b/src/main/java/org/example/petshopdesktop/database/SupplierDB.java @@ -5,10 +5,7 @@ import javafx.collections.ObservableList; import org.example.petshopdesktop.models.Product; import org.example.petshopdesktop.models.Supplier; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; +import java.sql.*; /** * A class containing all the methods relating to CRUD on Suppliers table @@ -44,4 +41,90 @@ public class SupplierDB { conn.close(); return suppliers; } + + /** + * Inserts a new supplier to the database + * @param supplier supplier entity to be inserted + * @return number of rows affected in the database + * @throws SQLException if insertion failed + */ + public static int insertSupplier(Supplier supplier) throws SQLException { + int numRows = 0; + + Connection conn = ConnectionDB.getConnection(); + String sql = "INSERT INTO supplier (supId, supCompany, supContactFirstName, supContactLastName, supEmail, supPhone)" + + "VALUES (?, ?, ?, ?, ?, ?)"; + + //These are the values from supplier to put into the query above + PreparedStatement stmt = conn.prepareStatement(sql); + stmt.setInt(1, supplier.getSupId()); + stmt.setString(2, supplier.getSupCompany()); + stmt.setString(3, supplier.getSupContactFirstName()); + stmt.setString(4, supplier.getSupContactLastName()); + stmt.setString(5, supplier.getSupEmail()); + stmt.setString(6, supplier.getSupPhone()); + + //update the number of rows affected, return and close connection + numRows = stmt.executeUpdate(); + conn.close(); + + return numRows; + } + + /** + * Update an existing supplier to the database + * @param supId id of supplier + * @param supplier new supplier data + * @return number of rows affected in the database + * @throws SQLException if update failed + */ + public static int updateSupplier(int supId, Supplier supplier) throws SQLException { + int numRows = 0; + + Connection conn = ConnectionDB.getConnection(); + String sql = "UPDATE supplier SET " + + " supCompany = ?, " + + " supContactFirstName = ?, " + + " supContactLastName = ?, " + + " supEmail = ?, " + + " supPhone = ? " + + " WHERE supId = ?"; + + //updated values to update the supplier with the query above + PreparedStatement stmt = conn.prepareStatement(sql); + stmt.setString(1, supplier.getSupCompany()); + stmt.setString(2, supplier.getSupContactFirstName()); + stmt.setString(3, supplier.getSupContactLastName()); + stmt.setString(4, supplier.getSupEmail()); + stmt.setString(5, supplier.getSupPhone()); + stmt.setInt(6, supId); + + //Update the rows and close connection + numRows = stmt.executeUpdate(); + conn.close(); + + return numRows; + } + + /** + * Delete a supplier form the database + * @param supId supplier id to be deleted + * @return number of rows affected in the database + * @throws SQLException if delete failed + */ + public static int deleteSupplier(int supId) throws SQLException { + int numRows = 0; + Connection conn = ConnectionDB.getConnection(); + + String sql = "DELETE FROM supplier WHERE supId = ?"; + PreparedStatement stmt = conn.prepareStatement(sql); + //The supplier id to be deleted for the query above + stmt.setInt(1, supId); + + //close connection and update rows affected + numRows = stmt.executeUpdate(); + conn.close(); + + return numRows; + } } diff --git a/src/main/resources/org/example/petshopdesktop/dialogviews/supplier-dialog-view.fxml b/src/main/resources/org/example/petshopdesktop/dialogviews/supplier-dialog-view.fxml new file mode 100644 index 00000000..e26557c8 --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/dialogviews/supplier-dialog-view.fxml @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 07a6d3bfc6dba02149487fee69a7946ddce29187 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 3 Feb 2026 20:02:46 -0700 Subject: [PATCH 007/127] Added CRUD to Products and added Validation to dialog --- Petstoredata.sql | 215 ++++++++++++------ .../petshopdesktop/DTOs/ProductDTO.java | 17 +- .../org/example/petshopdesktop/Validator.java | 131 +++++++++++ .../controllers/ProductController.java | 169 +++++++++++++- .../controllers/SupplierController.java | 47 +++- .../ProductDialogController.java | 211 +++++++++++++++++ .../SupplierDialogController.java | 21 +- .../petshopdesktop/database/CategoryDB.java | 41 ++++ .../petshopdesktop/database/ProductDB.java | 155 +++++++++++-- .../petshopdesktop/database/SupplierDB.java | 52 ++++- .../petshopdesktop/models/Category.java | 59 +++++ .../petshopdesktop/models/Product.java | 16 +- .../dialogviews/product-dialog-view.fxml | 149 ++++++++++++ .../modelviews/product-view.fxml | 9 +- 14 files changed, 1147 insertions(+), 145 deletions(-) create mode 100644 src/main/java/org/example/petshopdesktop/Validator.java create mode 100644 src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductDialogController.java create mode 100644 src/main/java/org/example/petshopdesktop/database/CategoryDB.java create mode 100644 src/main/java/org/example/petshopdesktop/models/Category.java create mode 100644 src/main/resources/org/example/petshopdesktop/dialogviews/product-dialog-view.fxml diff --git a/Petstoredata.sql b/Petstoredata.sql index 763c21cf..c1d1046b 100644 --- a/Petstoredata.sql +++ b/Petstoredata.sql @@ -7,24 +7,24 @@ USE Petstoredb; CREATE TABLE storeLocation ( storeId INT AUTO_INCREMENT PRIMARY KEY, storeName VARCHAR(100) NOT NULL, - address VARCHAR(255), - phone VARCHAR(20), - email VARCHAR(100) + address VARCHAR(255) NOT NULL, + phone VARCHAR(20) NOT NULL, + email VARCHAR(100) NOT NULL ); CREATE TABLE employee ( employeeId INT AUTO_INCREMENT PRIMARY KEY, firstName VARCHAR(50) NOT NULL, lastName VARCHAR(50) NOT NULL, - email VARCHAR(100), - phone VARCHAR(20), - role VARCHAR(50), - isActive BOOLEAN DEFAULT TRUE + email VARCHAR(100) NOT NULL, + phone VARCHAR(20) NOT NULL, + role VARCHAR(50) NOT NULL, + isActive BOOLEAN DEFAULT TRUE NOT NULL ); CREATE TABLE employeeStore ( - employeeId INT, - storeId INT, + employeeId INT NOT NULL, + storeId INT NOT NULL, PRIMARY KEY (employeeId, storeId), FOREIGN KEY (employeeId) REFERENCES employee(employeeId), FOREIGN KEY (storeId) REFERENCES storeLocation(storeId) @@ -34,26 +34,26 @@ CREATE TABLE customer ( customerId INT AUTO_INCREMENT PRIMARY KEY, firstName VARCHAR(50) NOT NULL, lastName VARCHAR(50) NOT NULL, - email VARCHAR(100), - phone VARCHAR(20) + email VARCHAR(100) NOT NULL, + phone VARCHAR(20) NOT NULL ); CREATE TABLE pet ( petId INT AUTO_INCREMENT PRIMARY KEY, - petName VARCHAR(50), - petSpecies VARCHAR(50), - petBreed VARCHAR(50), - petAge INT, - petStatus VARCHAR(20), - petPrice DECIMAL(10, 2) + petName VARCHAR(50) NOT NULL, + petSpecies VARCHAR(50) NOT NULL, + petBreed VARCHAR(50) NOT NULL, + petAge INT NOT NULL, + petStatus VARCHAR(20) NOT NULL, + petPrice DECIMAL(10, 2) NOT NULL ); CREATE TABLE adoption ( adoptionId INT AUTO_INCREMENT PRIMARY KEY, - petId INT, - customerId INT, - adoptionDate DATE, - adoptionStatus VARCHAR(20), + petId INT NOT NULL, + customerId INT NOT NULL, + adoptionDate DATE NOT NULL, + adoptionStatus VARCHAR(20) NOT NULL, FOREIGN KEY (petId) REFERENCES pet(petId), FOREIGN KEY (customerId) REFERENCES customer(customerId) ); @@ -61,31 +61,30 @@ CREATE TABLE adoption ( CREATE TABLE supplier ( supId INT AUTO_INCREMENT PRIMARY KEY, supCompany VARCHAR(100) NOT NULL, - supContactFirstName VARCHAR(50), - supContactLastName VARCHAR(50), - supEmail VARCHAR(100), - supPhone VARCHAR(20) + supContactFirstName VARCHAR(50) NOT NULL, + supContactLastName VARCHAR(50) NOT NULL, + supEmail VARCHAR(100) NOT NULL, + supPhone VARCHAR(20) NOT NULL ); CREATE TABLE category ( categoryId INT AUTO_INCREMENT PRIMARY KEY, categoryName VARCHAR(100) NOT NULL, - categoryType VARCHAR(50) + categoryType VARCHAR(50) NOT NULL ); CREATE TABLE product ( prodId INT AUTO_INCREMENT PRIMARY KEY, prodName VARCHAR(100) NOT NULL, - prodSku VARCHAR(50) UNIQUE, - prodPrice DECIMAL(10, 2), - categoryId INT, + prodPrice DECIMAL(10, 2) NOT NULL, + categoryId INT NOT NULL, prodDesc TEXT, FOREIGN KEY (categoryId) REFERENCES category(categoryId) ); CREATE TABLE productSupplier ( - supId INT, - prodId INT, + supId INT NOT NULL, + prodId INT NOT NULL, PRIMARY KEY (supId, prodId), FOREIGN KEY (supId) REFERENCES supplier(supId), FOREIGN KEY (prodId) REFERENCES product(prodId) @@ -93,8 +92,8 @@ CREATE TABLE productSupplier ( CREATE TABLE inventory ( inventoryId INT AUTO_INCREMENT PRIMARY KEY, - prodId INT, - quantity INT DEFAULT 0, + prodId INT NOT NULL, + quantity INT DEFAULT 0 NOT NULL, FOREIGN KEY (prodId) REFERENCES product(prodId) ); @@ -102,24 +101,24 @@ CREATE TABLE service ( serviceId INT AUTO_INCREMENT PRIMARY KEY, serviceName VARCHAR(100) NOT NULL, serviceDesc TEXT, - serviceDuration INT, - servicePrice DECIMAL(10, 2) + serviceDuration INT NOT NULL, + servicePrice DECIMAL(10, 2) NOT NULL ); CREATE TABLE appointment ( appointmentId INT AUTO_INCREMENT PRIMARY KEY, - serviceId INT, - customerId INT, - appointmentDate DATE, - appointmentTime TIME, - appointmentStatus VARCHAR(20), + serviceId INT NOT NULL, + customerId INT NOT NULL, + appointmentDate DATE NOT NULL, + appointmentTime TIME NOT NULL, + appointmentStatus VARCHAR(20) NOT NULL, FOREIGN KEY (serviceId) REFERENCES service(serviceId), FOREIGN KEY (customerId) REFERENCES customer(customerId) ); CREATE TABLE appointmentPet ( - appointmentId INT, - petId INT, + appointmentId INT NOT NULL, + petId INT NOT NULL, PRIMARY KEY (appointmentId, petId), FOREIGN KEY (appointmentId) REFERENCES appointment(appointmentId), FOREIGN KEY (petId) REFERENCES pet(petId) @@ -127,30 +126,30 @@ CREATE TABLE appointmentPet ( CREATE TABLE sale ( saleId INT AUTO_INCREMENT PRIMARY KEY, - saleDate DATETIME, - totalAmount DECIMAL(10, 2), - paymentMethod VARCHAR(50), - employeeId INT, - storeId INT, + saleDate DATETIME NOT NULL, + totalAmount DECIMAL(10, 2) NOT NULL, + paymentMethod VARCHAR(50) NOT NULL, + employeeId INT NOT NULL, + storeId INT NOT NULL, FOREIGN KEY (employeeId) REFERENCES employee(employeeId), FOREIGN KEY (storeId) REFERENCES storeLocation(storeId) ); CREATE TABLE saleItem ( saleItemId INT AUTO_INCREMENT PRIMARY KEY, - saleId INT, - prodId INT, - quantity INT, - unitPrice DECIMAL(10, 2), + saleId INT NOT NULL, + prodId INT NOT NULL, + quantity INT NOT NULL, + unitPrice DECIMAL(10, 2) NOT NULL, FOREIGN KEY (saleId) REFERENCES sale(saleId), FOREIGN KEY (prodId) REFERENCES product(prodId) ); CREATE TABLE activityLog ( logId INT AUTO_INCREMENT PRIMARY KEY, - employeeId INT, - activity TEXT, - logTimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + employeeId INT NOT NULL, + activity TEXT NOT NULL, + logTimestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, FOREIGN KEY (employeeId) REFERENCES employee(employeeId) ); @@ -159,78 +158,148 @@ CREATE TABLE activityLog ( INSERT INTO storeLocation (storeName, address, phone, email) VALUES ('Downtown Branch', '123 Main St', '123-456-7890', 'downtown@petshop.com'), -('North Branch', '456 North Ave', '987-654-3210', 'north@petshop.com'); +('North Branch', '456 North Ave', '987-654-3210', 'north@petshop.com'), +('West Side Store', '789 West Blvd', '555-123-4567', 'westside@petshop.com'), +('East End Shop', '321 East Road', '555-987-6543', 'eastend@petshop.com'), +('South Mall Location', '654 South Plaza', '555-246-8135', 'southmall@petshop.com'); INSERT INTO employee (firstName, lastName, email, phone, role, isActive) VALUES ('John', 'Doe', 'john@petshop.com', '111-222-3333', 'Manager', TRUE), -('Sara', 'Smith', 'sara@petshop.com', '444-555-6666', 'Staff', TRUE); +('Sara', 'Smith', 'sara@petshop.com', '444-555-6666', 'Staff', TRUE), +('Michael', 'Johnson', 'michael@petshop.com', '222-333-4444', 'Groomer', TRUE), +('Lisa', 'Williams', 'lisa@petshop.com', '333-444-5555', 'Staff', TRUE), +('David', 'Brown', 'david@petshop.com', '555-666-7777', 'Veterinarian', TRUE), +('Emma', 'Davis', 'emma@petshop.com', '666-777-8888', 'Manager', FALSE); INSERT INTO employeeStore (employeeId, storeId) VALUES (1, 1), (2, 1), -(2, 2); +(2, 2), +(3, 2), +(4, 3), +(5, 1), +(5, 4), +(6, 5); INSERT INTO customer (firstName, lastName, email, phone) VALUES ('Alex', 'Brown', 'alex@gmail.com', '777-888-9999'), -('Emily', 'Clark', 'emily@gmail.com', '666-555-4444'); +('Emily', 'Clark', 'emily@gmail.com', '666-555-4444'), +('James', 'Wilson', 'james@gmail.com', '888-999-0000'), +('Olivia', 'Martinez', 'olivia@gmail.com', '999-000-1111'), +('William', 'Anderson', 'william@gmail.com', '000-111-2222'), +('Sophia', 'Taylor', 'sophia@gmail.com', '111-222-3333'); INSERT INTO pet (petName, petSpecies, petBreed, petAge, petStatus, petPrice) VALUES ('Buddy', 'Dog', 'Labrador', 2, 'Available', 500.00), -('Milo', 'Cat', 'Persian', 1, 'Available', 300.00); +('Milo', 'Cat', 'Persian', 1, 'Available', 300.00), +('Charlie', 'Dog', 'Golden Retriever', 3, 'Available', 550.00), +('Luna', 'Cat', 'Siamese', 2, 'Adopted', 350.00), +('Max', 'Dog', 'Beagle', 1, 'Available', 450.00), +('Bella', 'Cat', 'Maine Coon', 4, 'Available', 400.00); INSERT INTO adoption (petId, customerId, adoptionDate, adoptionStatus) VALUES -(1, 1, '2026-01-15', 'Completed'); +(1, 1, '2026-01-15', 'Completed'), +(4, 3, '2026-01-20', 'Completed'), +(2, 2, '2026-01-25', 'Pending'), +(5, 4, '2026-02-01', 'Completed'), +(6, 5, '2026-02-02', 'Pending'); INSERT INTO supplier (supCompany, supContactFirstName, supContactLastName, supEmail, supPhone) VALUES -('PetFood Inc', 'Robert', 'King', 'contact@petfood.com', '888-111-2222'); +('PetFood Inc', 'Robert', 'King', 'contact@petfood.com', '888-111-2222'), +('Toy World', 'Jennifer', 'Lee', 'sales@toyworld.com', '888-222-3333'), +('Pet Supplies Co', 'Kevin', 'White', 'info@petsupplies.com', '888-333-4444'), +('Animal Care Products', 'Nancy', 'Green', 'orders@animalcare.com', '888-444-5555'), +('Premium Pet Goods', 'Tom', 'Black', 'support@premiumpet.com', '888-555-6666'); INSERT INTO category (categoryName, categoryType) VALUES ('Dog Food', 'Product'), -('Cat Toys', 'Product'); +('Cat Toys', 'Product'), +('Bird Supplies', 'Product'), +('Aquarium', 'Product'), +('Small Animals', 'Product'); -INSERT INTO product (prodName, prodSku, prodPrice, categoryId, prodDesc) +INSERT INTO product (prodName, prodPrice, categoryId, prodDesc) VALUES -('Premium Dog Food', 'DF001', 50.00, 1, 'High quality dog food'), -('Cat Toy Ball', 'CT001', 10.00, 2, 'Colorful toy for cats'); +('Premium Dog Food', 50.00, 1, 'High quality dog food'), +('Cat Toy Ball', 10.00, 2, 'Colorful toy for cats'), +('Bird Cage Large', 120.00, 3, 'Spacious bird cage'), +('Fish Tank 20 Gallon', 80.00, 4, 'Complete aquarium kit'), +('Hamster Wheel', 15.00, 5, 'Exercise wheel for small pets'), +('Organic Dog Treats', 25.00, 1, 'Natural dog treats'); INSERT INTO productSupplier (supId, prodId) VALUES (1, 1), -(1, 2); +(1, 2), +(2, 2), +(3, 3), +(3, 4), +(4, 5), +(5, 6), +(1, 6); INSERT INTO inventory (prodId, quantity) VALUES (1, 100), -(2, 200); +(2, 200), +(3, 50), +(4, 30), +(5, 150), +(6, 75); INSERT INTO service (serviceName, serviceDesc, serviceDuration, servicePrice) VALUES -('Pet Grooming', 'Full grooming service', 60, 40.00); +('Pet Grooming', 'Full grooming service', 60, 40.00), +('Nail Trimming', 'Quick nail trim', 15, 10.00), +('Bath and Brush', 'Bathing and brushing service', 45, 30.00), +('Veterinary Checkup', 'Complete health examination', 30, 75.00), +('Teeth Cleaning', 'Professional dental cleaning', 90, 100.00); INSERT INTO appointment (serviceId, customerId, appointmentDate, appointmentTime, appointmentStatus) VALUES -(1, 2, '2026-02-01', '10:30:00', 'Booked'); +(1, 2, '2026-02-01', '10:30:00', 'Booked'), +(2, 1, '2026-02-03', '14:00:00', 'Booked'), +(3, 3, '2026-02-05', '09:00:00', 'Completed'), +(4, 4, '2026-02-07', '11:30:00', 'Booked'), +(5, 5, '2026-02-10', '15:00:00', 'Cancelled'); INSERT INTO appointmentPet (appointmentId, petId) VALUES -(1, 2); +(1, 2), +(2, 1), +(3, 3), +(4, 5), +(5, 6); INSERT INTO sale (saleDate, totalAmount, paymentMethod, employeeId, storeId) VALUES -(NOW(), 60.00, 'Card', 2, 1); +(NOW(), 60.00, 'Card', 2, 1), +('2026-01-28 10:30:00', 50.00, 'Cash', 1, 1), +('2026-01-29 14:15:00', 120.00, 'Card', 4, 3), +('2026-01-30 16:45:00', 80.00, 'Card', 2, 2), +('2026-02-01 11:20:00', 150.00, 'Cash', 5, 4); INSERT INTO saleItem (saleId, prodId, quantity, unitPrice) VALUES -(1, 2, 2, 10.00); +(1, 2, 2, 10.00), +(2, 1, 1, 50.00), +(3, 3, 1, 120.00), +(4, 4, 1, 80.00), +(5, 6, 6, 25.00), +(2, 2, 3, 10.00); INSERT INTO activityLog (employeeId, activity) VALUES (1, 'Created new sale'), -(2, 'Booked appointment'); +(2, 'Booked appointment'), +(3, 'Completed grooming service'), +(4, 'Processed inventory order'), +(5, 'Conducted health checkup'), +(1, 'Updated customer information'); \ No newline at end of file diff --git a/src/main/java/org/example/petshopdesktop/DTOs/ProductDTO.java b/src/main/java/org/example/petshopdesktop/DTOs/ProductDTO.java index 865af1de..3ea081df 100644 --- a/src/main/java/org/example/petshopdesktop/DTOs/ProductDTO.java +++ b/src/main/java/org/example/petshopdesktop/DTOs/ProductDTO.java @@ -11,17 +11,15 @@ import org.example.petshopdesktop.models.Product; public class ProductDTO { private SimpleIntegerProperty prodId; private SimpleStringProperty prodName; - private SimpleStringProperty prodSku; private SimpleDoubleProperty prodPrice; private SimpleIntegerProperty categoryId; //used for edit and delete private SimpleStringProperty categoryName; private SimpleStringProperty prodDesc; //constructor - public ProductDTO(int prodId, String prodName, String prodSku, double prodPrice, int categoryId, String categoryName, String prodDesc) { + public ProductDTO(int prodId, String prodName, double prodPrice, int categoryId, String categoryName, String prodDesc) { this.prodId = new SimpleIntegerProperty(prodId); this.prodName = new SimpleStringProperty(prodName); - this.prodSku = new SimpleStringProperty(prodSku); this.prodPrice = new SimpleDoubleProperty(prodPrice); this.categoryId = new SimpleIntegerProperty(categoryId); this.categoryName = new SimpleStringProperty(categoryName); @@ -53,18 +51,6 @@ public class ProductDTO { this.prodName.set(prodName); } - public String getProdSku() { - return prodSku.get(); - } - - public SimpleStringProperty prodSkuProperty() { - return prodSku; - } - - public void setProdSku(String prodSku) { - this.prodSku.set(prodSku); - } - public double getProdPrice() { return prodPrice.get(); } @@ -121,7 +107,6 @@ public class ProductDTO { Product product = new Product( getProdId(), getProdName(), - getProdSku(), getProdPrice(), getCategoryId(), getProdDesc() diff --git a/src/main/java/org/example/petshopdesktop/Validator.java b/src/main/java/org/example/petshopdesktop/Validator.java new file mode 100644 index 00000000..29182e20 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/Validator.java @@ -0,0 +1,131 @@ +package org.example.petshopdesktop; + +public class Validator { + + /** + * Checks if string is not empty + * @param value string to check + * @param name name of the input + * @return error msg if string is not empty, otherwise empty + */ + public static String isPresent(String value, String name){ + String msg =""; //OK so far + if(value.isEmpty() || name.isBlank()){ + msg += name + " is required. \n"; + } + return msg; + } + + /** + * Checks if the input is a non-negative double + * @param value input of string + * @param name name of input + * @return error msg if input is not a number or negative, otherwise empty + */ + public static String isNonNegativeDouble(String value, String name){ + String msg =""; //OK so far + double result; + try{ + result = Double.parseDouble(value); + if (result < 0){ + msg += name + " must be greater than or equal 0. \n"; + } + } + catch (NumberFormatException e){ + msg += name + " must be a number.\n"; + } + return msg; + } + + /** + * Checks if the input is a double in 2 different range + * @param value input of string + * @param name name of inpt + * @param minValue min value of range + * @param maxValue max value of range + * @return error msg if input is out of range, otherwise empty + */ + public static String isDoubleInRange(String value, String name, double minValue, double maxValue){ + String msg =""; //OK so far + double result; + try{ + result = Double.parseDouble(value); + if (result < minValue || result > maxValue){ + msg += name + " must be between " + minValue + " and " + maxValue + "\n"; + } + } + catch (NumberFormatException e){ + msg += name + " must be a number.\n"; + } + return msg; + } + + /** + * Checks if the input is a non-negative integer + * @param value input of string + * @param name name of input + * @return error msg if input is not a number or negative, otherwise empty + */ + public static String isNonNegativeInteger(String value, String name){ + String msg =""; //OK so far + int result; + try{ + result = Integer.parseInt(value); + if (result < 0){ + msg += name + " must be greater than or equal 0. \n"; + } + } + catch (NumberFormatException e){ + msg += name + " must be a whole number.\n"; + } + return msg; + } + + /** + * check if the string is a given amount of characters or fewer + * @param value input of string + * @param name name of input + * @return error msg if input is more than given characters length + */ + public static String isLessThanVarChars(String value, String name, int length){ + String msg =""; + if (value.length() > length){ + msg += name + " must be less than " + length + " characters. \n"; + } + return msg; + } + + /** + * Checks if the input is a valid email format + * @param value input of string + * @param name name of input + * @return error msg if input is not a valid email format, otherwise empty + */ + public static String isValidEmail(String value, String name){ + String msg = ""; //OK so far + // Email regex + String regex = "^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$"; + + if (!value.matches(regex)){ + msg += name + " is not in a valid format. \n"; + } + return msg; + } + + /** + * Checks if the input is a valid phone number in format XXX-XXX-XXXX + * @param value input of string + * @param name name of input + * @return error msg if input is not in valid phone format, otherwise empty + */ + public static String isValidPhoneNumber(String value, String name){ + String msg = ""; //OK so far + // Phone regex + String regex = "^\\d{3}-\\d{3}-\\d{4}$"; + + if (!value.matches(regex)){ + msg += name + " must be in format XXX-XXX-XXXX. \n"; + } + return msg; + } +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/ProductController.java b/src/main/java/org/example/petshopdesktop/controllers/ProductController.java index d8811cc0..4dc1587e 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/ProductController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/ProductController.java @@ -4,16 +4,24 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; -import javafx.scene.control.Button; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableView; -import javafx.scene.control.TextField; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.control.*; import javafx.scene.control.cell.PropertyValueFactory; +import javafx.stage.Modality; +import javafx.stage.Stage; import org.example.petshopdesktop.DTOs.ProductDTO; +import org.example.petshopdesktop.controllers.dialogcontrollers.ProductDialogController; +import org.example.petshopdesktop.controllers.dialogcontrollers.SupplierDialogController; import org.example.petshopdesktop.database.ProductDB; +import org.example.petshopdesktop.database.SupplierDB; import org.example.petshopdesktop.models.Product; +import org.example.petshopdesktop.models.Supplier; +import java.io.IOException; import java.sql.SQLException; +import java.sql.SQLIntegrityConstraintViolationException; +import java.util.Optional; /** * The controller for any operations in the products view @@ -44,9 +52,6 @@ public class ProductController { @FXML private TableColumn colProductPrice; - @FXML - private TableColumn colProductSKU; - @FXML private TableView tvProducts; @@ -68,19 +73,31 @@ public class ProductController { //set up table columns colProductId.setCellValueFactory(new PropertyValueFactory("prodId")); colProductName.setCellValueFactory(new PropertyValueFactory("prodName")); - colProductSKU.setCellValueFactory(new PropertyValueFactory("prodSku")); colProductPrice.setCellValueFactory(new PropertyValueFactory("prodPrice")); colProductCategory.setCellValueFactory(new PropertyValueFactory("categoryName")); colProductDesc.setCellValueFactory(new PropertyValueFactory("prodDesc")); - displayProducts(); + displayProduct(); + + //EventListener to Enable buttons when a row is selected + tvProducts.getSelectionModel().selectedItemProperty().addListener( + (observable, oldValue, newValue) -> { + btnEdit.setDisable(false); + btnDelete.setDisable(false); + } + ); + + //EventListener to search when text is changed on searchbar + txtSearch.textProperty().addListener((observable, oldValue, newValue) -> { + displayFilteredProduct(newValue); + }); } /** * Display the productDTO to table view */ - private void displayProducts(){ + private void displayProduct(){ //Erase old content data.clear(); @@ -95,20 +112,148 @@ public class ProductController { tvProducts.setItems(data); } - + /** + * open a new dialog for adding a product + * @param event + */ @FXML void btnAddClicked(ActionEvent event) { - + mode = "Add"; + openDialog(null,mode); } + /** + * Delete a selected product when delete is clicked + * @param event click event for button + */ @FXML void btnDeleteClicked(ActionEvent event) { + int numRows = 0; + //set selected product + ProductDTO selectedProduct = tvProducts.getSelectionModel().getSelectedItem(); + //ask user to confirm + Alert question = new Alert(Alert.AlertType.CONFIRMATION); + question.setHeaderText("Please confirm delete"); + question.setContentText("Are you sure you want to delete this product?"); + Optional result = question.showAndWait(); //show alert and wait for response + + //if confirmed,start deletion + if (result.isPresent() && result.get() == ButtonType.OK) { + int prodId = selectedProduct.getProdId(); + + //try deleting + try{ + numRows = ProductDB.deleteProduct(prodId); + } + catch (SQLIntegrityConstraintViolationException e){ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Database Operation Error"); + alert.setContentText("Delete failed\n" + + "the selected product is being referred in another table"); + alert.showAndWait(); + return; + } + catch (SQLException e) { + throw new RuntimeException(e); + } + + //prompt user of any errors + if (numRows == 0){ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Database Operation Error"); + alert.setContentText("Delete failed"); + alert.showAndWait(); + } + else{ + //prompt user of delete conformation + Alert alert = new Alert(Alert.AlertType.CONFIRMATION); + alert.setHeaderText("Database Operation Confirmed"); + alert.setContentText("Delete successful"); + alert.showAndWait(); + //refresh display and reset inputs + displayProduct(); + btnDelete.setDisable(true); + btnEdit.setDisable(true); + txtSearch.setText(""); + } + } } + /** + * Open a new dialog for editing a product + * @param event click event for button + */ @FXML void btnEditClicked(ActionEvent event) { + //set selected product + ProductDTO selectedProduct = tvProducts.getSelectionModel().getSelectedItem(); + if (selectedProduct != null) { + mode = "Edit"; + openDialog(selectedProduct, mode); + } + } + + /** + * Filter the table given the string from the searchbar + * @param filter word to filter table + */ + private void displayFilteredProduct(String filter){ + data.clear(); + try{ + if (txtSearch.getText() == null || txtSearch.getText().isEmpty()){ + displayProduct(); //If search bar is empty just display everything + } + else{ + //Filter the using the keyword + data = ProductDB.getFilteredProductDTOs(filter); + tvProducts.setItems(data); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + /** + * Function to open the new Dialog for edit or adding + * depending on the mode given + * @param product the product entity for editing, null if adding + * @param mode the mode the dialog should be in + */ + private void openDialog(ProductDTO product, String mode){ + //Get new view + FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/org/example/petshopdesktop/dialogviews/product-dialog-view.fxml")); + Scene scene = null; + try{ + scene = new Scene(fxmlLoader.load()); + } catch (IOException e) { + throw new RuntimeException(e); + } + ProductDialogController dialogController = fxmlLoader.getController(); //controller associated with this view + dialogController.setMode(mode); + + //Open the dialog depending on the mode + if(mode.equals("Edit")){ + //Make it display suppliers details in dialog + dialogController.displayProductDetails(product); + } + Stage dialogStage = new Stage(); + dialogStage.initModality(Modality.APPLICATION_MODAL); //make it modal + if(mode.equals("Add")){ + dialogStage.setTitle("Add Product"); + } + else { + dialogStage.setTitle("Edit Product"); + } + dialogStage.setScene(scene); + dialogStage.showAndWait(); + + //When dialog closes update table view and disable edit and delete buttons, and reset search bar + displayProduct(); + btnDelete.setDisable(true); + btnEdit.setDisable(true); + txtSearch.setText(""); } } diff --git a/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java b/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java index c64eff6c..080cc751 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java @@ -74,7 +74,7 @@ public class SupplierController { displaySupplier(); - // Enable buttons when a row is selected + //EventListener to Enable buttons when a row is selected tvSuppliers.getSelectionModel().selectedItemProperty().addListener( (observable, oldValue, newValue) -> { btnEdit.setDisable(false); @@ -82,6 +82,11 @@ public class SupplierController { } ); + //EventListener to search when text is changed on searchbar + txtSearch.textProperty().addListener((observable, oldValue, newValue) -> { + displayFilteredSupplier(newValue); + }); + } @@ -100,10 +105,30 @@ public class SupplierController { tvSuppliers.setItems(data); } + /** + * Filter the table given the string from the searchbar + * @param filter word to filter table + */ + private void displayFilteredSupplier(String filter){ + data.clear(); + try{ + if (txtSearch.getText() == null || txtSearch.getText().isEmpty()){ + displaySupplier(); //If search bar is empty just display everything + } + else{ + //Filter the using the keyword + data = SupplierDB.getFilteredSuppliers(filter); + tvSuppliers.setItems(data); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + /** * open a new dialog for adding a supplier - * @param event + * @param event click event for button */ @FXML void btnAddClicked(ActionEvent event) { @@ -112,8 +137,8 @@ public class SupplierController { } /** - * - * @param event + * Delete a selected supplier when delete is clicked + * @param event click event for button */ @FXML void btnDeleteClicked(ActionEvent event) { @@ -162,13 +187,16 @@ public class SupplierController { alert.showAndWait(); //refresh display displaySupplier(); + btnDelete.setDisable(true); + btnEdit.setDisable(true); + txtSearch.setText(""); } } } /** * Open a new dialog for editing a supplier - * @param event click event + * @param event click event for button */ @FXML void btnEditClicked(ActionEvent event) { @@ -184,12 +212,12 @@ public class SupplierController { /** * Function to open the new Dialog for edit or adding * depending on the mode given - * @param supplier the supplier entity fo editing, null if adding + * @param supplier the supplier entity for editing, null if adding * @param mode the mode the dialog should be in */ private void openDialog(Supplier supplier, String mode){ //Get new view - FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/org/example/petshopdesktop/dialogviews/supplier-dialog-view.fxml")); //CHECK + FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/org/example/petshopdesktop/dialogviews/supplier-dialog-view.fxml")); Scene scene = null; try{ scene = new Scene(fxmlLoader.load()); @@ -215,10 +243,11 @@ public class SupplierController { dialogStage.setScene(scene); dialogStage.showAndWait(); - //When dialog closes update table view and disable edit and delete buttons + //When dialog closes update table view and disable edit and delete buttons, and reset search bar displaySupplier(); btnDelete.setDisable(true); btnEdit.setDisable(true); + txtSearch.setText(""); } -} +} \ No newline at end of file diff --git a/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductDialogController.java b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductDialogController.java new file mode 100644 index 00000000..5cc58d87 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductDialogController.java @@ -0,0 +1,211 @@ +package org.example.petshopdesktop.controllers.dialogcontrollers; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.scene.Node; +import javafx.scene.control.*; +import javafx.scene.input.MouseEvent; +import javafx.stage.Stage; +import org.example.petshopdesktop.DTOs.ProductDTO; +import org.example.petshopdesktop.Validator; +import org.example.petshopdesktop.database.CategoryDB; +import org.example.petshopdesktop.database.ProductDB; +import org.example.petshopdesktop.models.Category; +import org.example.petshopdesktop.models.Product; +import org.example.petshopdesktop.models.Supplier; + +import java.sql.SQLException; +import java.util.ArrayList; + +public class ProductDialogController { + + @FXML + private Button btnCancel; + + @FXML + private Button btnSave; + + @FXML + private ComboBox cbProdCategory; + + @FXML + private Label lblMode; + + @FXML + private Label lblProdId; + + @FXML + private TextField txtProdDesc; + + @FXML + private TextField txtProdName; + + @FXML + private TextField txtProdPrice; + + private String mode = null; + + /** + * Add event listeners to buttons when dialog loads + */ + @FXML + void initialize() { + //Set up mouse handlers for buttons + btnSave.setOnMouseClicked(new EventHandler() { + @Override + public void handle(MouseEvent mouseEvent) { + buttonSaveClicked(mouseEvent); + } + }); + + btnCancel.setOnMouseClicked(new EventHandler() { + @Override + public void handle(MouseEvent mouseEvent) { + closeStage(mouseEvent); + } + }); + + //Set up combobox for selecting category + try { + //set up combobox + ObservableList categories = FXCollections.observableArrayList(); //empty list + categories = CategoryDB.getCategories(); + cbProdCategory.setItems(categories); + } catch (SQLException e) { + throw new RuntimeException(e); + } + + } + + private void buttonSaveClicked(MouseEvent mouseEvent) { + int numRow = 0; //how many rows affected + String errorMsg = ""; //error message for validation + + //Check Validation (input required) + errorMsg += Validator.isPresent(txtProdName.getText(), "Product Name"); + errorMsg += Validator.isPresent(txtProdPrice.getText(), "Product Price"); + if (cbProdCategory.getSelectionModel().getSelectedItem() == null) { + errorMsg += "Category is required \n"; + } + + //Check validation (length size) + errorMsg += Validator.isLessThanVarChars(txtProdName.getText(), "Product Name", 100); + errorMsg += Validator.isLessThanVarChars(txtProdDesc.getText(), "Description", 100); + errorMsg += Validator.isLessThanVarChars(txtProdPrice.getText(), "Product Price", 12); + + //Check Validation (format) + errorMsg += Validator.isNonNegativeDouble(txtProdPrice.getText(), "Product Price"); + + if (errorMsg.isEmpty()) { //no validation errors detected + Product product = collectProduct(); //get product info + if (mode.equals("Add")){ //add mode + try{ + numRow = ProductDB.insertProduct(product); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + else { //edit + try{ + numRow = ProductDB.updateProduct(product.getProdId(),product); + } catch (SQLException e) { + throw new RuntimeException(e); + } + } + + //if no rows were affected then there was an error (prompt user of error) + if (numRow == 0){ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Database Operation Error"); + alert.setContentText(mode + " failed"); + alert.showAndWait(); + closeStage(mouseEvent); + } + else { + //tell the user operation was successful + Alert alert = new Alert(Alert.AlertType.CONFIRMATION); + alert.setHeaderText("Database Operation Confirmed"); + alert.setContentText(mode + " succeeded"); + alert.showAndWait(); + closeStage(mouseEvent); + } + } + else{ //Display validation errors + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Input Error"); + alert.setContentText(errorMsg); + alert.showAndWait(); + } + } + + /** + * Collect the product info + * @return product info with the id or the new product + */ + private Product collectProduct(){ + int prodId = 0; + Product product = null; + + if(lblProdId.isVisible()){ //Edit mode + //get product id from lblId (split the string so we only get the int) + prodId = Integer.parseInt(lblProdId.getText().split(": ")[1]); + } + product = new Product( + prodId, + txtProdName.getText(), + Double.parseDouble(txtProdPrice.getText()), + cbProdCategory.getSelectionModel().getSelectedItem().getCategoryId(), + txtProdDesc.getText() + ); + return product; + } + + /** + * Display the product data in text fields and combobox + * @param product the supplier entity containing data to display + */ + public void displayProductDetails(ProductDTO product){ + if (product!=null){ + lblProdId.setText("ID: " + product.getProdId()); + txtProdName.setText(product.getProdName()); + txtProdDesc.setText(product.getProdDesc()); + txtProdPrice.setText(product.getProdPrice() + ""); + + //get the right combobox selection + for (Category category : cbProdCategory.getItems()) { + if(category.getCategoryId() == product.getCategoryId()){ + cbProdCategory.setValue(category); + } + } + + } + } + + /** + * Close the window + * @param mouseEvent mouse event to close + */ + private void closeStage(MouseEvent mouseEvent) { + Node node = (Node) mouseEvent.getSource(); + Stage stage = (Stage) node.getScene().getWindow(); + stage.close(); + } + + /** + * Set the mode of the dialog + * @param mode the mode to for the dialog + */ + public void setMode(String mode) { + this.mode = mode; + lblMode.setText(mode + " Product"); + if(mode.equals("Add")) { + lblProdId.setVisible(false); + } + else if(mode.equals("Edit")) { + lblProdId.setVisible(true); + } + } + +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/SupplierDialogController.java b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/SupplierDialogController.java index fe6e06c2..d901d3d5 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/SupplierDialogController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/SupplierDialogController.java @@ -9,6 +9,7 @@ import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.input.MouseEvent; import javafx.stage.Stage; +import org.example.petshopdesktop.Validator; import org.example.petshopdesktop.database.SupplierDB; import org.example.petshopdesktop.models.Supplier; @@ -45,6 +46,9 @@ public class SupplierDialogController { private String mode = null; + /** + * Add event listeners to buttons when dialog loads + */ @FXML void initialize() { //Set up mouse handlers for buttons @@ -67,7 +71,22 @@ public class SupplierDialogController { int numRow = 0; //how many rows affected String errorMsg = ""; //error message for validation - //TODO: Import validation class and validate text fields here + //Check validation (input required) + errorMsg += Validator.isPresent(txtCompanyName.getText(), "Company Name"); + errorMsg += Validator.isPresent(txtContactFirstName.getText(), "Contact First Name"); + errorMsg += Validator.isPresent(txtContactLastName.getText(), "Contact Last Name"); + errorMsg += Validator.isPresent(txtEmail.getText(), "Email Address"); + errorMsg += Validator.isPresent(txtPhone.getText(), "Phone Number"); + + //Check validation (Length size) + errorMsg += Validator.isLessThanVarChars(txtCompanyName.getText(),"Company Name", 100); + errorMsg += Validator.isLessThanVarChars(txtContactFirstName.getText(), "Contact First Name", 50); + errorMsg += Validator.isLessThanVarChars(txtContactLastName.getText(), "Contact Last Name", 50); + errorMsg += Validator.isLessThanVarChars(txtEmail.getText(), "Email Address", 100); + + //Check validation (format) + errorMsg += Validator.isValidEmail(txtEmail.getText(), "Email Address"); + errorMsg += Validator.isValidPhoneNumber(txtPhone.getText(), "Phone Number"); if(errorMsg.isEmpty()){ //no validation errors detected Supplier supplier = collectSupplier(); //get supplier info diff --git a/src/main/java/org/example/petshopdesktop/database/CategoryDB.java b/src/main/java/org/example/petshopdesktop/database/CategoryDB.java new file mode 100644 index 00000000..f9a2a434 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/database/CategoryDB.java @@ -0,0 +1,41 @@ +package org.example.petshopdesktop.database; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import org.example.petshopdesktop.models.Category; +import org.example.petshopdesktop.models.Product; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; + +public class CategoryDB { + /** + * gets all the category into an observable list + * @return a list of all the category + * @throws SQLException if failed to find categories in the database + */ + public static ObservableList getCategories() throws SQLException{ + //Connect to the database + ObservableList categories = FXCollections.observableArrayList(); + Connection conn = ConnectionDB.getConnection(); + + //Execute Query + Statement stmt = conn.createStatement(); + ResultSet rs = stmt.executeQuery("SELECT * FROM category"); + + //While there is still data add categories to the list + while(rs.next()){ + Category category = new Category( + rs.getInt(1), + rs.getString(2), + rs.getString(3)); + categories.add(category); + } + + //close connection and return categories + conn.close(); + return categories; + } +} diff --git a/src/main/java/org/example/petshopdesktop/database/ProductDB.java b/src/main/java/org/example/petshopdesktop/database/ProductDB.java index 5eaf1e89..b5fbeb07 100644 --- a/src/main/java/org/example/petshopdesktop/database/ProductDB.java +++ b/src/main/java/org/example/petshopdesktop/database/ProductDB.java @@ -4,11 +4,9 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; import org.example.petshopdesktop.DTOs.ProductDTO; import org.example.petshopdesktop.models.Product; +import org.example.petshopdesktop.models.Supplier; -import java.io.FileInputStream; -import java.io.IOException; import java.sql.*; -import java.util.Properties; /** * A class containing all the methods relating to CRUD on Products table @@ -34,10 +32,9 @@ public class ProductDB { Product product = new Product( rs.getInt(1), rs.getString(2), - rs.getString(3), - rs.getDouble(4), - rs.getInt(5), - rs.getString(6)); + rs.getDouble(3), + rs.getInt(4), + rs.getString(5)); products.add(product); } @@ -58,7 +55,7 @@ public class ProductDB { //Execute Query Statement stmt = conn.createStatement(); - String sql = "SELECT p.prodId, p.prodName, p.prodSku, p.prodPrice, p.categoryId, c.categoryName, p.prodDesc " + + String sql = "SELECT p.prodId, p.prodName, p.prodPrice, p.categoryId, c.categoryName, p.prodDesc " + "FROM product p " + "LEFT JOIN category c ON p.categoryId = c.categoryId"; ResultSet rs = stmt.executeQuery(sql); @@ -68,11 +65,10 @@ public class ProductDB { ProductDTO product = new ProductDTO( rs.getInt(1), rs.getString(2), - rs.getString(3), - rs.getDouble(4), - rs.getInt(5), - rs.getString(6), - rs.getString(7)); + rs.getDouble(3), + rs.getInt(4), + rs.getString(5), + rs.getString(6)); products.add(product); } @@ -80,4 +76,137 @@ public class ProductDB { conn.close(); return products; } + + /** + * Inserts a new product to the database + * @param product product entity to be inserted + * @return number of rows affected in the database + * @throws SQLException if insertion failed + */ + public static int insertProduct(Product product) throws SQLException { + int numRows = 0; + + Connection conn = ConnectionDB.getConnection(); + String sql = "INSERT INTO product (prodId, prodName, prodPrice, categoryId, prodDesc)" + + "VALUES (?, ?, ?, ?, ?)"; + + //These are the values from product to put into the query above + PreparedStatement stmt = conn.prepareStatement(sql); + stmt.setInt(1, product.getProdId()); + stmt.setString(2, product.getProdName()); + stmt.setDouble(3, product.getProdPrice()); + stmt.setInt(4, product.getCategoryId()); + stmt.setString(5, product.getProdDesc()); + + //update the number of rows affected, return and close connection + numRows = stmt.executeUpdate(); + conn.close(); + + return numRows; + } + + /** + * Update an existing product to the database + * @param prodId id of product + * @param product new product data + * @return number of rows affected in the database + * @throws SQLException if update failed + */ + public static int updateProduct(int prodId, Product product) throws SQLException { + int numRows = 0; + + Connection conn = ConnectionDB.getConnection(); + String sql = "UPDATE product SET " + + " prodName = ?, " + + " prodPrice = ?, " + + " categoryId = ?, " + + " prodDesc = ? " + + " WHERE prodId = ?"; + + //update values to query + PreparedStatement stmt = conn.prepareStatement(sql); + stmt.setString(1, product.getProdName()); + stmt.setDouble(2, product.getProdPrice()); + stmt.setInt(3, product.getCategoryId()); + stmt.setString(4, product.getProdDesc()); + stmt.setInt(5, prodId); + + //Update rows and close connection + numRows = stmt.executeUpdate(); + conn.close(); + + return numRows; + } + + /** + * Delete a product from the database + * @param prodId product id to be deleted + * @return number of rows affected in the database + * @throws SQLException if delete failed + */ + public static int deleteProduct(int prodId) throws SQLException { + int numRows = 0; + Connection conn = ConnectionDB.getConnection(); + + String sql = "DELETE FROM product WHERE prodId = ?"; + PreparedStatement stmt = conn.prepareStatement(sql); + + stmt.setInt(1, prodId); + + //close connection and update rows affected + numRows = stmt.executeUpdate(); + conn.close(); + + return numRows; + } + + /** + * Gets a list of productDTOs that is filtered by a given string + * @param filter the word to filter table + * @return ObservableList of ProductDTOs with the filtered data + * @throws SQLException if getting products failed + */ + public static ObservableList getFilteredProductDTOs(String filter) throws SQLException { + //Connect to the database + ObservableList products = FXCollections.observableArrayList(); + Connection conn = ConnectionDB.getConnection(); + + //Get SQL query for filtered word + String sql = + "SELECT p.prodId, p.prodName, p.prodPrice, p.categoryId, c.categoryName, p.prodDesc" + + " FROM product p" + + " LEFT JOIN category c ON p.categoryId = c.categoryId" + + " WHERE " + + "prodName LIKE ? OR " + + "prodPrice LIKE ? OR " + + "categoryName LIKE ? OR " + + "prodDesc LIKE ?"; + + //add % wildcard so the query can use LIKE to filter data + String filteredString = "%" + filter + "%"; + + PreparedStatement stmt = conn.prepareStatement(sql); + stmt.setString(1, filteredString); + stmt.setString(2, filteredString); + stmt.setString(3, filteredString); + stmt.setString(4, filteredString); + + //execute query + ResultSet rs = stmt.executeQuery(); + + //While there is still data add products to the list + while(rs.next()){ + ProductDTO product = new ProductDTO( + rs.getInt(1), + rs.getString(2), + rs.getDouble(3), + rs.getInt(4), + rs.getString(5), + rs.getString(6)); + products.add(product); + } + + conn.close(); + return products; + } } diff --git a/src/main/java/org/example/petshopdesktop/database/SupplierDB.java b/src/main/java/org/example/petshopdesktop/database/SupplierDB.java index cc186081..325b6dd4 100644 --- a/src/main/java/org/example/petshopdesktop/database/SupplierDB.java +++ b/src/main/java/org/example/petshopdesktop/database/SupplierDB.java @@ -26,7 +26,7 @@ public class SupplierDB { Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM supplier"); - //While there is still data add products to the list + //While there is still data add suppliers to the list while(rs.next()){ Supplier supplier = new Supplier( rs.getInt(1), @@ -127,4 +127,54 @@ public class SupplierDB { return numRows; } + + /** + * Gets a list of Suppliers that is filtered by a given string + * @param filter the word to filter table + * @return ObservableList of suppliers with the filtered data + * @throws SQLException if getting suppliers failed + */ + public static ObservableList getFilteredSuppliers(String filter) throws SQLException { + //Connect to the database + ObservableList suppliers = FXCollections.observableArrayList(); + Connection conn = ConnectionDB.getConnection(); + + //Get SQL query for filtered word + String sql = + "SELECT * FROM supplier" + + " WHERE " + + "supCompany LIKE ? OR " + + "supContactFirstName LIKE ? OR " + + "supContactLastName LIKE ? OR " + + "supEmail LIKE ? OR " + + "supPhone LIKE ?"; + + //add % wildcard so the query can use LIKE to filter data + String filteredString = "%" + filter + "%"; + + PreparedStatement stmt = conn.prepareStatement(sql); + stmt.setString(1, filteredString); + stmt.setString(2, filteredString); + stmt.setString(3, filteredString); + stmt.setString(4, filteredString); + stmt.setString(5, filteredString); + + //execute query + ResultSet rs = stmt.executeQuery(); + + //While there is still data add suppliers to the list + while(rs.next()){ + Supplier supplier = new Supplier( + rs.getInt(1), + rs.getString(2), + rs.getString(3), + rs.getString(4), + rs.getString(5), + rs.getString(6)); + suppliers.add(supplier); + } + + conn.close(); + return suppliers; + } } diff --git a/src/main/java/org/example/petshopdesktop/models/Category.java b/src/main/java/org/example/petshopdesktop/models/Category.java new file mode 100644 index 00000000..1f28182b --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/models/Category.java @@ -0,0 +1,59 @@ +package org.example.petshopdesktop.models; + +import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.property.SimpleStringProperty; + +public class Category { + private SimpleIntegerProperty categoryId; + private SimpleStringProperty categoryName; + private SimpleStringProperty categoryType; + + //Constrctor + public Category(int categoryId, String categoryName, String categoryType) { + this.categoryId = new SimpleIntegerProperty(categoryId); + this.categoryName = new SimpleStringProperty(categoryName); + this.categoryType = new SimpleStringProperty(categoryType); + } + + //getters and setters + public int getCategoryId() { + return categoryId.get(); + } + + public SimpleIntegerProperty categoryIdProperty() { + return categoryId; + } + + public void setCategoryId(int categoryId) { + this.categoryId.set(categoryId); + } + + public String getCategoryName() { + return categoryName.get(); + } + + public SimpleStringProperty categoryNameProperty() { + return categoryName; + } + + public void setCategoryName(String categoryName) { + this.categoryName.set(categoryName); + } + + public String getCategoryType() { + return categoryType.get(); + } + + public SimpleStringProperty categoryTypeProperty() { + return categoryType; + } + + public void setCategoryType(String categoryType) { + this.categoryType.set(categoryType); + } + + @Override + public String toString() { + return getCategoryName(); + } +} diff --git a/src/main/java/org/example/petshopdesktop/models/Product.java b/src/main/java/org/example/petshopdesktop/models/Product.java index 1a7333b3..0738068a 100644 --- a/src/main/java/org/example/petshopdesktop/models/Product.java +++ b/src/main/java/org/example/petshopdesktop/models/Product.java @@ -10,16 +10,14 @@ import javafx.beans.property.SimpleStringProperty; public class Product { private SimpleIntegerProperty prodId; private SimpleStringProperty prodName; - private SimpleStringProperty prodSku; private SimpleDoubleProperty prodPrice; private SimpleIntegerProperty categoryId; private SimpleStringProperty prodDesc; //constructor - public Product(int prodId, String prodName, String prodSku, double prodPrice, int categoryId, String prodDesc) { + public Product(int prodId, String prodName, double prodPrice, int categoryId, String prodDesc) { this.prodId = new SimpleIntegerProperty(prodId); this.prodName = new SimpleStringProperty(prodName); - this.prodSku = new SimpleStringProperty(prodSku); this.prodPrice = new SimpleDoubleProperty(prodPrice); this.categoryId = new SimpleIntegerProperty(categoryId); this.prodDesc = new SimpleStringProperty(prodDesc); @@ -50,18 +48,6 @@ public class Product { this.prodName.set(prodName); } - public String getProdSku() { - return prodSku.get(); - } - - public SimpleStringProperty prodSkuProperty() { - return prodSku; - } - - public void setProdSku(String prodSku) { - this.prodSku.set(prodSku); - } - public double getProdPrice() { return prodPrice.get(); } diff --git a/src/main/resources/org/example/petshopdesktop/dialogviews/product-dialog-view.fxml b/src/main/resources/org/example/petshopdesktop/dialogviews/product-dialog-view.fxml new file mode 100644 index 00000000..2972f5ed --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/dialogviews/product-dialog-view.fxml @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/example/petshopdesktop/modelviews/product-view.fxml b/src/main/resources/org/example/petshopdesktop/modelviews/product-view.fxml index 68f15d78..2473d057 100644 --- a/src/main/resources/org/example/petshopdesktop/modelviews/product-view.fxml +++ b/src/main/resources/org/example/petshopdesktop/modelviews/product-view.fxml @@ -68,11 +68,10 @@ - - - - - + + + + From b53dcf10a7c5a306610b810fafbe211f206cfa25 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 4 Feb 2026 19:05:41 -0700 Subject: [PATCH 008/127] Added CRUD to productSuppliers -add CRUD to productSupplier and changed sqlDatabase so cost is in productSuppliers table --- Petstoredata.sql | 19 +- .../DTOs/ProductSupplierDTO.java | 83 ++++++ .../controllers/ProductController.java | 6 +- .../ProductSupplierController.java | 221 +++++++++++++++- .../controllers/SupplierController.java | 4 +- .../ProductDialogController.java | 9 +- .../ProductSupplierDialogController.java | 245 ++++++++++++++++++ .../SupplierDialogController.java | 5 + .../database/ProductSupplierDB.java | 197 ++++++++++++++ .../petshopdesktop/models/Product.java | 5 + .../models/ProductSupplier.java | 54 ++++ .../petshopdesktop/models/Supplier.java | 5 + .../product-supplier-dialog-view.fxml | 136 ++++++++++ 13 files changed, 962 insertions(+), 27 deletions(-) create mode 100644 src/main/java/org/example/petshopdesktop/DTOs/ProductSupplierDTO.java create mode 100644 src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductSupplierDialogController.java create mode 100644 src/main/java/org/example/petshopdesktop/database/ProductSupplierDB.java create mode 100644 src/main/java/org/example/petshopdesktop/models/ProductSupplier.java create mode 100644 src/main/resources/org/example/petshopdesktop/dialogviews/product-supplier-dialog-view.fxml diff --git a/Petstoredata.sql b/Petstoredata.sql index c1d1046b..1b968e23 100644 --- a/Petstoredata.sql +++ b/Petstoredata.sql @@ -85,6 +85,7 @@ CREATE TABLE product ( CREATE TABLE productSupplier ( supId INT NOT NULL, prodId INT NOT NULL, + cost DECIMAL(10, 2) NOT NULL, PRIMARY KEY (supId, prodId), FOREIGN KEY (supId) REFERENCES supplier(supId), FOREIGN KEY (prodId) REFERENCES product(prodId) @@ -234,16 +235,16 @@ VALUES ('Hamster Wheel', 15.00, 5, 'Exercise wheel for small pets'), ('Organic Dog Treats', 25.00, 1, 'Natural dog treats'); -INSERT INTO productSupplier (supId, prodId) +INSERT INTO productSupplier (supId, prodId, cost) VALUES -(1, 1), -(1, 2), -(2, 2), -(3, 3), -(3, 4), -(4, 5), -(5, 6), -(1, 6); +(1, 1, 35.00), +(1, 2, 6.50), +(2, 2, 7.00), +(3, 3, 90.00), +(3, 4, 60.00), +(4, 5, 10.00), +(5, 6, 18.00), +(1, 6, 17.50); INSERT INTO inventory (prodId, quantity) VALUES diff --git a/src/main/java/org/example/petshopdesktop/DTOs/ProductSupplierDTO.java b/src/main/java/org/example/petshopdesktop/DTOs/ProductSupplierDTO.java new file mode 100644 index 00000000..8fb481b0 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/DTOs/ProductSupplierDTO.java @@ -0,0 +1,83 @@ +package org.example.petshopdesktop.DTOs; + +import javafx.beans.property.SimpleDoubleProperty; +import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.property.SimpleStringProperty; + +public class ProductSupplierDTO { + private SimpleIntegerProperty supId; + private SimpleIntegerProperty prodId; + private SimpleStringProperty supCompany; + private SimpleStringProperty prodName; + private SimpleDoubleProperty cost; + + //constructor + public ProductSupplierDTO(int supId, int prodId, String supCompany, String prodName, double cost) { + this.supId = new SimpleIntegerProperty(supId); + this.prodId = new SimpleIntegerProperty(prodId); + this.supCompany = new SimpleStringProperty(supCompany); + this.prodName = new SimpleStringProperty(prodName); + this.cost = new SimpleDoubleProperty(cost); + } + + //getter and setters + public int getSupId() { + return supId.get(); + } + + public SimpleIntegerProperty supIdProperty() { + return supId; + } + + public void setSupId(int supId) { + this.supId.set(supId); + } + + public int getProdId() { + return prodId.get(); + } + + public SimpleIntegerProperty prodIdProperty() { + return prodId; + } + + public void setProdId(int prodId) { + this.prodId.set(prodId); + } + + public String getSupCompany() { + return supCompany.get(); + } + + public SimpleStringProperty supCompanyProperty() { + return supCompany; + } + + public void setSupCompany(String supCompany) { + this.supCompany.set(supCompany); + } + + public String getProdName() { + return prodName.get(); + } + + public SimpleStringProperty prodNameProperty() { + return prodName; + } + + public void setProdName(String prodName) { + this.prodName.set(prodName); + } + + public double getCost() { + return cost.get(); + } + + public SimpleDoubleProperty costProperty() { + return cost; + } + + public void setCost(double cost) { + this.cost.set(cost); + } +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/ProductController.java b/src/main/java/org/example/petshopdesktop/controllers/ProductController.java index 4dc1587e..8c0021fb 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/ProductController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/ProductController.java @@ -105,7 +105,7 @@ public class ProductController { try{ data = ProductDB.getProductDTO(); } catch (SQLException e) { - System.out.println(e.getMessage()); + System.out.println("Error while fetching table data: " + e.getMessage()); } //put data in the table @@ -114,7 +114,7 @@ public class ProductController { /** * open a new dialog for adding a product - * @param event + * @param event click event for button */ @FXML void btnAddClicked(ActionEvent event) { @@ -211,7 +211,7 @@ public class ProductController { tvProducts.setItems(data); } } catch (Exception e) { - throw new RuntimeException(e); + System.out.println("Error while fetching table data: " + e.getMessage()); } } diff --git a/src/main/java/org/example/petshopdesktop/controllers/ProductSupplierController.java b/src/main/java/org/example/petshopdesktop/controllers/ProductSupplierController.java index d8a6e90a..56080c6e 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/ProductSupplierController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/ProductSupplierController.java @@ -1,11 +1,27 @@ package org.example.petshopdesktop.controllers; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; -import javafx.scene.control.Button; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableView; -import javafx.scene.control.TextField; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.control.*; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.stage.Modality; +import javafx.stage.Stage; +import org.example.petshopdesktop.DTOs.ProductDTO; +import org.example.petshopdesktop.DTOs.ProductSupplierDTO; +import org.example.petshopdesktop.controllers.dialogcontrollers.ProductDialogController; +import org.example.petshopdesktop.controllers.dialogcontrollers.ProductSupplierDialogController; +import org.example.petshopdesktop.database.ProductDB; +import org.example.petshopdesktop.database.ProductSupplierDB; +import org.example.petshopdesktop.models.ProductSupplier; + +import java.io.IOException; +import java.sql.SQLException; +import java.sql.SQLIntegrityConstraintViolationException; +import java.util.Optional; public class ProductSupplierController { @@ -19,39 +35,222 @@ public class ProductSupplierController { private Button btnEdit; @FXML - private TableColumn colCost; + private TableColumn colCost; @FXML - private TableColumn colProductId; + private TableColumn colProductId; @FXML - private TableColumn colProductName; + private TableColumn colProductName; @FXML - private TableColumn colSupplierId; + private TableColumn colSupplierId; @FXML - private TableColumn colSupplierName; + private TableColumn colSupplierName; @FXML - private TableView tvProductSuppliers; + private TableView tvProductSuppliers; @FXML private TextField txtSearch; + //data declaration + private ObservableList data = FXCollections.observableArrayList(); + private String mode = null; + + /** + * Set up the table view for table and display it when starting up + */ @FXML - void btnAddClicked(ActionEvent event) { + public void initialize() { + //Disable buttons until a row is selected + btnEdit.setDisable(true); + btnDelete.setDisable(true); + //set up table columns + colProductId.setCellValueFactory(new PropertyValueFactory("prodId")); + colProductName.setCellValueFactory(new PropertyValueFactory("prodName")); + colSupplierId.setCellValueFactory(new PropertyValueFactory("supId")); + colSupplierName.setCellValueFactory(new PropertyValueFactory("supCompany")); + colCost.setCellValueFactory(new PropertyValueFactory("cost")); + + displayProductSupplier(); + + //EventListener to Enable buttons when a row is selected + tvProductSuppliers.getSelectionModel().selectedItemProperty().addListener( + (observable, oldValue, newValue) -> { + btnEdit.setDisable(false); + btnDelete.setDisable(false); + } + ); + + //EventListener to search when text is changed on searchbar + txtSearch.textProperty().addListener((observable, oldValue, newValue) -> { + displayFilteredProductSupplier(newValue); + }); } + /** + * Display the ProductSupplierDTO to table view + */ + private void displayProductSupplier() { + //Erase old content + data.clear(); + + //get ProductSupplier from database + try{ + data = ProductSupplierDB.getProductSupplierDTO(); + } catch (SQLException e) { + System.out.println("Error while fetching table data: " + e.getMessage()); + } + + //put data in the table + tvProductSuppliers.setItems(data); + } + + /** + * Filter the table given the string from the searchbar + * @param filter word to filter table + */ + private void displayFilteredProductSupplier(String filter){ + data.clear(); + try{ + if (txtSearch.getText() == null || txtSearch.getText().isEmpty()){ + displayProductSupplier(); //If search bar is empty just display everything + } + else{ + //Filter the using the keyword + data = ProductSupplierDB.getFilteredProductSupplierDTO(filter); + tvProductSuppliers.setItems(data); + } + } catch (Exception e) { + System.out.println("Error while fetching table data: " + e.getMessage()); + } + } + + /** + * open a new dialog for adding a productSupplier + * @param event click event for button + */ + @FXML + void btnAddClicked(ActionEvent event) { + mode = "Add"; + openDialog(null,mode); + } + + /** + * Delete a selected productSupplier when delete is clicked + * @param event click event for button + */ @FXML void btnDeleteClicked(ActionEvent event) { + int numRows = 0; + //set selected item + ProductSupplierDTO selectedProductSupplier = tvProductSuppliers.getSelectionModel().getSelectedItem(); + //ask user to confirm + Alert question = new Alert(Alert.AlertType.CONFIRMATION); + question.setHeaderText("Please confirm delete"); + question.setContentText("Are you sure you want to delete this product-supplier?"); + Optional result = question.showAndWait(); //show alert and wait for response + + //if confirmed,start deletion + if (result.isPresent() && result.get() == ButtonType.OK) { + int supId = selectedProductSupplier.getSupId(); + int prodId = selectedProductSupplier.getProdId(); + + //try deleting + try{ + numRows = ProductSupplierDB.deleteProductSupplier(supId, prodId); + } + catch (SQLIntegrityConstraintViolationException e){ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Database Operation Error"); + alert.setContentText("Delete failed\n" + + "the selected product-supplier is being referred in another table"); + alert.showAndWait(); + return; + } + catch (SQLException e) { + throw new RuntimeException(e); + } + + //prompt user of any errors + if (numRows == 0){ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Database Operation Error"); + alert.setContentText("Delete failed"); + alert.showAndWait(); + } + else{ + //prompt user of delete conformation + Alert alert = new Alert(Alert.AlertType.CONFIRMATION); + alert.setHeaderText("Database Operation Confirmed"); + alert.setContentText("Delete successful"); + alert.showAndWait(); + //refresh display and reset inputs + displayProductSupplier(); + btnDelete.setDisable(true); + btnEdit.setDisable(true); + txtSearch.setText(""); + } + } } @FXML void btnEditClicked(ActionEvent event) { + //set selected item + ProductSupplierDTO selectedProductSupplier = tvProductSuppliers.getSelectionModel().getSelectedItem(); + if (selectedProductSupplier != null) { + mode = "Edit"; + openDialog(selectedProductSupplier,mode); + } + } + + /** + * Function to open the new Dialog for edit or adding + * depending on the mode given + * @param productSupplier the productSupplier entity for editing, null if adding + * @param mode the mode the dialog should be in + */ + private void openDialog(ProductSupplierDTO productSupplier, String mode){ + //Get new view + FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/org/example/petshopdesktop/dialogviews/product-supplier-dialog-view.fxml")); + Scene scene = null; + try{ + scene = new Scene(fxmlLoader.load()); + } catch (IOException e) { + throw new RuntimeException(e); + } + ProductSupplierDialogController dialogController = fxmlLoader.getController(); //controller associated with this view + dialogController.setMode(mode); + if (productSupplier != null) { + dialogController.setSelectedIds(productSupplier.getSupId(), productSupplier.getProdId()); + } + + //Open the dialog depending on the mode + if(mode.equals("Edit")){ + //Make it display suppliers details in dialog + dialogController.displayProductSupplierDetails(productSupplier); + } + Stage dialogStage = new Stage(); + dialogStage.initModality(Modality.APPLICATION_MODAL); //make it modal + if(mode.equals("Add")){ + dialogStage.setTitle("Add Product-Supplier"); + } + else { + dialogStage.setTitle("Edit Product-Supplier"); + } + dialogStage.setScene(scene); + dialogStage.showAndWait(); + + //When dialog closes update table view and disable edit and delete buttons, and reset search bar + displayProductSupplier(); + btnDelete.setDisable(true); + btnEdit.setDisable(true); + txtSearch.setText(""); } } diff --git a/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java b/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java index 080cc751..aa909103 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/SupplierController.java @@ -99,7 +99,7 @@ public class SupplierController { try{ data = SupplierDB.getSuppliers(); } catch (SQLException e) { - throw new RuntimeException(e); + System.out.println("Error while fetching table data: " + e.getMessage()); } tvSuppliers.setItems(data); @@ -121,7 +121,7 @@ public class SupplierController { tvSuppliers.setItems(data); } } catch (Exception e) { - throw new RuntimeException(e); + System.out.println("Error while fetching table data: " + e.getMessage()); } } diff --git a/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductDialogController.java b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductDialogController.java index 5cc58d87..3aa29a93 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductDialogController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductDialogController.java @@ -79,6 +79,11 @@ public class ProductDialogController { } + /** + * Validates the inputs, then add or update the database depending + * on the mode + * @param mouseEvent click event for save button + */ private void buttonSaveClicked(MouseEvent mouseEvent) { int numRow = 0; //how many rows affected String errorMsg = ""; //error message for validation @@ -164,7 +169,7 @@ public class ProductDialogController { /** * Display the product data in text fields and combobox - * @param product the supplier entity containing data to display + * @param product the product entity containing data to display */ public void displayProductDetails(ProductDTO product){ if (product!=null){ @@ -176,7 +181,7 @@ public class ProductDialogController { //get the right combobox selection for (Category category : cbProdCategory.getItems()) { if(category.getCategoryId() == product.getCategoryId()){ - cbProdCategory.setValue(category); + cbProdCategory.getSelectionModel().select(category); } } diff --git a/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductSupplierDialogController.java b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductSupplierDialogController.java new file mode 100644 index 00000000..909363b2 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ProductSupplierDialogController.java @@ -0,0 +1,245 @@ +package org.example.petshopdesktop.controllers.dialogcontrollers; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.scene.Node; +import javafx.scene.control.*; +import javafx.scene.input.MouseEvent; +import javafx.stage.Stage; +import org.example.petshopdesktop.DTOs.ProductSupplierDTO; +import org.example.petshopdesktop.Validator; +import org.example.petshopdesktop.database.ProductDB; +import org.example.petshopdesktop.database.ProductSupplierDB; +import org.example.petshopdesktop.database.SupplierDB; +import org.example.petshopdesktop.models.Product; +import org.example.petshopdesktop.models.ProductSupplier; +import org.example.petshopdesktop.models.Supplier; + +import java.sql.SQLException; +import java.sql.SQLIntegrityConstraintViolationException; + +public class ProductSupplierDialogController { + + @FXML + private Button btnCancel; + + @FXML + private Button btnSave; + + @FXML + private ComboBox cbProduct; + + @FXML + private ComboBox cbSupplier; + + @FXML + private Label lblMode; + + @FXML + private Label lblProductSupplierId; + + @FXML + private TextField txtCost; + + private String mode = null; + private int selectedSupId = -1; + private int selectedProdId = -1; + + /** + * add event listeners to buttons and set up combobox + */ + @FXML + void initialize() { //Set up mouse handlers for buttons + btnSave.setOnMouseClicked(new EventHandler() { + @Override + public void handle(MouseEvent mouseEvent) { + buttonSaveClicked(mouseEvent); + } + }); + + btnCancel.setOnMouseClicked(new EventHandler() { + @Override + public void handle(MouseEvent mouseEvent) { + closeStage(mouseEvent); + } + }); + + //Set up combobox for selecting product and supplier + try{ + ObservableList suppliers = FXCollections.observableArrayList(); //empty list + ObservableList products = FXCollections.observableArrayList(); //empty list + + //get suppliers and products from DB + suppliers = SupplierDB.getSuppliers(); + products = ProductDB.getProducts(); + + //Populate combobox + cbSupplier.setItems(suppliers); + cbProduct.setItems(products); + } + catch(SQLException e){ + throw new RuntimeException(e); + } + + } + + /** + * Validates the inputs, then add or update the database depending + * on the mode + * @param mouseEvent click event for save button + */ + private void buttonSaveClicked(MouseEvent mouseEvent) { + int numRows = 0; + String errorMsg = ""; //error message for validation + + //Check Validation (input required) + errorMsg += Validator.isPresent(txtCost.getText(), "Cost"); + if (cbProduct.getSelectionModel().getSelectedItem() == null) { + errorMsg += "Product is required \n"; + } + if (cbSupplier.getSelectionModel().getSelectedItem() == null) { + errorMsg += "Supplier is required \n"; + } + + //Check validation (length size) + errorMsg += Validator.isLessThanVarChars(txtCost.getText(), "Cost", 12); + + //Check validation (format) + errorMsg += Validator.isNonNegativeDouble(txtCost.getText(), "Cost"); + + if(errorMsg.isEmpty()){ //no validation errors + ProductSupplier productSupplier = collectProductSupplier(); //get productSupplier info + if (mode.equals("Add")) { //add mode + try{ + numRows = ProductSupplierDB.insertProductSupplier(productSupplier); + } + catch(SQLIntegrityConstraintViolationException e){ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Database Operation Error"); + alert.setContentText("Add failed \n" + + "the product-supplier link is already in the database"); + alert.showAndWait(); + numRows = -1; //Update numRow so alert only shows once + closeStage(mouseEvent); + } + catch(SQLException e){ + throw new RuntimeException(e); + } + } + else { //edit + try{ + numRows = ProductSupplierDB.updateProductSupplier(selectedSupId, selectedProdId, productSupplier); + } + catch(SQLIntegrityConstraintViolationException e){ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Database Operation Error"); + alert.setContentText("Edit failed \n" + + "the product-supplier link is already in the database"); + alert.showAndWait(); + numRows = -1; //Update numRow so alert only shows once + closeStage(mouseEvent); + } + catch(SQLException e){ + throw new RuntimeException(e); + } + } + + //if no rows were affected then there was an error (prompt user of error) + if (numRows == 0){ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Database Operation Error"); + alert.setContentText(mode + " failed"); + alert.showAndWait(); + closeStage(mouseEvent); + } + else if (numRows > 0){ + //tell the user operation was successful + Alert alert = new Alert(Alert.AlertType.CONFIRMATION); + alert.setHeaderText("Database Operation Confirmed"); + alert.setContentText(mode + " succeeded"); + alert.showAndWait(); + closeStage(mouseEvent); + } + } + else { //Display validation errors + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Input Error"); + alert.setContentText(errorMsg); + alert.showAndWait(); + } + } + + /** + * collect the data for new/updated productSupplier + * @return productSupplier entity with data + */ + private ProductSupplier collectProductSupplier() { + ProductSupplier productSupplier = null; + + productSupplier = new ProductSupplier( + cbSupplier.getSelectionModel().getSelectedItem().getSupId(), + cbProduct.getSelectionModel().getSelectedItem().getProdId(), + Double.parseDouble(txtCost.getText()) + ); + + return productSupplier; + } + + /** + * Display the productsupplier data in text fields and combobox + * @param productSupplier + */ + public void displayProductSupplierDetails(ProductSupplierDTO productSupplier){ + if(productSupplier != null){ + txtCost.setText(productSupplier.getCost() + ""); + } + + //Get the right combobox selection (product) + for (Product product : cbProduct.getItems()) { + if(product.getProdId() == productSupplier.getProdId()){ + cbProduct.getSelectionModel().select(product); + } + } + + //Get the right combobox selection (supplier) + for (Supplier supplier : cbSupplier.getItems()) { + if (supplier.getSupId() == productSupplier.getSupId()) { + cbSupplier.getSelectionModel().select(supplier); + } + } + + } + + /** + * Close the window + * @param mouseEvent mouse event to close + */ + private void closeStage(MouseEvent mouseEvent) { + Node node = (Node) mouseEvent.getSource(); + Stage stage = (Stage) node.getScene().getWindow(); + stage.close(); + } + + /** + * Set the mode of the dialog + * @param mode the mode for the dialog + */ + public void setMode(String mode) { + this.mode = mode; + lblMode.setText(mode + " Product"); + lblProductSupplierId.setVisible(false); + } + + /** + * set the current supplier and productId for (needed for update since compound primary key) + * @param supId supplier id + * @param prodId product id + */ + public void setSelectedIds(int supId, int prodId){ + this.selectedSupId = supId; + this.selectedProdId = prodId; + } + +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/SupplierDialogController.java b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/SupplierDialogController.java index d901d3d5..34cb91eb 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/SupplierDialogController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/SupplierDialogController.java @@ -67,6 +67,11 @@ public class SupplierDialogController { }); } + /** + * Validates the inputs, then add or update the database depending + * on the mode + * @param mouseEvent click event for save button + */ private void buttonSaveClicked(MouseEvent mouseEvent) { int numRow = 0; //how many rows affected String errorMsg = ""; //error message for validation diff --git a/src/main/java/org/example/petshopdesktop/database/ProductSupplierDB.java b/src/main/java/org/example/petshopdesktop/database/ProductSupplierDB.java new file mode 100644 index 00000000..cc651bd0 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/database/ProductSupplierDB.java @@ -0,0 +1,197 @@ +package org.example.petshopdesktop.database; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import org.example.petshopdesktop.DTOs.ProductDTO; +import org.example.petshopdesktop.DTOs.ProductSupplierDTO; +import org.example.petshopdesktop.models.Product; +import org.example.petshopdesktop.models.ProductSupplier; + +import java.sql.*; + +public class ProductSupplierDB { + /** + * gets all the productSupplier into an observable list + * @return a list of all the productSupplierDTOs + * @throws SQLException if failed to find productSupplier in the database + */ + public static ObservableList getProductSupplierDTO() throws SQLException{ + //Connect to the database + ObservableList productSuppliers = FXCollections.observableArrayList(); + Connection conn = ConnectionDB.getConnection(); + + //Execute Query + Statement stmt = conn.createStatement(); + String sql = "SELECT ps.supId, ps.prodId, s.supCompany, p.prodName, ps.cost " + + "FROM productsupplier ps " + + "LEFT JOIN product p " + + "ON p.prodId = ps.prodId " + + "LEFT JOIN supplier s " + + "ON s.supId = ps.supId"; + ResultSet rs = stmt.executeQuery(sql); + + //While there is still data add productSupplier to list + while(rs.next()){ + ProductSupplierDTO productSupplier = new ProductSupplierDTO( + rs.getInt(1), + rs.getInt(2), + rs.getString(3), + rs.getString(4), + rs.getDouble(5) + ); + productSuppliers.add(productSupplier); + } + + //close connection and return products + conn.close(); + return productSuppliers; + } + + /** + * Gets a list of ProductSupplierDTOs that is filtered by a given string + * @param filter the word to filter table + * @return ObservableList of ProductSupplierDTOs with the filtered data + * @throws SQLException if getting productSuppliers failed + */ + public static ObservableList getFilteredProductSupplierDTO (String filter) throws SQLException { + //connect to the database + ObservableList productSuppliers = FXCollections.observableArrayList(); + Connection conn = ConnectionDB.getConnection(); + + //Get SQL query for filter word + String sql = + "SELECT ps.supId, ps.prodId, s.supCompany, p.prodName, ps.cost " + + "FROM product p " + + "LEFT JOIN productsupplier ps " + + "ON p.prodId = ps.prodId " + + "LEFT JOIN supplier s " + + "ON s.supId = ps.supId " + + "WHERE " + + "prodName LIKE ? OR " + + "supCompany LIKE ? OR " + + "cost LIKE ?"; + + //add % wildcard so query can use LIKE to filter data + String filteredString = "%" + filter + "%"; + + PreparedStatement stmt = conn.prepareStatement(sql); + stmt.setString(1, filteredString); + stmt.setString(2, filteredString); + stmt.setString(3, filteredString); + + //execute query + ResultSet rs = stmt.executeQuery(); + + //While there is still data add productSupplier to the list + while(rs.next()){ + ProductSupplierDTO productSupplier = new ProductSupplierDTO( + rs.getInt(1), + rs.getInt(2), + rs.getString(3), + rs.getString(4), + rs.getDouble(5) + ); + productSuppliers.add(productSupplier); + } + + conn.close(); + return productSuppliers; + } + + /** + * Inserts a new productSupplier to the database + * @param productSupplier productSupplier entity to be inserted + * @return number of rows affected + * @throws SQLException if insert failed + */ + public static int insertProductSupplier(ProductSupplier productSupplier) throws SQLException{ + int numRows = 0; + + Connection conn = ConnectionDB.getConnection(); + String sql = "INSERT INTO productsupplier (prodId, supId, cost) " + + "VALUES (?, ?, ?)"; + + //These are the values from productSupplier to put into query above + PreparedStatement stmt = conn.prepareStatement(sql); + stmt.setInt(1, productSupplier.getProdId()); + stmt.setInt(2, productSupplier.getSupId()); + stmt.setDouble(3, productSupplier.getCost()); + + //update number of rows affected, return and close connection + numRows = stmt.executeUpdate(); + conn.close(); + + return numRows; + } + + /** + * Update a productSupplier by deleting old productSupplier and inserting new one + * @param oldProdId old product id (used to change primary compound key) + * @param oldSupId old supplier id (used to change primary compound key) + * @param productSupplier productSupplier entity with new info to update (including new primary compound key) + * @return number of rows affected in database + * @throws SQLException if update failed + */ + public static int updateProductSupplier(int oldSupId, int oldProdId, ProductSupplier productSupplier) throws SQLException{ + int numRows = 0; + Connection conn = ConnectionDB.getConnection(); + + //Make transaction so update can be rolled back if insert failed + conn.setAutoCommit(false); + + try{ + //Delete old data first + String sql = "DELETE FROM productsupplier WHERE supId = ? AND prodId = ?"; + PreparedStatement stmt = conn.prepareStatement(sql); + stmt.setInt(1, oldSupId); + stmt.setInt(2, oldProdId); + numRows = stmt.executeUpdate(); + + //Then change the data by inserting a new relation with given keys (only if delete worked) + if(numRows > 0){ + sql = "INSERT INTO productsupplier (prodId, supId, cost) " + + "VALUES (?, ?, ?)"; + stmt = conn.prepareStatement(sql); + stmt.setInt(1, productSupplier.getProdId()); + stmt.setInt(2, productSupplier.getSupId()); + stmt.setDouble(3, productSupplier.getCost()); + numRows = stmt.executeUpdate(); + } + //Commit changes if both delete and insert worked + conn.commit(); + } + catch(SQLException e){ + //Rollback CRUD failed + conn.rollback(); + throw e; + } + finally { + //Set auto commit back to true before closing connection + conn.setAutoCommit(true); + conn.close(); + } + return numRows; + } + + /** + * Delete a productSupplier from the database + * @param prodId id of the product + * @param supId id of the supplier + * @return number of rows affected in the database + * @throws SQLException if delete failed + */ + public static int deleteProductSupplier(int supId, int prodId) throws SQLException{ + int numRows = 0; + Connection conn = ConnectionDB.getConnection(); + + String sql = "DELETE FROM productsupplier WHERE supId = ? AND prodId = ?"; + PreparedStatement stmt = conn.prepareStatement(sql); + stmt.setInt(1, supId); + stmt.setInt(2, prodId); + + numRows = stmt.executeUpdate(); + conn.close(); + + return numRows; + } +} diff --git a/src/main/java/org/example/petshopdesktop/models/Product.java b/src/main/java/org/example/petshopdesktop/models/Product.java index 0738068a..bf0913e5 100644 --- a/src/main/java/org/example/petshopdesktop/models/Product.java +++ b/src/main/java/org/example/petshopdesktop/models/Product.java @@ -83,4 +83,9 @@ public class Product { public void setProdDesc(String prodDesc) { this.prodDesc.set(prodDesc); } + + @Override + public String toString() { + return getProdName(); + } } diff --git a/src/main/java/org/example/petshopdesktop/models/ProductSupplier.java b/src/main/java/org/example/petshopdesktop/models/ProductSupplier.java new file mode 100644 index 00000000..e674974d --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/models/ProductSupplier.java @@ -0,0 +1,54 @@ +package org.example.petshopdesktop.models; + +import javafx.beans.property.SimpleDoubleProperty; +import javafx.beans.property.SimpleIntegerProperty; + +public class ProductSupplier { + private SimpleIntegerProperty supId; + private SimpleIntegerProperty prodId; + private SimpleDoubleProperty cost; + + //constructor + public ProductSupplier(int supId, int prodId, double cost) { + this.supId = new SimpleIntegerProperty(supId); + this.prodId = new SimpleIntegerProperty(prodId); + this.cost = new SimpleDoubleProperty(cost); + } + + //getter and setters + public int getSupId() { + return supId.get(); + } + + public SimpleIntegerProperty supIdProperty() { + return supId; + } + + public void setSupId(int supId) { + this.supId.set(supId); + } + + public int getProdId() { + return prodId.get(); + } + + public SimpleIntegerProperty prodIdProperty() { + return prodId; + } + + public void setProdId(int prodId) { + this.prodId.set(prodId); + } + + public double getCost() { + return cost.get(); + } + + public SimpleDoubleProperty costProperty() { + return cost; + } + + public void setCost(double cost) { + this.cost.set(cost); + } +} diff --git a/src/main/java/org/example/petshopdesktop/models/Supplier.java b/src/main/java/org/example/petshopdesktop/models/Supplier.java index 36f05094..1120670a 100644 --- a/src/main/java/org/example/petshopdesktop/models/Supplier.java +++ b/src/main/java/org/example/petshopdesktop/models/Supplier.java @@ -106,4 +106,9 @@ public class Supplier { public String getSupFullName() { return getSupContactFirstName() + " " + getSupContactLastName(); } + + @Override + public String toString() { + return getSupCompany(); + } } diff --git a/src/main/resources/org/example/petshopdesktop/dialogviews/product-supplier-dialog-view.fxml b/src/main/resources/org/example/petshopdesktop/dialogviews/product-supplier-dialog-view.fxml new file mode 100644 index 00000000..0ef57a60 --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/dialogviews/product-supplier-dialog-view.fxml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From e8322cb8f50c72b1c42e0fc7a61ef608b83d57cc Mon Sep 17 00:00:00 2001 From: Harkamal Randhawa Date: Tue, 10 Feb 2026 09:10:32 -0700 Subject: [PATCH 009/127] Added docker compose for consistent MySQL setup --- docker-compose.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..6703b07c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +services: + mysql: + image: mysql:8.4 + container_name: petstore-mysql + ports: + - "3306:3306" + environment: + MYSQL_ROOT_PASSWORD: rootpass + MYSQL_DATABASE: Petstoredb + MYSQL_USER: petapp + MYSQL_PASSWORD: petapppass + volumes: + - ./Petstoredata.sql:/docker-entrypoint-initdb.d/01-Petstoredata.sql:ro + - petstore_mysql_data:/var/lib/mysql + +volumes: + petstore_mysql_data: + From c2294d2faa5b533d2bde65c020f0e1367655569f Mon Sep 17 00:00:00 2001 From: Harkamal Randhawa Date: Tue, 10 Feb 2026 09:15:20 -0700 Subject: [PATCH 010/127] Added an example connection file and also added proper error tracing --- connectionpetstore.properties.example | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 connectionpetstore.properties.example diff --git a/connectionpetstore.properties.example b/connectionpetstore.properties.example new file mode 100644 index 00000000..426ecafb --- /dev/null +++ b/connectionpetstore.properties.example @@ -0,0 +1,3 @@ +url=jdbc:mysql://127.0.0.1:3306/Petstoredb?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC +user=petapp +password=petapppass \ No newline at end of file From 12020a2feb678267c2dcc45b50301d129ac6cee5 Mon Sep 17 00:00:00 2001 From: Harkamal Randhawa Date: Tue, 10 Feb 2026 16:35:49 -0700 Subject: [PATCH 011/127] Fixed DB connection and java version issue --- .gitignore | 5 ++- pom.xml | 9 +++-- .../controllers/MainLayoutController.java | 3 +- .../petshopdesktop/database/ConnectionDB.java | 33 ++++++++++++------- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 480bdf52..4a8c77b5 100644 --- a/.gitignore +++ b/.gitignore @@ -36,4 +36,7 @@ build/ .vscode/ ### Mac OS ### -.DS_Store \ No newline at end of file +.DS_Store + +## Database related +connectionpetstore.properties diff --git a/pom.xml b/pom.xml index 8cb9a1ba..6da4edce 100644 --- a/pom.xml +++ b/pom.xml @@ -8,9 +8,9 @@ PetShopDesktop 1.0-SNAPSHOT PetShopDesktop - UTF-8 + 25.0.2 5.12.1 @@ -18,12 +18,12 @@ org.openjfx javafx-controls - 21.0.6 + ${javafx.version} org.openjfx javafx-fxml - 21.0.6 + ${javafx.version} @@ -66,8 +66,7 @@ default-cli - org.example.petshopdesktop/org.example.petshopdesktop.PetShopApplication - + org.example.petshopdesktop/org.example.petshopdesktop.PetShopApplication app app app diff --git a/src/main/java/org/example/petshopdesktop/controllers/MainLayoutController.java b/src/main/java/org/example/petshopdesktop/controllers/MainLayoutController.java index a5a3060d..431d38d4 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/MainLayoutController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/MainLayoutController.java @@ -111,7 +111,8 @@ public class MainLayoutController { spContentArea.getChildren().clear(); spContentArea.getChildren().add(view); } catch (Exception e) { - System.out.println("Error loading view: " + fxmlFile); + System.err.println("Error loading view: " + fxmlFile); + e.printStackTrace(); } } diff --git a/src/main/java/org/example/petshopdesktop/database/ConnectionDB.java b/src/main/java/org/example/petshopdesktop/database/ConnectionDB.java index 2b0bad1d..3435c7ac 100644 --- a/src/main/java/org/example/petshopdesktop/database/ConnectionDB.java +++ b/src/main/java/org/example/petshopdesktop/database/ConnectionDB.java @@ -2,6 +2,9 @@ package org.example.petshopdesktop.database; import java.io.FileInputStream; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @@ -9,8 +12,7 @@ import java.util.Properties; public class ConnectionDB { /** - * Method to try and connect to the database sing cnnection.properties located in the - * root of C drive + * Method to try and connect to the database using connectionpetstore.properties. * @return Connection to the database */ public static Connection getConnection(){ @@ -18,10 +20,23 @@ public class ConnectionDB { String user = ""; String password = ""; - try{ - //Read connection.properties file - FileInputStream fis = new FileInputStream("c:\\connectionpetstore.properties"); //location of connection can be changed here - Properties prop = new Properties(); + Properties prop = new Properties(); + Path propsPath; + + String explicitPath = System.getenv("PETSTORE_DB_PROPS"); + if (explicitPath != null && !explicitPath.isBlank()) { + propsPath = Paths.get(explicitPath); + } else { + Path cwd = Paths.get(System.getProperty("user.dir"), "connectionpetstore.properties"); + Path xdg = Paths.get(System.getProperty("user.home"), ".config", "petstore", "connectionpetstore.properties"); + Path legacyWindows = Paths.get("./connectionpetstore.properties"); + + if (Files.exists(cwd)) propsPath = cwd; + else if (Files.exists(xdg)) propsPath = xdg; + else propsPath = legacyWindows; + } + + try (FileInputStream fis = new FileInputStream(propsPath.toString())) { prop.load(fis); url = prop.getProperty("url"); user = prop.getProperty("user"); @@ -31,12 +46,8 @@ public class ConnectionDB { throw new RuntimeException("Problem with reading connection info: "+e.getMessage()); } - Connection conn = null; - try{ - //try to get connection with the data taken from connection.properties - conn = DriverManager.getConnection(url,user,password); - return conn; + return DriverManager.getConnection(url,user,password); } catch (SQLException e) { throw new RuntimeException("Problem with database connection: "+e.getMessage()); From bcb383c40a77a48c098fe6e4c4b33dec8deb0515 Mon Sep 17 00:00:00 2001 From: augmentedpotato Date: Wed, 11 Feb 2026 08:40:31 -0700 Subject: [PATCH 012/127] Pets CRUD --- connectionpetstore.properties | 3 + .../controllers/PetController.java | 187 ++++++++++++++-- .../PetDialogController.java | 203 ++++++++++++++++++ .../petshopdesktop/database/PetDB.java | 145 +++++++++++++ .../example/petshopdesktop/models/Pet.java | 109 ++++++++++ 5 files changed, 633 insertions(+), 14 deletions(-) create mode 100644 connectionpetstore.properties create mode 100644 src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/PetDialogController.java create mode 100644 src/main/java/org/example/petshopdesktop/database/PetDB.java create mode 100644 src/main/java/org/example/petshopdesktop/models/Pet.java diff --git a/connectionpetstore.properties b/connectionpetstore.properties new file mode 100644 index 00000000..426ecafb --- /dev/null +++ b/connectionpetstore.properties @@ -0,0 +1,3 @@ +url=jdbc:mysql://127.0.0.1:3306/Petstoredb?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC +user=petapp +password=petapppass \ No newline at end of file diff --git a/src/main/java/org/example/petshopdesktop/controllers/PetController.java b/src/main/java/org/example/petshopdesktop/controllers/PetController.java index 26834d72..7eb55cb8 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/PetController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/PetController.java @@ -1,11 +1,24 @@ package org.example.petshopdesktop.controllers; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; -import javafx.scene.control.Button; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableView; -import javafx.scene.control.TextField; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.control.*; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.stage.Modality; +import javafx.stage.Stage; +import org.example.petshopdesktop.controllers.dialogcontrollers.PetDialogController; +import org.example.petshopdesktop.database.PetDB; +import org.example.petshopdesktop.database.ProductDB; +import org.example.petshopdesktop.models.Pet; + +import java.io.IOException; +import java.sql.SQLException; +import java.sql.SQLIntegrityConstraintViolationException; +import java.util.Optional; public class PetController { @@ -19,45 +32,191 @@ public class PetController { private Button btnEdit; @FXML - private TableColumn colPetAge; + private TableColumn colPetAge; @FXML - private TableColumn colPetBreed; + private TableColumn colPetBreed; @FXML - private TableColumn colPetId; + private TableColumn colPetId; @FXML - private TableColumn colPetName; + private TableColumn colPetName; @FXML - private TableColumn colPetPrice; + private TableColumn colPetPrice; @FXML - private TableColumn colPetSpecies; + private TableColumn colPetSpecies; @FXML - private TableColumn colPetStatus; + private TableColumn colPetStatus; @FXML - private TableView tvPets; + private TableView tvPets; @FXML private TextField txtSearch; @FXML void btnAddClicked(ActionEvent event) { - + mode = "Add"; + openDialog(null,mode); } @FXML void btnDeleteClicked(ActionEvent event) { + int numRows = 0; + Pet selectedPet = tvPets.getSelectionModel().getSelectedItem(); + //ask user to confirm + Alert question = new Alert(Alert.AlertType.CONFIRMATION); + question.setHeaderText("Please confirm delete"); + question.setContentText("Are you sure you want to delete this pet?"); + Optional result = question.showAndWait(); //show alert and wait for response + + //if confirmed,start deletion + if (result.isPresent() && result.get() == ButtonType.OK) { + int petId = selectedPet.getPetId(); + + //try deleting + try{ + numRows = PetDB.deletePet(petId); + } + catch (SQLIntegrityConstraintViolationException e){ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Database Operation Error"); + alert.setContentText("Delete failed\n" + + "the selected pet is being referred in another table"); + alert.showAndWait(); + return; + } + catch (SQLException e) { + throw new RuntimeException(e); + } + + //prompt user of any errors + if (numRows == 0){ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Database Operation Error"); + alert.setContentText("Delete failed"); + alert.showAndWait(); + } + else{ + //prompt user of delete conformation + Alert alert = new Alert(Alert.AlertType.CONFIRMATION); + alert.setHeaderText("Database Operation Confirmed"); + alert.setContentText("Delete successful"); + alert.showAndWait(); + //refresh display and reset inputs + displayPets(); + btnDelete.setDisable(true); + btnEdit.setDisable(true); + txtSearch.setText(""); + } + } } @FXML void btnEditClicked(ActionEvent event) { + Pet selectedPet = tvPets.getSelectionModel().getSelectedItem(); + if(selectedPet != null){ + mode = "Edit"; + openDialog(selectedPet,mode); + } } -} + private ObservableList data = FXCollections.observableArrayList(); + String mode = null; + + @FXML + void initialize() { + btnEdit.setDisable(true); + btnDelete.setDisable(true); + + colPetId.setCellValueFactory(new PropertyValueFactory("petId")); + colPetName.setCellValueFactory(new PropertyValueFactory("petName")); + colPetSpecies.setCellValueFactory(new PropertyValueFactory("petSpecies")); + colPetBreed.setCellValueFactory(new PropertyValueFactory("petBreed")); + colPetAge.setCellValueFactory(new PropertyValueFactory("petAge")); + colPetStatus.setCellValueFactory(new PropertyValueFactory("petStatus")); + colPetPrice.setCellValueFactory(new PropertyValueFactory("petPrice")); + + displayPets(); + + tvPets.getSelectionModel().selectedItemProperty().addListener( + (observable, oldValue, newValue) -> { + btnEdit.setDisable(false); + btnDelete.setDisable(false); + }); + + txtSearch.textProperty().addListener((observable, oldValue, newValue) -> { + displayFilteredPet(newValue); + }); + } + + private void displayFilteredPet(String filter) { + data.clear(); + try{ + if (txtSearch.getText() == null || txtSearch.getText().isEmpty()){ + displayPets(); + } + else { + data = PetDB.getFilteredPets(filter); + tvPets.setItems(data); + } + } catch (Exception e) { + System.out.println("Error while fetching table data: " + e.getMessage()); + } + } + + private void displayPets() { + data.clear(); + + try{ + data = PetDB.getPets(); + } + catch(SQLException e){ + System.out.println("Error while fetching table data: " + e.getMessage()); + } + + tvPets.setItems(data); + } + + private void openDialog(Pet pet, String mode){ + //Get new view + FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/org/example/petshopdesktop/dialogviews/pet-dialog-view.fxml")); + Scene scene = null; + try{ + scene = new Scene(fxmlLoader.load()); + } catch (IOException e) { + throw new RuntimeException(e); + } + PetDialogController dialogController = fxmlLoader.getController(); //controller associated with this view + dialogController.setMode(mode); + + //Open the dialog depending on the mode + if(mode.equals("Edit")){ + //Make it display pet details in dialog + dialogController.displayPetDetails(pet); + } + Stage dialogStage = new Stage(); + dialogStage.initModality(Modality.APPLICATION_MODAL); //make it modal + if(mode.equals("Add")){ + dialogStage.setTitle("Add Pet"); + } + else { + dialogStage.setTitle("Edit Pet"); + } + dialogStage.setScene(scene); + dialogStage.showAndWait(); + + //When dialog closes update table view and disable edit and delete buttons, and reset search bar + displayPets(); + btnDelete.setDisable(true); + btnEdit.setDisable(true); + txtSearch.setText(""); + } + +} \ No newline at end of file diff --git a/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/PetDialogController.java b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/PetDialogController.java new file mode 100644 index 00000000..45be6c3c --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/PetDialogController.java @@ -0,0 +1,203 @@ +package org.example.petshopdesktop.controllers.dialogcontrollers; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.scene.Node; +import javafx.scene.control.*; +import javafx.scene.input.MouseEvent; +import javafx.stage.Stage; +import org.example.petshopdesktop.DTOs.ProductDTO; +import org.example.petshopdesktop.Validator; +import org.example.petshopdesktop.database.PetDB; +import org.example.petshopdesktop.models.Category; +import org.example.petshopdesktop.models.Pet; + +import java.sql.SQLException; + +public class PetDialogController { + + @FXML + private Button btnCancel; + + @FXML + private Button btnSave; + + @FXML + private ComboBox cbPetStatus; + + @FXML + private Label lblMode; + + @FXML + private Label lblPetId; + + @FXML + private TextField txtPetAge; + + @FXML + private TextField txtPetBreed; + + @FXML + private TextField txtPetName; + + @FXML + private TextField txtPetPrice; + + @FXML + private TextField txtPetSpecies; + + private String mode = null; + + private ObservableList statusList = FXCollections.observableArrayList( + "Available", "Adopted" + ); + + @FXML + void initialize() { + + cbPetStatus.setItems(statusList); //set status combobox + + //Set up mouse handlers for buttons + btnSave.setOnMouseClicked(new EventHandler() { + @Override + public void handle(MouseEvent mouseEvent) { + buttonSaveClicked(mouseEvent); + } + }); + + btnCancel.setOnMouseClicked(new EventHandler() { + @Override + public void handle(MouseEvent mouseEvent) { + closeStage(mouseEvent); + } + }); + } + + private void buttonSaveClicked(MouseEvent mouseEvent) { + int numRow = 0; + String errorMsg = ""; + + //Check validation (input required) + errorMsg += Validator.isPresent(txtPetName.getText(), "Pet Name"); + errorMsg += Validator.isPresent(txtPetAge.getText(), "Age"); + errorMsg += Validator.isPresent(txtPetBreed.getText(), "Breed"); + errorMsg += Validator.isPresent(txtPetSpecies.getText(), "Species"); + errorMsg += Validator.isPresent(txtPetPrice.getText(), "Price"); + if (cbPetStatus.getSelectionModel().getSelectedItem() == null){ + errorMsg += "Status is required"; + } + + //Check validation (length size) + errorMsg += Validator.isLessThanVarChars(txtPetName.getText(), "Pet Name", 50); + errorMsg += Validator.isLessThanVarChars(txtPetSpecies.getText(), "Species", 50); + errorMsg += Validator.isLessThanVarChars(txtPetBreed.getText(), "Breed", 50); + errorMsg += Validator.isLessThanVarChars(txtPetPrice.getText(), "Price", 12); + errorMsg += Validator.isLessThanVarChars(txtPetAge.getText(), "Age", 11); + + //Check validation (format) + errorMsg += Validator.isNonNegativeDouble(txtPetPrice.getText(), "Price"); + errorMsg += Validator.isNonNegativeInteger(txtPetAge.getText(), "Age"); + + if(errorMsg.isEmpty()){ + Pet pet = collectPet(); + if(mode.equals("Add")) { + try{ + numRow = PetDB.insertPet(pet); + } + catch (SQLException e) { + throw new RuntimeException(e); + } + } + else { + try { + numRow = PetDB.updatePet(pet.getPetId(), pet); + } + catch (SQLException e) { + throw new RuntimeException(e); + } + } + + //if no rows were affected then there was an error (prompt user of error) + if (numRow == 0){ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Database Operation Error"); + alert.setContentText(mode + " failed"); + alert.showAndWait(); + closeStage(mouseEvent); + } + else { + //tell the user operation was successful + Alert alert = new Alert(Alert.AlertType.CONFIRMATION); + alert.setHeaderText("Database Operation Confirmed"); + alert.setContentText(mode + " succeeded"); + alert.showAndWait(); + closeStage(mouseEvent); + } + } + else{ + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setHeaderText("Input Error"); + alert.setContentText(errorMsg); + alert.showAndWait(); + } + } + + private Pet collectPet() { + int petId =0; + Pet pet = null; + + if(lblPetId.isVisible()){ + petId = Integer.parseInt(lblPetId.getText().split(": ")[1]); + } + pet = new Pet( + petId, + txtPetName.getText(), + txtPetSpecies.getText(), + txtPetBreed.getText(), + Integer.parseInt(txtPetAge.getText()), + cbPetStatus.getValue(), + Double.parseDouble(txtPetPrice.getText()) + ); + return pet; + } + + private void closeStage(MouseEvent mouseEvent) { + Node node = (Node) mouseEvent.getSource(); + Stage stage = (Stage) node.getScene().getWindow(); + stage.close(); + } + + public void displayPetDetails(Pet pet){ + if (pet!=null){ + lblPetId.setText("ID: " + pet.getPetId()); + txtPetName.setText(pet.getPetName()); + txtPetSpecies.setText(pet.getPetSpecies()); + txtPetBreed.setText(pet.getPetBreed()); + txtPetAge.setText(pet.getPetAge() + ""); + txtPetPrice.setText(pet.getPetPrice() + ""); + + //get the right combobox selection + for (String status : cbPetStatus.getItems()) { + if(status.equals(pet.getPetStatus())){ + cbPetStatus.getSelectionModel().select(status); + } + } + + + } + } + + public void setMode(String mode) { + this.mode = mode; + lblMode.setText(mode + " Pet"); + if(mode.equals("Add")) { + lblPetId.setVisible(false); + } + else if(mode.equals("Edit")) { + lblPetId.setVisible(true); + } + } + +} diff --git a/src/main/java/org/example/petshopdesktop/database/PetDB.java b/src/main/java/org/example/petshopdesktop/database/PetDB.java new file mode 100644 index 00000000..d1b7ca37 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/database/PetDB.java @@ -0,0 +1,145 @@ +package org.example.petshopdesktop.database; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import org.example.petshopdesktop.models.Pet; + +import java.sql.*; + +public class PetDB { + public static ObservableList getPets() throws SQLException { + //Connect to the database + ObservableList pets = FXCollections.observableArrayList(); + Connection conn = ConnectionDB.getConnection(); + + //Execute Query + Statement stmt = conn.createStatement(); + ResultSet rs = stmt.executeQuery("SELECT * FROM pet"); + + //While there is still data add pets to the list + while(rs.next()){ + Pet pet = new Pet( + rs.getInt(1), + rs.getString(2), + rs.getString(3), + rs.getString(4), + rs.getInt(5), + rs.getString(6), + rs.getDouble(7) + ); + pets.add(pet); + } + + //close connection and return pets + conn.close(); + return pets; + } + + public static ObservableList getFilteredPets(String filter) throws SQLException { + //Connect to the database + ObservableList pets = FXCollections.observableArrayList(); + Connection conn = ConnectionDB.getConnection(); + + //Get SQL query for filtered word + String sql = "SELECT * FROM pet " + + " WHERE " + + "petName LIKE ? OR " + + "petSpecies LIKE ? OR " + + "petBreed LIKE ? OR " + + "petAge LIKE ? OR " + + "petStatus LIKE ? OR " + + "petPrice LIKE ?"; + + String filteredString = "%" + filter + "%"; + + PreparedStatement stmt = conn.prepareStatement(sql); + stmt.setString(1, filteredString); + stmt.setString(2, filteredString); + stmt.setString(3, filteredString); + stmt.setString(4, filteredString); + stmt.setString(5, filteredString); + stmt.setString(6, filteredString); + + ResultSet rs = stmt.executeQuery(); + + while(rs.next()){ + Pet pet = new Pet( + rs.getInt(1), + rs.getString(2), + rs.getString(3), + rs.getString(4), + rs.getInt(5), + rs.getString(6), + rs.getDouble(7) + ); + pets.add(pet); + } + + conn.close(); + return pets; + } + + public static int insertPet(Pet pet) throws SQLException { + int numRows = 0; + + Connection conn = ConnectionDB.getConnection(); + String sql = "INSERT INTO pet (petId, petName, petSpecies, petBreed, petAge, petStatus, petPrice)" + + " VALUES (?, ?, ?, ?, ?, ?, ?)"; + + PreparedStatement stmt = conn.prepareStatement(sql); + stmt.setInt(1, pet.getPetId()); + stmt.setString(2, pet.getPetName()); + stmt.setString(3, pet.getPetSpecies()); + stmt.setString(4, pet.getPetBreed()); + stmt.setInt(5, pet.getPetAge()); + stmt.setString(6, pet.getPetStatus()); + stmt.setDouble(7, pet.getPetPrice()); + + numRows = stmt.executeUpdate(); + conn.close(); + + return numRows; + } + + public static int updatePet(int petId, Pet pet) throws SQLException { + int numRows = 0; + + Connection conn = ConnectionDB.getConnection(); + String sql = "UPDATE pet SET " + + " petName = ?, " + + " petSpecies = ?, " + + " petBreed = ?, " + + " petAge = ?, " + + " petStatus = ?, " + + " petPrice = ? " + + " WHERE petId = ?"; + PreparedStatement stmt = conn.prepareStatement(sql); + stmt.setString(1, pet.getPetName()); + stmt.setString(2, pet.getPetSpecies()); + stmt.setString(3, pet.getPetBreed()); + stmt.setInt(4, pet.getPetAge()); + stmt.setString(5, pet.getPetStatus()); + stmt.setDouble(6, pet.getPetPrice()); + stmt.setInt(7, petId); + + numRows = stmt.executeUpdate(); + conn.close(); + + return numRows; + } + + public static int deletePet(int petId) throws SQLException { + int numRows = 0; + Connection conn = ConnectionDB.getConnection(); + + String sql = "DELETE FROM pet WHERE petId = ?"; + PreparedStatement stmt = conn.prepareStatement(sql); + + stmt.setInt(1, petId); + + numRows = stmt.executeUpdate(); + conn.close(); + + return numRows; + } +} diff --git a/src/main/java/org/example/petshopdesktop/models/Pet.java b/src/main/java/org/example/petshopdesktop/models/Pet.java new file mode 100644 index 00000000..e1f2e3fb --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/models/Pet.java @@ -0,0 +1,109 @@ +package org.example.petshopdesktop.models; + +import javafx.beans.property.SimpleDoubleProperty; +import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.property.SimpleStringProperty; + +public class Pet { + private SimpleIntegerProperty petId; + private SimpleStringProperty petName; + private SimpleStringProperty petSpecies; + private SimpleStringProperty petBreed; + private SimpleIntegerProperty petAge; + private SimpleStringProperty petStatus; + private SimpleDoubleProperty petPrice; + + public Pet(int petId, String petName, String petSpecies, String petBreed, int petAge, String petStatus, double petPrice) { + this.petId = new SimpleIntegerProperty(petId); + this.petName = new SimpleStringProperty(petName); + this.petSpecies = new SimpleStringProperty(petSpecies); + this.petBreed = new SimpleStringProperty(petBreed); + this.petAge = new SimpleIntegerProperty(petAge); + this.petStatus = new SimpleStringProperty(petStatus); + this.petPrice = new SimpleDoubleProperty(petPrice); + } + + public int getPetId() { + return petId.get(); + } + + public void setPetId(int petId) { + this.petId.set(petId); + } + + public SimpleIntegerProperty petIdProperty() { + return petId; + } + + public String getPetName() { + return petName.get(); + } + + public void setPetName(String petName) { + this.petName.set(petName); + } + + public SimpleStringProperty petNameProperty() { + return petName; + } + + public String getPetSpecies() { + return petSpecies.get(); + } + + public void setPetSpecies(String petSpecies) { + this.petSpecies.set(petSpecies); + } + + public SimpleStringProperty petSpeciesProperty() { + return petSpecies; + } + + public String getPetBreed() { + return petBreed.get(); + } + + public void setPetBreed(String petBreed) { + this.petBreed.set(petBreed); + } + + public SimpleStringProperty petBreedProperty() { + return petBreed; + } + + public int getPetAge() { + return petAge.get(); + } + + public void setPetAge(int petAge) { + this.petAge.set(petAge); + } + + public SimpleIntegerProperty petAgeProperty() { + return petAge; + } + + public String getPetStatus() { + return petStatus.get(); + } + + public void setPetStatus(String petStatus) { + this.petStatus.set(petStatus); + } + + public SimpleStringProperty petStatusProperty() { + return petStatus; + } + + public double getPetPrice() { + return petPrice.get(); + } + + public void setPetPrice(double petPrice) { + this.petPrice.set(petPrice); + } + + public SimpleDoubleProperty petPriceProperty() { + return petPrice; + } +} From edf5bb7a7e07a97da94252ecbcd916f8575807d7 Mon Sep 17 00:00:00 2001 From: Nikitha Date: Thu, 19 Feb 2026 19:38:14 -0700 Subject: [PATCH 013/127] Appoinment,service,Purchase fxml --- .../dialogviews/appointment-dialog-view.fxml | 176 ++++++++++++++++++ .../dialogviews/service-dialog-view.fxml | 147 +++++++++++++++ .../modelviews/appointment-view.fxml | 8 +- .../modelviews/purchaseorder-view.fxml | 82 ++++++++ .../modelviews/service-view.fxml | 8 +- 5 files changed, 413 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/org/example/petshopdesktop/dialogviews/appointment-dialog-view.fxml create mode 100644 src/main/resources/org/example/petshopdesktop/dialogviews/service-dialog-view.fxml create mode 100644 src/main/resources/org/example/petshopdesktop/modelviews/purchaseorder-view.fxml diff --git a/src/main/resources/org/example/petshopdesktop/dialogviews/appointment-dialog-view.fxml b/src/main/resources/org/example/petshopdesktop/dialogviews/appointment-dialog-view.fxml new file mode 100644 index 00000000..7ff155b2 --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/dialogviews/appointment-dialog-view.fxml @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/example/petshopdesktop/dialogviews/service-dialog-view.fxml b/src/main/resources/org/example/petshopdesktop/dialogviews/service-dialog-view.fxml new file mode 100644 index 00000000..ccd4c24f --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/dialogviews/service-dialog-view.fxml @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/example/petshopdesktop/modelviews/appointment-view.fxml b/src/main/resources/org/example/petshopdesktop/modelviews/appointment-view.fxml index ec7e6cce..4bfd3029 100644 --- a/src/main/resources/org/example/petshopdesktop/modelviews/appointment-view.fxml +++ b/src/main/resources/org/example/petshopdesktop/modelviews/appointment-view.fxml @@ -66,15 +66,15 @@ - - - + + + - + diff --git a/src/main/resources/org/example/petshopdesktop/modelviews/purchaseorder-view.fxml b/src/main/resources/org/example/petshopdesktop/modelviews/purchaseorder-view.fxml new file mode 100644 index 00000000..fdac860e --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/modelviews/purchaseorder-view.fxml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/org/example/petshopdesktop/modelviews/service-view.fxml b/src/main/resources/org/example/petshopdesktop/modelviews/service-view.fxml index c3398855..2adac139 100644 --- a/src/main/resources/org/example/petshopdesktop/modelviews/service-view.fxml +++ b/src/main/resources/org/example/petshopdesktop/modelviews/service-view.fxml @@ -66,13 +66,13 @@ - - - + + + - + From 168400a6b310b638f933d3fea21143264c94757f Mon Sep 17 00:00:00 2001 From: augmentedpotato Date: Fri, 20 Feb 2026 20:16:35 -0700 Subject: [PATCH 014/127] Dialog view now exists --- .../dialogviews/pet-dialog-view.fxml | 175 ++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 src/main/resources/org/example/petshopdesktop/dialogviews/pet-dialog-view.fxml diff --git a/src/main/resources/org/example/petshopdesktop/dialogviews/pet-dialog-view.fxml b/src/main/resources/org/example/petshopdesktop/dialogviews/pet-dialog-view.fxml new file mode 100644 index 00000000..0784811b --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/dialogviews/pet-dialog-view.fxml @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a12af3f0ee9dee7c041883e9f3a21dd1d321a285 Mon Sep 17 00:00:00 2001 From: Harkamal Randhawa Date: Sat, 21 Feb 2026 13:27:50 -0700 Subject: [PATCH 015/127] Implement RBAC with login screen for admin and staff roles - Add Role enum (ADMIN, STAFF) and UserSession singleton - Add User model and UserDB with SHA2-256 authentication - Add login screen (login-view.fxml + LoginController) - Update main-layout-view.fxml: dynamic username/role labels, logout button - Update MainLayoutController: hide Inventory/Suppliers/Product-Suppliers for STAFF, show username/role, handle logout - Update PetShopApplication to start with login screen and initialize users table - Update module-info.java to open/export auth package --- src/main/java/module-info.java | 2 + .../petshopdesktop/PetShopApplication.java | 10 ++- .../org/example/petshopdesktop/auth/Role.java | 6 ++ .../petshopdesktop/auth/UserSession.java | 44 ++++++++++ .../controllers/LoginController.java | 67 ++++++++++++++++ .../controllers/MainLayoutController.java | 45 +++++++++++ .../petshopdesktop/database/UserDB.java | 71 ++++++++++++++++ .../example/petshopdesktop/models/User.java | 27 +++++++ .../example/petshopdesktop/login-view.fxml | 80 +++++++++++++++++++ .../petshopdesktop/main-layout-view.fxml | 15 +++- 10 files changed, 363 insertions(+), 4 deletions(-) create mode 100644 src/main/java/org/example/petshopdesktop/auth/Role.java create mode 100644 src/main/java/org/example/petshopdesktop/auth/UserSession.java create mode 100644 src/main/java/org/example/petshopdesktop/controllers/LoginController.java create mode 100644 src/main/java/org/example/petshopdesktop/database/UserDB.java create mode 100644 src/main/java/org/example/petshopdesktop/models/User.java create mode 100644 src/main/resources/org/example/petshopdesktop/login-view.fxml diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 7459e876..d1f07dd9 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -8,7 +8,9 @@ module org.example.petshopdesktop { opens org.example.petshopdesktop to javafx.fxml; opens org.example.petshopdesktop.controllers.dialogcontrollers to javafx.fxml; opens org.example.petshopdesktop.controllers to javafx.fxml; + opens org.example.petshopdesktop.auth to javafx.fxml; exports org.example.petshopdesktop; exports org.example.petshopdesktop.controllers; + exports org.example.petshopdesktop.auth; } \ No newline at end of file diff --git a/src/main/java/org/example/petshopdesktop/PetShopApplication.java b/src/main/java/org/example/petshopdesktop/PetShopApplication.java index 8a8fcd65..06def37b 100644 --- a/src/main/java/org/example/petshopdesktop/PetShopApplication.java +++ b/src/main/java/org/example/petshopdesktop/PetShopApplication.java @@ -4,15 +4,21 @@ import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.stage.Stage; +import org.example.petshopdesktop.database.UserDB; import java.io.IOException; public class PetShopApplication extends Application { @Override public void start(Stage stage) throws IOException { - FXMLLoader fxmlLoader = new FXMLLoader(PetShopApplication.class.getResource("main-layout-view.fxml")); + try { + UserDB.initializeTable(); + } catch (Exception e) { + System.err.println("Warning: could not initialize users table: " + e.getMessage()); + } + FXMLLoader fxmlLoader = new FXMLLoader(PetShopApplication.class.getResource("login-view.fxml")); Scene scene = new Scene(fxmlLoader.load()); - stage.setTitle("Pet Shop Manager"); + stage.setTitle("Pet Shop Manager - Login"); stage.setScene(scene); stage.show(); } diff --git a/src/main/java/org/example/petshopdesktop/auth/Role.java b/src/main/java/org/example/petshopdesktop/auth/Role.java new file mode 100644 index 00000000..64f38459 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/auth/Role.java @@ -0,0 +1,6 @@ +package org.example.petshopdesktop.auth; + +public enum Role { + ADMIN, + STAFF +} diff --git a/src/main/java/org/example/petshopdesktop/auth/UserSession.java b/src/main/java/org/example/petshopdesktop/auth/UserSession.java new file mode 100644 index 00000000..748c9546 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/auth/UserSession.java @@ -0,0 +1,44 @@ +package org.example.petshopdesktop.auth; + +public class UserSession { + + private static UserSession instance; + + private String username; + private Role role; + + private UserSession() {} + + public static UserSession getInstance() { + if (instance == null) { + instance = new UserSession(); + } + return instance; + } + + public void login(String username, Role role) { + this.username = username; + this.role = role; + } + + public void logout() { + this.username = null; + this.role = null; + } + + public String getUsername() { + return username; + } + + public Role getRole() { + return role; + } + + public boolean isAdmin() { + return Role.ADMIN.equals(role); + } + + public boolean isLoggedIn() { + return username != null && role != null; + } +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/LoginController.java b/src/main/java/org/example/petshopdesktop/controllers/LoginController.java new file mode 100644 index 00000000..43bb3334 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/controllers/LoginController.java @@ -0,0 +1,67 @@ +package org.example.petshopdesktop.controllers; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.control.Label; +import javafx.scene.control.PasswordField; +import javafx.scene.control.TextField; +import javafx.stage.Stage; +import org.example.petshopdesktop.auth.UserSession; +import org.example.petshopdesktop.database.UserDB; +import org.example.petshopdesktop.models.User; + +import java.sql.SQLException; + +public class LoginController { + + @FXML + private TextField txtUsername; + + @FXML + private PasswordField txtPassword; + + @FXML + private Label lblError; + + @FXML + void btnLoginClicked(ActionEvent event) { + String username = txtUsername.getText().trim(); + String password = txtPassword.getText(); + + if (username.isEmpty() || password.isEmpty()) { + lblError.setText("Please enter username and password."); + return; + } + + try { + User user = UserDB.authenticate(username, password); + if (user == null) { + lblError.setText("Invalid username or password."); + txtPassword.clear(); + return; + } + + UserSession.getInstance().login(user.getUsername(), user.getRole()); + openMainLayout(); + + } catch (SQLException e) { + lblError.setText("Database error: " + e.getMessage()); + } + } + + private void openMainLayout() { + try { + FXMLLoader loader = new FXMLLoader( + getClass().getResource("/org/example/petshopdesktop/main-layout-view.fxml")); + Scene scene = new Scene(loader.load()); + Stage stage = (Stage) txtUsername.getScene().getWindow(); + stage.setScene(scene); + stage.setTitle("Pet Shop Manager"); + } catch (Exception e) { + lblError.setText("Error loading application: " + e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/org/example/petshopdesktop/controllers/MainLayoutController.java b/src/main/java/org/example/petshopdesktop/controllers/MainLayoutController.java index 431d38d4..3584a0cc 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/MainLayoutController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/MainLayoutController.java @@ -4,8 +4,12 @@ import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; +import javafx.scene.Scene; import javafx.scene.control.Button; +import javafx.scene.control.Label; import javafx.scene.layout.StackPane; +import javafx.stage.Stage; +import org.example.petshopdesktop.auth.UserSession; public class MainLayoutController { @@ -18,6 +22,9 @@ public class MainLayoutController { @FXML private Button btnInventory; + @FXML + private Button btnLogout; + @FXML private Button btnPets; @@ -36,6 +43,12 @@ public class MainLayoutController { @FXML private Button btnSuppliers; + @FXML + private Label lblUsername; + + @FXML + private Label lblRole; + @FXML private StackPane spContentArea; @@ -93,11 +106,43 @@ public class MainLayoutController { updateButtons(btnSuppliers); } + @FXML + void btnLogoutClicked(ActionEvent event) { + UserSession.getInstance().logout(); + try { + FXMLLoader loader = new FXMLLoader( + getClass().getResource("/org/example/petshopdesktop/login-view.fxml")); + Scene scene = new Scene(loader.load()); + Stage stage = (Stage) btnLogout.getScene().getWindow(); + stage.setScene(scene); + stage.setTitle("Pet Shop Manager - Login"); + } catch (Exception e) { + System.err.println("Error loading login view: " + e.getMessage()); + e.printStackTrace(); + } + } + @FXML public void initialize() { + applyRBAC(); loadView("pet-view.fxml"); } + private void applyRBAC() { + UserSession session = UserSession.getInstance(); + + lblUsername.setText(session.getUsername()); + lblRole.setText(session.getRole().toString()); + + boolean isAdmin = session.isAdmin(); + btnInventory.setVisible(isAdmin); + btnInventory.setManaged(isAdmin); + btnSuppliers.setVisible(isAdmin); + btnSuppliers.setManaged(isAdmin); + btnProductSuppliers.setVisible(isAdmin); + btnProductSuppliers.setManaged(isAdmin); + } + /** * Load a view when a button is clicked on the navigation * @param fxmlFile the fxmlFile name to be loaded diff --git a/src/main/java/org/example/petshopdesktop/database/UserDB.java b/src/main/java/org/example/petshopdesktop/database/UserDB.java new file mode 100644 index 00000000..8909d211 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/database/UserDB.java @@ -0,0 +1,71 @@ +package org.example.petshopdesktop.database; + +import org.example.petshopdesktop.auth.Role; +import org.example.petshopdesktop.models.User; + +import java.sql.*; + +public class UserDB { + + /** + * Authenticate a user by username and password. + * Passwords are stored as SHA-256 hex digests in the database. + * + * @param username the username to authenticate + * @param password the plaintext password + * @return the User if credentials are valid, or null if authentication fails + */ + public static User authenticate(String username, String password) throws SQLException { + String sql = "SELECT user_id, username, role FROM users " + + "WHERE username = ? AND password_hash = SHA2(?, 256)"; + + try (Connection conn = ConnectionDB.getConnection(); + PreparedStatement ps = conn.prepareStatement(sql)) { + + ps.setString(1, username); + ps.setString(2, password); + + try (ResultSet rs = ps.executeQuery()) { + if (rs.next()) { + int userId = rs.getInt("user_id"); + String uname = rs.getString("username"); + Role role = Role.valueOf(rs.getString("role").toUpperCase()); + return new User(userId, uname, role); + } + } + } + return null; + } + + /** + * Create the users table and seed default admin/staff accounts if they do not exist. + * Passwords are stored as SHA2-256 hashes. + */ + public static void initializeTable() throws SQLException { + String createTable = """ + CREATE TABLE IF NOT EXISTS users ( + user_id INT AUTO_INCREMENT PRIMARY KEY, + username VARCHAR(100) NOT NULL UNIQUE, + password_hash CHAR(64) NOT NULL, + role ENUM('ADMIN','STAFF') NOT NULL + ) + """; + + String seedAdmin = """ + INSERT IGNORE INTO users (username, password_hash, role) + VALUES ('admin', SHA2('admin123', 256), 'ADMIN') + """; + + String seedStaff = """ + INSERT IGNORE INTO users (username, password_hash, role) + VALUES ('staff', SHA2('staff123', 256), 'STAFF') + """; + + try (Connection conn = ConnectionDB.getConnection(); + Statement st = conn.createStatement()) { + st.executeUpdate(createTable); + st.executeUpdate(seedAdmin); + st.executeUpdate(seedStaff); + } + } +} diff --git a/src/main/java/org/example/petshopdesktop/models/User.java b/src/main/java/org/example/petshopdesktop/models/User.java new file mode 100644 index 00000000..02089be4 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/models/User.java @@ -0,0 +1,27 @@ +package org.example.petshopdesktop.models; + +import org.example.petshopdesktop.auth.Role; + +public class User { + private int userId; + private String username; + private Role role; + + public User(int userId, String username, Role role) { + this.userId = userId; + this.username = username; + this.role = role; + } + + public int getUserId() { + return userId; + } + + public String getUsername() { + return username; + } + + public Role getRole() { + return role; + } +} diff --git a/src/main/resources/org/example/petshopdesktop/login-view.fxml b/src/main/resources/org/example/petshopdesktop/login-view.fxml new file mode 100644 index 00000000..65199c95 --- /dev/null +++ b/src/main/resources/org/example/petshopdesktop/login-view.fxml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/org/example/petshopdesktop/main-layout-view.fxml b/src/main/resources/org/example/petshopdesktop/main-layout-view.fxml index 9579dff6..983d07a9 100644 --- a/src/main/resources/org/example/petshopdesktop/main-layout-view.fxml +++ b/src/main/resources/org/example/petshopdesktop/main-layout-view.fxml @@ -16,12 +16,12 @@ - From bbf06456f5b12c4a35b02c88681116e0957fd002 Mon Sep 17 00:00:00 2001 From: Harkamal Randhawa Date: Sun, 22 Feb 2026 17:39:42 -0700 Subject: [PATCH 016/127] comments --- .../org/example/petshopdesktop/auth/Role.java | 7 +++++++ .../example/petshopdesktop/auth/UserSession.java | 15 +++++++++++++++ .../controllers/LoginController.java | 9 +++++++++ .../controllers/MainLayoutController.java | 13 +++++++++++++ .../example/petshopdesktop/database/UserDB.java | 9 +++++++++ 5 files changed, 53 insertions(+) diff --git a/src/main/java/org/example/petshopdesktop/auth/Role.java b/src/main/java/org/example/petshopdesktop/auth/Role.java index 64f38459..e631ddf7 100644 --- a/src/main/java/org/example/petshopdesktop/auth/Role.java +++ b/src/main/java/org/example/petshopdesktop/auth/Role.java @@ -1,6 +1,13 @@ package org.example.petshopdesktop.auth; +/* +Petshop Desktop +Purpose: Application role definitions used by session state and role based access control. +*/ public enum Role { + // Administrative access, includes system management screens. ADMIN, + + // Staff access, limited to day to day operational screens. STAFF } diff --git a/src/main/java/org/example/petshopdesktop/auth/UserSession.java b/src/main/java/org/example/petshopdesktop/auth/UserSession.java index 748c9546..2cc4538a 100644 --- a/src/main/java/org/example/petshopdesktop/auth/UserSession.java +++ b/src/main/java/org/example/petshopdesktop/auth/UserSession.java @@ -1,14 +1,24 @@ package org.example.petshopdesktop.auth; +/* +Petshop Desktop +Purpose: In memory session state for the authenticated user. +Notes: Session is process local and cleared on logout or application restart. +*/ public class UserSession { + // Singleton instance used to share session state across controllers. private static UserSession instance; + // Current authenticated username, null when logged out. private String username; + + // Current authenticated role, null when logged out. private Role role; private UserSession() {} + // Lazily initialised singleton accessor. public static UserSession getInstance() { if (instance == null) { instance = new UserSession(); @@ -16,11 +26,13 @@ public class UserSession { return instance; } + // Stores identity and role for the active session. public void login(String username, Role role) { this.username = username; this.role = role; } + // Clears session state and returns the application to an unauthenticated state. public void logout() { this.username = null; this.role = null; @@ -34,10 +46,13 @@ public class UserSession { return role; } + // Convenience check for administrative privileges. + // Role.ADMIN.equals(role) remains safe when role is null. public boolean isAdmin() { return Role.ADMIN.equals(role); } + // Session is considered active only when both username and role are set. public boolean isLoggedIn() { return username != null && role != null; } diff --git a/src/main/java/org/example/petshopdesktop/controllers/LoginController.java b/src/main/java/org/example/petshopdesktop/controllers/LoginController.java index 43bb3334..440c5686 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/LoginController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/LoginController.java @@ -14,6 +14,10 @@ import org.example.petshopdesktop.models.User; import java.sql.SQLException; +/* +Petshop Desktop +Purpose: Authentication controller responsible for validating credentials and initialising the user session. +*/ public class LoginController { @FXML @@ -27,15 +31,18 @@ public class LoginController { @FXML void btnLoginClicked(ActionEvent event) { + // Input normalisation keeps authentication behaviour consistent. String username = txtUsername.getText().trim(); String password = txtPassword.getText(); + // Basic validation to avoid unnecessary database calls. if (username.isEmpty() || password.isEmpty()) { lblError.setText("Please enter username and password."); return; } try { + // Credential verification returns a fully populated User on success. User user = UserDB.authenticate(username, password); if (user == null) { lblError.setText("Invalid username or password."); @@ -43,6 +50,7 @@ public class LoginController { return; } + // Session state is stored in memory for use by controllers and UI RBAC. UserSession.getInstance().login(user.getUsername(), user.getRole()); openMainLayout(); @@ -53,6 +61,7 @@ public class LoginController { private void openMainLayout() { try { + // View transition into the post login application shell. FXMLLoader loader = new FXMLLoader( getClass().getResource("/org/example/petshopdesktop/main-layout-view.fxml")); Scene scene = new Scene(loader.load()); diff --git a/src/main/java/org/example/petshopdesktop/controllers/MainLayoutController.java b/src/main/java/org/example/petshopdesktop/controllers/MainLayoutController.java index 3584a0cc..a910432e 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/MainLayoutController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/MainLayoutController.java @@ -11,6 +11,10 @@ import javafx.scene.layout.StackPane; import javafx.stage.Stage; import org.example.petshopdesktop.auth.UserSession; +/* +Petshop Desktop +Purpose: Main application shell controller, includes navigation and UI level role based access control. +*/ public class MainLayoutController { @FXML @@ -108,6 +112,7 @@ public class MainLayoutController { @FXML void btnLogoutClicked(ActionEvent event) { + // Logout clears session state before returning to the login view. UserSession.getInstance().logout(); try { FXMLLoader loader = new FXMLLoader( @@ -124,16 +129,22 @@ public class MainLayoutController { @FXML public void initialize() { + // RBAC state is applied once during initial layout load. applyRBAC(); + + // Default landing view after successful authentication. loadView("pet-view.fxml"); } private void applyRBAC() { UserSession session = UserSession.getInstance(); + // Session identity is displayed in the header for clarity and auditing. lblUsername.setText(session.getUsername()); lblRole.setText(session.getRole().toString()); + // UI level RBAC hides admin only navigation entries for non admin users. + // setManaged(false) removes the node from layout calculations to avoid empty spacing. boolean isAdmin = session.isAdmin(); btnInventory.setVisible(isAdmin); btnInventory.setManaged(isAdmin); @@ -141,6 +152,8 @@ public class MainLayoutController { btnSuppliers.setManaged(isAdmin); btnProductSuppliers.setVisible(isAdmin); btnProductSuppliers.setManaged(isAdmin); + + // Privileged operations should still be enforced within the relevant controllers and database methods. } /** diff --git a/src/main/java/org/example/petshopdesktop/database/UserDB.java b/src/main/java/org/example/petshopdesktop/database/UserDB.java index 8909d211..3b5f78b4 100644 --- a/src/main/java/org/example/petshopdesktop/database/UserDB.java +++ b/src/main/java/org/example/petshopdesktop/database/UserDB.java @@ -5,6 +5,10 @@ import org.example.petshopdesktop.models.User; import java.sql.*; +/* +Petshop Desktop +Purpose: User authentication and role lookup against the users table. +*/ public class UserDB { /** @@ -29,7 +33,11 @@ public class UserDB { if (rs.next()) { int userId = rs.getInt("user_id"); String uname = rs.getString("username"); + + // Role values are stored in the database as strings and normalised to match the enum. + // Table constraints limit role values, Role.valueOf is expected to be safe under normal operation. Role role = Role.valueOf(rs.getString("role").toUpperCase()); + return new User(userId, uname, role); } } @@ -51,6 +59,7 @@ public class UserDB { ) """; + // Default accounts support initial development and testing, credentials should be rotated or removed for deployment. String seedAdmin = """ INSERT IGNORE INTO users (username, password_hash, role) VALUES ('admin', SHA2('admin123', 256), 'ADMIN') From 1f784f72d166153b1ca5a69c0765058641ab29c3 Mon Sep 17 00:00:00 2001 From: Nikitha Date: Sun, 22 Feb 2026 18:21:22 -0700 Subject: [PATCH 017/127] appionmeent,service --- .../petshopdesktop/DTOs/ServiceDTO.java | 110 ++++++++++++++ .../controllers/AppointmentController.java | 77 +++++++++- .../controllers/ServiceController.java | 135 +++++++++++++----- .../AppointmentDialogController.java | 111 ++++++++++++++ .../ServiceDialogController.java | 98 +++++++++++++ .../database/AppointmentDB.java | 73 ++++++++++ .../petshopdesktop/database/ServiceDB.java | 120 ++++++++++++++++ .../petshopdesktop/models/Appointment.java | 40 ++++++ .../petshopdesktop/models/Service.java | 98 +++++++++++++ .../dialogviews/appointment-dialog-view.fxml | 11 +- 10 files changed, 835 insertions(+), 38 deletions(-) create mode 100644 src/main/java/org/example/petshopdesktop/DTOs/ServiceDTO.java create mode 100644 src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/AppointmentDialogController.java create mode 100644 src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/ServiceDialogController.java create mode 100644 src/main/java/org/example/petshopdesktop/database/AppointmentDB.java create mode 100644 src/main/java/org/example/petshopdesktop/database/ServiceDB.java create mode 100644 src/main/java/org/example/petshopdesktop/models/Appointment.java create mode 100644 src/main/java/org/example/petshopdesktop/models/Service.java diff --git a/src/main/java/org/example/petshopdesktop/DTOs/ServiceDTO.java b/src/main/java/org/example/petshopdesktop/DTOs/ServiceDTO.java new file mode 100644 index 00000000..c876cd3f --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/DTOs/ServiceDTO.java @@ -0,0 +1,110 @@ +package org.example.petshopdesktop.DTOs; + +import javafx.beans.property.SimpleDoubleProperty; +import javafx.beans.property.SimpleIntegerProperty; +import javafx.beans.property.SimpleStringProperty; +import org.example.petshopdesktop.models.Service; + +/** + * The class for ServiceDTO, all service data stored here + */ +public class ServiceDTO { + + private SimpleIntegerProperty serviceId; + private SimpleStringProperty serviceName; + private SimpleStringProperty serviceDesc; + private SimpleIntegerProperty serviceDuration; + private SimpleDoubleProperty servicePrice; + + // constructor + public ServiceDTO(int serviceId, + String serviceName, + String serviceDesc, + int serviceDuration, + double servicePrice) { + + this.serviceId = new SimpleIntegerProperty(serviceId); + this.serviceName = new SimpleStringProperty(serviceName); + this.serviceDesc = new SimpleStringProperty(serviceDesc); + this.serviceDuration = new SimpleIntegerProperty(serviceDuration); + this.servicePrice = new SimpleDoubleProperty(servicePrice); + } + + // getters & setters + + public int getServiceId() { + return serviceId.get(); + } + + public SimpleIntegerProperty serviceIdProperty() { + return serviceId; + } + + public void setServiceId(int serviceId) { + this.serviceId.set(serviceId); + } + + public String getServiceName() { + return serviceName.get(); + } + + public SimpleStringProperty serviceNameProperty() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName.set(serviceName); + } + + public String getServiceDesc() { + return serviceDesc.get(); + } + + public SimpleStringProperty serviceDescProperty() { + return serviceDesc; + } + + public void setServiceDesc(String serviceDesc) { + this.serviceDesc.set(serviceDesc); + } + + public int getServiceDuration() { + return serviceDuration.get(); + } + + public SimpleIntegerProperty serviceDurationProperty() { + return serviceDuration; + } + + public void setServiceDuration(int serviceDuration) { + this.serviceDuration.set(serviceDuration); + } + + public double getServicePrice() { + return servicePrice.get(); + } + + public SimpleDoubleProperty servicePriceProperty() { + return servicePrice; + } + + public void setServicePrice(double servicePrice) { + this.servicePrice.set(servicePrice); + } + + /** + * Converts DTO into Service model (for edit/delete) + */ + public Service toService() { + + Service service = new Service( + getServiceId(), + getServiceName(), + getServiceDesc(), + getServiceDuration(), + getServicePrice() + ); + + return service; + } +} \ No newline at end of file diff --git a/src/main/java/org/example/petshopdesktop/controllers/AppointmentController.java b/src/main/java/org/example/petshopdesktop/controllers/AppointmentController.java index 9eb6dfce..3d5f6d13 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/AppointmentController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/AppointmentController.java @@ -6,9 +6,39 @@ import javafx.scene.control.Button; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.TextField; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; + +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +import java.io.IOException; +import org.example.petshopdesktop.database.AppointmentDB; +import org.example.petshopdesktop.models.Appointment; + public class AppointmentController { + + private ObservableList appointments = + FXCollections.observableArrayList(); + + @FXML + + + public void initialize() { + loadAppointments(); + } + + + + private void loadAppointments() { + appointments.setAll(AppointmentDB.getAllAppointments()); + tvAppointments.setItems(appointments); + } + @FXML private Button btnAdd; @@ -40,7 +70,7 @@ public class AppointmentController { private TableColumn colServiceName; @FXML - private TableView tvAppointments; + private TableView tvAppointments; @FXML private TextField txtSearch; @@ -48,16 +78,61 @@ public class AppointmentController { @FXML void btnAddClicked(ActionEvent event) { + try { + FXMLLoader loader = new FXMLLoader( + getClass().getResource("/appointment-dialog-view.fxml") + ); + + Stage stage = new Stage(); + stage.setScene(new Scene(loader.load())); + stage.showAndWait(); + + loadAppointments(); + + } catch (Exception e) { + e.printStackTrace(); + } } @FXML void btnDeleteClicked(ActionEvent event) { + Appointment selected = tvAppointments.getSelectionModel().getSelectedItem(); + + if (selected == null) return; + + try { + AppointmentDB.deleteAppointment( + selected.getAppointmentId() + ); + loadAppointments(); + } catch (Exception e) { + e.printStackTrace(); + } } @FXML void btnEditClicked(ActionEvent event) { + Appointment selected = tvAppointments.getSelectionModel().getSelectedItem(); + + if (selected == null) return; + + try { + FXMLLoader loader = new FXMLLoader( + getClass().getResource("/appointment-dialog-view.fxml") + ); + + Stage stage = new Stage(); + stage.setScene(new Scene(loader.load())); + stage.showAndWait(); + + loadAppointments(); + + } catch (Exception e) { + e.printStackTrace(); + } } } + diff --git a/src/main/java/org/example/petshopdesktop/controllers/ServiceController.java b/src/main/java/org/example/petshopdesktop/controllers/ServiceController.java index 65f73c7d..d0c361f7 100644 --- a/src/main/java/org/example/petshopdesktop/controllers/ServiceController.java +++ b/src/main/java/org/example/petshopdesktop/controllers/ServiceController.java @@ -2,56 +2,123 @@ package org.example.petshopdesktop.controllers; import javafx.event.ActionEvent; import javafx.fxml.FXML; -import javafx.scene.control.Button; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableView; -import javafx.scene.control.TextField; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.control.*; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.stage.Stage; +import org.example.petshopdesktop.database.ServiceDB; +import org.example.petshopdesktop.models.Service; +import org.example.petshopdesktop.controllers.dialogcontrollers.ServiceDialogController; public class ServiceController { - @FXML - private Button btnAdd; + @FXML private Button btnAdd; + @FXML private Button btnDelete; + @FXML private Button btnEdit; + + @FXML private TableColumn colServiceId; + @FXML private TableColumn colServiceName; + @FXML private TableColumn colServiceDesc; + @FXML private TableColumn colServiceDuration; + @FXML private TableColumn colServicePrice; + + @FXML private TableView tvServices; + + @FXML private TextField txtSearch; @FXML - private Button btnDelete; + public void initialize() { - @FXML - private Button btnEdit; + colServiceId.setCellValueFactory(new PropertyValueFactory<>("serviceId")); + colServiceName.setCellValueFactory(new PropertyValueFactory<>("serviceName")); + colServiceDesc.setCellValueFactory(new PropertyValueFactory<>("serviceDesc")); + colServiceDuration.setCellValueFactory(new PropertyValueFactory<>("serviceDuration")); + colServicePrice.setCellValueFactory(new PropertyValueFactory<>("servicePrice")); - @FXML - private TableColumn colServiceDesc; + loadServices(); + } - @FXML - private TableColumn colServiceDuration; + private void loadServices() { + try { + tvServices.setItems(ServiceDB.getServices()); + } catch (Exception e) { + showAlert("Database Error", "Unable to load services."); + e.printStackTrace(); + } + } - @FXML - private TableColumn colServiceId; - - @FXML - private TableColumn colServiceName; - - @FXML - private TableColumn colServicePrice; - - @FXML - private TableView tvServices; - - @FXML - private TextField txtSearch; @FXML void btnAddClicked(ActionEvent event) { - - } - - @FXML - void btnDeleteClicked(ActionEvent event) { - + openDialog(null); + loadServices(); } @FXML void btnEditClicked(ActionEvent event) { + Service selected = tvServices.getSelectionModel().getSelectedItem(); + + if (selected == null) { + showAlert("Select Service", "Please select a service to edit."); + return; + } + + openDialog(selected); + loadServices(); } -} + @FXML + void btnDeleteClicked(ActionEvent event) { + + Service selected = tvServices.getSelectionModel().getSelectedItem(); + + if (selected == null) { + showAlert("Select Service", "Please select a service to delete."); + return; + } + + try { + ServiceDB.deleteService(selected.getServiceId()); + loadServices(); + } catch (Exception e) { + showAlert("Database Error", "Unable to delete service."); + e.printStackTrace(); + } + } + + private void openDialog(Service service) { + + try { + FXMLLoader loader = new FXMLLoader( + getClass().getResource( + "/org.example.petshopdesktop/dialogviews/ServiceDialogView.fxml" + ) + ); + + Parent root = loader.load(); + + // IMPORTANT: specify controller type + ServiceDialogController controller = + loader.getController(); + + controller.setService(service); + + Stage stage = new Stage(); + stage.setScene(new Scene(root)); + stage.showAndWait(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + private void showAlert(String title, String msg) { + Alert alert = new Alert(Alert.AlertType.INFORMATION); + alert.setTitle(title); + alert.setHeaderText(null); + alert.setContentText(msg); + alert.showAndWait(); + } +} \ No newline at end of file diff --git a/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/AppointmentDialogController.java b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/AppointmentDialogController.java new file mode 100644 index 00000000..af607180 --- /dev/null +++ b/src/main/java/org/example/petshopdesktop/controllers/dialogcontrollers/AppointmentDialogController.java @@ -0,0 +1,111 @@ +package org.example.petshopdesktop.controllers.dialogcontrollers; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.scene.Node; +import javafx.scene.control.Button; +import javafx.scene.control.ComboBox; +import javafx.scene.control.DatePicker; +import javafx.scene.control.Label; +import javafx.scene.input.MouseEvent; +import javafx.stage.Stage; + +import org.example.petshopdesktop.database.AppointmentDB; +import org.example.petshopdesktop.models.Appointment; + +import java.sql.Time; + +public class AppointmentDialogController { + + @FXML + private Button btnCancel; + + @FXML + private Button btnSave; + + @FXML + private ComboBox cbAppointmentStatus; + + @FXML + private ComboBox