├── .gitignore ├── README.md ├── build.gradle ├── doc └── README.md ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── imgs ├── additem.JPG ├── loginpage.JPG └── mainpage.JPG ├── lib ├── jgoodies-forms-1.8.0-sources.jar └── mysql-connector-java-5.1.38-bin.jar ├── products.sql ├── settings.gradle └── src └── main ├── java └── easy │ ├── dao │ └── ProductDAO.java │ ├── gui │ ├── AddNewProductItem.java │ ├── LogIn.java │ ├── ProductSearch.java │ ├── ProductTableModel.java │ ├── RegistrationPage.java │ └── StartUpPage.java │ ├── model │ └── Product.java │ └── util │ ├── EasyConstant.java │ └── SecureRandomTagGen.java └── resource ├── application.properties ├── easyInlogo.png ├── rsz_1add-item-icon.png ├── rsz_1easyinlogo.png ├── rsz_2easyinlogo.png ├── rsz_billingreport.png ├── rsz_easyinlogo.png ├── rsz_login.png ├── rsz_password_icon.png ├── rsz_sell.png └── rsz_update-icon.png /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .setting 3 | bin 4 | .classpath 5 | .project 6 | .settings 7 | .idea 8 | build -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Easy-Inventory 2 | Simple inventory management system build in Swing Java. It uses MySQL to store data. This can be use in small store and manage personal stuff. 3 | 4 | ###Layouts 5 | ![Main relative page](https://github.com/achyutdev/Easy-Inventory/blob/master/imgs/mainpage.JPG) 6 | 7 | | ![Login relative page](https://github.com/achyutdev/Easy-Inventory/blob/master/imgs/loginpage.JPG) | ![Update page](https://github.com/achyutdev/Easy-Inventory/blob/master/imgs/additem.JPG) 8 | |-------------|---------------: 9 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | 2 | apply plugin: 'java-library' 3 | 4 | repositories { 5 | jcenter() 6 | } 7 | jar { 8 | manifest { 9 | attributes 'Main-Class': 'easy.gui.StartUpPage.java' 10 | } 11 | } 12 | dependencies { 13 | 14 | compile files('lib/jgoodies-forms-1.8.0-sources.jar') 15 | compile files('lib/mysql-connector-java-5.1.38-bin.jar') 16 | 17 | compile group: 'org.springframework', name: 'spring-context', version: '5.0.8.RELEASE' 18 | 19 | } -------------------------------------------------------------------------------- /doc/README.md: -------------------------------------------------------------------------------- 1 | ##Test 2 | 3 | This is the test page 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/achyutdev/Easy-Inventory/cb3a72a6cd3b4e275fdd09a80ae1548e496839d4/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Dec 27 14:23:40 EST 2019 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip 3 | distributionBase=GRADLE_USER_HOME 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS='"-Xmx64m"' 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS="-Xmx64m" 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /imgs/additem.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/achyutdev/Easy-Inventory/cb3a72a6cd3b4e275fdd09a80ae1548e496839d4/imgs/additem.JPG -------------------------------------------------------------------------------- /imgs/loginpage.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/achyutdev/Easy-Inventory/cb3a72a6cd3b4e275fdd09a80ae1548e496839d4/imgs/loginpage.JPG -------------------------------------------------------------------------------- /imgs/mainpage.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/achyutdev/Easy-Inventory/cb3a72a6cd3b4e275fdd09a80ae1548e496839d4/imgs/mainpage.JPG -------------------------------------------------------------------------------- /lib/jgoodies-forms-1.8.0-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/achyutdev/Easy-Inventory/cb3a72a6cd3b4e275fdd09a80ae1548e496839d4/lib/jgoodies-forms-1.8.0-sources.jar -------------------------------------------------------------------------------- /lib/mysql-connector-java-5.1.38-bin.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/achyutdev/Easy-Inventory/cb3a72a6cd3b4e275fdd09a80ae1548e496839d4/lib/mysql-connector-java-5.1.38-bin.jar -------------------------------------------------------------------------------- /products.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 4.1.14 3 | -- http://www.phpmyadmin.net 4 | -- 5 | -- Host: 127.0.0.1 6 | -- Generation Time: Dec 17, 2015 at 07:30 PM 7 | -- Server version: 5.6.17 8 | -- PHP Version: 5.5.12 9 | 10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 11 | SET time_zone = "+00:00"; 12 | 13 | 14 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 15 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 16 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 17 | /*!40101 SET NAMES utf8 */; 18 | 19 | -- 20 | -- Database: `inventorymgtsys` 21 | -- 22 | 23 | -- -------------------------------------------------------- 24 | 25 | -- 26 | -- Table structure for table `products` 27 | -- 28 | 29 | CREATE TABLE IF NOT EXISTS `products` ( 30 | `id` int(11) NOT NULL AUTO_INCREMENT, 31 | `tag` varchar(45) DEFAULT NULL, 32 | `name` varchar(45) DEFAULT NULL, 33 | `company` varchar(45) DEFAULT NULL, 34 | `cost_price` double DEFAULT NULL, 35 | `selling_price` double DEFAULT NULL, 36 | `profit` double DEFAULT NULL, 37 | `status` tinyint(1) DEFAULT NULL, 38 | PRIMARY KEY (`id`) 39 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ; 40 | 41 | -- 42 | -- Dumping data for table `products` 43 | -- 44 | 45 | INSERT INTO `products` (`id`, `tag`, `name`, `company`, `cost_price`, `selling_price`, `profit`, `status`) VALUES 46 | (1, '131312s', 'Milk', 'Daber', 341, 32, NULL, 0), 47 | (2, '3423a', 'Tea', 'Jupitor', 123.435, 624, NULL, 0), 48 | (3, '484AOSGGF1', 'Laptop', 'Asus', 23.432, 24.36928, NULL, 0), 49 | (4, '739184ew', 'Trimer', 'Jpt-J', 123.34, 345, NULL, 0), 50 | (12, '3IURSDNNK', 'Moffeee', 'TestMart', 32.99, 33.319900000000004, 0.3299000000000021, 1), 51 | (13, 'KIOFG2B0TV', 'dgs', 'twert', 231, 233.31, 2.3100000000000023, 0), 52 | (14, 'Q9116BQFCV', 'Test Pro', 'Ptotp', 432, 444.96, 12.95999999999998, 0), 53 | (15, 'IPKVDTC4I5', 'Trunk', 'Cisco', 321.9, 337.995, 16.095000000000027, 0), 54 | (17, 'I3K1Q1FOMJ', 'Hard Drive', 'HP', 324, 324, 0, 1), 55 | (18, 'JVVUTQTTPH', 'Electric Bulb', 'GE', 34, 41.14, 2.5600000000000023, 7), 56 | (19, 'T9L3SMD13J', 'HDMI Cable', 'Dev Electric', 69.09, 72.5445, 3.454499999999996, 0), 57 | (20, 'TPO88Q4FB6', 'HeadSet', 'Beat', 325, 344.5, 19.5, 0); 58 | 59 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 60 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 61 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 62 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'EasyInventory' 2 | -------------------------------------------------------------------------------- /src/main/java/easy/dao/ProductDAO.java: -------------------------------------------------------------------------------- 1 | package easy.dao; 2 | 3 | import easy.model.Product; 4 | import org.springframework.beans.factory.annotation.Value; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.*; 8 | import java.text.DecimalFormat; 9 | import java.util.ArrayList; 10 | 11 | import static easy.util.EasyConstant.INSERT_PRODUCT_QUERY; 12 | 13 | 14 | @Component 15 | public class ProductDAO { 16 | 17 | private Connection myConn; 18 | private DecimalFormat df = new DecimalFormat("#.00"); 19 | 20 | @Value("${username}") 21 | private String dbUser; 22 | 23 | @Value("${password}") 24 | private String dbPassword; 25 | 26 | @Value("${dburl}") 27 | private String dbUrl; 28 | 29 | 30 | public ProductDAO() throws Exception { 31 | this.myConn = DriverManager.getConnection(dbUrl, dbUser, dbPassword); 32 | 33 | } 34 | 35 | // Add New Product items 36 | public void addProduct(Product product) throws Exception { 37 | PreparedStatement myStmt = null; 38 | try { 39 | myStmt = myConn.prepareStatement(INSERT_PRODUCT_QUERY); 40 | 41 | myStmt.setString(1, product.getTag()); 42 | myStmt.setString(2, product.getName()); 43 | myStmt.setString(3, product.getCompany()); 44 | myStmt.setDouble(4, product.getCp()); 45 | myStmt.setDouble(5, product.getSp()); 46 | myStmt.setDouble(6, product.getProfit()); 47 | myStmt.setBoolean(7, product.getStatus()); 48 | 49 | myStmt.executeUpdate(); 50 | 51 | } finally { 52 | if (myStmt != null) 53 | myStmt.close(); 54 | } 55 | } 56 | 57 | //Delete 58 | public void deleteItem(int productId) throws SQLException { 59 | PreparedStatement myStmt = null; 60 | 61 | try { 62 | myStmt = myConn.prepareStatement("DELETE FROM `inventorymgtsys`.`products` WHERE `products`.`id` = ?"); 63 | 64 | myStmt.setInt(1, productId); 65 | 66 | myStmt.executeUpdate(); 67 | 68 | } finally { 69 | myStmt.close(); 70 | } 71 | } 72 | 73 | // Get All product 74 | public ArrayList getAllProduct() throws Exception { 75 | ArrayList list = new ArrayList(); 76 | 77 | Statement myStmt = null; 78 | ResultSet myRst = null; 79 | 80 | try { 81 | myStmt = myConn.createStatement(); 82 | myRst = myStmt.executeQuery("select * from products"); 83 | 84 | while (myRst.next()) { 85 | Product tempEmployee = converRowToProduct(myRst); 86 | list.add(tempEmployee); 87 | } 88 | 89 | return list; 90 | } catch (Exception e) { 91 | e.printStackTrace(); 92 | } finally { 93 | close(myStmt, myRst); 94 | } 95 | return list; 96 | 97 | } 98 | 99 | // Search Product 100 | public ArrayList searchProduct(String name) throws SQLException { 101 | ArrayList list = new ArrayList<>(); 102 | 103 | java.sql.PreparedStatement mystmt = null; 104 | ResultSet myRst = null; 105 | 106 | try { 107 | name += "%"; 108 | mystmt = myConn.prepareStatement("SELECT * FROM products WHERE name LIKE ?"); 109 | 110 | mystmt.setString(1, name); 111 | 112 | myRst = mystmt.executeQuery(); 113 | 114 | while (myRst.next()) { 115 | Product tmp = converRowToProduct(myRst); 116 | list.add(tmp); 117 | } 118 | return list; 119 | } finally { 120 | close(mystmt, myRst); 121 | } 122 | } 123 | 124 | private void close(Statement myStmt, ResultSet myRs) throws SQLException { 125 | close(null, myStmt, myRs); 126 | } 127 | 128 | private static void close(Connection myConn, Statement myStmt, ResultSet myRs) throws SQLException { 129 | 130 | if (myRs != null) { 131 | myRs.close(); 132 | } 133 | 134 | if (myStmt != null) { 135 | 136 | } 137 | 138 | if (myConn != null) { 139 | myConn.close(); 140 | } 141 | } 142 | 143 | private Product converRowToProduct(ResultSet myRst) throws SQLException { 144 | 145 | int id = myRst.getInt("id"); 146 | String tag = myRst.getString("tag"); 147 | String name = myRst.getString("name"); 148 | String company = myRst.getString("company"); 149 | double cprice = myRst.getDouble("cost_price"); 150 | double sprice = myRst.getDouble("selling_price"); 151 | boolean status = myRst.getBoolean("status"); 152 | 153 | Product product = new Product(id, tag, name, company, cprice, sprice, status); 154 | return product; 155 | } 156 | 157 | public void UpdateProduct(Product product) throws SQLException, InterruptedException { 158 | PreparedStatement myStmt = null; 159 | 160 | try { 161 | myStmt = myConn.prepareStatement("UPDATE products" + 162 | " set name= ?, company=?, cost_price=?, selling_price=?, status=?, tag=?" + 163 | " where id=?"); 164 | 165 | myStmt.setString(1, product.getName()); 166 | myStmt.setString(2, product.getCompany()); 167 | myStmt.setDouble(3, product.getCp()); 168 | myStmt.setDouble(4, product.getSp()); 169 | myStmt.setDouble(5, product.getProfit()); 170 | myStmt.setString(6, product.getTag()); 171 | myStmt.setInt(7, product.getId()); 172 | 173 | System.out.println(product); 174 | myStmt.executeUpdate(); 175 | 176 | } finally { 177 | myStmt.close(); 178 | } 179 | } 180 | 181 | public String getTotalItems() throws SQLException { 182 | Statement myStmt = null; 183 | ResultSet myRst = null; 184 | String total = null; 185 | 186 | try { 187 | myStmt = myConn.createStatement(); 188 | myRst = myStmt.executeQuery("SELECT COUNT(*) FROM products"); 189 | while (myRst.next()) 190 | total = myRst.getString("count(*)"); 191 | } catch (SQLException e) { 192 | e.printStackTrace(); 193 | } finally { 194 | close(myStmt, myRst); 195 | } 196 | return total; 197 | 198 | } 199 | 200 | 201 | public String getAvaiItems() throws SQLException { 202 | Statement myStmt = null; 203 | ResultSet myRst = null; 204 | String avai = null; 205 | 206 | try { 207 | myStmt = myConn.createStatement(); 208 | myRst = myStmt.executeQuery("SELECT COUNT(*) FROM products where status=1"); 209 | while (myRst.next()) 210 | avai = myRst.getString("count(*)"); 211 | } catch (SQLException e) { 212 | e.printStackTrace(); 213 | } finally { 214 | close(myStmt, myRst); 215 | } 216 | return avai; 217 | } 218 | 219 | public String getSoldItems() throws SQLException { 220 | Statement myStmt = null; 221 | ResultSet myRst = null; 222 | String sold = null; 223 | 224 | try { 225 | myStmt = myConn.createStatement(); 226 | myRst = myStmt.executeQuery("SELECT COUNT(*) FROM products where status=0"); 227 | while (myRst.next()) 228 | sold = myRst.getString("count(*)"); 229 | } catch (SQLException e) { 230 | e.printStackTrace(); 231 | } finally { 232 | close(myStmt, myRst); 233 | } 234 | return sold; 235 | } 236 | 237 | public String getTotalInvest() throws SQLException { 238 | Statement myStmt = null; 239 | ResultSet myRst = null; 240 | String totalInv = null; 241 | 242 | 243 | try { 244 | myStmt = myConn.createStatement(); 245 | myRst = myStmt.executeQuery("SELECT SUM(cost_price) FROM products"); 246 | while (myRst.next()) 247 | totalInv = df.format(myRst.getDouble("sum(cost_price)")).toString(); 248 | } catch (SQLException e) { 249 | e.printStackTrace(); 250 | } finally { 251 | close(myStmt, myRst); 252 | } 253 | return totalInv; 254 | } 255 | 256 | public String getTotalSell() throws SQLException { 257 | Statement myStmt = null; 258 | ResultSet myRst = null; 259 | String totalsell = null; 260 | 261 | try { 262 | myStmt = myConn.createStatement(); 263 | myRst = myStmt.executeQuery("SELECT SUM(selling_price) FROM products"); 264 | while (myRst.next()) 265 | totalsell = df.format(myRst.getDouble("sum(selling_price)")).toString(); 266 | } catch (SQLException e) { 267 | e.printStackTrace(); 268 | } finally { 269 | close(myStmt, myRst); 270 | } 271 | return totalsell; 272 | } 273 | 274 | public String getProfit() throws SQLException { 275 | Statement myStmt = null; 276 | ResultSet myRst = null; 277 | String profit = null; 278 | 279 | try { 280 | myStmt = myConn.createStatement(); 281 | myRst = myStmt.executeQuery("SELECT SUM(profit) FROM products"); 282 | while (myRst.next()) 283 | profit = df.format(myRst.getDouble("sum(profit)")).toString(); 284 | } catch (SQLException e) { 285 | e.printStackTrace(); 286 | } finally { 287 | close(myStmt, myRst); 288 | } 289 | return profit; 290 | } 291 | 292 | public void soldItem(int id) throws SQLException { 293 | PreparedStatement myStmt = null; 294 | 295 | try { 296 | myStmt = myConn.prepareStatement("UPDATE `products` SET `status` = '0' WHERE `products`.`id` = ?"); 297 | 298 | myStmt.setInt(1, id); 299 | 300 | myStmt.executeUpdate(); 301 | 302 | } finally { 303 | myStmt.close(); 304 | } 305 | 306 | } 307 | } 308 | -------------------------------------------------------------------------------- /src/main/java/easy/gui/AddNewProductItem.java: -------------------------------------------------------------------------------- 1 | package easy.gui; 2 | 3 | import java.awt.BorderLayout; 4 | import java.awt.Color; 5 | import java.awt.FlowLayout; 6 | import java.awt.Font; 7 | import java.awt.event.ActionEvent; 8 | import java.awt.event.ActionListener; 9 | 10 | import javax.swing.BorderFactory; 11 | import javax.swing.GroupLayout; 12 | import javax.swing.GroupLayout.Alignment; 13 | import javax.swing.ImageIcon; 14 | import javax.swing.JButton; 15 | import javax.swing.JDialog; 16 | import javax.swing.JLabel; 17 | import javax.swing.JOptionPane; 18 | import javax.swing.JPanel; 19 | import javax.swing.JSlider; 20 | import javax.swing.JTextField; 21 | import javax.swing.LayoutStyle.ComponentPlacement; 22 | import javax.swing.border.EmptyBorder; 23 | import javax.swing.event.ChangeEvent; 24 | import javax.swing.event.ChangeListener; 25 | 26 | import easy.dao.ProductDAO; 27 | import easy.model.Product; 28 | import easy.util.SecureRandomTagGen; 29 | 30 | public class AddNewProductItem extends JDialog { 31 | 32 | private static final long serialVersionUID = 1L; 33 | private final JPanel contentPanel = new JPanel(); 34 | private JTextField productNameTextField; 35 | private JTextField brandTextField; 36 | private JTextField tagNumtextField; 37 | private JTextField cpTextField; 38 | private JSlider profitMargin; 39 | private JPanel addTitleField; 40 | 41 | private String tagNum; 42 | 43 | private ProductDAO productdao; 44 | private ProductSearch productsearch; 45 | 46 | private Product previousProduct = null; 47 | private boolean updateMode = false; 48 | 49 | private JTextField sptextField; 50 | 51 | public AddNewProductItem(ProductDAO productdao, ProductSearch productsearch, Product previousProduct, 52 | boolean updateMode) { 53 | this(); 54 | this.productdao = productdao; 55 | this.productsearch = productsearch; 56 | this.previousProduct = previousProduct; 57 | this.updateMode = updateMode; 58 | 59 | if (updateMode) { 60 | setTitle("Update Item"); 61 | populateGui(previousProduct); 62 | 63 | // 64 | JLabel lblAddNewItem = new JLabel(" Update Product Details"); 65 | lblAddNewItem.setFont(new Font("Segoe Script", Font.BOLD, 18)); 66 | lblAddNewItem 67 | .setIcon(new ImageIcon("rsz_update-icon.png")); 68 | addTitleField.add(lblAddNewItem); 69 | } else { 70 | JLabel lblAddNewItem = new JLabel(" Add Product Details"); 71 | lblAddNewItem.setFont(new Font("Segoe Script", Font.BOLD, 18)); 72 | lblAddNewItem 73 | .setIcon(new ImageIcon("rsz_1add-item-icon.png")); 74 | addTitleField.add(lblAddNewItem); 75 | } 76 | } 77 | 78 | public AddNewProductItem(ProductDAO productdao, ProductSearch productsearch) { 79 | this(productdao, productsearch, null, false); 80 | } 81 | 82 | private void populateGui(Product previousProduct) { 83 | productNameTextField.setText(previousProduct.getName()); 84 | brandTextField.setText(previousProduct.getCompany()); 85 | cpTextField.setText(previousProduct.getCp() + ""); 86 | sptextField.setText(previousProduct.getSp() + ""); 87 | tagNumtextField.setText(previousProduct.getTag()); 88 | profitMargin.setValue(getProfitPercentage(previousProduct.getSp(), previousProduct.getCp())); 89 | } 90 | 91 | private int getProfitPercentage(double d, double e) { 92 | 93 | return (int) ((d - e) * 100 / e); 94 | } 95 | 96 | public AddNewProductItem() { 97 | setTitle("Add New Item"); 98 | setBounds(100, 100, 450, 448); 99 | getContentPane().setLayout(new BorderLayout()); 100 | contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); 101 | getContentPane().add(contentPanel, BorderLayout.CENTER); 102 | 103 | addTitleField = new JPanel(); 104 | 105 | JPanel inputDetailsPanel = new JPanel(); 106 | GroupLayout gl_contentPanel = new GroupLayout(contentPanel); 107 | gl_contentPanel.setHorizontalGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING) 108 | .addGroup(gl_contentPanel.createSequentialGroup().addGap(47) 109 | .addComponent(addTitleField, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE).addGap(58)) 110 | .addGroup(gl_contentPanel.createSequentialGroup().addGap(23) 111 | .addComponent(inputDetailsPanel, GroupLayout.PREFERRED_SIZE, 368, GroupLayout.PREFERRED_SIZE) 112 | .addContainerGap(31, Short.MAX_VALUE))); 113 | gl_contentPanel.setVerticalGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING) 114 | .addGroup(gl_contentPanel.createSequentialGroup().addContainerGap() 115 | .addComponent(addTitleField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 116 | GroupLayout.PREFERRED_SIZE) 117 | .addPreferredGap(ComponentPlacement.UNRELATED) 118 | .addComponent(inputDetailsPanel, GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE).addGap(7))); 119 | 120 | JLabel lblproductName = new JLabel("Product Name"); 121 | 122 | productNameTextField = new JTextField(); 123 | productNameTextField.setColumns(10); 124 | 125 | JLabel lblBrandName = new JLabel("Brand Name"); 126 | 127 | brandTextField = new JTextField(); 128 | brandTextField.setColumns(10); 129 | 130 | JLabel lblTagNumber = new JLabel("Tag Number"); 131 | 132 | tagNumtextField = new JTextField(); 133 | tagNumtextField.setColumns(10); 134 | 135 | JButton btnGenerate = new JButton("Generate"); 136 | 137 | btnGenerate.addActionListener(new ActionListener() { 138 | public void actionPerformed(ActionEvent e) { 139 | SecureRandomTagGen test = new SecureRandomTagGen(); 140 | tagNum = test.getTagNumber().toUpperCase(); 141 | tagNumtextField.setText(tagNum); 142 | } 143 | 144 | }); 145 | 146 | JLabel lblPrice = new JLabel("Cost Price"); 147 | 148 | cpTextField = new JTextField(); 149 | cpTextField.addActionListener(new ActionListener() { 150 | public void actionPerformed(ActionEvent e) { 151 | cpTextField.setBorder(null); 152 | } 153 | }); 154 | cpTextField.setColumns(10); 155 | 156 | JLabel labelPersentage = new JLabel("0%"); 157 | 158 | profitMargin = new JSlider(); 159 | profitMargin.setValue(0); 160 | profitMargin.setMinimum(-100); 161 | profitMargin.addChangeListener(new ChangeListener() { 162 | public void stateChanged(ChangeEvent arg0) { 163 | try { 164 | int percentage = profitMargin.getValue(); 165 | double costp = Double.parseDouble(cpTextField.getText()); 166 | labelPersentage.setText(String.valueOf(profitMargin.getValue()) + "%"); 167 | sptextField.setText(String.valueOf((double) (costp + costp * percentage * 0.01))); 168 | } catch (NumberFormatException e) { 169 | JOptionPane.showMessageDialog(productsearch, "Invalid Cost Price.", "Error", 170 | JOptionPane.ERROR_MESSAGE); 171 | cpTextField.setBorder(BorderFactory.createLineBorder(Color.red)); 172 | } 173 | 174 | } 175 | }); 176 | 177 | JLabel lblProfitMargin = new JLabel("Profit Margin"); 178 | 179 | JLabel lblSellingPrice = new JLabel("Selling Price"); 180 | 181 | sptextField = new JTextField(); 182 | sptextField.setColumns(10); 183 | 184 | GroupLayout gl_inputDetailsPanel = new GroupLayout(inputDetailsPanel); 185 | gl_inputDetailsPanel.setHorizontalGroup(gl_inputDetailsPanel.createParallelGroup(Alignment.LEADING) 186 | .addGroup(gl_inputDetailsPanel.createSequentialGroup().addContainerGap().addGroup(gl_inputDetailsPanel 187 | .createParallelGroup(Alignment.LEADING) 188 | .addGroup(gl_inputDetailsPanel 189 | .createParallelGroup( 190 | Alignment.LEADING) 191 | .addGroup(gl_inputDetailsPanel.createParallelGroup(Alignment.LEADING) 192 | .addGroup(gl_inputDetailsPanel.createSequentialGroup() 193 | .addGroup(gl_inputDetailsPanel.createParallelGroup(Alignment.LEADING) 194 | .addComponent(lblproductName).addComponent(lblBrandName) 195 | .addComponent(lblTagNumber)) 196 | .addGap(18)) 197 | .addGroup( 198 | gl_inputDetailsPanel.createSequentialGroup() 199 | .addComponent(lblPrice, GroupLayout.DEFAULT_SIZE, 71, 200 | Short.MAX_VALUE) 201 | .addGap(27))) 202 | .addGroup(gl_inputDetailsPanel.createSequentialGroup().addComponent(lblProfitMargin) 203 | .addPreferredGap(ComponentPlacement.RELATED))) 204 | .addGroup( 205 | gl_inputDetailsPanel.createSequentialGroup().addComponent(lblSellingPrice).addGap(28))) 206 | .addGroup(gl_inputDetailsPanel.createParallelGroup(Alignment.TRAILING) 207 | .addComponent(sptextField, GroupLayout.DEFAULT_SIZE, 246, Short.MAX_VALUE) 208 | .addComponent(brandTextField, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 246, 209 | Short.MAX_VALUE) 210 | .addComponent(productNameTextField, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 246, 211 | Short.MAX_VALUE) 212 | .addGroup(Alignment.LEADING, gl_inputDetailsPanel.createSequentialGroup() 213 | .addComponent(tagNumtextField, GroupLayout.PREFERRED_SIZE, 149, 214 | GroupLayout.PREFERRED_SIZE) 215 | .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(btnGenerate)) 216 | .addComponent(cpTextField, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 246, 217 | Short.MAX_VALUE) 218 | .addGroup(gl_inputDetailsPanel.createSequentialGroup() 219 | .addPreferredGap(ComponentPlacement.RELATED) 220 | .addComponent(profitMargin, GroupLayout.PREFERRED_SIZE, 180, 221 | GroupLayout.PREFERRED_SIZE) 222 | .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(labelPersentage, 223 | GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE) 224 | .addGap(8))) 225 | .addGap(12))); 226 | gl_inputDetailsPanel.setVerticalGroup(gl_inputDetailsPanel.createParallelGroup(Alignment.LEADING) 227 | .addGroup(gl_inputDetailsPanel.createSequentialGroup().addGap(33) 228 | .addGroup(gl_inputDetailsPanel.createParallelGroup(Alignment.BASELINE) 229 | .addComponent(lblproductName).addComponent(productNameTextField, 230 | GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 231 | GroupLayout.PREFERRED_SIZE)) 232 | .addGap(18) 233 | .addGroup(gl_inputDetailsPanel.createParallelGroup(Alignment.LEADING).addComponent(lblBrandName) 234 | .addComponent(brandTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 235 | GroupLayout.PREFERRED_SIZE)) 236 | .addGap(18) 237 | .addGroup(gl_inputDetailsPanel.createParallelGroup(Alignment.BASELINE) 238 | .addComponent(lblTagNumber) 239 | .addComponent(tagNumtextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 240 | GroupLayout.PREFERRED_SIZE) 241 | .addComponent(btnGenerate)) 242 | .addGap(18) 243 | .addGroup(gl_inputDetailsPanel.createParallelGroup(Alignment.LEADING).addComponent(lblPrice) 244 | .addComponent(cpTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 245 | GroupLayout.PREFERRED_SIZE)) 246 | .addGap(18) 247 | .addGroup(gl_inputDetailsPanel.createParallelGroup(Alignment.LEADING, false) 248 | .addComponent(labelPersentage, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, 249 | Short.MAX_VALUE) 250 | .addComponent(lblProfitMargin).addComponent(profitMargin, GroupLayout.DEFAULT_SIZE, 251 | GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 252 | .addGap(18) 253 | .addGroup(gl_inputDetailsPanel.createParallelGroup(Alignment.BASELINE) 254 | .addComponent(lblSellingPrice).addComponent(sptextField, GroupLayout.PREFERRED_SIZE, 255 | GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 256 | .addContainerGap(21, Short.MAX_VALUE))); 257 | inputDetailsPanel.setLayout(gl_inputDetailsPanel); 258 | { 259 | // JLabel lblAddNewItem = new JLabel(" Add Product Details"); 260 | // lblAddNewItem.setFont(new Font("Segoe Script", Font.BOLD, 18)); 261 | // lblAddNewItem 262 | // .setIcon(new 263 | // ImageIcon("C:\\Users\\Dev\\workspace\\InventoryMgtSys\\lib\\rsz_1add-item-icon.png")); 264 | // addTitleField.add(lblAddNewItem); 265 | } 266 | contentPanel.setLayout(gl_contentPanel); 267 | { 268 | JPanel buttonPane = new JPanel(); 269 | buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); 270 | getContentPane().add(buttonPane, BorderLayout.SOUTH); 271 | { 272 | JButton addButton = new JButton("Add"); 273 | addButton.addActionListener(new ActionListener() { 274 | public void actionPerformed(ActionEvent arg0) { 275 | addProductDetailInDB(); 276 | 277 | } 278 | 279 | // public void errorHandler(JTextField field, String str){ 280 | // JOptionPane.showMessageDialog(null, "Invalid Input 281 | // "+str+"."); 282 | // cpTextField.setBorder(BorderFactory.createLineBorder(Color.red)); 283 | // } 284 | public void addProductDetailInDB() { 285 | String productName = productNameTextField.getText(); 286 | String productTagNum = tagNum; 287 | String productBrand = brandTextField.getText(); 288 | double cprice = getPriceDoubleValue(cpTextField); 289 | double sprice = getPriceDoubleValue(sptextField); 290 | boolean status = true; 291 | // int id = 292 | 293 | Product tmpProduct = null; 294 | if (updateMode) { 295 | tmpProduct = previousProduct; 296 | tmpProduct.setName(productName); 297 | tmpProduct.setCompany(productBrand); 298 | tmpProduct.setTag(productTagNum); 299 | tmpProduct.setCp(cprice); 300 | tmpProduct.setSp(sprice); 301 | 302 | } else { 303 | tmpProduct = new Product(productTagNum, productName, productBrand, cprice, sprice, status); 304 | } 305 | try { 306 | // save to db 307 | if (updateMode) { 308 | productdao.UpdateProduct(tmpProduct); 309 | } else { 310 | productdao.addProduct(tmpProduct); 311 | } 312 | // closing dialog box 313 | setVisible(false); 314 | dispose(); 315 | 316 | // refresh panel 317 | productsearch.refreshProductView(); 318 | 319 | // show saved message 320 | JOptionPane.showMessageDialog(productsearch, "Product added Successfully.", 321 | "New Product Added", JOptionPane.INFORMATION_MESSAGE); 322 | 323 | } catch (Exception e) { 324 | JOptionPane.showMessageDialog(productsearch, "Error Saving Product Details.", "Error", 325 | JOptionPane.ERROR_MESSAGE); 326 | } 327 | 328 | } 329 | 330 | protected double getPriceDoubleValue(JTextField field) { 331 | try { 332 | return Double.parseDouble(field.getText()); 333 | } catch (Exception e) { 334 | JOptionPane.showMessageDialog(null, "Invalid Input price."); 335 | field.setBorder(BorderFactory.createLineBorder(Color.red)); 336 | } 337 | return 0; 338 | } 339 | 340 | }); 341 | addButton.setActionCommand("OK"); 342 | buttonPane.add(addButton); 343 | getRootPane().setDefaultButton(addButton); 344 | 345 | } 346 | { 347 | JButton cancelButton = new JButton("Cancel"); 348 | cancelButton.addActionListener(new ActionListener() { 349 | public void actionPerformed(ActionEvent e) { 350 | dispose(); 351 | } 352 | }); 353 | cancelButton.setActionCommand("Cancel"); 354 | buttonPane.add(cancelButton); 355 | } 356 | 357 | } 358 | 359 | } 360 | 361 | } 362 | -------------------------------------------------------------------------------- /src/main/java/easy/gui/LogIn.java: -------------------------------------------------------------------------------- 1 | package easy.gui; 2 | 3 | import java.awt.BorderLayout; 4 | import java.awt.FlowLayout; 5 | 6 | import javax.swing.JButton; 7 | import javax.swing.JDialog; 8 | import javax.swing.JPanel; 9 | import javax.swing.border.EmptyBorder; 10 | 11 | import easy.dao.ProductDAO; 12 | 13 | import java.awt.event.ActionListener; 14 | import java.awt.event.ActionEvent; 15 | import javax.swing.GroupLayout; 16 | import javax.swing.GroupLayout.Alignment; 17 | import javax.swing.JLabel; 18 | import javax.swing.JOptionPane; 19 | import javax.swing.JTextField; 20 | import javax.swing.LayoutStyle.ComponentPlacement; 21 | import java.awt.Font; 22 | import javax.swing.ImageIcon; 23 | import java.awt.Toolkit; 24 | import java.awt.SystemColor; 25 | import javax.swing.JPasswordField; 26 | 27 | public class LogIn extends JDialog { 28 | 29 | /** 30 | * 31 | */ 32 | private static final long serialVersionUID = 1L; 33 | private final JPanel contentPanel = new JPanel(); 34 | private JTextField usernameField; 35 | private ProductDAO productdao; 36 | private ProductSearch productSearch; 37 | private JPasswordField passwordField; 38 | 39 | /** 40 | * Launch the application. 41 | */ 42 | public static void main(String[] args) { 43 | try { 44 | LogIn dialog = new LogIn(); 45 | dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); 46 | dialog.setVisible(true); 47 | } catch (Exception e) { 48 | e.printStackTrace(); 49 | } 50 | } 51 | 52 | /** 53 | * Create the dialog. 54 | * @param productSearch 55 | * @param productdao 56 | */ 57 | LogIn(ProductDAO productdao, ProductSearch productSearch){ 58 | this(); 59 | this.productdao=productdao; 60 | this.productSearch = productSearch; 61 | 62 | } 63 | public LogIn() { 64 | setIconImage(Toolkit.getDefaultToolkit().getImage("rsz_password_icon.png")); 65 | setTitle("Login"); 66 | setBounds(100, 100, 450, 256); 67 | getContentPane().setLayout(new BorderLayout()); 68 | contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); 69 | getContentPane().add(contentPanel, BorderLayout.CENTER); 70 | 71 | JLabel lblUsername = new JLabel("Username"); 72 | 73 | usernameField = new JTextField(); 74 | usernameField.setColumns(10); 75 | 76 | JLabel lblNewLabel = new JLabel("Password"); 77 | 78 | JLabel lblLoginToEasy = new JLabel("Login to Easy Inventory"); 79 | lblLoginToEasy.setForeground(SystemColor.textHighlight); 80 | lblLoginToEasy.setIcon(new ImageIcon("rsz_login.png")); 81 | lblLoginToEasy.setFont(new Font("Segoe Script", Font.BOLD, 20)); 82 | 83 | passwordField = new JPasswordField(); 84 | GroupLayout gl_contentPanel = new GroupLayout(contentPanel); 85 | gl_contentPanel.setHorizontalGroup( 86 | gl_contentPanel.createParallelGroup(Alignment.TRAILING) 87 | .addGroup(gl_contentPanel.createSequentialGroup() 88 | .addContainerGap() 89 | .addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING) 90 | .addComponent(lblUsername) 91 | .addComponent(lblNewLabel)) 92 | .addGap(18) 93 | .addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING, false) 94 | .addComponent(passwordField) 95 | .addComponent(usernameField, GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)) 96 | .addContainerGap(38, Short.MAX_VALUE)) 97 | .addGroup(gl_contentPanel.createSequentialGroup() 98 | .addContainerGap(71, Short.MAX_VALUE) 99 | .addComponent(lblLoginToEasy) 100 | .addGap(44)) 101 | ); 102 | gl_contentPanel.setVerticalGroup( 103 | gl_contentPanel.createParallelGroup(Alignment.TRAILING) 104 | .addGroup(gl_contentPanel.createSequentialGroup() 105 | .addContainerGap() 106 | .addComponent(lblLoginToEasy) 107 | .addPreferredGap(ComponentPlacement.RELATED, 15, Short.MAX_VALUE) 108 | .addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE) 109 | .addComponent(usernameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) 110 | .addComponent(lblUsername)) 111 | .addGap(18) 112 | .addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE) 113 | .addComponent(lblNewLabel) 114 | .addComponent(passwordField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 115 | .addGap(24)) 116 | ); 117 | contentPanel.setLayout(gl_contentPanel); 118 | { 119 | JPanel buttonPane = new JPanel(); 120 | buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); 121 | getContentPane().add(buttonPane, BorderLayout.SOUTH); 122 | { 123 | JButton okButton = new JButton("Login"); 124 | okButton.addActionListener(e -> { 125 | 126 | if(usernameField.getText().equals("admin")&&passwordField.getPassword().equals("admin")){ 127 | dispose(); 128 | } 129 | 130 | 131 | }); 132 | okButton.setActionCommand("OK"); 133 | buttonPane.add(okButton); 134 | getRootPane().setDefaultButton(okButton); 135 | } 136 | { 137 | JButton cancelButton = new JButton("Cancel"); 138 | cancelButton.setActionCommand("Cancel"); 139 | cancelButton.addActionListener(e -> System.exit(0)); 140 | buttonPane.add(cancelButton); 141 | } 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/main/java/easy/gui/ProductSearch.java: -------------------------------------------------------------------------------- 1 | package easy.gui; 2 | 3 | import java.awt.Color; 4 | import java.awt.EventQueue; 5 | import java.awt.FlowLayout; 6 | import java.awt.Font; 7 | import java.awt.SystemColor; 8 | import java.awt.event.ActionEvent; 9 | import java.awt.event.ActionListener; 10 | import java.sql.SQLException; 11 | import java.util.ArrayList; 12 | 13 | import javax.swing.GroupLayout; 14 | import javax.swing.GroupLayout.Alignment; 15 | import javax.swing.ImageIcon; 16 | import javax.swing.JButton; 17 | import javax.swing.JFrame; 18 | import javax.swing.JLabel; 19 | import javax.swing.JMenu; 20 | import javax.swing.JMenuBar; 21 | import javax.swing.JMenuItem; 22 | import javax.swing.JOptionPane; 23 | import javax.swing.JPanel; 24 | import javax.swing.JScrollPane; 25 | import javax.swing.JTable; 26 | import javax.swing.JTextField; 27 | import javax.swing.LayoutStyle.ComponentPlacement; 28 | import javax.swing.UIManager; 29 | import javax.swing.border.EmptyBorder; 30 | 31 | import easy.dao.ProductDAO; 32 | import easy.model.Product; 33 | 34 | public class ProductSearch extends JFrame { 35 | 36 | /** 37 | * 38 | */ 39 | private static final long serialVersionUID = 1L; 40 | private JPanel contentPane; 41 | private JTextField searchField; 42 | private ProductDAO productdao; 43 | private JTable table; 44 | private JScrollPane scrollPane; 45 | private JMenuBar menuBar; 46 | private JMenu mnProducts; 47 | private JMenu mnAccount; 48 | private JMenuItem mntmAddNewItems; 49 | private JMenuItem mntmFind; 50 | private JMenuItem mntmDelete; 51 | private JMenuItem mntmExit; 52 | private JMenuItem mntmEditAccount; 53 | private JPanel reportPanel; 54 | private JLabel lblTotalItems; 55 | private JLabel label; 56 | private JLabel lblAvaibleItems; 57 | private JLabel availablela; 58 | private JLabel lblReport; 59 | private JButton btnSell; 60 | private JLabel soldNum; 61 | private JLabel investmentNum; 62 | private JLabel sellNum; 63 | private JLabel profitNum; 64 | private JMenuItem mntmUpdate; 65 | //report data 66 | 67 | /** 68 | * Launch the application. 69 | */ 70 | public static void main(String[] args) { 71 | EventQueue.invokeLater(new Runnable() { 72 | public void run() { 73 | try { 74 | 75 | ProductSearch frame = new ProductSearch(); 76 | frame.setVisible(true); 77 | } catch (Exception e) { 78 | e.printStackTrace(); 79 | } 80 | } 81 | }); 82 | } 83 | 84 | /** 85 | * Create the frame. 86 | * 87 | * @throws SQLException 88 | */ 89 | public ProductSearch() throws SQLException { 90 | 91 | try { 92 | productdao = new ProductDAO(); 93 | } catch (Exception e1) { 94 | JOptionPane.showMessageDialog(this, "Error:" + e1, "Error", JOptionPane.ERROR_MESSAGE); 95 | } 96 | 97 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 98 | setBounds(100, 100, 800, 572); 99 | 100 | menuBar = new JMenuBar(); 101 | setJMenuBar(menuBar); 102 | 103 | mnProducts = new JMenu("Products"); 104 | menuBar.add(mnProducts); 105 | 106 | mntmAddNewItems = new JMenuItem("Add"); 107 | mntmAddNewItems.addActionListener(new ActionListener() { 108 | public void actionPerformed(ActionEvent arg0) { 109 | AddNewProductItem dialog = new AddNewProductItem(productdao, ProductSearch.this); 110 | dialog.setVisible(true); 111 | } 112 | }); 113 | mnProducts.add(mntmAddNewItems); 114 | 115 | mntmFind = new JMenuItem("Find"); 116 | mntmFind.addActionListener(new ActionListener() { 117 | public void actionPerformed(ActionEvent e) { 118 | JOptionPane.showMessageDialog(null, "Use Search Field to Find Item."); 119 | } 120 | }); 121 | mnProducts.add(mntmFind); 122 | 123 | mntmDelete = new JMenuItem("Delete"); 124 | mntmDelete.addActionListener(new ActionListener() { 125 | public void actionPerformed(ActionEvent arg0) { 126 | // get selected row 127 | int row = table.getSelectedRow(); 128 | 129 | if (row < 0) { 130 | JOptionPane.showMessageDialog(ProductSearch.this, "You must select a Product.", "Error", 131 | JOptionPane.ERROR_MESSAGE); 132 | return; 133 | } 134 | 135 | int response = JOptionPane.showConfirmDialog(ProductSearch.this,"Delete this products?","Confirmation",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE); 136 | 137 | if(response != JOptionPane.YES_OPTION){ 138 | return; 139 | } 140 | 141 | // get selected product object 142 | Product tmpProduct = (Product) table.getValueAt(row, ProductTableModel.OBJECT_COL); 143 | 144 | try { 145 | productdao.deleteItem(tmpProduct.getId()); 146 | refreshProductView(); 147 | } catch (SQLException e1) { 148 | e1.printStackTrace(); 149 | } 150 | } 151 | }); 152 | 153 | mntmUpdate = new JMenuItem("Update"); 154 | mnProducts.add(mntmUpdate); 155 | mnProducts.add(mntmDelete); 156 | 157 | mntmExit = new JMenuItem("Exit"); 158 | mntmExit.addActionListener(new ActionListener() { 159 | public void actionPerformed(ActionEvent e) { 160 | System.exit(0); 161 | } 162 | }); 163 | mnProducts.add(mntmExit); 164 | 165 | mnAccount = new JMenu("Account"); 166 | menuBar.add(mnAccount); 167 | 168 | mntmEditAccount = new JMenuItem("Edit Account"); 169 | mnAccount.add(mntmEditAccount); 170 | 171 | contentPane = new JPanel(); 172 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 173 | setContentPane(contentPane); 174 | 175 | JPanel panel = new JPanel(); 176 | FlowLayout flowLayout = (FlowLayout) panel.getLayout(); 177 | flowLayout.setAlignment(FlowLayout.LEFT); 178 | 179 | JLabel productLebel = new JLabel("Type Product Name"); 180 | panel.add(productLebel); 181 | 182 | searchField = new JTextField(); 183 | panel.add(searchField); 184 | searchField.setColumns(20); 185 | 186 | JButton btnNewButton = new JButton("search"); 187 | btnNewButton.addActionListener(new ActionListener() { 188 | public void actionPerformed(ActionEvent arg0) { 189 | String searchtext = searchField.getText(); 190 | try { 191 | ArrayList items = new ArrayList<>(); 192 | if (searchtext != null && searchtext.trim().length() > 0) { 193 | items = productdao.searchProduct(searchtext); 194 | } else { 195 | items = productdao.getAllProduct(); 196 | } 197 | // Using table Model 198 | ProductTableModel model = new ProductTableModel(items); 199 | table.setModel(model); 200 | } catch (Exception e) { 201 | e.printStackTrace(); 202 | } 203 | } 204 | }); 205 | panel.add(btnNewButton); 206 | 207 | scrollPane = new JScrollPane(); 208 | 209 | table = new JTable(); 210 | scrollPane.setViewportView(table); 211 | 212 | JLabel lblCopyrightReserved = new JLabel("\u00A9copyright reserved - Achyut Dev, 2015 "); 213 | lblCopyrightReserved.setFont(new Font("Tahoma", Font.PLAIN, 9)); 214 | 215 | JButton btnaddNewProduct = new JButton("Add New"); 216 | btnaddNewProduct.setForeground(new Color(0, 128, 0)); 217 | btnaddNewProduct.setFont(new Font("Segoe Script", Font.BOLD, 13)); 218 | btnaddNewProduct.addActionListener(new ActionListener() { 219 | public void actionPerformed(ActionEvent arg0) { 220 | AddNewProductItem dialog = new AddNewProductItem(productdao, ProductSearch.this); 221 | dialog.setVisible(true); 222 | } 223 | }); 224 | 225 | JButton btnUpdateItem = new JButton("Update"); 226 | btnUpdateItem.setForeground(Color.BLUE); 227 | btnUpdateItem.setFont(new Font("Segoe Script", Font.BOLD, 13)); 228 | btnUpdateItem.addActionListener(new ActionListener() { 229 | public void actionPerformed(ActionEvent arg0) { 230 | // get selected row 231 | int row = table.getSelectedRow(); 232 | 233 | if (row < 0) { 234 | JOptionPane.showMessageDialog(ProductSearch.this, "You must select a Product.", "Error", 235 | JOptionPane.ERROR_MESSAGE); 236 | return; 237 | } 238 | 239 | Product tmpProduct = (Product) table.getValueAt(row, ProductTableModel.OBJECT_COL); 240 | // System.out.println(tmpProduct); 241 | AddNewProductItem dialog = new AddNewProductItem(productdao, ProductSearch.this, tmpProduct, true); 242 | 243 | dialog.setVisible(true); 244 | } 245 | }); 246 | 247 | JPanel panel_1 = new JPanel(); 248 | 249 | reportPanel = new JPanel(); 250 | 251 | lblReport = new JLabel("Report !"); 252 | lblReport.setForeground(new Color(160, 82, 45)); 253 | lblReport.setFont(new Font("Segoe Script", Font.BOLD, 20)); 254 | lblReport.setIcon(new ImageIcon("rsz_billingreport.png")); 255 | 256 | JButton btnDelete = new JButton("Delete"); 257 | btnDelete.setForeground(Color.RED); 258 | btnDelete.setFont(new Font("Segoe Script", Font.BOLD, 13)); 259 | btnDelete.addActionListener(new ActionListener() { 260 | public void actionPerformed(ActionEvent e) { 261 | 262 | // get selected row 263 | int row = table.getSelectedRow(); 264 | 265 | if (row < 0) { 266 | JOptionPane.showMessageDialog(ProductSearch.this, "You must select a Product.", "Error", 267 | JOptionPane.ERROR_MESSAGE); 268 | return; 269 | } 270 | 271 | int response = JOptionPane.showConfirmDialog(ProductSearch.this,"Delete this products?","Confirmation",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE); 272 | 273 | if(response != JOptionPane.YES_OPTION){ 274 | return; 275 | } 276 | 277 | // get selected product object 278 | Product tmpProduct = (Product) table.getValueAt(row, ProductTableModel.OBJECT_COL); 279 | 280 | try { 281 | productdao.deleteItem(tmpProduct.getId()); 282 | refreshProductView(); 283 | } catch (SQLException e1) { 284 | e1.printStackTrace(); 285 | } 286 | } 287 | }); 288 | 289 | btnSell = new JButton("Sell"); 290 | btnSell.setBackground(SystemColor.inactiveCaptionBorder); 291 | btnSell.setFont(new Font("Arial Black", Font.BOLD, 16)); 292 | btnSell.setForeground(new Color(34, 139, 34)); 293 | btnSell.addActionListener(new ActionListener() { 294 | public void actionPerformed(ActionEvent e) { 295 | int row = table.getSelectedRow(); 296 | 297 | if (row < 0) { 298 | JOptionPane.showMessageDialog(ProductSearch.this, "You must select a Product.", "Error", 299 | JOptionPane.ERROR_MESSAGE); 300 | return; 301 | } 302 | int response = JOptionPane.showConfirmDialog(ProductSearch.this,"Sell this products?","Confirmation",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE); 303 | 304 | if(response != JOptionPane.YES_OPTION){ 305 | return; 306 | } 307 | 308 | Product tmpProduct = (Product) table.getValueAt(row, ProductTableModel.OBJECT_COL); 309 | 310 | try { 311 | productdao.soldItem(tmpProduct.getId()); 312 | refreshProductView(); 313 | } catch (SQLException e1) { 314 | e1.printStackTrace(); 315 | } 316 | } 317 | }); 318 | btnSell.setIcon(new ImageIcon("rsz_sell.png")); 319 | GroupLayout gl_contentPane = new GroupLayout(contentPane); 320 | gl_contentPane.setHorizontalGroup( 321 | gl_contentPane.createParallelGroup(Alignment.TRAILING) 322 | .addGroup(gl_contentPane.createSequentialGroup() 323 | .addContainerGap() 324 | .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING) 325 | .addGroup(gl_contentPane.createSequentialGroup() 326 | .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) 327 | .addGroup(gl_contentPane.createSequentialGroup() 328 | .addComponent(panel_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) 329 | .addGap(78)) 330 | .addGroup(gl_contentPane.createSequentialGroup() 331 | .addComponent(panel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 332 | .addGap(18)) 333 | .addGroup(gl_contentPane.createSequentialGroup() 334 | .addComponent(btnSell) 335 | .addPreferredGap(ComponentPlacement.RELATED, 35, Short.MAX_VALUE) 336 | .addComponent(btnDelete) 337 | .addGap(18) 338 | .addComponent(btnUpdateItem) 339 | .addGap(18) 340 | .addComponent(btnaddNewProduct)) 341 | .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) 342 | .addPreferredGap(ComponentPlacement.UNRELATED) 343 | .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING) 344 | .addComponent(lblReport) 345 | .addComponent(reportPanel, GroupLayout.PREFERRED_SIZE, 315, GroupLayout.PREFERRED_SIZE)) 346 | .addGap(30)) 347 | .addGroup(gl_contentPane.createSequentialGroup() 348 | .addComponent(lblCopyrightReserved, GroupLayout.PREFERRED_SIZE, 174, GroupLayout.PREFERRED_SIZE) 349 | .addGap(49)))) 350 | ); 351 | gl_contentPane.setVerticalGroup( 352 | gl_contentPane.createParallelGroup(Alignment.LEADING) 353 | .addGroup(gl_contentPane.createSequentialGroup() 354 | .addContainerGap() 355 | .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING) 356 | .addGroup(gl_contentPane.createSequentialGroup() 357 | .addComponent(panel_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) 358 | .addGap(31) 359 | .addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) 360 | .addGap(18) 361 | .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE) 362 | .addGap(18) 363 | .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE) 364 | .addComponent(btnaddNewProduct, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 365 | .addComponent(btnUpdateItem, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 366 | .addComponent(btnDelete) 367 | .addComponent(btnSell))) 368 | .addGroup(gl_contentPane.createSequentialGroup() 369 | .addComponent(lblReport) 370 | .addGap(3) 371 | .addComponent(reportPanel, GroupLayout.PREFERRED_SIZE, 354, GroupLayout.PREFERRED_SIZE) 372 | .addGap(10))) 373 | .addGap(8) 374 | .addComponent(lblCopyrightReserved, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 375 | ); 376 | 377 | lblTotalItems = new JLabel("Total Items "); 378 | lblTotalItems.setForeground(UIManager.getColor("ToggleButton.darkShadow")); 379 | lblTotalItems.setFont(new Font("Tahoma", Font.BOLD, 14)); 380 | 381 | // Total items 382 | String totalItems = productdao.getTotalItems(); 383 | label = new JLabel(totalItems); 384 | label.setForeground(new Color(30, 144, 255)); 385 | label.setFont(new Font("Segoe Script", Font.BOLD, 18)); 386 | 387 | // Available Items 388 | String availableItem = productdao.getAvaiItems(); 389 | lblAvaibleItems = new JLabel("Available Items"); 390 | lblAvaibleItems.setForeground(UIManager.getColor("ToggleButton.darkShadow")); 391 | lblAvaibleItems.setFont(new Font("Tahoma", Font.BOLD, 14)); 392 | 393 | availablela = new JLabel(availableItem); 394 | availablela.setBackground(new Color(255, 240, 245)); 395 | availablela.setForeground(new Color(30, 144, 255)); 396 | availablela.setFont(new Font("Segoe Script", Font.BOLD, 18)); 397 | 398 | JLabel lblSoldItems = new JLabel("Sold Items"); 399 | lblSoldItems.setForeground(UIManager.getColor("ToggleButton.darkShadow")); 400 | lblSoldItems.setFont(new Font("Tahoma", Font.BOLD, 14)); 401 | 402 | String soldItemNum = productdao.getSoldItems(); 403 | soldNum = new JLabel(soldItemNum); 404 | soldNum.setBackground(new Color(255, 240, 245)); 405 | soldNum.setForeground(new Color(30, 144, 255)); 406 | soldNum.setFont(new Font("Segoe Script", Font.BOLD, 18)); 407 | 408 | JLabel lblTotalInvestment = new JLabel("Total Investment"); 409 | lblTotalInvestment.setForeground(UIManager.getColor("ToggleButton.darkShadow")); 410 | lblTotalInvestment.setFont(new Font("Tahoma", Font.BOLD, 14)); 411 | 412 | String investNUm = "$" + productdao.getTotalInvest(); 413 | investmentNum = new JLabel(investNUm); 414 | investmentNum.setBackground(new Color(255, 240, 245)); 415 | investmentNum.setForeground(new Color(30, 144, 255)); 416 | investmentNum.setFont(new Font("Segoe Script", Font.BOLD, 18)); 417 | 418 | JLabel lblTotalSales = new JLabel("Total Sales"); 419 | lblTotalSales.setForeground(UIManager.getColor("ToggleButton.darkShadow")); 420 | lblTotalSales.setFont(new Font("Tahoma", Font.BOLD, 14)); 421 | 422 | String sellingNUm = "$" + productdao.getTotalSell(); 423 | sellNum = new JLabel(sellingNUm); 424 | sellNum.setBackground(new Color(255, 240, 245)); 425 | sellNum.setForeground(new Color(30, 144, 255)); 426 | sellNum.setFont(new Font("Segoe Script", Font.BOLD, 18)); 427 | 428 | JLabel lblTotalProfits = new JLabel("Total Profits"); 429 | lblTotalProfits.setForeground(UIManager.getColor("ToggleButton.darkShadow")); 430 | lblTotalProfits.setFont(new Font("Tahoma", Font.BOLD, 14)); 431 | 432 | String totalprofit = "$" + productdao.getProfit(); 433 | profitNum = new JLabel(totalprofit); 434 | profitNum.setBackground(new Color(255, 240, 245)); 435 | profitNum.setForeground(new Color(30, 144, 255)); 436 | profitNum.setFont(new Font("Segoe Script", Font.BOLD, 18)); 437 | GroupLayout gl_reportPanel = new GroupLayout(reportPanel); 438 | gl_reportPanel 439 | .setHorizontalGroup( 440 | gl_reportPanel.createParallelGroup(Alignment.LEADING) 441 | .addGroup( 442 | gl_reportPanel.createSequentialGroup().addContainerGap() 443 | .addGroup(gl_reportPanel 444 | .createParallelGroup( 445 | Alignment.LEADING) 446 | .addGroup(gl_reportPanel.createSequentialGroup() 447 | .addGroup(gl_reportPanel 448 | .createParallelGroup(Alignment.LEADING) 449 | .addComponent(lblTotalItems) 450 | .addComponent(lblAvaibleItems) 451 | .addComponent(lblSoldItems)) 452 | .addGap(25) 453 | .addGroup(gl_reportPanel.createParallelGroup(Alignment.LEADING) 454 | .addComponent(soldNum).addComponent(availablela) 455 | .addComponent(label))) 456 | .addGroup(gl_reportPanel.createSequentialGroup() 457 | .addGroup(gl_reportPanel.createParallelGroup(Alignment.LEADING) 458 | .addComponent(lblTotalInvestment).addComponent(lblTotalProfits) 459 | .addComponent(lblTotalSales)) 460 | .addPreferredGap(ComponentPlacement.RELATED) 461 | .addGroup(gl_reportPanel.createParallelGroup(Alignment.LEADING).addComponent(profitNum) 462 | .addComponent(sellNum).addComponent(investmentNum)))) 463 | .addContainerGap(133, Short.MAX_VALUE))); 464 | gl_reportPanel.setVerticalGroup(gl_reportPanel.createParallelGroup(Alignment.LEADING) 465 | .addGroup(gl_reportPanel.createSequentialGroup().addGap(42) 466 | .addGroup(gl_reportPanel.createParallelGroup(Alignment.BASELINE).addComponent(lblTotalItems) 467 | .addComponent(label)) 468 | .addGap(18) 469 | .addGroup(gl_reportPanel.createParallelGroup(Alignment.BASELINE).addComponent(lblAvaibleItems) 470 | .addComponent(availablela)) 471 | .addGap(18) 472 | .addGroup(gl_reportPanel.createParallelGroup(Alignment.BASELINE).addComponent(lblSoldItems) 473 | .addComponent(soldNum)) 474 | .addGap(18) 475 | .addGroup(gl_reportPanel.createParallelGroup(Alignment.BASELINE).addComponent(lblTotalInvestment) 476 | .addComponent(investmentNum)) 477 | .addGap(18) 478 | .addGroup(gl_reportPanel.createParallelGroup(Alignment.BASELINE).addComponent(sellNum) 479 | .addComponent(lblTotalSales)).addGap(18) 480 | .addGroup(gl_reportPanel.createParallelGroup(Alignment.BASELINE).addComponent(lblTotalProfits) 481 | .addComponent(profitNum)).addContainerGap(213, Short.MAX_VALUE))); 482 | reportPanel.setLayout(gl_reportPanel); 483 | 484 | JLabel lbllogoName = new JLabel(" - Easy Inventory"); 485 | lbllogoName.setIcon(new ImageIcon("resource/rsz_2easyinlogo.png")); 486 | lbllogoName.setForeground(SystemColor.textHighlight); 487 | lbllogoName.setFont(new Font("Segoe Script", Font.BOLD, 24)); 488 | panel_1.add(lbllogoName); 489 | contentPane.setLayout(gl_contentPane); 490 | } 491 | 492 | public void refreshProductView() { 493 | try { 494 | ArrayList list = productdao.getAllProduct(); 495 | ProductTableModel mode = new ProductTableModel(list); 496 | table.setModel(mode); 497 | updateReport(); 498 | } catch (Exception e) { 499 | JOptionPane.showMessageDialog(this, "Error:" + e, "Error", JOptionPane.ERROR_MESSAGE); 500 | } 501 | 502 | } 503 | 504 | private void updateReport() throws SQLException { 505 | label.setText(productdao.getTotalItems()); 506 | 507 | availablela.setText(productdao.getAvaiItems()); 508 | soldNum.setText(productdao.getSoldItems()); 509 | investmentNum.setText(productdao.getTotalInvest()); 510 | sellNum.setText(productdao.getTotalSell()); 511 | profitNum.setText(productdao.getProfit()); 512 | 513 | } 514 | 515 | 516 | } 517 | -------------------------------------------------------------------------------- /src/main/java/easy/gui/ProductTableModel.java: -------------------------------------------------------------------------------- 1 | package easy.gui; 2 | 3 | import java.text.DecimalFormat; 4 | import java.util.ArrayList; 5 | 6 | import javax.swing.table.AbstractTableModel; 7 | 8 | import easy.model.Product; 9 | 10 | public class ProductTableModel extends AbstractTableModel { 11 | 12 | public static final int OBJECT_COL = -1; 13 | private static final int TAG_COL = 0; 14 | private static final int NAME_COL = 1; 15 | private static final int COMPANY_COL = 2; 16 | private static final int CPRICE_COL = 3; 17 | private static final int SPRICE_COL = 4; 18 | private static final int PROFIT_COL = 5; 19 | private static final int STATUS_COL = 6; 20 | DecimalFormat df = new DecimalFormat("#.00"); 21 | 22 | private String[] columnName = { "Tag Number", "Item Name", "Item Brand", "Cost Price", "Selling Price", "Profit", 23 | "ST" }; 24 | private ArrayList products; 25 | 26 | public ProductTableModel(ArrayList products) { 27 | this.products = products; 28 | } 29 | 30 | @Override 31 | public int getColumnCount() { 32 | return columnName.length; 33 | } 34 | 35 | @Override 36 | public int getRowCount() { 37 | return products.size(); 38 | } 39 | 40 | @Override 41 | public String getColumnName(int col) { 42 | return columnName[col]; 43 | } 44 | 45 | @Override 46 | public Object getValueAt(int row, int col) { 47 | 48 | Product tmpProduct = products.get(row); 49 | switch (col) { 50 | case TAG_COL: 51 | return tmpProduct.getTag(); 52 | case NAME_COL: 53 | return tmpProduct.getName(); 54 | case COMPANY_COL: 55 | return tmpProduct.getCompany(); 56 | case CPRICE_COL: 57 | return df.format(tmpProduct.getCp()); 58 | case SPRICE_COL: 59 | return df.format(tmpProduct.getSp()); 60 | case PROFIT_COL: 61 | return df.format(tmpProduct.getProfit()); 62 | case STATUS_COL: 63 | if (tmpProduct.getStatus()) { 64 | return "avaible"; 65 | } 66 | 67 | else { 68 | return "Sold"; 69 | } 70 | case OBJECT_COL: 71 | return tmpProduct; 72 | 73 | default: 74 | break; 75 | } 76 | return null; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/easy/gui/RegistrationPage.java: -------------------------------------------------------------------------------- 1 | package easy.gui; 2 | 3 | import java.awt.BorderLayout; 4 | import java.awt.Color; 5 | import java.awt.FlowLayout; 6 | import java.awt.Font; 7 | import java.awt.SystemColor; 8 | import java.awt.event.ActionEvent; 9 | import java.awt.event.ActionListener; 10 | import java.awt.event.MouseAdapter; 11 | import java.awt.event.MouseEvent; 12 | 13 | import javax.swing.GroupLayout; 14 | import javax.swing.GroupLayout.Alignment; 15 | import javax.swing.JButton; 16 | import javax.swing.JDialog; 17 | import javax.swing.JLabel; 18 | import javax.swing.JPanel; 19 | import javax.swing.JPasswordField; 20 | import javax.swing.JTextField; 21 | import javax.swing.LayoutStyle.ComponentPlacement; 22 | import javax.swing.border.EmptyBorder; 23 | 24 | public class RegistrationPage extends JDialog { 25 | 26 | /** 27 | * 28 | */ 29 | private static final long serialVersionUID = 1L; 30 | private final JPanel contentPanel = new JPanel(); 31 | private JTextField usernametextField; 32 | private JPasswordField pwdPassword; 33 | private JTextField nameTextField; 34 | private JTextField emailTextField; 35 | private JTextField addressTextField; 36 | private JTextField phonenumTextField; 37 | private JTextField titletextField; 38 | 39 | /** 40 | * Launch the application. 41 | */ 42 | public static void main(String[] args) { 43 | try { 44 | RegistrationPage dialog = new RegistrationPage(); 45 | dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); 46 | dialog.setVisible(true); 47 | } catch (Exception e) { 48 | e.printStackTrace(); 49 | } 50 | } 51 | 52 | /** 53 | * Create the dialog. 54 | */ 55 | 56 | public void clearFieldOnClick(String fieldName) { 57 | switch (fieldName) { 58 | case "username": 59 | usernametextField.setText(""); 60 | System.out.println("username"); 61 | break; 62 | case "address": 63 | addressTextField.setText(""); 64 | break; 65 | case "email": 66 | emailTextField.setText(""); 67 | break; 68 | case "phonenum": 69 | phonenumTextField.setText(""); 70 | break; 71 | case "title": 72 | titletextField.setText(""); 73 | break; 74 | case "name": 75 | nameTextField.setText(""); 76 | break; 77 | default: 78 | break; 79 | } 80 | } 81 | 82 | public RegistrationPage() { 83 | setTitle("Registration "); 84 | setBounds(100, 100, 450, 450); 85 | getContentPane().setLayout(new BorderLayout()); 86 | contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); 87 | getContentPane().add(contentPanel, BorderLayout.WEST); 88 | 89 | JLabel lbllogo = new JLabel("[Logo]"); 90 | 91 | JLabel lblRegistorNewUser = new JLabel("Registor New User Account"); 92 | lblRegistorNewUser.setForeground(SystemColor.textHighlight); 93 | lblRegistorNewUser.setFont(new Font("Segoe Script", Font.BOLD, 20)); 94 | 95 | JLabel lblUsername = new JLabel("Username"); 96 | 97 | JLabel lblPassword = new JLabel("Password"); 98 | 99 | JLabel lblName = new JLabel("Name"); 100 | 101 | JLabel lblEmail = new JLabel("Email"); 102 | 103 | JLabel lblAddress = new JLabel("Address"); 104 | 105 | JLabel lblPhone = new JLabel("Phone"); 106 | 107 | JLabel lblTitle = new JLabel("Title"); 108 | 109 | 110 | usernametextField = new JTextField(); 111 | usernametextField.addMouseListener(new MouseAdapter() { 112 | @Override 113 | public void mouseClicked(MouseEvent arg0) { 114 | clearFieldOnClick("username"); 115 | } 116 | }); 117 | usernametextField.setForeground(SystemColor.activeCaptionBorder); 118 | usernametextField.setText("e.g. username"); 119 | usernametextField.setColumns(10); 120 | 121 | pwdPassword = new JPasswordField(); 122 | 123 | nameTextField = new JTextField(); 124 | nameTextField.addMouseListener(new MouseAdapter() { 125 | @Override 126 | public void mouseClicked(MouseEvent e) { 127 | clearFieldOnClick("name"); 128 | } 129 | }); 130 | nameTextField.setForeground(Color.LIGHT_GRAY); 131 | nameTextField.setText("e.g. Achyut Dev"); 132 | nameTextField.setColumns(10); 133 | 134 | emailTextField = new JTextField(); 135 | emailTextField.addMouseListener(new MouseAdapter() { 136 | @Override 137 | public void mouseClicked(MouseEvent e) { 138 | clearFieldOnClick("email"); 139 | } 140 | }); 141 | emailTextField.setForeground(Color.LIGHT_GRAY); 142 | emailTextField.setText("e.g. achyut.dev@gmail.com"); 143 | emailTextField.setColumns(10); 144 | 145 | addressTextField = new JTextField(); 146 | addressTextField.addMouseListener(new MouseAdapter() { 147 | @Override 148 | public void mouseClicked(MouseEvent e) { 149 | clearFieldOnClick("address"); 150 | } 151 | }); 152 | addressTextField.setForeground(Color.LIGHT_GRAY); 153 | addressTextField.setText("e.g. Fairfield, IA"); 154 | addressTextField.setColumns(10); 155 | 156 | phonenumTextField = new JTextField(); 157 | phonenumTextField.addMouseListener(new MouseAdapter() { 158 | @Override 159 | public void mouseClicked(MouseEvent e) { 160 | clearFieldOnClick("phonenum"); 161 | } 162 | }); 163 | phonenumTextField.setForeground(Color.LIGHT_GRAY); 164 | phonenumTextField.setText("e.g. 4323234423"); 165 | phonenumTextField.setColumns(10); 166 | 167 | titletextField = new JTextField(); 168 | titletextField.addMouseListener(new MouseAdapter() { 169 | @Override 170 | public void mouseClicked(MouseEvent e) { 171 | clearFieldOnClick("title"); 172 | } 173 | }); 174 | titletextField.setForeground(Color.LIGHT_GRAY); 175 | titletextField.setText("e.g. Sale Manager"); 176 | titletextField.setColumns(10); 177 | GroupLayout gl_contentPanel = new GroupLayout(contentPanel); 178 | gl_contentPanel.setHorizontalGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING) 179 | .addGroup(gl_contentPanel.createSequentialGroup().addGap(31) 180 | .addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING).addComponent(lblName) 181 | .addComponent(lblEmail).addComponent(lblAddress).addComponent(lblPhone) 182 | .addComponent(lblTitle) 183 | .addGroup(gl_contentPanel.createParallelGroup(Alignment.TRAILING) 184 | .addGroup(Alignment.LEADING, 185 | gl_contentPanel.createSequentialGroup().addComponent(lbllogo).addGap(18) 186 | .addComponent(lblRegistorNewUser)) 187 | .addGroup(gl_contentPanel.createSequentialGroup() 188 | .addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING) 189 | .addComponent(lblUsername).addComponent(lblPassword)) 190 | .addPreferredGap(ComponentPlacement.RELATED, 36, Short.MAX_VALUE) 191 | .addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING, false) 192 | .addComponent(pwdPassword) 193 | .addComponent(usernametextField, GroupLayout.DEFAULT_SIZE, 241, 194 | Short.MAX_VALUE) 195 | .addComponent(emailTextField).addComponent(nameTextField) 196 | .addComponent(addressTextField).addComponent(phonenumTextField) 197 | .addComponent(titletextField))))) 198 | .addGap(57))); 199 | gl_contentPanel.setVerticalGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING) 200 | .addGroup(gl_contentPanel.createSequentialGroup().addContainerGap() 201 | .addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE).addComponent(lbllogo) 202 | .addComponent(lblRegistorNewUser)) 203 | .addGap(18) 204 | .addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE).addComponent(lblUsername) 205 | .addComponent(usernametextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 206 | GroupLayout.PREFERRED_SIZE)) 207 | .addGap(18) 208 | .addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE).addComponent(lblPassword) 209 | .addComponent(pwdPassword, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 210 | GroupLayout.PREFERRED_SIZE)) 211 | .addGap(18) 212 | .addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE).addComponent(lblName).addComponent( 213 | nameTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 214 | GroupLayout.PREFERRED_SIZE)) 215 | .addGap(18) 216 | .addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE).addComponent(lblEmail).addComponent( 217 | emailTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 218 | GroupLayout.PREFERRED_SIZE)) 219 | .addGap(18) 220 | .addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE).addComponent(lblAddress).addComponent( 221 | addressTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 222 | GroupLayout.PREFERRED_SIZE)) 223 | .addGap(18) 224 | .addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE).addComponent(lblPhone).addComponent( 225 | phonenumTextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 226 | GroupLayout.PREFERRED_SIZE)) 227 | .addGap(18) 228 | .addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE).addComponent(lblTitle).addComponent( 229 | titletextField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, 230 | GroupLayout.PREFERRED_SIZE)).addContainerGap(49, Short.MAX_VALUE))); 231 | contentPanel.setLayout(gl_contentPanel); 232 | { 233 | JPanel buttonPane = new JPanel(); 234 | buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); 235 | getContentPane().add(buttonPane, BorderLayout.SOUTH); 236 | { 237 | JButton okButton = new JButton("OK"); 238 | okButton.setActionCommand("OK"); 239 | buttonPane.add(okButton); 240 | getRootPane().setDefaultButton(okButton); 241 | } 242 | { 243 | JButton cancelButton = new JButton("Cancel"); 244 | cancelButton.setActionCommand("Cancel"); 245 | cancelButton.addActionListener(new ActionListener() { 246 | public void actionPerformed(ActionEvent e) { 247 | System.exit(0); 248 | } 249 | }); 250 | buttonPane.add(cancelButton); 251 | } 252 | } 253 | } 254 | } 255 | -------------------------------------------------------------------------------- /src/main/java/easy/gui/StartUpPage.java: -------------------------------------------------------------------------------- 1 | package easy.gui; 2 | 3 | import easy.dao.ProductDAO; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | 6 | import javax.swing.*; 7 | import javax.swing.border.EmptyBorder; 8 | import java.awt.*; 9 | import java.awt.event.ActionEvent; 10 | import java.awt.event.ActionListener; 11 | import java.sql.Connection; 12 | 13 | import static java.awt.EventQueue.invokeLater; 14 | 15 | public class StartUpPage extends JFrame { 16 | 17 | private JPanel contentPane; 18 | private JTextField companyName; 19 | private JTextField adminUsername; 20 | private JTextField adminPassword; 21 | private JTextField logopath; 22 | private String companylogopath =null; 23 | private Connection myConn; 24 | 25 | private final Component verticalStrut = Box.createVerticalStrut(20); 26 | 27 | /** 28 | * Launch the application. 29 | */ 30 | 31 | public static void main(String[] args) { 32 | invokeLater(new Runnable() { 33 | 34 | @Autowired 35 | private ProductDAO productDAO; 36 | 37 | public void run() { 38 | try { 39 | if(isThisANewCompany()) { 40 | StartUpPage frame = new StartUpPage(); 41 | frame.setVisible(true); 42 | }else{ 43 | LogIn logIn = new LogIn(); 44 | logIn.setVisible(true); 45 | } 46 | } catch (Exception e) { 47 | e.printStackTrace(); 48 | } 49 | } 50 | 51 | private boolean isThisANewCompany() throws Exception { 52 | return productDAO.getAllProduct().isEmpty(); 53 | } 54 | }); 55 | } 56 | 57 | /** 58 | * Create the frame. 59 | */ 60 | public StartUpPage() { 61 | setIconImage( 62 | Toolkit.getDefaultToolkit().getImage("easy/resource/rsz_easyInlogo.png")); 63 | setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 64 | setBounds(100, 100, 450, 300); 65 | contentPane = new JPanel(); 66 | contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); 67 | contentPane.setLayout(new BorderLayout(0, 0)); 68 | setContentPane(contentPane); 69 | 70 | JPanel titlePanel = new JPanel(); 71 | contentPane.add(titlePanel, BorderLayout.NORTH); 72 | 73 | JLabel lblEasyInventory = new JLabel("- Easy Inventory"); 74 | lblEasyInventory.setFont(new Font("Segoe Script", Font.BOLD, 20)); 75 | ImageIcon iconEI = new ImageIcon("rsz_easyInlogo.png"); 76 | lblEasyInventory.setIcon(iconEI); 77 | titlePanel.add(lblEasyInventory); 78 | 79 | JPanel adminPanel = new JPanel(); 80 | contentPane.add(adminPanel, BorderLayout.CENTER); 81 | adminPanel.setLayout(new BoxLayout(adminPanel, BoxLayout.Y_AXIS)); 82 | 83 | JPanel panel_2 = new JPanel(); 84 | FlowLayout flowLayout = (FlowLayout) panel_2.getLayout(); 85 | flowLayout.setAlignment(FlowLayout.RIGHT); 86 | adminPanel.add(panel_2); 87 | 88 | JLabel lblNewLabel = new JLabel("Enter Company Name"); 89 | panel_2.add(lblNewLabel); 90 | 91 | companyName = new JTextField(); 92 | panel_2.add(companyName); 93 | companyName.setColumns(20); 94 | 95 | Component horizontalStrut = Box.createHorizontalStrut(10); 96 | panel_2.add(horizontalStrut); 97 | 98 | JPanel panel_3 = new JPanel(); 99 | FlowLayout flowLayout_1 = (FlowLayout) panel_3.getLayout(); 100 | flowLayout_1.setAlignment(FlowLayout.RIGHT); 101 | adminPanel.add(panel_3); 102 | 103 | JLabel lblCompanyUserName = new JLabel("Company Admin Username"); 104 | panel_3.add(lblCompanyUserName); 105 | 106 | adminUsername = new JTextField(); 107 | adminUsername.setColumns(20); 108 | panel_3.add(adminUsername); 109 | 110 | Component horizontalStrut_1 = Box.createHorizontalStrut(10); 111 | panel_3.add(horizontalStrut_1); 112 | 113 | JPanel panel_4 = new JPanel(); 114 | FlowLayout flowLayout_2 = (FlowLayout) panel_4.getLayout(); 115 | flowLayout_2.setAlignment(FlowLayout.RIGHT); 116 | adminPanel.add(panel_4); 117 | 118 | JLabel lblCompanyName = new JLabel("Company Admin Password"); 119 | panel_4.add(lblCompanyName); 120 | 121 | adminPassword = new JTextField(); 122 | adminPassword.setColumns(20); 123 | panel_4.add(adminPassword); 124 | 125 | Component horizontalStrut_2 = Box.createHorizontalStrut(10); 126 | panel_4.add(horizontalStrut_2); 127 | 128 | JPanel panel = new JPanel(); 129 | FlowLayout flowLayout_3 = (FlowLayout) panel.getLayout(); 130 | flowLayout_3.setAlignment(FlowLayout.RIGHT); 131 | adminPanel.add(panel); 132 | 133 | JLabel lblCompanyLogo = new JLabel("Company logo"); 134 | panel.add(lblCompanyLogo); 135 | 136 | logopath = new JTextField(); 137 | logopath.setColumns(12); 138 | panel.add(logopath); 139 | 140 | JButton btnNewButton = new JButton("Browser"); 141 | 142 | btnNewButton.addActionListener(new ActionListener() { 143 | public void actionPerformed(ActionEvent arg0) { 144 | JFileChooser fileDialog = new JFileChooser(); 145 | int returnVal = fileDialog.showOpenDialog(contentPane); 146 | if (returnVal == JFileChooser.APPROVE_OPTION) { 147 | java.io.File file = fileDialog.getSelectedFile(); 148 | companylogopath = file.getAbsolutePath(); 149 | logopath.setText(companylogopath); 150 | 151 | } else { 152 | JOptionPane.showMessageDialog(null, "Select Company Logo [ format - .jpg or .png only]"); 153 | } 154 | } 155 | }); 156 | panel.add(btnNewButton); 157 | 158 | Component horizontalStrut_3 = Box.createHorizontalStrut(10); 159 | panel.add(horizontalStrut_3); 160 | 161 | JPanel controlBotton = new JPanel(); 162 | FlowLayout flowLayout_4 = (FlowLayout) controlBotton.getLayout(); 163 | flowLayout_4.setAlignment(FlowLayout.RIGHT); 164 | contentPane.add(controlBotton, BorderLayout.SOUTH); 165 | 166 | JButton Reset = new JButton("Reset"); 167 | Reset.setFont(new Font("Tahoma", Font.BOLD, 13)); 168 | Reset.addActionListener(new ActionListener() { 169 | public void actionPerformed(ActionEvent e) { 170 | companyName.setText(""); 171 | adminUsername.setText(""); 172 | adminPassword.setText(""); 173 | logopath.setText(""); 174 | } 175 | }); 176 | controlBotton.add(Reset); 177 | 178 | Component horizontalStrut_4 = Box.createHorizontalStrut(20); 179 | controlBotton.add(horizontalStrut_4); 180 | 181 | JButton next = new JButton("Next"); 182 | next.setFont(new Font("Tahoma", Font.BOLD, 13)); 183 | next.addActionListener(new ActionListener() { 184 | public void actionPerformed(ActionEvent e) { 185 | 186 | } 187 | }); 188 | controlBotton.add(next); 189 | 190 | Component horizontalStrut_5 = Box.createHorizontalStrut(20); 191 | controlBotton.add(horizontalStrut_5); 192 | 193 | JButton cancel = new JButton("Cancel"); 194 | cancel.setFont(new Font("Tahoma", Font.BOLD, 13)); 195 | cancel.addActionListener(new ActionListener() { 196 | public void actionPerformed(ActionEvent e) { 197 | System.exit(0); 198 | } 199 | }); 200 | controlBotton.add(cancel); 201 | 202 | Component horizontalStrut_6 = Box.createHorizontalStrut(20); 203 | controlBotton.add(horizontalStrut_6); 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /src/main/java/easy/model/Product.java: -------------------------------------------------------------------------------- 1 | package easy.model; 2 | 3 | 4 | public class Product { 5 | 6 | private int id; 7 | private String tag; 8 | private String name; 9 | private String company; 10 | private double cp; 11 | private double sp; 12 | private double profit; 13 | private boolean status; 14 | 15 | 16 | public Product(int id,String tag, String name, String company, double cp, double sp, boolean status) { 17 | super(); 18 | this.id = id; 19 | this.tag = tag; 20 | this.name = name; 21 | this.company = company; 22 | this.status = status; 23 | this.cp = cp; 24 | this.sp = sp; 25 | this.profit = sp-cp; 26 | 27 | } 28 | public Product(String tag, String name, String company, double cp, double sp, boolean status) { 29 | this(0,tag,name,company,cp,sp,status); 30 | } 31 | 32 | 33 | 34 | public double getCp() { 35 | return cp; 36 | } 37 | 38 | 39 | 40 | public void setCp(double cp) { 41 | this.cp = cp; 42 | } 43 | 44 | 45 | 46 | public double getSp() { 47 | return sp; 48 | } 49 | 50 | 51 | 52 | public void setSp(double sp) { 53 | this.sp = sp; 54 | } 55 | 56 | 57 | 58 | public double getProfit() { 59 | return profit; 60 | } 61 | 62 | 63 | 64 | public void setProfit(double profit) { 65 | this.profit = profit; 66 | } 67 | 68 | 69 | 70 | public String getTag() { 71 | return tag; 72 | } 73 | public void setTag(String tag) { 74 | this.tag = tag; 75 | } 76 | public int getId() { 77 | return id; 78 | } 79 | public void setId(int id) { 80 | this.id = id; 81 | } 82 | public String getName() { 83 | return name; 84 | } 85 | public void setName(String name) { 86 | this.name = name; 87 | } 88 | public String getCompany() { 89 | return company; 90 | } 91 | public void setCompany(String company) { 92 | this.company = company; 93 | } 94 | public boolean isStatus() { 95 | return status; 96 | } 97 | public void setStatus(boolean status) { 98 | this.status = status; 99 | } 100 | 101 | public boolean getStatus(){ 102 | return status; 103 | } 104 | 105 | @Override 106 | public String toString() { 107 | return String 108 | .format("Product [id=%s, Name=%s, Company=%s, Cost Price=%.2f, Selling Price=%.2f Status=%B]", 109 | id, name, company, cp,sp , status); 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/easy/util/EasyConstant.java: -------------------------------------------------------------------------------- 1 | package easy.util; 2 | 3 | public class EasyConstant { 4 | public static final String INSERT_PRODUCT_QUERY = "INSERT INTO products ( `tag`, `name`, `company`, `cost_price`,`selling_price`,`profit`, `status`) VALUES (?,?,?,?,?,?,?)"; 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/main/java/easy/util/SecureRandomTagGen.java: -------------------------------------------------------------------------------- 1 | package easy.util; 2 | 3 | import java.math.BigInteger; 4 | import java.security.SecureRandom; 5 | 6 | public final class SecureRandomTagGen { 7 | private SecureRandom random = new SecureRandom(); 8 | 9 | public String getTagNumber() { 10 | return new BigInteger(50, random).toString(32); 11 | } 12 | } -------------------------------------------------------------------------------- /src/main/resource/application.properties: -------------------------------------------------------------------------------- 1 | username=root 2 | password=rammaya2009 3 | dburl=jdbc:mysql://localhost:3306/inventorymgtsys?useSSL=false -------------------------------------------------------------------------------- /src/main/resource/easyInlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/achyutdev/Easy-Inventory/cb3a72a6cd3b4e275fdd09a80ae1548e496839d4/src/main/resource/easyInlogo.png -------------------------------------------------------------------------------- /src/main/resource/rsz_1add-item-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/achyutdev/Easy-Inventory/cb3a72a6cd3b4e275fdd09a80ae1548e496839d4/src/main/resource/rsz_1add-item-icon.png -------------------------------------------------------------------------------- /src/main/resource/rsz_1easyinlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/achyutdev/Easy-Inventory/cb3a72a6cd3b4e275fdd09a80ae1548e496839d4/src/main/resource/rsz_1easyinlogo.png -------------------------------------------------------------------------------- /src/main/resource/rsz_2easyinlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/achyutdev/Easy-Inventory/cb3a72a6cd3b4e275fdd09a80ae1548e496839d4/src/main/resource/rsz_2easyinlogo.png -------------------------------------------------------------------------------- /src/main/resource/rsz_billingreport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/achyutdev/Easy-Inventory/cb3a72a6cd3b4e275fdd09a80ae1548e496839d4/src/main/resource/rsz_billingreport.png -------------------------------------------------------------------------------- /src/main/resource/rsz_easyinlogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/achyutdev/Easy-Inventory/cb3a72a6cd3b4e275fdd09a80ae1548e496839d4/src/main/resource/rsz_easyinlogo.png -------------------------------------------------------------------------------- /src/main/resource/rsz_login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/achyutdev/Easy-Inventory/cb3a72a6cd3b4e275fdd09a80ae1548e496839d4/src/main/resource/rsz_login.png -------------------------------------------------------------------------------- /src/main/resource/rsz_password_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/achyutdev/Easy-Inventory/cb3a72a6cd3b4e275fdd09a80ae1548e496839d4/src/main/resource/rsz_password_icon.png -------------------------------------------------------------------------------- /src/main/resource/rsz_sell.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/achyutdev/Easy-Inventory/cb3a72a6cd3b4e275fdd09a80ae1548e496839d4/src/main/resource/rsz_sell.png -------------------------------------------------------------------------------- /src/main/resource/rsz_update-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/achyutdev/Easy-Inventory/cb3a72a6cd3b4e275fdd09a80ae1548e496839d4/src/main/resource/rsz_update-icon.png --------------------------------------------------------------------------------