diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..acd2672
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,6 @@
+{
+ "java.project.referencedLibraries": [
+ "lib/**/*.jar",
+ "c:\\Program Files\\Java\\mysql-connector-j-8.0.32\\mysql-connector-j-8.0.32.jar"
+ ]
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index 43e3df4..de2e5d2 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,67 @@
-# Project_PBO_A
\ No newline at end of file
+# OtakuSide Application
+
+OtakuSide is a Java Swing application for managing product data. It provides a user interface to add, edit, and delete product information, as well as calculate total prices and handle transactions.
+
+## Features
+
+The OtakuSide application includes the following features:
+
+1. **Add Product**: Allows the user to add new products by entering the product name, price, and stock quantity.
+
+2. **Edit Product**: Enables the user to edit the details of an existing product, including the name, price, and stock quantity.
+
+3. **Delete Product**: Allows the user to remove a product from the database.
+
+4. **Calculate Total**: Calculates the total price of a selected product based on the quantity entered.
+
+5. **Save Transaction**: Saves the transaction by updating the stock quantity of the selected product and displaying the change amount (if applicable).
+
+6. **Clear**: Resets the input fields to their default values.
+
+7. **Populate Table**: Retrieves product data from the database and populates the table in the user interface.
+
+## Requirements
+
+To run the OtakuSide application on your local machine, make sure you have the following:
+
+- Java SE Development Kit (JDK): Ensure that you have Java SE Development Kit installed on your machine.
+
+- MySQL Connector/J 8.0.32: You need to have the MySQL Connector/J library to establish a connection between the application and the MySQL database.
+
+## Technology Used
+
+The OtakuSide application is built using the following technologies:
+
+- Java: The core programming language used for the application's logic and user interface.
+
+- Java Swing: The Java Swing framework is used for creating the graphical user interface (GUI) components.
+
+- MySQL: The application integrates with a MySQL database to store and retrieve product data.
+
+- MySQL Connector/J: The MySQL Connector/J library provides the JDBC driver for connecting the application to the MySQL database.
+
+## Getting Started
+
+To run the OtakuSide application on your local machine, follow these steps:
+
+1. Ensure that you have Java and MySQL installed on your system.
+
+2. Download or clone the OtakuSide repository to your local machine.
+
+3. Add the `mysql-connector-java-8.0.32.jar` file to your project's dependencies.
+
+4. Open the project in your preferred Java IDE.
+
+5. Compile and run the `App.java` file.
+
+## Contributing
+
+Contributions to the OtakuSide application are welcome. If you find any issues or want to add new features, please submit a pull request or open an issue on the GitHub repository.
+
+## License
+
+The OtakuSide application is released under the [MIT License](https://opensource.org/licenses/MIT). You are free to modify and distribute the code as per the terms of the license.
+
+## About the Author
+
+OtakuSide was created by Muhammad Nabil Shadiq (H071221083).
diff --git a/build.xml b/build.xml
new file mode 100644
index 0000000..a364fc3
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project OtakuSide.
+
+
+
diff --git a/build/classes/.netbeans_automatic_build b/build/classes/.netbeans_automatic_build
new file mode 100644
index 0000000..e69de29
diff --git a/build/classes/.netbeans_update_resources b/build/classes/.netbeans_update_resources
new file mode 100644
index 0000000..e69de29
diff --git a/build/classes/app/App$1.class b/build/classes/app/App$1.class
new file mode 100644
index 0000000..3f3693c
Binary files /dev/null and b/build/classes/app/App$1.class differ
diff --git a/build/classes/app/App$10.class b/build/classes/app/App$10.class
new file mode 100644
index 0000000..44b50b8
Binary files /dev/null and b/build/classes/app/App$10.class differ
diff --git a/build/classes/app/App$11.class b/build/classes/app/App$11.class
new file mode 100644
index 0000000..fcd91b5
Binary files /dev/null and b/build/classes/app/App$11.class differ
diff --git a/build/classes/app/App$12.class b/build/classes/app/App$12.class
new file mode 100644
index 0000000..72cea4f
Binary files /dev/null and b/build/classes/app/App$12.class differ
diff --git a/build/classes/app/App$13.class b/build/classes/app/App$13.class
new file mode 100644
index 0000000..09848ac
Binary files /dev/null and b/build/classes/app/App$13.class differ
diff --git a/build/classes/app/App$14.class b/build/classes/app/App$14.class
new file mode 100644
index 0000000..e678230
Binary files /dev/null and b/build/classes/app/App$14.class differ
diff --git a/build/classes/app/App$15.class b/build/classes/app/App$15.class
new file mode 100644
index 0000000..587b13c
Binary files /dev/null and b/build/classes/app/App$15.class differ
diff --git a/build/classes/app/App$2.class b/build/classes/app/App$2.class
new file mode 100644
index 0000000..5f8766e
Binary files /dev/null and b/build/classes/app/App$2.class differ
diff --git a/build/classes/app/App$3.class b/build/classes/app/App$3.class
new file mode 100644
index 0000000..02fe0d2
Binary files /dev/null and b/build/classes/app/App$3.class differ
diff --git a/build/classes/app/App$4.class b/build/classes/app/App$4.class
new file mode 100644
index 0000000..b137287
Binary files /dev/null and b/build/classes/app/App$4.class differ
diff --git a/build/classes/app/App$5.class b/build/classes/app/App$5.class
new file mode 100644
index 0000000..9c7ee24
Binary files /dev/null and b/build/classes/app/App$5.class differ
diff --git a/build/classes/app/App$6.class b/build/classes/app/App$6.class
new file mode 100644
index 0000000..d867418
Binary files /dev/null and b/build/classes/app/App$6.class differ
diff --git a/build/classes/app/App$7.class b/build/classes/app/App$7.class
new file mode 100644
index 0000000..9c44a89
Binary files /dev/null and b/build/classes/app/App$7.class differ
diff --git a/build/classes/app/App$8.class b/build/classes/app/App$8.class
new file mode 100644
index 0000000..f3b8ae7
Binary files /dev/null and b/build/classes/app/App$8.class differ
diff --git a/build/classes/app/App$9.class b/build/classes/app/App$9.class
new file mode 100644
index 0000000..c84f8e3
Binary files /dev/null and b/build/classes/app/App$9.class differ
diff --git a/build/classes/app/App.class b/build/classes/app/App.class
new file mode 100644
index 0000000..964be48
Binary files /dev/null and b/build/classes/app/App.class differ
diff --git a/build/classes/app/App.form b/build/classes/app/App.form
new file mode 100644
index 0000000..84dc397
--- /dev/null
+++ b/build/classes/app/App.form
@@ -0,0 +1,507 @@
+
+
+
diff --git a/build/classes/com/config/MyConnection.class b/build/classes/com/config/MyConnection.class
new file mode 100644
index 0000000..8df52e1
Binary files /dev/null and b/build/classes/com/config/MyConnection.class differ
diff --git a/build/classes/com/database/DataBase.class b/build/classes/com/database/DataBase.class
new file mode 100644
index 0000000..c5d0fea
Binary files /dev/null and b/build/classes/com/database/DataBase.class differ
diff --git a/build/classes/com/models/Product.class b/build/classes/com/models/Product.class
new file mode 100644
index 0000000..4e2192a
Binary files /dev/null and b/build/classes/com/models/Product.class differ
diff --git a/manifest.mf b/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml
new file mode 100644
index 0000000..bb1d1a3
--- /dev/null
+++ b/nbproject/build-impl.xml
@@ -0,0 +1,1771 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties
new file mode 100644
index 0000000..d819cb8
--- /dev/null
+++ b/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=3a58c70c
+build.xml.script.CRC32=77a386cb
+build.xml.stylesheet.CRC32=f85dc8f2@1.107.0.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=3a58c70c
+nbproject/build-impl.xml.script.CRC32=52032f21
+nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.107.0.48
diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties
new file mode 100644
index 0000000..3aefbdd
--- /dev/null
+++ b/nbproject/private/private.properties
@@ -0,0 +1,2 @@
+compile.on.save=true
+user.properties.file=C:\\Users\\ASUS\\AppData\\Roaming\\NetBeans\\18\\build.properties
diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml
new file mode 100644
index 0000000..8c2ed5f
--- /dev/null
+++ b/nbproject/private/private.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+ file:/C:/Users/ASUS/Documents/NetBeansProjects/OtakuSide/src/com/models/Product.java
+ file:/C:/Users/ASUS/Documents/NetBeansProjects/OtakuSide/src/app/App.java
+ file:/C:/Users/ASUS/Documents/NetBeansProjects/OtakuSide/src/com/config/MyConnection.java
+
+
+
diff --git a/nbproject/project.properties b/nbproject/project.properties
new file mode 100644
index 0000000..9fd6963
--- /dev/null
+++ b/nbproject/project.properties
@@ -0,0 +1,97 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.modulepath=\
+ ${run.modulepath}
+debug.test.classpath=\
+ ${run.test.classpath}
+debug.test.modulepath=\
+ ${run.test.modulepath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/OtakuSide.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+dist.jlink.dir=${dist.dir}/jlink
+dist.jlink.output=${dist.jlink.dir}/OtakuSide
+excludes=
+file.reference.mysql-connector-j-8.0.32.jar=C:\\Program Files\\Java\\mysql-connector-j-8.0.32\\mysql-connector-j-8.0.32.jar
+includes=**
+jar.compress=false
+javac.classpath=\
+ ${file.reference.mysql-connector-j-8.0.32.jar}
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.modulepath=
+javac.processormodulepath=
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=17
+javac.target=17
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.modulepath=\
+ ${javac.modulepath}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.html5=false
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+# The jlink additional root modules to resolve
+jlink.additionalmodules=
+# The jlink additional command line parameters
+jlink.additionalparam=
+jlink.launcher=true
+jlink.launcher.name=OtakuSide
+main.class=app.App
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.modulepath=\
+ ${javac.modulepath}
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+run.test.modulepath=\
+ ${javac.test.modulepath}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/nbproject/project.xml b/nbproject/project.xml
new file mode 100644
index 0000000..855a2f6
--- /dev/null
+++ b/nbproject/project.xml
@@ -0,0 +1,15 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ OtakuSide
+
+
+
+
+
+
+
+
+
diff --git a/src/app/App.java b/src/app/App.java
new file mode 100644
index 0000000..22b7617
--- /dev/null
+++ b/src/app/App.java
@@ -0,0 +1,689 @@
+package app;
+
+import java.awt.event.ActionEvent;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JOptionPane;
+import javax.swing.table.DefaultTableModel;
+
+import com.database.DataBase;
+import com.models.Product;
+import com.mysql.cj.result.Field;
+
+public class App extends javax.swing.JFrame {
+
+ ArrayList listProduct = new ArrayList<>();
+
+ public void clear() {
+ inputNama.setText("");
+ inputHarga.setText("");
+ inputStok.setText("");
+ inputNama.requestFocus();
+ }
+
+ public void insertData() {
+ DefaultTableModel model = (DefaultTableModel) tabelProduk.getModel();
+ int row = tabelProduk.getRowCount();
+ model.addRow(new Object[] {
+ row += 1,
+ inputNama.getText(),
+ inputHarga.getText(),
+ inputStok.getText()
+ });
+ }
+
+ public App() {
+ initComponents();
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jPanel1 = new javax.swing.JPanel();
+ jLabel1 = new javax.swing.JLabel();
+ jPanel2 = new javax.swing.JPanel();
+ jLabel2 = new javax.swing.JLabel();
+ jLabel3 = new javax.swing.JLabel();
+ jLabel4 = new javax.swing.JLabel();
+ inputNama = new javax.swing.JTextField();
+ inputHarga = new javax.swing.JTextField();
+ inputStok = new javax.swing.JTextField();
+ buttonAdd = new javax.swing.JButton();
+ buttonEdit = new javax.swing.JButton();
+ buttonDelete = new javax.swing.JButton();
+ buttonClear = new javax.swing.JButton();
+ jPanel3 = new javax.swing.JPanel();
+ jLabel5 = new javax.swing.JLabel();
+ jLabel6 = new javax.swing.JLabel();
+ jLabel7 = new javax.swing.JLabel();
+ inputTotal = new javax.swing.JTextField();
+ inputTunai = new javax.swing.JTextField();
+ inputKembalian = new javax.swing.JTextField();
+ buttonCount = new javax.swing.JButton();
+ buttonSave = new javax.swing.JButton();
+ jPanel4 = new javax.swing.JPanel();
+ jLabel8 = new javax.swing.JLabel();
+ jScrollPane1 = new javax.swing.JScrollPane();
+ tabelProduk = new javax.swing.JTable();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+ setTitle("OtakuSide Shop");
+
+ jPanel1.setBackground(new java.awt.Color(0, 153, 153));
+
+ jLabel1.setFont(new java.awt.Font("Segoe UI", 3, 36)); // NOI18N
+ jLabel1.setForeground(new java.awt.Color(255, 255, 255));
+ jLabel1.setText("OtakuSide SHOP");
+
+ javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
+ jPanel1.setLayout(jPanel1Layout);
+ jPanel1Layout.setHorizontalGroup(
+ jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel1Layout.createSequentialGroup()
+ .addGap(44, 44, 44)
+ .addComponent(jLabel1)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ jPanel1Layout.setVerticalGroup(
+ jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel1Layout.createSequentialGroup()
+ .addGap(41, 41, 41)
+ .addComponent(jLabel1)
+ .addContainerGap(43, Short.MAX_VALUE))
+ );
+
+ jPanel2.setBackground(new java.awt.Color(0, 153, 153));
+
+ javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
+ jPanel2.setLayout(jPanel2Layout);
+ jPanel2Layout.setHorizontalGroup(
+ jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGap(0, 0, Short.MAX_VALUE)
+ );
+ jPanel2Layout.setVerticalGroup(
+ jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGap(0, 50, Short.MAX_VALUE)
+ );
+
+ jLabel2.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
+ jLabel2.setText("NAMA");
+
+ jLabel3.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
+ jLabel3.setText("STOK");
+
+ jLabel4.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
+ jLabel4.setText("HARGA");
+
+ inputNama.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ inputNamaActionPerformed(evt);
+ }
+ });
+
+ inputHarga.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ inputHargaActionPerformed(evt);
+ }
+ });
+
+ inputStok.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ inputStokActionPerformed(evt);
+ }
+ });
+
+ buttonAdd.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N
+ buttonAdd.setText("Add");
+ buttonAdd.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonAddActionPerformed(evt);
+ }
+ });
+
+ buttonEdit.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N
+ buttonEdit.setText("Edit");
+ buttonEdit.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonEditActionPerformed(evt);
+ }
+ });
+
+ buttonDelete.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N
+ buttonDelete.setText("Delete");
+ buttonDelete.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonDeleteActionPerformed(evt);
+ }
+ });
+
+ buttonClear.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N
+ buttonClear.setText("Clear");
+ buttonClear.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonClearActionPerformed(evt);
+ }
+ });
+
+ jPanel3.setBackground(new java.awt.Color(204, 204, 204));
+
+ jLabel5.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N
+ jLabel5.setText("TOTAL");
+
+ jLabel6.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N
+ jLabel6.setText("TUNAI");
+
+ jLabel7.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N
+ jLabel7.setText("KEMBALI");
+
+ inputTotal.setEditable(false);
+ inputTotal.setText("Rp. ");
+ inputTotal.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ inputTotalActionPerformed(evt);
+ }
+ });
+
+ inputTunai.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ inputTunaiActionPerformed(evt);
+ }
+ });
+
+ inputKembalian.setEditable(false);
+ inputKembalian.setText("Rp. ");
+ inputKembalian.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ inputKembalianActionPerformed(evt);
+ }
+ });
+
+ buttonCount.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N
+ buttonCount.setText("Count");
+ buttonCount.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonCountActionPerformed(evt);
+ }
+ });
+
+ buttonSave.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N
+ buttonSave.setText("Save");
+ buttonSave.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonSaveActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
+ jPanel3.setLayout(jPanel3Layout);
+ jPanel3Layout.setHorizontalGroup(
+ jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel3Layout.createSequentialGroup()
+ .addGap(12, 12, 12)
+ .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel3Layout.createSequentialGroup()
+ .addComponent(buttonCount)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(buttonSave)
+ .addGap(0, 0, Short.MAX_VALUE))
+ .addGroup(jPanel3Layout.createSequentialGroup()
+ .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel3Layout.createSequentialGroup()
+ .addGap(31, 31, 31)
+ .addComponent(inputTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(inputTunai, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))))
+ .addGroup(jPanel3Layout.createSequentialGroup()
+ .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(inputKembalian, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addContainerGap())
+ );
+
+ jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonCount, buttonSave});
+
+ jPanel3Layout.setVerticalGroup(
+ jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel3Layout.createSequentialGroup()
+ .addGap(21, 21, 21)
+ .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel5)
+ .addComponent(inputTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel6)
+ .addComponent(inputTunai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel7)
+ .addComponent(inputKembalian, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(18, 18, 18)
+ .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(buttonCount)
+ .addComponent(buttonSave))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ jPanel3Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {buttonCount, buttonSave});
+
+ jPanel4.setBackground(new java.awt.Color(204, 204, 204));
+
+ jLabel8.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
+ jLabel8.setText("TABEL PRODUK");
+
+ tabelProduk.setModel(new javax.swing.table.DefaultTableModel(
+ new Object [][] {
+
+ },
+ new String [] {
+ "ID", "NAMA", "HARGA", "STOK"
+ }
+ ) {
+ boolean[] canEdit = new boolean [] {
+ false, false, false, false
+ };
+
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return canEdit [columnIndex];
+ }
+ });
+ tabelProduk.setGridColor(new java.awt.Color(51, 51, 51));
+ tabelProduk.setShowGrid(true);
+ tabelProduk.addMouseListener(new java.awt.event.MouseAdapter() {
+ public void mouseClicked(java.awt.event.MouseEvent evt) {
+ tabelProdukMouseClicked(evt);
+ }
+ });
+ jScrollPane1.setViewportView(tabelProduk);
+ populateTableWithData();
+ tabelProduk.getAccessibleContext().setAccessibleName("");
+
+ javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
+ jPanel4.setLayout(jPanel4Layout);
+ jPanel4Layout.setHorizontalGroup(
+ jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel4Layout.createSequentialGroup()
+ .addGap(207, 207, 207)
+ .addComponent(jLabel8)
+ .addContainerGap(212, Short.MAX_VALUE))
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(27, 27, 27))
+ );
+ jPanel4Layout.setVerticalGroup(
+ jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel4Layout.createSequentialGroup()
+ .addGap(17, 17, 17)
+ .addComponent(jLabel8)
+ .addGap(18, 18, 18)
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
+ .addContainerGap())
+ );
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
+ .addGroup(layout.createSequentialGroup()
+ .addGap(24, 24, 24)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(18, 18, 18)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(inputHarga, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(inputStok, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(inputNama, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(0, 0, Short.MAX_VALUE))
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(buttonAdd, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(buttonEdit, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(buttonDelete, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(buttonClear, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addGap(18, 18, 18)
+ .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(18, 18, 18)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel2)
+ .addComponent(inputNama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel4)
+ .addComponent(inputHarga, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel3)
+ .addComponent(inputStok, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(18, 18, 18)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(buttonAdd)
+ .addComponent(buttonEdit)
+ .addComponent(buttonDelete)
+ .addComponent(buttonClear))
+ .addGap(18, 18, 18)
+ .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, 48, Short.MAX_VALUE)
+ .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap())
+ );
+
+ pack();
+ }// //GEN-END:initComponents
+
+ protected void inputKembalianActionPerformed(ActionEvent evt) {
+ }
+
+ protected void inputTunaiActionPerformed(ActionEvent evt) {
+ }
+
+ protected void inputTotalActionPerformed(ActionEvent evt) {
+ }
+
+ protected void inputStokActionPerformed(ActionEvent evt) {
+ }
+
+ protected void inputHargaActionPerformed(ActionEvent evt) {
+ }
+
+ protected void inputNamaActionPerformed(ActionEvent evt) {
+ }
+
+ private void populateTableWithData() {
+ DefaultTableModel model = (DefaultTableModel) tabelProduk.getModel();
+ model.setRowCount(0);
+
+ List datas = DataBase.readDatabase();
+ // model.addRow(new Object[]{"1", "Barang 1", "100", "10"});
+ // model.addRow(new Object[]{"2", "Barang 2", "200", "20"});
+ // model.addRow(new Object[]{"3", "Barang 3", "300", "30"});
+ // model.addRow(new Object[]{"4", "Barang 4", "400", "40"});
+ for (Product data : datas) {
+ model.addRow(new Object[] {
+ data.getId(),
+ data.getNama(),
+ data.getHarga(),
+ data.getStok()
+ });
+ }
+ }
+
+ private void buttonAddActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_buttonAddActionPerformed
+ if (inputNama.getText().isEmpty() || inputHarga.getText().isEmpty() || inputStok.getText().isEmpty()) {
+ JOptionPane.showMessageDialog(null, "Lengkapi Inputan!");
+ } else {
+ String nama = inputNama.getText();
+ int harga = Integer.parseInt(inputHarga.getText());
+ int stok = Integer.parseInt(inputStok.getText());
+
+ if (DataBase.addDataBase(nama, harga, stok)) {
+ JOptionPane.showMessageDialog(null, "Data berhasil disimpan ke database!");
+ populateTableWithData();
+ } else {
+ JOptionPane.showMessageDialog(null, "Gagal menyimpan data ke database!");
+ }
+ clear();
+ }
+ }
+
+ private void buttonEditActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_buttonEditActionPerformed
+ DefaultTableModel model = (DefaultTableModel) tabelProduk.getModel();
+ int rowSelect = tabelProduk.getSelectedRow();
+ if (rowSelect >= 0) {
+ if ("Edit".equals(buttonEdit.getText())) {
+ buttonAdd.setEnabled(false);
+ buttonDelete.setEnabled(false);
+ buttonEdit.setText("Update");
+ buttonCount.setEnabled(false);
+ buttonSave.setEnabled(false);
+ inputNama.setText(model.getValueAt(rowSelect, 1).toString());
+ inputHarga.setText(model.getValueAt(rowSelect, 2).toString());
+ inputStok.setText(model.getValueAt(rowSelect, 3).toString());
+ } else {
+ buttonAdd.setEnabled(true);
+ buttonDelete.setEnabled(true);
+ buttonEdit.setText("Edit");
+ buttonCount.setEnabled(true);
+ buttonSave.setEnabled(true);
+
+ String nama = inputNama.getText();
+ String harga = inputHarga.getText();
+ String stok = inputStok.getText();
+
+ try {
+ int id = Integer.parseInt(model.getValueAt(rowSelect, 0).toString());
+ int hargaProduk = Integer.parseInt(harga);
+ int stokProduk = Integer.parseInt(stok);
+
+ model.setValueAt(inputNama.getText(), rowSelect, 1);
+ model.setValueAt(inputHarga.getText(), rowSelect, 2);
+ model.setValueAt(inputStok.getText(), rowSelect, 3);
+
+ if (DataBase.updateDatabase(id, nama, hargaProduk, stokProduk)) {
+ JOptionPane.showMessageDialog(this,
+ "Data berhasil diupdate!");
+ populateTableWithData();
+ } else {
+ JOptionPane.showMessageDialog(this,
+ "Gagal mengupdate database!");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ clear();
+ }
+ } else {
+ JOptionPane.showMessageDialog(this, "Pilih baris yang ingin diubah", "Pilih baris",
+ JOptionPane.WARNING_MESSAGE);
+ }
+ }
+
+ private void buttonDeleteActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_buttonDeleteActionPerformed
+ int rowSelected = tabelProduk.getSelectedRow();
+ DefaultTableModel model = (DefaultTableModel) tabelProduk.getModel();
+ int index = (int) model.getValueAt(rowSelected, 0);
+ if (DataBase.deleteDatabase(index)) {
+ JOptionPane.showMessageDialog(null, "Data berhasil dihapus dari database!");
+ populateTableWithData();
+ } else {
+ JOptionPane.showMessageDialog(null, "Gagal menghapus data dari database!");
+ }
+ clear();
+ }
+
+ private void buttonClearActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_buttonClearActionPerformed
+ clear();
+ }
+
+ private void buttonSaveActionPerformed(java.awt.event.ActionEvent evt) {
+ int rowSelect = tabelProduk.getSelectedRow();
+ DefaultTableModel model = (DefaultTableModel) tabelProduk.getModel();
+
+ if (rowSelect >= 0) {
+ if (!inputTunai.getText().isEmpty()) {
+ if (!inputKembalian.getText().equals("Rp. ")) {
+
+ int id = 0;
+ try {
+ id = Integer.parseInt(model.getValueAt(rowSelect, 0).toString());
+ } catch (NumberFormatException e) {
+ e.printStackTrace();
+ }
+ String nama = model.getValueAt(rowSelect, 1).toString();
+ String harga = model.getValueAt(rowSelect, 2).toString();
+ String stok = model.getValueAt(rowSelect, 3).toString();
+
+ try {
+ int hargaBarang = Integer.parseInt(harga);
+ int stokBarang = Integer.parseInt(stok) - 1;
+ if (DataBase.updateDatabase(id, nama, hargaBarang, stokBarang)) {
+ populateTableWithData();
+ JOptionPane.showMessageDialog(this, "Produk berhasil Dibeli!");
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ JOptionPane.showMessageDialog(this, "Click tombol calculate", "Error", JOptionPane.ERROR_MESSAGE);
+ buttonSave.setEnabled(false);
+ }
+ } else {
+ JOptionPane.showMessageDialog(this, "Lengkapi form beli", "Error", JOptionPane.ERROR_MESSAGE);
+ buttonSave.setEnabled(false);
+ }
+
+ } else {
+ JOptionPane.showMessageDialog(this, "tidak ada baris yang dipilih", "Error", JOptionPane.ERROR_MESSAGE);
+ }
+
+ inputTotal.setText("Rp. ");
+ inputTunai.setText("");
+ inputKembalian.setText("Rp.");
+ }
+
+ private void buttonCountActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_buttonSaveActionPerformed
+ // String[] valueTotal = btn_hitung.getText().split("");'
+ DefaultTableModel model = (DefaultTableModel) tabelProduk.getModel();
+ int rowSelected = tabelProduk.getSelectedRow();
+
+ try {
+ // int intTotal = Integer.parseInt(valueTotal[1]);
+ String valueHarga = model.getValueAt(rowSelected, 2).toString();
+ String valueJumlah = model.getValueAt(rowSelected, 3).toString();
+ int intHarga = Integer.parseInt(valueHarga);
+ int intJumlah = Integer.parseInt(valueJumlah);
+ int intTunai = Integer.parseInt(inputTunai.getText());
+ if (intTunai >= intHarga) {
+ inputKembalian.setText(String.format("Rp. %d", intTunai - intHarga));
+ } else {
+ JOptionPane.showMessageDialog(this, "Uang anda tidak cukup", "Konfirmasi pembelian",
+ JOptionPane.ERROR_MESSAGE);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ // String harga = in_harga.getText();
+ // String stok = in_stok.getText();
+ // updateTotal(harga, stok);
+ }
+
+ private void tabelProdukMouseClicked(java.awt.event.MouseEvent evt) {// GEN-FIRST:event_tabelProdukMouseClicked
+ DefaultTableModel model = (DefaultTableModel) tabelProduk.getModel();
+ int rowSelect = tabelProduk.getSelectedRow();
+ try {
+ int t = (int) model.getValueAt(rowSelect, 2);
+ inputTotal.setText("Rp." + Integer.toString(t));
+ } catch (Exception e) {
+ // TODO: handle exception
+ }
+ }
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String args[]) {
+ try {
+ for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager
+ .getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(info.getName())) {
+ javax.swing.UIManager.setLookAndFeel(info.getClassName());
+ break;
+ }
+ }
+ } catch (ClassNotFoundException ex) {
+ java.util.logging.Logger.getLogger(App.class
+ .getName()).log(java.util.logging.Level.SEVERE, null, ex);
+
+ } catch (InstantiationException ex) {
+ java.util.logging.Logger.getLogger(App.class
+ .getName()).log(java.util.logging.Level.SEVERE, null, ex);
+
+ } catch (IllegalAccessException ex) {
+ java.util.logging.Logger.getLogger(App.class
+ .getName()).log(java.util.logging.Level.SEVERE, null, ex);
+
+ } catch (javax.swing.UnsupportedLookAndFeelException ex) {
+ java.util.logging.Logger.getLogger(App.class
+ .getName()).log(java.util.logging.Level.SEVERE, null, ex);
+ }
+ //
+
+ /* Create and display the form */
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ new App().setVisible(true);
+
+ }
+ });
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton buttonAdd;
+ private javax.swing.JButton buttonClear;
+ private javax.swing.JButton buttonCount;
+ private javax.swing.JButton buttonDelete;
+ private javax.swing.JButton buttonEdit;
+ private javax.swing.JButton buttonSave;
+ private javax.swing.JTextField inputHarga;
+ private javax.swing.JTextField inputKembalian;
+ private javax.swing.JTextField inputNama;
+ private javax.swing.JTextField inputStok;
+ private javax.swing.JTextField inputTotal;
+ private javax.swing.JTextField inputTunai;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel3;
+ private javax.swing.JLabel jLabel4;
+ private javax.swing.JLabel jLabel5;
+ private javax.swing.JLabel jLabel6;
+ private javax.swing.JLabel jLabel7;
+ private javax.swing.JLabel jLabel8;
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JPanel jPanel3;
+ private javax.swing.JPanel jPanel4;
+ private javax.swing.JScrollPane jScrollPane1;
+ private javax.swing.JTable tabelProduk;
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/src/app/app.form b/src/app/app.form
new file mode 100644
index 0000000..84dc397
--- /dev/null
+++ b/src/app/app.form
@@ -0,0 +1,507 @@
+
+
+
diff --git a/src/com/config/MyConnection.java b/src/com/config/MyConnection.java
new file mode 100644
index 0000000..c8284e1
--- /dev/null
+++ b/src/com/config/MyConnection.java
@@ -0,0 +1,30 @@
+package com.config;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+public class MyConnection {
+ private static final String DB_URL = "jdbc:mysql://localhost:3306/db_produk";
+ private static final String DB_USER = "root";
+ private static final String DB_PASS = "";
+
+ protected static Connection connect;
+ protected static Statement statement;
+ protected static ResultSet resultSet;
+ protected static String query;
+ protected static PreparedStatement preparedStatement;
+
+ public static void connection() {
+ try {
+ connect = DriverManager.getConnection(DB_URL, DB_USER, DB_PASS);
+ } catch (SQLException e) {
+ e.printStackTrace();
+ System.out.println("Connection Failed");
+ }
+ }
+}
+
\ No newline at end of file
diff --git a/src/com/database/DataBase.java b/src/com/database/DataBase.java
new file mode 100644
index 0000000..4ed1c3e
--- /dev/null
+++ b/src/com/database/DataBase.java
@@ -0,0 +1,96 @@
+package com.database;
+
+import java.sql.SQLException;
+import com.config.MyConnection;
+import com.models.Product;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DataBase extends MyConnection {
+ public static List readDatabase() {
+ List productList = new ArrayList<>();
+
+ MyConnection.connection();
+ try {
+ String query = "SELECT * FROM tb_produk";
+ statement = connect.createStatement();
+ resultSet = statement.executeQuery(query);
+
+ while (resultSet.next()) {
+ int id = resultSet.getInt("ID");
+ String nama = resultSet.getString("NAMA");
+ int harga = resultSet.getInt("HARGA");
+ int stok = resultSet.getInt("STOK");
+
+ Product product = new Product();
+ product.setId(id);
+ product.setNama(nama);
+ product.setHarga(harga);
+ product.setStok(stok);
+
+ productList.add(product);
+ }
+ resultSet.close();
+ statement.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+
+ return productList;
+ }
+
+ public static boolean addDataBase(String product, int harga, int stok) {
+ connection();
+ query = "INSERT INTO tb_produk (NAMA, HARGA, STOK) VALUES (?, ?, ?)";
+ try {
+ preparedStatement = connect.prepareStatement(query);
+ preparedStatement.setString(1, product);
+ preparedStatement.setInt(2, harga);
+ preparedStatement.setInt(3, stok);
+ preparedStatement.executeUpdate();
+ preparedStatement.close();
+ return true;
+ } catch (SQLException e) {
+ e.printStackTrace();
+
+ }
+ return false;
+ }
+
+ public static boolean updateDatabase(int id, String nama, int harga, Integer stok) {
+ connection();
+ try {
+ String query = "UPDATE tb_produk SET NAMA=?, HARGA=?, STOK=? WHERE ID=?";
+ preparedStatement = connect.prepareStatement(query);
+ preparedStatement.setString(1, nama);
+ preparedStatement.setInt(2, harga);
+ preparedStatement.setInt(3, stok);
+ preparedStatement.setInt(4, id);
+ preparedStatement.executeUpdate();
+ preparedStatement.close();
+ return true;
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ public static boolean deleteDatabase(int id) {
+ connection();
+ query = "DELETE FROM tb_produk WHERE ID = ?";
+ try {
+ preparedStatement = connect.prepareStatement(query);
+ preparedStatement.setInt(1, id);
+ int rowDelete = preparedStatement.executeUpdate();
+ if (rowDelete > 0) {
+ return true;
+ }
+ preparedStatement.close();
+ } catch (SQLException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+}
diff --git a/src/com/models/Product.java b/src/com/models/Product.java
new file mode 100644
index 0000000..4e6ac62
--- /dev/null
+++ b/src/com/models/Product.java
@@ -0,0 +1,57 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.models;
+
+
+public class Product {
+ private int id;
+ private String nama;
+ private int harga;
+ private int stok;
+
+ public Product(int id, String nama, int harga, int stok) {
+ this.id = id;
+ this.nama = nama;
+ this.harga = harga;
+ this.stok = stok;
+ }
+
+ public Product(){}
+
+ public Product(String nama, int harga, int stok) {
+ this.nama = nama;
+ this.harga = harga;
+ this.stok = stok;
+ }
+
+ public int getId() {
+ return id;
+ }
+ public void setId(int id) {
+ this.id = id;
+ }
+ public String getNama() {
+ return nama;
+ }
+ public void setNama(String nama) {
+ this.nama = nama;
+ }
+ public int getHarga() {
+ return harga;
+ }
+ public void setHarga(int harga) {
+ this.harga = harga;
+ }
+ public int getStok() {
+ return stok;
+ }
+ public void setStok(int stok) {
+ this.stok = stok;
+ }
+
+ public int getPrice() {
+ return 0;
+ }
+}