├── README.md
├── manifest.mf
├── src
├── img
│ ├── reload.png
│ ├── supplier.png
│ ├── employee (1).png
│ ├── google-docs.png
│ ├── inventory (1).png
│ ├── programmer (1).png
│ ├── validating-ticket.png
│ └── customer-questions.png
├── report
│ └── shopReport.jasper
├── model
│ ├── MySQL.java
│ ├── invoiceItem.java
│ └── GRNItem.java
└── gui
│ ├── Signin.form
│ ├── Signin.java
│ ├── CompanyRegistion.form
│ ├── Home.form
│ ├── AddressView.form
│ ├── Home.java
│ ├── CompanyRegistion.java
│ ├── AddressView.java
│ ├── empolyee_register.form
│ ├── suppllerRegister.form
│ ├── customer_register.form
│ └── customer_register.java
├── lib
├── flatlaf-3.1.1.jar
├── commons-digester-2.1.jar
├── commons-logging-1.2.jar
├── jasperreports-6.20.5.jar
├── commons-beanutils-1.9.4.jar
├── jcalnder
│ └── jcalendar-1.4.jar
├── commons-collections-3.2.2.jar
├── commons-collections4-4.4.jar
├── mysql-connector-java-8.0.24.jar
├── flatlaf-intellij-themes-3.1.1.jar
├── CopyLibs
│ └── org-netbeans-modules-java-j2seproject-copylibstask.jar
└── nblibraries.properties
└── nbproject
├── private
├── private.properties
└── private.xml
├── genfiles.properties
├── project.xml
└── project.properties
/README.md:
--------------------------------------------------------------------------------
1 | # possystem
2 | java pos system
3 |
--------------------------------------------------------------------------------
/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/src/img/reload.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/src/img/reload.png
--------------------------------------------------------------------------------
/lib/flatlaf-3.1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/lib/flatlaf-3.1.1.jar
--------------------------------------------------------------------------------
/src/img/supplier.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/src/img/supplier.png
--------------------------------------------------------------------------------
/src/img/employee (1).png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/src/img/employee (1).png
--------------------------------------------------------------------------------
/src/img/google-docs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/src/img/google-docs.png
--------------------------------------------------------------------------------
/src/img/inventory (1).png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/src/img/inventory (1).png
--------------------------------------------------------------------------------
/src/img/programmer (1).png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/src/img/programmer (1).png
--------------------------------------------------------------------------------
/lib/commons-digester-2.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/lib/commons-digester-2.1.jar
--------------------------------------------------------------------------------
/lib/commons-logging-1.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/lib/commons-logging-1.2.jar
--------------------------------------------------------------------------------
/lib/jasperreports-6.20.5.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/lib/jasperreports-6.20.5.jar
--------------------------------------------------------------------------------
/src/img/validating-ticket.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/src/img/validating-ticket.png
--------------------------------------------------------------------------------
/src/report/shopReport.jasper:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/src/report/shopReport.jasper
--------------------------------------------------------------------------------
/lib/commons-beanutils-1.9.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/lib/commons-beanutils-1.9.4.jar
--------------------------------------------------------------------------------
/lib/jcalnder/jcalendar-1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/lib/jcalnder/jcalendar-1.4.jar
--------------------------------------------------------------------------------
/src/img/customer-questions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/src/img/customer-questions.png
--------------------------------------------------------------------------------
/lib/commons-collections-3.2.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/lib/commons-collections-3.2.2.jar
--------------------------------------------------------------------------------
/lib/commons-collections4-4.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/lib/commons-collections4-4.4.jar
--------------------------------------------------------------------------------
/lib/mysql-connector-java-8.0.24.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/lib/mysql-connector-java-8.0.24.jar
--------------------------------------------------------------------------------
/lib/flatlaf-intellij-themes-3.1.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/lib/flatlaf-intellij-themes-3.1.1.jar
--------------------------------------------------------------------------------
/nbproject/private/private.properties:
--------------------------------------------------------------------------------
1 | compile.on.save=true
2 | user.properties.file=C:\\Users\\user\\AppData\\Roaming\\NetBeans\\15\\build.properties
3 |
--------------------------------------------------------------------------------
/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IshanNikeshalaNawarathna/possystem/HEAD/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
--------------------------------------------------------------------------------
/lib/nblibraries.properties:
--------------------------------------------------------------------------------
1 | libs.CopyLibs.classpath=\
2 | ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar
3 | libs.CopyLibs.displayName=CopyLibs Task
4 | libs.CopyLibs.prop-version=3.0
5 | libs.jcalnder.classpath=\
6 | ${base}/jcalnder/jcalendar-1.4.jar
7 | libs.jcalnder.displayName=jcalendar
8 |
--------------------------------------------------------------------------------
/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=6bceaa04
2 | build.xml.script.CRC32=d5798013
3 | build.xml.stylesheet.CRC32=f85dc8f2@1.104.0.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=6bceaa04
7 | nbproject/build-impl.xml.script.CRC32=5ad791d2
8 | nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.104.0.48
9 |
--------------------------------------------------------------------------------
/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | shop_app
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | .\lib\nblibraries.properties
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/nbproject/private/private.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | file:/C:/Users/user/Documents/NetBeansProjects/shop_app/src/gui/CompanyRegistion.java
7 | file:/C:/Users/user/Documents/NetBeansProjects/shop_app/src/gui/Home.java
8 | file:/C:/Users/user/Documents/NetBeansProjects/shop_app/src/gui/Signin.java
9 | file:/C:/Users/user/Documents/NetBeansProjects/shop_app/src/gui/suppllerRegister.java
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/model/MySQL.java:
--------------------------------------------------------------------------------
1 | package model;
2 |
3 | import java.sql.Connection;
4 | import java.sql.DriverManager;
5 | import java.sql.ResultSet;
6 |
7 | public class MySQL {
8 |
9 | private static Connection connection;
10 |
11 | static {
12 | try {
13 | Class.forName("com.mysql.cj.jdbc.Driver");
14 | connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/shop_db", "root", "Ishan9952@*v$");
15 |
16 | } catch (Exception e) {
17 | e.printStackTrace();
18 | }
19 |
20 | }
21 |
22 | public static ResultSet execute(String query) throws Exception {
23 |
24 | if (query.startsWith("SELECT")) {
25 | return connection.createStatement().executeQuery(query);
26 | } else {
27 | connection.createStatement().executeUpdate(query);
28 | return null;
29 | }
30 |
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/model/invoiceItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
4 | */
5 | package model;
6 |
7 |
8 |
9 | /**
10 | *
11 | * @author user
12 | */
13 | public class invoiceItem {
14 |
15 | private String stockID;
16 | private String brandName;
17 | private String productName;
18 | private String mfg;
19 | private String exp;
20 | private String qty;
21 | private String sellingPrice;
22 |
23 | public String getStockID() {
24 | return stockID;
25 | }
26 |
27 | public void setStockID(String stockID) {
28 | this.stockID = stockID;
29 | }
30 |
31 | public String getBrandName() {
32 | return brandName;
33 | }
34 |
35 | public void setBrandName(String brandName) {
36 | this.brandName = brandName;
37 | }
38 |
39 | public String getProductName() {
40 | return productName;
41 | }
42 |
43 | public void setProductName(String productName) {
44 | this.productName = productName;
45 | }
46 |
47 | public String getQty() {
48 | return qty;
49 | }
50 |
51 | public void setQty(String qty) {
52 | this.qty = qty;
53 | }
54 |
55 | public String getSellingPrice() {
56 | return sellingPrice;
57 | }
58 |
59 | public void setSellingPrice(String sellingPrice) {
60 | this.sellingPrice = sellingPrice;
61 | }
62 |
63 | public String getMfg() {
64 | return mfg;
65 | }
66 |
67 | public void setMfg(String mfg) {
68 | this.mfg = mfg;
69 | }
70 |
71 | public String getExp() {
72 | return exp;
73 | }
74 |
75 | public void setExp(String exp) {
76 | this.exp = exp;
77 | }
78 |
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/src/model/GRNItem.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3 | * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
4 | */
5 | package model;
6 |
7 | import java.util.Date;
8 |
9 | /**
10 | *
11 | * @author user
12 | */
13 | public class GRNItem {
14 |
15 | private String productId;
16 | private String brandName;
17 | private String productName;
18 | private double qty;
19 | private double buyingPrice;
20 | private double sellingPrice;
21 | private Date mfg;
22 | private Date exp;
23 |
24 | public String getProductId() {
25 | return productId;
26 | }
27 |
28 | public void setProductId(String productId) {
29 | this.productId = productId;
30 | }
31 |
32 | public String getBrandName() {
33 | return brandName;
34 | }
35 |
36 | public void setBrandName(String brandName) {
37 | this.brandName = brandName;
38 | }
39 |
40 | public String getProductName() {
41 | return productName;
42 | }
43 |
44 | public void setProductName(String productName) {
45 | this.productName = productName;
46 | }
47 |
48 | public double getQty() {
49 | return qty;
50 | }
51 |
52 | public void setQty(double qty) {
53 | this.qty = qty;
54 | }
55 |
56 | public double getBuyingPrice() {
57 | return buyingPrice;
58 | }
59 |
60 | public void setBuyingPrice(double buyingPrice) {
61 | this.buyingPrice = buyingPrice;
62 | }
63 |
64 | public double getSellingPrice() {
65 | return sellingPrice;
66 | }
67 |
68 | public void setSellingPrice(double sellingPrice) {
69 | this.sellingPrice = sellingPrice;
70 | }
71 |
72 | public Date getMfg() {
73 | return mfg;
74 | }
75 |
76 | public void setMfg(Date mfg) {
77 | this.mfg = mfg;
78 | }
79 |
80 | public Date getExp() {
81 | return exp;
82 | }
83 |
84 | public void setExp(Date exp) {
85 | this.exp = exp;
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.modulepath=\
22 | ${run.modulepath}
23 | debug.test.classpath=\
24 | ${run.test.classpath}
25 | debug.test.modulepath=\
26 | ${run.test.modulepath}
27 | # Files in build.classes.dir which should be excluded from distribution jar
28 | dist.archive.excludes=
29 | # This directory is removed when the project is cleaned:
30 | dist.dir=dist
31 | dist.jar=${dist.dir}/shop_app.jar
32 | dist.javadoc.dir=${dist.dir}/javadoc
33 | dist.jlink.dir=${dist.dir}/jlink
34 | dist.jlink.output=${dist.jlink.dir}/shop_app
35 | excludes=
36 | file.reference.commons-beanutils-1.9.4.jar=lib\\commons-beanutils-1.9.4.jar
37 | file.reference.commons-collections-3.2.2.jar=lib\\commons-collections-3.2.2.jar
38 | file.reference.commons-collections4-4.4.jar=lib\\commons-collections4-4.4.jar
39 | file.reference.commons-digester-2.1.jar=lib\\commons-digester-2.1.jar
40 | file.reference.commons-logging-1.2.jar=lib\\commons-logging-1.2.jar
41 | file.reference.flatlaf-3.1.1.jar=lib\\flatlaf-3.1.1.jar
42 | file.reference.flatlaf-intellij-themes-3.1.1.jar=lib\\flatlaf-intellij-themes-3.1.1.jar
43 | file.reference.jasperreports-6.20.5.jar=lib\\jasperreports-6.20.5.jar
44 | file.reference.mysql-connector-java-8.0.24.jar=lib\\mysql-connector-java-8.0.24.jar
45 | includes=**
46 | jar.compress=false
47 | javac.classpath=\
48 | ${file.reference.mysql-connector-java-8.0.24.jar}:\
49 | ${file.reference.flatlaf-3.1.1.jar}:\
50 | ${file.reference.flatlaf-intellij-themes-3.1.1.jar}:\
51 | ${file.reference.jasperreports-6.20.5.jar}:\
52 | ${libs.jcalnder.classpath}:\
53 | ${file.reference.commons-beanutils-1.9.4.jar}:\
54 | ${file.reference.commons-collections-3.2.2.jar}:\
55 | ${file.reference.commons-collections4-4.4.jar}:\
56 | ${file.reference.commons-digester-2.1.jar}:\
57 | ${file.reference.commons-logging-1.2.jar}
58 | # Space-separated list of extra javac options
59 | javac.compilerargs=
60 | javac.deprecation=false
61 | javac.external.vm=true
62 | javac.modulepath=
63 | javac.processormodulepath=
64 | javac.processorpath=\
65 | ${javac.classpath}
66 | javac.source=1.8
67 | javac.target=1.8
68 | javac.test.classpath=\
69 | ${javac.classpath}:\
70 | ${build.classes.dir}
71 | javac.test.modulepath=\
72 | ${javac.modulepath}
73 | javac.test.processorpath=\
74 | ${javac.test.classpath}
75 | javadoc.additionalparam=
76 | javadoc.author=false
77 | javadoc.encoding=${source.encoding}
78 | javadoc.html5=false
79 | javadoc.noindex=false
80 | javadoc.nonavbar=false
81 | javadoc.notree=false
82 | javadoc.private=false
83 | javadoc.splitindex=true
84 | javadoc.use=true
85 | javadoc.version=false
86 | javadoc.windowtitle=
87 | # The jlink additional root modules to resolve
88 | jlink.additionalmodules=
89 | # The jlink additional command line parameters
90 | jlink.additionalparam=
91 | jlink.launcher=true
92 | jlink.launcher.name=shop_app
93 | main.class=
94 | manifest.file=manifest.mf
95 | meta.inf.dir=${src.dir}/META-INF
96 | mkdist.disabled=false
97 | platform.active=default_platform
98 | run.classpath=\
99 | ${javac.classpath}:\
100 | ${build.classes.dir}
101 | # Space-separated list of JVM arguments used when running the project.
102 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
103 | # To set system properties for unit tests define test-sys-prop.name=value:
104 | run.jvmargs=
105 | run.modulepath=\
106 | ${javac.modulepath}
107 | run.test.classpath=\
108 | ${javac.test.classpath}:\
109 | ${build.test.classes.dir}
110 | run.test.modulepath=\
111 | ${javac.test.modulepath}
112 | source.encoding=UTF-8
113 | src.dir=src
114 | test.src.dir=test
115 |
--------------------------------------------------------------------------------
/src/gui/Signin.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
128 |
--------------------------------------------------------------------------------
/src/gui/Signin.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3 | * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
4 | */
5 | package gui;
6 |
7 | import com.formdev.flatlaf.themes.FlatMacDarkLaf;
8 | import java.sql.ResultSet;
9 | import javax.swing.JButton;
10 | import javax.swing.JOptionPane;
11 | import model.MySQL;
12 |
13 | /**
14 | *
15 | * @author user
16 | */
17 | public class Signin extends javax.swing.JFrame {
18 |
19 | private static String newType;
20 |
21 | private static String employeeEmail;
22 |
23 | public static String getEmployeeEmail() {
24 | return employeeEmail;
25 | }
26 |
27 | private static void setEmployeeEmail(String employeeEmail) {
28 | Signin.employeeEmail = employeeEmail;
29 | }
30 |
31 | public static String getNewType() {
32 | return newType;
33 | }
34 |
35 | public static void setNewType(String aNewType) {
36 | newType = aNewType;
37 | }
38 |
39 | public Signin() {
40 | initComponents();
41 | }
42 |
43 | /**
44 | * This method is called from within the constructor to initialize the form.
45 | * WARNING: Do NOT modify this code. The content of this method is always
46 | * regenerated by the Form Editor.
47 | */
48 | @SuppressWarnings("unchecked")
49 | // //GEN-BEGIN:initComponents
50 | private void initComponents() {
51 |
52 | jPanel1 = new javax.swing.JPanel();
53 | jLabel1 = new javax.swing.JLabel();
54 | jLabel2 = new javax.swing.JLabel();
55 | jLabel3 = new javax.swing.JLabel();
56 | jTextField1 = new javax.swing.JTextField();
57 | jPasswordField1 = new javax.swing.JPasswordField();
58 | jButton1 = new javax.swing.JButton();
59 |
60 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
61 |
62 | jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N
63 | jLabel1.setText("SIGN IN");
64 |
65 | jLabel2.setText("Pasword");
66 |
67 | jLabel3.setText("Email");
68 |
69 | jPasswordField1.addActionListener(new java.awt.event.ActionListener() {
70 | public void actionPerformed(java.awt.event.ActionEvent evt) {
71 | jPasswordField1ActionPerformed(evt);
72 | }
73 | });
74 |
75 | jButton1.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N
76 | jButton1.setText("Sign In");
77 | jButton1.addActionListener(new java.awt.event.ActionListener() {
78 | public void actionPerformed(java.awt.event.ActionEvent evt) {
79 | jButton1ActionPerformed(evt);
80 | }
81 | });
82 |
83 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
84 | jPanel1.setLayout(jPanel1Layout);
85 | jPanel1Layout.setHorizontalGroup(
86 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
87 | .addGroup(jPanel1Layout.createSequentialGroup()
88 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
89 | .addGroup(jPanel1Layout.createSequentialGroup()
90 | .addGap(60, 60, 60)
91 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
92 | .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
93 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
94 | .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
95 | .addComponent(jTextField1)
96 | .addComponent(jPasswordField1, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE))))
97 | .addGroup(jPanel1Layout.createSequentialGroup()
98 | .addGap(24, 24, 24)
99 | .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE))
100 | .addGroup(jPanel1Layout.createSequentialGroup()
101 | .addGap(110, 110, 110)
102 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)))
103 | .addContainerGap(60, Short.MAX_VALUE))
104 | );
105 | jPanel1Layout.setVerticalGroup(
106 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
107 | .addGroup(jPanel1Layout.createSequentialGroup()
108 | .addContainerGap()
109 | .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
110 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
111 | .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
112 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
113 | .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
114 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
115 | .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
116 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
117 | .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
118 | .addGap(20, 20, 20)
119 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
120 | .addContainerGap(21, Short.MAX_VALUE))
121 | );
122 |
123 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
124 | getContentPane().setLayout(layout);
125 | layout.setHorizontalGroup(
126 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
127 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
128 | );
129 | layout.setVerticalGroup(
130 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
131 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
132 | );
133 |
134 | pack();
135 | setLocationRelativeTo(null);
136 | }// //GEN-END:initComponents
137 |
138 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
139 | // TODO add your handling code here:
140 |
141 | String email = jTextField1.getText();
142 | String password = String.valueOf(jPasswordField1.getPassword());
143 |
144 | if (email.isEmpty()) {
145 | JOptionPane.showMessageDialog(this, "Please Enter Email Address", "warning", JOptionPane.INFORMATION_MESSAGE);
146 | } else if (!email.matches("^(?=.{1,64}@)[A-Za-z0-9_-]+(\\.[A-Za-z0-9_-]+)*@"
147 | + "[^-][A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$")) {
148 | JOptionPane.showMessageDialog(this, "Invalid Email Address", "warning", JOptionPane.INFORMATION_MESSAGE);
149 | } else if (password.isEmpty()) {
150 | JOptionPane.showMessageDialog(this, "Please Enter Password", "warning", JOptionPane.INFORMATION_MESSAGE);
151 | } else {
152 |
153 | try {
154 |
155 | ResultSet resultset = MySQL.execute("SELECT * FROM `employee` INNER JOIN `employee_type` ON `employee`.`employee_type_id`=`employee_type`.`id` WHERE `email`='" + email + "' AND `password`='" + password + "'");
156 |
157 | if (resultset.next()) {
158 |
159 | String fname = resultset.getString("first_name");
160 | String lname = resultset.getString("last_name");
161 | String ty = resultset.getString("employee_type.name");
162 | setEmployeeEmail(email);
163 | setNewType(ty);
164 | Home home = new Home(email, fname, lname);
165 | home.setVisible(true);
166 | this.dispose();
167 |
168 | } else {
169 | JOptionPane.showMessageDialog(this, "Invalid Detalis", "warning", JOptionPane.INFORMATION_MESSAGE);
170 | }
171 |
172 | } catch (Exception e) {
173 | e.printStackTrace();
174 | }
175 |
176 | }
177 |
178 | }//GEN-LAST:event_jButton1ActionPerformed
179 |
180 | private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField1ActionPerformed
181 | // TODO add your handling code here:
182 | }//GEN-LAST:event_jPasswordField1ActionPerformed
183 |
184 | /**
185 | * @param args the command line arguments
186 | */
187 | public static void main(String args[]) {
188 |
189 | FlatMacDarkLaf.setup();
190 |
191 | java.awt.EventQueue.invokeLater(new Runnable() {
192 | public void run() {
193 | new Signin().setVisible(true);
194 | }
195 | });
196 | }
197 |
198 | // Variables declaration - do not modify//GEN-BEGIN:variables
199 | private javax.swing.JButton jButton1;
200 | private javax.swing.JLabel jLabel1;
201 | private javax.swing.JLabel jLabel2;
202 | private javax.swing.JLabel jLabel3;
203 | private javax.swing.JPanel jPanel1;
204 | private javax.swing.JPasswordField jPasswordField1;
205 | private javax.swing.JTextField jTextField1;
206 | // End of variables declaration//GEN-END:variables
207 |
208 | }
209 |
--------------------------------------------------------------------------------
/src/gui/CompanyRegistion.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
180 |
--------------------------------------------------------------------------------
/src/gui/Home.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
213 |
--------------------------------------------------------------------------------
/src/gui/AddressView.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
256 |
--------------------------------------------------------------------------------
/src/gui/Home.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3 | * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
4 | */
5 | package gui;
6 |
7 | public class Home extends javax.swing.JFrame {
8 |
9 | public Home(String email, String lname, String fname) {
10 | initComponents();
11 | jLabel2.setText(lname + " " + fname);
12 | jLabel4.setText(email);
13 | if (Signin.getNewType().equals("Cashiya")) {
14 | jButton2.setEnabled(false);
15 | jButton3.setEnabled(false);
16 | }
17 | }
18 |
19 | /**
20 | * This method is called from within the constructor to initialize the form.
21 | * WARNING: Do NOT modify this code. The content of this method is always
22 | * regenerated by the Form Editor.
23 | */
24 | @SuppressWarnings("unchecked")
25 | // //GEN-BEGIN:initComponents
26 | private void initComponents() {
27 |
28 | jPanel1 = new javax.swing.JPanel();
29 | jLabel1 = new javax.swing.JLabel();
30 | jLabel2 = new javax.swing.JLabel();
31 | jLabel3 = new javax.swing.JLabel();
32 | jLabel4 = new javax.swing.JLabel();
33 | jButton1 = new javax.swing.JButton();
34 | jButton2 = new javax.swing.JButton();
35 | jButton3 = new javax.swing.JButton();
36 | jButton4 = new javax.swing.JButton();
37 | jButton5 = new javax.swing.JButton();
38 | jButton6 = new javax.swing.JButton();
39 | jLabel5 = new javax.swing.JLabel();
40 |
41 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
42 |
43 | jLabel1.setText("Name");
44 |
45 | jLabel2.setText("None");
46 |
47 | jLabel3.setText("Email");
48 |
49 | jLabel4.setText("None");
50 |
51 | jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/customer-questions.png"))); // NOI18N
52 | jButton1.setText("Customer Registation");
53 | jButton1.addActionListener(new java.awt.event.ActionListener() {
54 | public void actionPerformed(java.awt.event.ActionEvent evt) {
55 | jButton1ActionPerformed(evt);
56 | }
57 | });
58 |
59 | jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/supplier.png"))); // NOI18N
60 | jButton2.setText("Supplier Registation");
61 | jButton2.addActionListener(new java.awt.event.ActionListener() {
62 | public void actionPerformed(java.awt.event.ActionEvent evt) {
63 | jButton2ActionPerformed(evt);
64 | }
65 | });
66 |
67 | jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/employee (1).png"))); // NOI18N
68 | jButton3.setText("Employee Registation ");
69 | jButton3.addActionListener(new java.awt.event.ActionListener() {
70 | public void actionPerformed(java.awt.event.ActionEvent evt) {
71 | jButton3ActionPerformed(evt);
72 | }
73 | });
74 |
75 | jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/google-docs.png"))); // NOI18N
76 | jButton4.setText("GRN");
77 | jButton4.addActionListener(new java.awt.event.ActionListener() {
78 | public void actionPerformed(java.awt.event.ActionEvent evt) {
79 | jButton4ActionPerformed(evt);
80 | }
81 | });
82 |
83 | jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/validating-ticket.png"))); // NOI18N
84 | jButton5.setText("Invoice");
85 | jButton5.addActionListener(new java.awt.event.ActionListener() {
86 | public void actionPerformed(java.awt.event.ActionEvent evt) {
87 | jButton5ActionPerformed(evt);
88 | }
89 | });
90 |
91 | jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/inventory (1).png"))); // NOI18N
92 | jButton6.setText("Stock");
93 | jButton6.addActionListener(new java.awt.event.ActionListener() {
94 | public void actionPerformed(java.awt.event.ActionEvent evt) {
95 | jButton6ActionPerformed(evt);
96 | }
97 | });
98 |
99 | jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
100 | jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/programmer (1).png"))); // NOI18N
101 |
102 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
103 | jPanel1.setLayout(jPanel1Layout);
104 | jPanel1Layout.setHorizontalGroup(
105 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
106 | .addGroup(jPanel1Layout.createSequentialGroup()
107 | .addGap(10, 10, 10)
108 | .addComponent(jButton1)
109 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
110 | .addComponent(jButton2)
111 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
112 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
113 | .addGap(55, 55, 55)
114 | .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))
115 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
116 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
117 | .addComponent(jButton3)
118 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
119 | .addComponent(jButton4)))
120 | .addGap(6, 6, 6)
121 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
122 | .addGroup(jPanel1Layout.createSequentialGroup()
123 | .addComponent(jButton5)
124 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
125 | .addComponent(jButton6))
126 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
127 | .addGroup(jPanel1Layout.createSequentialGroup()
128 | .addComponent(jLabel3)
129 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
130 | .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
131 | .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
132 | .addComponent(jLabel1)
133 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
134 | .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE))))
135 | .addContainerGap(12, Short.MAX_VALUE))
136 | );
137 | jPanel1Layout.setVerticalGroup(
138 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
139 | .addGroup(jPanel1Layout.createSequentialGroup()
140 | .addContainerGap()
141 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
142 | .addGroup(jPanel1Layout.createSequentialGroup()
143 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
144 | .addComponent(jLabel1)
145 | .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
146 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
147 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
148 | .addComponent(jLabel3)
149 | .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
150 | .addGap(10, 10, 10))
151 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
152 | .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
153 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
154 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
155 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
156 | .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
157 | .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
158 | .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
159 | .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
160 | .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
161 | .addContainerGap(10, Short.MAX_VALUE))
162 | );
163 |
164 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
165 | getContentPane().setLayout(layout);
166 | layout.setHorizontalGroup(
167 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
168 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
169 | );
170 | layout.setVerticalGroup(
171 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
172 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
173 | );
174 |
175 | pack();
176 | setLocationRelativeTo(null);
177 | }// //GEN-END:initComponents
178 |
179 | private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
180 | // TODO add your handling code here:
181 | // type();
182 | stock sk = new stock();
183 | sk.setVisible(true);
184 |
185 | }//GEN-LAST:event_jButton6ActionPerformed
186 |
187 | private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
188 | // TODO add your handling code here:
189 | // type();
190 | invoice in = new invoice();
191 | in.setVisible(true);
192 |
193 | }//GEN-LAST:event_jButton5ActionPerformed
194 |
195 | private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
196 | // TODO add your handling code here:
197 | // type();
198 | grn GRN = new grn();
199 | GRN.setVisible(true);
200 |
201 | }//GEN-LAST:event_jButton4ActionPerformed
202 |
203 | private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
204 | // TODO add your handling code here:
205 | // type();
206 | empolyee_register emp = new empolyee_register();
207 | emp.setVisible(true);
208 | // if(type == string)
209 | }//GEN-LAST:event_jButton3ActionPerformed
210 |
211 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
212 | // TODO add your handling code here:
213 | // type();
214 | suppllerRegister sp = new suppllerRegister();
215 | sp.setVisible(true);
216 |
217 | }//GEN-LAST:event_jButton2ActionPerformed
218 |
219 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
220 | // TODO add your handling code here:
221 | // type();
222 | customer_register creg = new customer_register();
223 | creg.setVisible(true);
224 |
225 | }//GEN-LAST:event_jButton1ActionPerformed
226 |
227 | /**
228 | * @param args the command line arguments
229 | */
230 | // public static void main(String args[]) {
231 | // /* Set the Nimbus look and feel */
232 | // //
233 | // /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
234 | // * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
235 | // */
236 | // try {
237 | // for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
238 | // if ("Nimbus".equals(info.getName())) {
239 | // javax.swing.UIManager.setLookAndFeel(info.getClassName());
240 | // break;
241 | // }
242 | // }
243 | // } catch (ClassNotFoundException ex) {
244 | // java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
245 | // } catch (InstantiationException ex) {
246 | // java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
247 | // } catch (IllegalAccessException ex) {
248 | // java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
249 | // } catch (javax.swing.UnsupportedLookAndFeelException ex) {
250 | // java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
251 | // }
252 | // //
253 | //
254 | // /* Create and display the form */
255 | // java.awt.EventQueue.invokeLater(new Runnable() {
256 | // public void run() {
257 | // new Home().setVisible(true);
258 | // }
259 | // });
260 | // }
261 |
262 | // Variables declaration - do not modify//GEN-BEGIN:variables
263 | private javax.swing.JButton jButton1;
264 | private javax.swing.JButton jButton2;
265 | private javax.swing.JButton jButton3;
266 | private javax.swing.JButton jButton4;
267 | private javax.swing.JButton jButton5;
268 | private javax.swing.JButton jButton6;
269 | private javax.swing.JLabel jLabel1;
270 | private javax.swing.JLabel jLabel2;
271 | private javax.swing.JLabel jLabel3;
272 | private javax.swing.JLabel jLabel4;
273 | private javax.swing.JLabel jLabel5;
274 | private javax.swing.JPanel jPanel1;
275 | // End of variables declaration//GEN-END:variables
276 | }
277 |
--------------------------------------------------------------------------------
/src/gui/CompanyRegistion.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3 | * Click nbfs://nbhost/SystemFileSystem/Templates/AWTForms/Dialog.java to edit this template
4 | */
5 | package gui;
6 |
7 | import com.formdev.flatlaf.themes.FlatMacDarkLaf;
8 | import java.sql.ResultSet;
9 | import java.util.Vector;
10 | import javax.swing.JOptionPane;
11 | import javax.swing.table.DefaultTableModel;
12 | import model.MySQL;
13 |
14 | /**
15 | *
16 | * @author user
17 | */
18 | public class CompanyRegistion extends java.awt.Dialog {
19 |
20 | suppllerRegister sr;
21 |
22 | /**
23 | * Creates new form CompanyRegistion
24 | */
25 | public CompanyRegistion(java.awt.Frame parent, boolean modal) {
26 | super(parent, modal);
27 | initComponents();
28 | loadCompany();
29 | sr = (suppllerRegister) parent;
30 | }
31 |
32 | private void loadCompany() {
33 |
34 | try {
35 | ResultSet resultset = MySQL.execute("SELECT * FROM `company`");
36 |
37 | DefaultTableModel table = (DefaultTableModel) jTable1.getModel();
38 | table.setRowCount(0);
39 |
40 | while (resultset.next()) {
41 | Vector vector = new Vector<>();
42 | vector.add(resultset.getString("id"));
43 | vector.add(resultset.getString("name"));
44 | vector.add(resultset.getString("hotline"));
45 |
46 | table.addRow(vector);
47 | }
48 |
49 | } catch (Exception e) {
50 | e.printStackTrace();
51 | }
52 |
53 | }
54 |
55 | private void rest() {
56 |
57 | jTextField2.setText("");
58 | jTextField3.setText("");
59 | jTextField1.requestFocus();
60 | jButton1.setEnabled(true);
61 | jTable1.clearSelection();
62 |
63 | }
64 |
65 | /**
66 | * This method is called from within the constructor to initialize the form.
67 | * WARNING: Do NOT modify this code. The content of this method is always
68 | * regenerated by the Form Editor.
69 | */
70 | // //GEN-BEGIN:initComponents
71 | private void initComponents() {
72 |
73 | jTextField1 = new javax.swing.JTextField();
74 | jPanel1 = new javax.swing.JPanel();
75 | jScrollPane1 = new javax.swing.JScrollPane();
76 | jTable1 = new javax.swing.JTable();
77 | jLabel1 = new javax.swing.JLabel();
78 | jTextField2 = new javax.swing.JTextField();
79 | jLabel2 = new javax.swing.JLabel();
80 | jTextField3 = new javax.swing.JTextField();
81 | jButton1 = new javax.swing.JButton();
82 | jButton2 = new javax.swing.JButton();
83 | jButton3 = new javax.swing.JButton();
84 |
85 | jTextField1.setText("jTextField1");
86 |
87 | addWindowListener(new java.awt.event.WindowAdapter() {
88 | public void windowClosing(java.awt.event.WindowEvent evt) {
89 | closeDialog(evt);
90 | }
91 | });
92 |
93 | jTable1.setModel(new javax.swing.table.DefaultTableModel(
94 | new Object [][] {
95 |
96 | },
97 | new String [] {
98 | "ID", "Company Name", "Hotline Number"
99 | }
100 | ) {
101 | boolean[] canEdit = new boolean [] {
102 | false, false, false
103 | };
104 |
105 | public boolean isCellEditable(int rowIndex, int columnIndex) {
106 | return canEdit [columnIndex];
107 | }
108 | });
109 | jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
110 | public void mouseClicked(java.awt.event.MouseEvent evt) {
111 | jTable1MouseClicked(evt);
112 | }
113 | });
114 | jScrollPane1.setViewportView(jTable1);
115 |
116 | jLabel1.setText("Name");
117 |
118 | jLabel2.setText("Hotline");
119 | jLabel2.setToolTipText("");
120 |
121 | jButton1.setText("Add");
122 | jButton1.addActionListener(new java.awt.event.ActionListener() {
123 | public void actionPerformed(java.awt.event.ActionEvent evt) {
124 | jButton1ActionPerformed(evt);
125 | }
126 | });
127 |
128 | jButton2.setText("Update");
129 | jButton2.addActionListener(new java.awt.event.ActionListener() {
130 | public void actionPerformed(java.awt.event.ActionEvent evt) {
131 | jButton2ActionPerformed(evt);
132 | }
133 | });
134 |
135 | jButton3.addActionListener(new java.awt.event.ActionListener() {
136 | public void actionPerformed(java.awt.event.ActionEvent evt) {
137 | jButton3ActionPerformed(evt);
138 | }
139 | });
140 |
141 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
142 | jPanel1.setLayout(jPanel1Layout);
143 | jPanel1Layout.setHorizontalGroup(
144 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
145 | .addGroup(jPanel1Layout.createSequentialGroup()
146 | .addGap(10, 10, 10)
147 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
148 | .addComponent(jScrollPane1)
149 | .addGroup(jPanel1Layout.createSequentialGroup()
150 | .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
151 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
152 | .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
153 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
154 | .addComponent(jLabel2)
155 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
156 | .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
157 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
158 | .addComponent(jButton1)
159 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
160 | .addComponent(jButton2)
161 | .addGap(18, 18, 18)
162 | .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)))
163 | .addContainerGap(10, Short.MAX_VALUE))
164 | );
165 | jPanel1Layout.setVerticalGroup(
166 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
167 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
168 | .addGap(10, 10, 10)
169 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
170 | .addComponent(jButton3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
171 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
172 | .addComponent(jLabel1)
173 | .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
174 | .addComponent(jLabel2)
175 | .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
176 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
177 | .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)))
178 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
179 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
180 | .addGap(10, 10, 10))
181 | );
182 |
183 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
184 | this.setLayout(layout);
185 | layout.setHorizontalGroup(
186 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
187 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
188 | );
189 | layout.setVerticalGroup(
190 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
191 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
192 | );
193 |
194 | pack();
195 | setLocationRelativeTo(null);
196 | }// //GEN-END:initComponents
197 |
198 | /**
199 | * Closes the dialog
200 | */
201 | private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
202 | setVisible(false);
203 | dispose();
204 | }//GEN-LAST:event_closeDialog
205 |
206 | private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
207 | // TODO add your handling code here:
208 | }//GEN-LAST:event_jButton3ActionPerformed
209 |
210 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
211 | // TODO add your handling code here:
212 |
213 | String name = jTextField2.getText();
214 | String hotline = jTextField3.getText();
215 |
216 | if (name.isEmpty()) {
217 | JOptionPane.showMessageDialog(this, "Please Enter Company Name", "warning", JOptionPane.INFORMATION_MESSAGE);
218 | } else if (hotline.isEmpty()) {
219 | JOptionPane.showMessageDialog(this, "Please Enter Company Hotline Number", "warning", JOptionPane.INFORMATION_MESSAGE);
220 | } else if (!hotline.matches("^0((11)|(2(1|[3-7]))|(3[1-8])|(4(1|5|7))|(5(1|2|4|5|7))|(6(3|[5-7]))|([8-9]1))[0-9]{7}$")) {
221 | JOptionPane.showMessageDialog(this, "Invalid Hotline Number", "warning", JOptionPane.INFORMATION_MESSAGE);
222 | } else {
223 |
224 | try {
225 |
226 | ResultSet resultset = MySQL.execute("SELECT * FROM `company` WHERE `name`='" + name + "' OR `hotline`='" + hotline + "'");
227 | if (resultset.next()) {
228 | JOptionPane.showMessageDialog(this, "Company Name or Hotline already used.", "warning", JOptionPane.INFORMATION_MESSAGE);
229 | }
230 |
231 | MySQL.execute("INSERT INTO `company`(`name`,`hotline`)VALUES('" + name + "','" + hotline + "')");
232 | loadCompany();
233 | rest();
234 | } catch (Exception e) {
235 | e.printStackTrace();
236 | }
237 |
238 | }
239 |
240 | }//GEN-LAST:event_jButton1ActionPerformed
241 |
242 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
243 | // TODO add your handling code here:
244 |
245 | if (jTable1.getSelectedRow() == -1) {
246 | JOptionPane.showMessageDialog(this, "Please Select Company to Update", "warning", JOptionPane.INFORMATION_MESSAGE);
247 | } else {
248 |
249 | String name = jTextField2.getText();
250 | String hotline = jTextField3.getText();
251 |
252 | int row = jTable1.getSelectedRow();
253 | String id = String.valueOf(jTable1.getValueAt(row, 0));
254 |
255 | String selectName = String.valueOf(jTable1.getValueAt(row, 1));
256 | String selectHotline = String.valueOf(jTable1.getValueAt(row, 2));
257 |
258 | if (name.isEmpty()) {
259 | JOptionPane.showMessageDialog(this, "Please Enter Company Name", "warning", JOptionPane.INFORMATION_MESSAGE);
260 | } else if (hotline.isEmpty()) {
261 | JOptionPane.showMessageDialog(this, "Please Enter Company Hotline Number", "warning", JOptionPane.INFORMATION_MESSAGE);
262 | } else if (!hotline.matches("^0((11)|(2(1|[3-7]))|(3[1-8])|(4(1|5|7))|(5(1|2|4|5|7))|(6(3|[5-7]))|([8-9]1))[0-9]{7}$")) {
263 | JOptionPane.showMessageDialog(this, "Invalid Hotline Number", "warning", JOptionPane.INFORMATION_MESSAGE);
264 | } else if (selectName.equals(name) && selectHotline.equals(hotline)) {
265 | JOptionPane.showMessageDialog(this, "Please Change Name or Hotline Number", "warning", JOptionPane.INFORMATION_MESSAGE);
266 | } else {
267 |
268 | try {
269 |
270 | ResultSet resultset = MySQL.execute("SELECT * FROM `company` WHERE (`name`='" + name + "' OR `hotline`='" + hotline + "') AND `id`='" + id + "'");
271 | if (resultset.next()) {
272 | JOptionPane.showMessageDialog(this, "Company Name or Hotline already used.", "warning", JOptionPane.INFORMATION_MESSAGE);
273 | }
274 |
275 | MySQL.execute("UPDATE `company` SET `name`='" + name + "',`hotline`='" + hotline + "' WHERE `id`='" + id + "'");
276 | loadCompany();
277 | rest();
278 | } catch (Exception e) {
279 | e.printStackTrace();
280 | }
281 |
282 | }
283 |
284 | }
285 |
286 | }//GEN-LAST:event_jButton2ActionPerformed
287 |
288 | private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
289 | // TODO add your handling code here:
290 |
291 | int row = jTable1.getSelectedRow();
292 |
293 | jTextField2.setText(String.valueOf(jTable1.getValueAt(row, 1)));
294 | jTextField3.setText(String.valueOf(jTable1.getValueAt(row, 2)));
295 |
296 | jButton1.setEnabled(false);
297 |
298 | if (evt.getClickCount() == 2) {
299 |
300 | String name = String.valueOf(jTable1.getValueAt(row, 1));
301 | // sr.getjTextField1().setText(name);
302 | sr.comapnyName(name);
303 | this.dispose();
304 | // sr.getjTextField2().requestFocus();
305 | sr.gragFourcs();
306 |
307 | sr.setCompanyID(String.valueOf(jTable1.getValueAt(row, 0)));
308 | this.dispose();
309 | }
310 |
311 | }//GEN-LAST:event_jTable1MouseClicked
312 |
313 | /**
314 | * @param args the command line arguments
315 | */
316 | public static void main(String args[]) {
317 |
318 | java.awt.EventQueue.invokeLater(new Runnable() {
319 | public void run() {
320 | CompanyRegistion dialog = new CompanyRegistion(new java.awt.Frame(), true);
321 | dialog.addWindowListener(new java.awt.event.WindowAdapter() {
322 | public void windowClosing(java.awt.event.WindowEvent e) {
323 | System.exit(0);
324 | }
325 | });
326 | dialog.setVisible(true);
327 | }
328 | });
329 | }
330 |
331 |
332 | // Variables declaration - do not modify//GEN-BEGIN:variables
333 | private javax.swing.JButton jButton1;
334 | private javax.swing.JButton jButton2;
335 | private javax.swing.JButton jButton3;
336 | private javax.swing.JLabel jLabel1;
337 | private javax.swing.JLabel jLabel2;
338 | private javax.swing.JPanel jPanel1;
339 | private javax.swing.JScrollPane jScrollPane1;
340 | private javax.swing.JTable jTable1;
341 | private javax.swing.JTextField jTextField1;
342 | private javax.swing.JTextField jTextField2;
343 | private javax.swing.JTextField jTextField3;
344 | // End of variables declaration//GEN-END:variables
345 | }
346 |
--------------------------------------------------------------------------------
/src/gui/AddressView.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3 | * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
4 | */
5 | package gui;
6 |
7 | import java.sql.ResultSet;
8 | import java.util.HashMap;
9 | import java.util.Vector;
10 | import javax.swing.DefaultComboBoxModel;
11 | import javax.swing.JOptionPane;
12 | import javax.swing.table.DefaultTableModel;
13 | import model.MySQL;
14 |
15 | /**
16 | *
17 | * @author user
18 | */
19 | public class AddressView extends javax.swing.JDialog {
20 |
21 | private String email;
22 | private HashMap cityMap = new HashMap<>();
23 |
24 | /**
25 | * Creates new form AddressView
26 | */
27 | public AddressView(java.awt.Frame parent, boolean model, String em) {
28 | super(parent, model);
29 | initComponents();
30 | emailFiled.setText(em);
31 | this.email = em;
32 | loadAddress();
33 | loadCity();
34 | }
35 |
36 | private void loadAddress() {
37 |
38 | try {
39 | ResultSet resultset = MySQL.execute("SELECT * FROM `employee_address` INNER JOIN `city` ON `employee_address`.`city_id`=`city`.`id` WHERE `employee_email`='" + this.email + "' ");
40 |
41 | DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
42 | model.setRowCount(0);
43 |
44 | while (resultset.next()) {
45 | Vector vector = new Vector<>();
46 | vector.add(resultset.getString("id"));
47 | vector.add(resultset.getString("line1"));
48 | vector.add(resultset.getString("line2"));
49 | vector.add(resultset.getString("city.name"));
50 |
51 | model.addRow(vector);
52 | }
53 |
54 | } catch (Exception e) {
55 | e.printStackTrace();
56 | }
57 |
58 | }
59 |
60 | private void clera() {
61 |
62 | jTextField1.setText("");
63 | jTextField2.setText("");
64 | jComboBox1.setSelectedIndex(0);
65 | jTextField1.requestFocus();
66 |
67 | }
68 |
69 | private void loadCity() {
70 |
71 | try {
72 |
73 | ResultSet resultSet = MySQL.execute("SELECT * FROM `city`");
74 |
75 | Vector value = new Vector<>();
76 | value.add("Select");
77 |
78 | while (resultSet.next()) {
79 | value.add(resultSet.getString("name"));
80 | cityMap.put(resultSet.getString("name"), resultSet.getString("id"));
81 | }
82 |
83 | jComboBox1.setModel(new DefaultComboBoxModel<>(value));
84 |
85 | } catch (Exception e) {
86 | e.printStackTrace();
87 | }
88 |
89 | }
90 |
91 | /**
92 | * This method is called from within the constructor to initialize the form.
93 | * WARNING: Do NOT modify this code. The content of this method is always
94 | * regenerated by the Form Editor.
95 | */
96 | @SuppressWarnings("unchecked")
97 | // //GEN-BEGIN:initComponents
98 | private void initComponents() {
99 |
100 | jPanel1 = new javax.swing.JPanel();
101 | jLabel1 = new javax.swing.JLabel();
102 | jLabel2 = new javax.swing.JLabel();
103 | jLabel3 = new javax.swing.JLabel();
104 | jTextField1 = new javax.swing.JTextField();
105 | jTextField2 = new javax.swing.JTextField();
106 | jComboBox1 = new javax.swing.JComboBox<>();
107 | jButton1 = new javax.swing.JButton();
108 | jButton2 = new javax.swing.JButton();
109 | jButton3 = new javax.swing.JButton();
110 | jScrollPane1 = new javax.swing.JScrollPane();
111 | jTable1 = new javax.swing.JTable();
112 | jLabel4 = new javax.swing.JLabel();
113 | emailFiled = new javax.swing.JLabel();
114 |
115 | setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
116 |
117 | jLabel1.setText("Address Line1");
118 |
119 | jLabel2.setText("Address Line2");
120 |
121 | jLabel3.setText("City");
122 |
123 | jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
124 |
125 | jButton1.setText("Add");
126 | jButton1.addActionListener(new java.awt.event.ActionListener() {
127 | public void actionPerformed(java.awt.event.ActionEvent evt) {
128 | jButton1ActionPerformed(evt);
129 | }
130 | });
131 |
132 | jButton2.setText("Update");
133 | jButton2.addActionListener(new java.awt.event.ActionListener() {
134 | public void actionPerformed(java.awt.event.ActionEvent evt) {
135 | jButton2ActionPerformed(evt);
136 | }
137 | });
138 |
139 | jButton3.setText("Remove");
140 | jButton3.addActionListener(new java.awt.event.ActionListener() {
141 | public void actionPerformed(java.awt.event.ActionEvent evt) {
142 | jButton3ActionPerformed(evt);
143 | }
144 | });
145 |
146 | jTable1.setModel(new javax.swing.table.DefaultTableModel(
147 | new Object [][] {
148 | {null, null, null, null},
149 | {null, null, null, null},
150 | {null, null, null, null},
151 | {null, null, null, null}
152 | },
153 | new String [] {
154 | "ID", "Line1", "Line2", "City"
155 | }
156 | ) {
157 | boolean[] canEdit = new boolean [] {
158 | false, false, false, false
159 | };
160 |
161 | public boolean isCellEditable(int rowIndex, int columnIndex) {
162 | return canEdit [columnIndex];
163 | }
164 | });
165 | jTable1.addMouseListener(new java.awt.event.MouseAdapter() {
166 | public void mouseClicked(java.awt.event.MouseEvent evt) {
167 | jTable1MouseClicked(evt);
168 | }
169 | });
170 | jScrollPane1.setViewportView(jTable1);
171 |
172 | jLabel4.setText("Employee");
173 |
174 | emailFiled.setText("None");
175 |
176 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
177 | jPanel1.setLayout(jPanel1Layout);
178 | jPanel1Layout.setHorizontalGroup(
179 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
180 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
181 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
182 | .addGroup(jPanel1Layout.createSequentialGroup()
183 | .addContainerGap()
184 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
185 | .addGap(25, 25, 25)
186 | .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
187 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
188 | .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
189 | .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
190 | .addGap(10, 10, 10)
191 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
192 | .addGroup(jPanel1Layout.createSequentialGroup()
193 | .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
194 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
195 | .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
196 | .addGroup(jPanel1Layout.createSequentialGroup()
197 | .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
198 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
199 | .addComponent(jTextField1))
200 | .addGroup(jPanel1Layout.createSequentialGroup()
201 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
202 | .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
203 | .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE))
204 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
205 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
206 | .addComponent(emailFiled, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
207 | .addComponent(jTextField2))))))
208 | .addGap(10, 10, 10))
209 | .addGroup(jPanel1Layout.createSequentialGroup()
210 | .addContainerGap()
211 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 353, javax.swing.GroupLayout.PREFERRED_SIZE)
212 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
213 | );
214 | jPanel1Layout.setVerticalGroup(
215 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
216 | .addGroup(jPanel1Layout.createSequentialGroup()
217 | .addGap(10, 10, 10)
218 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
219 | .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
220 | .addComponent(emailFiled, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
221 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
222 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
223 | .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
224 | .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
225 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
226 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
227 | .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
228 | .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
229 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
230 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
231 | .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
232 | .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
233 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
234 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
235 | .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
236 | .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
237 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
238 | .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
239 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
240 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
241 | .addContainerGap())
242 | );
243 |
244 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
245 | getContentPane().setLayout(layout);
246 | layout.setHorizontalGroup(
247 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
248 | .addGroup(layout.createSequentialGroup()
249 | .addContainerGap()
250 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
251 | .addContainerGap())
252 | );
253 | layout.setVerticalGroup(
254 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
255 | .addGroup(layout.createSequentialGroup()
256 | .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
257 | .addGap(0, 10, Short.MAX_VALUE))
258 | );
259 |
260 | pack();
261 | setLocationRelativeTo(null);
262 | }// //GEN-END:initComponents
263 |
264 | private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
265 | // TODO add your handling code here:
266 |
267 | try {
268 |
269 | int row = jTable1.getSelectedRow();
270 |
271 | if (row == -1) {
272 | JOptionPane.showMessageDialog(this, "Select your Row", "warning", JOptionPane.INFORMATION_MESSAGE);
273 | } else {
274 |
275 | String id = String.valueOf(jTable1.getValueAt(row, 0));
276 |
277 | MySQL.execute("DELETE FROM `employee_address` WHERE `id`='" + id + "'");
278 |
279 | loadAddress();
280 |
281 | clera();
282 |
283 | }
284 |
285 | } catch (Exception e) {
286 | e.printStackTrace();
287 | }
288 |
289 |
290 | }//GEN-LAST:event_jButton3ActionPerformed
291 |
292 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
293 | // TODO add your handling code here:
294 |
295 | try {
296 |
297 | int row = jTable1.getSelectedRow();
298 |
299 | if (row == -1) {
300 | JOptionPane.showMessageDialog(this, "Please Select your row ", "warning", JOptionPane.INFORMATION_MESSAGE);
301 | } else {
302 | String id = String.valueOf(jTable1.getValueAt(row, 0));
303 |
304 | String line1 = jTextField1.getText();
305 | String line2 = jTextField2.getText();
306 | String city = String.valueOf(jComboBox1.getSelectedItem());
307 |
308 | if (line1.isEmpty()) {
309 | JOptionPane.showMessageDialog(this, "Type your Address line1 ", "warning", JOptionPane.INFORMATION_MESSAGE);
310 | } else if (line2.isEmpty()) {
311 | JOptionPane.showMessageDialog(this, "Type your Address line2 ", "warning", JOptionPane.INFORMATION_MESSAGE);
312 |
313 | } else if (city.equals("Select")) {
314 | JOptionPane.showMessageDialog(this, "Select your City", "warning", JOptionPane.INFORMATION_MESSAGE);
315 | } else {
316 |
317 | MySQL.execute("UPDATE `employee_address` SET `line1`='" + line1 + "',`line2`='" + line2 + "',`city_id`='" + cityMap.get(city) + "' WHERE `id`='" + id + "'");
318 |
319 | loadAddress();
320 | clera();
321 |
322 | }
323 | }
324 |
325 | } catch (Exception e) {
326 | e.printStackTrace();
327 | }
328 |
329 |
330 | }//GEN-LAST:event_jButton2ActionPerformed
331 |
332 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
333 | // TODO add your handling code here:
334 |
335 | try {
336 |
337 | String line1 = jTextField1.getText();
338 | String line2 = jTextField2.getText();
339 | String city = String.valueOf(jComboBox1.getSelectedItem());
340 |
341 | if (line1.isEmpty()) {
342 | JOptionPane.showMessageDialog(this, "Type your Address line1 ", "warning", JOptionPane.INFORMATION_MESSAGE);
343 | } else if (line2.isEmpty()) {
344 | JOptionPane.showMessageDialog(this, "Type your Address line2 ", "warning", JOptionPane.INFORMATION_MESSAGE);
345 | } else if (city.equals("Select")) {
346 | JOptionPane.showMessageDialog(this, "Select your City", "warning", JOptionPane.INFORMATION_MESSAGE);
347 | } else {
348 |
349 | boolean isFound = false;
350 |
351 | for (int row = 0; row < jTable1.getRowCount(); row++) {
352 |
353 | String getLine1 = String.valueOf(jTable1.getValueAt(row, 1));
354 | String getLine2 = String.valueOf(jTable1.getValueAt(row, 2));
355 | String getCity = String.valueOf(jTable1.getValueAt(row, 3));
356 |
357 | if (line1.equals(getLine1) && line2.equals(getLine2) && city.equals(getCity)) {
358 | JOptionPane.showMessageDialog(this, "Address alreay added", "warning", JOptionPane.INFORMATION_MESSAGE);
359 | isFound = true;
360 | break;
361 | }
362 |
363 | }
364 |
365 | if (!isFound) {
366 | MySQL.execute("INSERT INTO `employee_address`(`line1`,`line2`,`city_id`,`employee_email`) VALUES('" + line1 + "','" + line2 + "','" + cityMap.get(city) + "','" + this.email + "')");
367 |
368 | loadAddress();
369 | clera();
370 | }
371 |
372 | }
373 |
374 | } catch (Exception e) {
375 | e.printStackTrace();
376 | }
377 |
378 |
379 | }//GEN-LAST:event_jButton1ActionPerformed
380 |
381 | private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked
382 | // TODO add your handling code here:
383 |
384 | int row = jTable1.getSelectedRow();
385 |
386 | jTextField1.setText(String.valueOf(jTable1.getValueAt(row, 1)));
387 | jTextField2.setText(String.valueOf(jTable1.getValueAt(row, 2)));
388 | jComboBox1.setSelectedItem(String.valueOf(jTable1.getValueAt(row, 3)));
389 | }//GEN-LAST:event_jTable1MouseClicked
390 |
391 | /**
392 | * @param args the command line arguments
393 | */
394 | // public static void main(String args[]) {
395 | // /* Set the Nimbus look and feel */
396 | // //
397 | // /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
398 | // * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
399 | // */
400 | // try {
401 | // for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
402 | // if ("Nimbus".equals(info.getName())) {
403 | // javax.swing.UIManager.setLookAndFeel(info.getClassName());
404 | // break;
405 | // }
406 | // }
407 | // } catch (ClassNotFoundException ex) {
408 | // java.util.logging.Logger.getLogger(AddressView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
409 | // } catch (InstantiationException ex) {
410 | // java.util.logging.Logger.getLogger(AddressView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
411 | // } catch (IllegalAccessException ex) {
412 | // java.util.logging.Logger.getLogger(AddressView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
413 | // } catch (javax.swing.UnsupportedLookAndFeelException ex) {
414 | // java.util.logging.Logger.getLogger(AddressView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
415 | // }
416 | // //
417 | //
418 | // /* Create and display the form */
419 | // java.awt.EventQueue.invokeLater(new Runnable() {
420 | // public void run() {
421 | // new AddressView().setVisible(true);
422 | // }
423 | // });
424 | // }
425 |
426 | // Variables declaration - do not modify//GEN-BEGIN:variables
427 | private javax.swing.JLabel emailFiled;
428 | private javax.swing.JButton jButton1;
429 | private javax.swing.JButton jButton2;
430 | private javax.swing.JButton jButton3;
431 | private javax.swing.JComboBox jComboBox1;
432 | private javax.swing.JLabel jLabel1;
433 | private javax.swing.JLabel jLabel2;
434 | private javax.swing.JLabel jLabel3;
435 | private javax.swing.JLabel jLabel4;
436 | private javax.swing.JPanel jPanel1;
437 | private javax.swing.JScrollPane jScrollPane1;
438 | private javax.swing.JTable jTable1;
439 | private javax.swing.JTextField jTextField1;
440 | private javax.swing.JTextField jTextField2;
441 | // End of variables declaration//GEN-END:variables
442 |
443 | }
444 |
--------------------------------------------------------------------------------
/src/gui/empolyee_register.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
381 |
--------------------------------------------------------------------------------
/src/gui/suppllerRegister.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
406 |
--------------------------------------------------------------------------------
/src/gui/customer_register.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
400 |
--------------------------------------------------------------------------------
/src/gui/customer_register.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
3 | * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
4 | */
5 | package gui;
6 |
7 | import com.formdev.flatlaf.themes.FlatMacDarkLaf;
8 | import java.sql.ResultSet;
9 | import java.util.Vector;
10 | import javax.swing.JOptionPane;
11 | import javax.swing.table.DefaultTableModel;
12 | import model.MySQL;
13 |
14 | /**
15 | *
16 | * @author user
17 | */
18 | public class customer_register extends javax.swing.JFrame {
19 |
20 | private invoice Invoice;
21 |
22 | public void setInvoice(invoice Invoice) {
23 | this.Invoice = Invoice;
24 | }
25 |
26 | public customer_register() {
27 | initComponents();
28 | loadCustomer("first_name", "ASC", "0");
29 | }
30 |
31 | private void loadCustomer(String column, String method, String mobile) {
32 |
33 | try {
34 | ResultSet resultSet = MySQL.execute("SELECT * FROM `customer` WHERE `mobile` LIKE '" + mobile + "%' ORDER BY `" + column + "` " + method + "");
35 |
36 | DefaultTableModel table = (DefaultTableModel) jTable2.getModel();
37 | table.setRowCount(0);
38 |
39 | while (resultSet.next()) {
40 |
41 | Vector vector = new Vector<>();
42 | vector.add(resultSet.getString("mobile"));
43 | vector.add(resultSet.getString("first_name"));
44 | vector.add(resultSet.getString("last_name"));
45 | vector.add(resultSet.getString("email"));
46 | vector.add(resultSet.getString("points"));
47 |
48 | table.addRow(vector);
49 |
50 | }
51 |
52 | } catch (Exception e) {
53 | e.printStackTrace();
54 | }
55 |
56 | }
57 |
58 | private void reset() {
59 |
60 | jTextField1.setText("");
61 | jTextField1.setEditable(true);
62 | jTextField2.setText("");
63 | jTextField3.setText("");
64 | jTextField4.setText("");
65 | jTextField5.setText("");
66 | jComboBox1.setSelectedIndex(0);
67 | jTable2.clearSelection();
68 | jTextField1.grabFocus();
69 | jButton1.setEnabled(true);
70 |
71 | }
72 |
73 | private void search() {
74 |
75 | int sortIndex = jComboBox1.getSelectedIndex();
76 |
77 | if (sortIndex == 0) {
78 | loadCustomer("first_name", "ASC", jTextField1.getText());
79 | } else if (sortIndex == 1) {
80 | loadCustomer("first_name", "DESC", jTextField1.getText());
81 | } else if (sortIndex == 2) {
82 | loadCustomer("points", "ASC", jTextField1.getText());
83 | } else if (sortIndex == 3) {
84 | loadCustomer("points", "DESC", jTextField1.getText());
85 | }
86 |
87 | }
88 |
89 | /**
90 | * This method is called from within the constructor to initialize the form.
91 | * WARNING: Do NOT modify this code. The content of this method is always
92 | * regenerated by the Form Editor.
93 | */
94 | @SuppressWarnings("unchecked")
95 | // //GEN-BEGIN:initComponents
96 | private void initComponents() {
97 |
98 | jPanel1 = new javax.swing.JPanel();
99 | jPanel2 = new javax.swing.JPanel();
100 | jPanel3 = new javax.swing.JPanel();
101 | jLabel1 = new javax.swing.JLabel();
102 | jLabel2 = new javax.swing.JLabel();
103 | jLabel3 = new javax.swing.JLabel();
104 | jLabel4 = new javax.swing.JLabel();
105 | jTextField1 = new javax.swing.JTextField();
106 | jTextField2 = new javax.swing.JTextField();
107 | jTextField3 = new javax.swing.JTextField();
108 | jTextField4 = new javax.swing.JTextField();
109 | jButton1 = new javax.swing.JButton();
110 | jButton2 = new javax.swing.JButton();
111 | jPanel4 = new javax.swing.JPanel();
112 | jLabel5 = new javax.swing.JLabel();
113 | jComboBox1 = new javax.swing.JComboBox<>();
114 | jLabel6 = new javax.swing.JLabel();
115 | jTextField5 = new javax.swing.JTextField();
116 | jButton3 = new javax.swing.JButton();
117 | jPanel5 = new javax.swing.JPanel();
118 | jScrollPane2 = new javax.swing.JScrollPane();
119 | jTable2 = new javax.swing.JTable();
120 |
121 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
122 |
123 | jLabel1.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
124 | jLabel1.setText("Mobile");
125 |
126 | jLabel2.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
127 | jLabel2.setText("First Name");
128 |
129 | jLabel3.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
130 | jLabel3.setText("Last Name");
131 |
132 | jLabel4.setFont(new java.awt.Font("Segoe UI", 0, 14)); // NOI18N
133 | jLabel4.setText("Email");
134 |
135 | jTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
136 | public void keyReleased(java.awt.event.KeyEvent evt) {
137 | jTextField1KeyReleased(evt);
138 | }
139 | });
140 |
141 | jTextField3.addActionListener(new java.awt.event.ActionListener() {
142 | public void actionPerformed(java.awt.event.ActionEvent evt) {
143 | jTextField3ActionPerformed(evt);
144 | }
145 | });
146 |
147 | jButton1.setText("Create Account");
148 | jButton1.addActionListener(new java.awt.event.ActionListener() {
149 | public void actionPerformed(java.awt.event.ActionEvent evt) {
150 | jButton1ActionPerformed(evt);
151 | }
152 | });
153 |
154 | jButton2.setText("Update Account");
155 | jButton2.addActionListener(new java.awt.event.ActionListener() {
156 | public void actionPerformed(java.awt.event.ActionEvent evt) {
157 | jButton2ActionPerformed(evt);
158 | }
159 | });
160 |
161 | javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
162 | jPanel3.setLayout(jPanel3Layout);
163 | jPanel3Layout.setHorizontalGroup(
164 | jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
165 | .addGroup(jPanel3Layout.createSequentialGroup()
166 | .addGap(10, 10, 10)
167 | .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
168 | .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
169 | .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
170 | .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
171 | .addComponent(jLabel3)
172 | .addComponent(jLabel4))
173 | .addGap(13, 13, 13)
174 | .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
175 | .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 219, Short.MAX_VALUE)
176 | .addComponent(jTextField4)))
177 | .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
178 | .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
179 | .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
180 | .addComponent(jLabel2)
181 | .addComponent(jLabel1))
182 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
183 | .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
184 | .addComponent(jTextField1)
185 | .addComponent(jTextField2))))
186 | .addContainerGap(10, Short.MAX_VALUE))
187 | );
188 | jPanel3Layout.setVerticalGroup(
189 | jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
190 | .addGroup(jPanel3Layout.createSequentialGroup()
191 | .addGap(10, 10, 10)
192 | .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
193 | .addComponent(jLabel1)
194 | .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
195 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
196 | .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
197 | .addComponent(jLabel2)
198 | .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
199 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
200 | .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
201 | .addComponent(jLabel3)
202 | .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
203 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
204 | .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
205 | .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
206 | .addComponent(jLabel4))
207 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
208 | .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
209 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
210 | .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
211 | .addContainerGap(10, Short.MAX_VALUE))
212 | );
213 |
214 | jLabel5.setText("Sort By");
215 |
216 | jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Name ASC", "Name DESC", "Points ASC", "Points DESC" }));
217 | jComboBox1.addItemListener(new java.awt.event.ItemListener() {
218 | public void itemStateChanged(java.awt.event.ItemEvent evt) {
219 | jComboBox1ItemStateChanged(evt);
220 | }
221 | });
222 | jComboBox1.addActionListener(new java.awt.event.ActionListener() {
223 | public void actionPerformed(java.awt.event.ActionEvent evt) {
224 | jComboBox1ActionPerformed(evt);
225 | }
226 | });
227 |
228 | jLabel6.setText("Total Invoices");
229 |
230 | jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/reload.png"))); // NOI18N
231 | jButton3.addActionListener(new java.awt.event.ActionListener() {
232 | public void actionPerformed(java.awt.event.ActionEvent evt) {
233 | jButton3ActionPerformed(evt);
234 | }
235 | });
236 |
237 | javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
238 | jPanel4.setLayout(jPanel4Layout);
239 | jPanel4Layout.setHorizontalGroup(
240 | jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
241 | .addGroup(jPanel4Layout.createSequentialGroup()
242 | .addGap(10, 10, 10)
243 | .addComponent(jLabel5)
244 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
245 | .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
246 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
247 | .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
248 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 142, Short.MAX_VALUE)
249 | .addComponent(jLabel6)
250 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
251 | .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
252 | .addGap(15, 15, 15))
253 | );
254 | jPanel4Layout.setVerticalGroup(
255 | jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
256 | .addGroup(jPanel4Layout.createSequentialGroup()
257 | .addGap(10, 10, 10)
258 | .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
259 | .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
260 | .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
261 | .addComponent(jLabel5)
262 | .addComponent(jLabel6)
263 | .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
264 | .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)))
265 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
266 | );
267 |
268 | jTable2.setModel(new javax.swing.table.DefaultTableModel(
269 | new Object [][] {
270 |
271 | },
272 | new String [] {
273 | "Mobile", "First Name", "Last Name", "Email", "Porint"
274 | }
275 | ) {
276 | boolean[] canEdit = new boolean [] {
277 | false, false, false, false, false
278 | };
279 |
280 | public boolean isCellEditable(int rowIndex, int columnIndex) {
281 | return canEdit [columnIndex];
282 | }
283 | });
284 | jTable2.addMouseListener(new java.awt.event.MouseAdapter() {
285 | public void mouseClicked(java.awt.event.MouseEvent evt) {
286 | jTable2MouseClicked(evt);
287 | }
288 | });
289 | jScrollPane2.setViewportView(jTable2);
290 |
291 | javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
292 | jPanel5.setLayout(jPanel5Layout);
293 | jPanel5Layout.setHorizontalGroup(
294 | jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
295 | .addGroup(jPanel5Layout.createSequentialGroup()
296 | .addGap(10, 10, 10)
297 | .addComponent(jScrollPane2)
298 | .addContainerGap())
299 | );
300 | jPanel5Layout.setVerticalGroup(
301 | jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
302 | .addGroup(jPanel5Layout.createSequentialGroup()
303 | .addContainerGap()
304 | .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE)
305 | .addContainerGap(10, Short.MAX_VALUE))
306 | );
307 |
308 | javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
309 | jPanel2.setLayout(jPanel2Layout);
310 | jPanel2Layout.setHorizontalGroup(
311 | jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
312 | .addGroup(jPanel2Layout.createSequentialGroup()
313 | .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
314 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
315 | .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
316 | .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
317 | .addGroup(jPanel2Layout.createSequentialGroup()
318 | .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
319 | .addContainerGap())))
320 | );
321 | jPanel2Layout.setVerticalGroup(
322 | jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
323 | .addGroup(jPanel2Layout.createSequentialGroup()
324 | .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
325 | .addGroup(jPanel2Layout.createSequentialGroup()
326 | .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
327 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
328 | .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
329 | .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
330 | .addGap(0, 1, Short.MAX_VALUE))
331 | );
332 |
333 | javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
334 | jPanel1.setLayout(jPanel1Layout);
335 | jPanel1Layout.setHorizontalGroup(
336 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
337 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
338 | .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
339 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
340 | );
341 | jPanel1Layout.setVerticalGroup(
342 | jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
343 | .addGroup(jPanel1Layout.createSequentialGroup()
344 | .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
345 | .addGap(0, 0, Short.MAX_VALUE))
346 | );
347 |
348 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
349 | getContentPane().setLayout(layout);
350 | layout.setHorizontalGroup(
351 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
352 | .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
353 | );
354 | layout.setVerticalGroup(
355 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
356 | .addGroup(layout.createSequentialGroup()
357 | .addContainerGap()
358 | .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
359 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
360 | );
361 |
362 | pack();
363 | setLocationRelativeTo(null);
364 | }// //GEN-END:initComponents
365 |
366 | private void jTextField3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField3ActionPerformed
367 | // TODO add your handling code here:
368 | }//GEN-LAST:event_jTextField3ActionPerformed
369 |
370 | private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
371 | // TODO add your handling code here:
372 | }//GEN-LAST:event_jComboBox1ActionPerformed
373 |
374 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
375 | // TODO add your handling code here:
376 |
377 | String mobile = jTextField1.getText();
378 | String fname = jTextField2.getText();
379 | String lname = jTextField3.getText();
380 | String email = jTextField4.getText();
381 |
382 | if (mobile.isEmpty()) {
383 | JOptionPane.showMessageDialog(this, "Type your Mobile ", "warning", JOptionPane.INFORMATION_MESSAGE);
384 | } else if (!mobile.matches("^07[01245678]{1}[0-9]{7}$")) {
385 | JOptionPane.showMessageDialog(this, "Invalid Mobile ", "warning", JOptionPane.INFORMATION_MESSAGE);
386 | } else if (fname.isEmpty()) {
387 | JOptionPane.showMessageDialog(this, "Type your First Name ", "warning", JOptionPane.INFORMATION_MESSAGE);
388 | } else if (lname.isEmpty()) {
389 | JOptionPane.showMessageDialog(this, "Type your Last Name ", "warning", JOptionPane.INFORMATION_MESSAGE);
390 | } else if (email.isEmpty()) {
391 | JOptionPane.showMessageDialog(this, "Type your Email ", "warning", JOptionPane.INFORMATION_MESSAGE);
392 | } else if (!email.matches("^(?=.{1,64}@)[A-Za-z0-9_-]+(\\.[A-Za-z0-9_-]+)*@"
393 | + "[^-][A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$")) {
394 | JOptionPane.showMessageDialog(this, "Invalid Email Address", "warning", JOptionPane.INFORMATION_MESSAGE);
395 | } else {
396 |
397 | try {
398 | ResultSet resultset = MySQL.execute("SELECT * FROM `customer` WHERE `mobile`='" + mobile + "' OR `email`='" + email + "'");
399 |
400 | if (resultset.next()) {
401 | JOptionPane.showMessageDialog(this, "Customer already Registerted", "warning", JOptionPane.INFORMATION_MESSAGE);
402 | } else {
403 |
404 | MySQL.execute("INSERT INTO `customer`(`mobile`,`first_name`,`last_name`,`email`,`points`)VALUES('" + mobile + "','" + fname + "','" + lname + "','" + email + "','0')");
405 | loadCustomer("first_name", "ASC", "0");
406 | reset();
407 | }
408 |
409 | } catch (Exception e) {
410 | e.printStackTrace();
411 | }
412 |
413 | }
414 | }//GEN-LAST:event_jButton1ActionPerformed
415 |
416 | private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
417 | // TODO add your handling code here:
418 |
419 | reset();
420 | loadCustomer("first_name", "ASC", "0");
421 |
422 |
423 | }//GEN-LAST:event_jButton3ActionPerformed
424 |
425 | private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable2MouseClicked
426 | // TODO add your handling code here:
427 |
428 | int row = jTable2.getSelectedRow();
429 |
430 | String mobile = String.valueOf(jTable2.getValueAt(row, 0));
431 | jTextField1.setText(mobile);
432 | jTextField1.setEditable(false);
433 |
434 | String fname = String.valueOf(jTable2.getValueAt(row, 1));
435 | jTextField2.setText(fname);
436 |
437 | String lname = String.valueOf(jTable2.getValueAt(row, 2));
438 | jTextField3.setText(lname);
439 |
440 | String email = String.valueOf(jTable2.getValueAt(row, 3));
441 | jTextField4.setText(email);
442 |
443 | jButton1.setEnabled(false);
444 |
445 | if (evt.getClickCount() == 2) {
446 | if (Invoice != null) {
447 | Invoice.getjTextField2().setText(String.valueOf(jTable2.getValueAt(row, 0)));
448 | Invoice.getjLabel3().setText(String.valueOf(jTable2.getValueAt(row, 1) + " " + String.valueOf(jTable2.getValueAt(row, 2))));
449 | Invoice.getjLabel24().setText(String.valueOf(jTable2.getValueAt(row, 4)));
450 | this.dispose();
451 | }
452 | }
453 |
454 | try {
455 | ResultSet resultSet = MySQL.execute("SELECT * FROM `invoice` WHERE `customer_mobile`='" + mobile + "'");
456 |
457 | if (resultSet.next()) {
458 |
459 | String count = resultSet.getString(1);
460 | jTextField5.setText(count);
461 |
462 | }
463 | } catch (Exception e) {
464 | e.printStackTrace();
465 | }
466 |
467 |
468 | }//GEN-LAST:event_jTable2MouseClicked
469 |
470 | private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
471 | // TODO add your handling code here:
472 |
473 | String mobile = jTextField1.getText();
474 | String fname = jTextField2.getText();
475 | String lname = jTextField3.getText();
476 | String email = jTextField4.getText();
477 |
478 | if (fname.isEmpty()) {
479 | JOptionPane.showMessageDialog(this, "Type your First Name ", "warning", JOptionPane.INFORMATION_MESSAGE);
480 | } else if (lname.isEmpty()) {
481 | JOptionPane.showMessageDialog(this, "Type your Last Name ", "warning", JOptionPane.INFORMATION_MESSAGE);
482 | } else if (email.isEmpty()) {
483 | JOptionPane.showMessageDialog(this, "Type your Email ", "warning", JOptionPane.INFORMATION_MESSAGE);
484 | } else if (!email.matches("^(?=.{1,64}@)[A-Za-z0-9_-]+(\\.[A-Za-z0-9_-]+)*@"
485 | + "[^-][A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z]{2,})$")) {
486 | JOptionPane.showMessageDialog(this, "Invalid Email Address", "warning", JOptionPane.INFORMATION_MESSAGE);
487 | } else {
488 |
489 | try {
490 |
491 | boolean isFound = false;
492 |
493 | ResultSet resultset = MySQL.execute("SELECT * FROM `customer` WHERE `email`='" + email + "'");
494 |
495 | if (resultset.next()) {
496 |
497 | if (resultset.getString("mobile").equals(mobile)) {
498 | isFound = true;
499 | } else {
500 | JOptionPane.showMessageDialog(this, "Email already Use", "warning", JOptionPane.INFORMATION_MESSAGE);
501 | }
502 |
503 | } else {
504 | isFound = true;
505 | }
506 |
507 | if (isFound) {
508 | MySQL.execute("UPDATE `customer` SET `first_name`='" + fname + "',`last_name`='" + lname + "',`email`='" + email + "' WHERE `mobile`='" + mobile + "'");
509 | loadCustomer("first_name", "ASC", "0");
510 |
511 | reset();
512 |
513 | }
514 |
515 | } catch (Exception e) {
516 | e.printStackTrace();
517 | }
518 |
519 | }
520 |
521 | }//GEN-LAST:event_jButton2ActionPerformed
522 |
523 | private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBox1ItemStateChanged
524 | // TODO add your handling code here:
525 | search();
526 |
527 | }//GEN-LAST:event_jComboBox1ItemStateChanged
528 |
529 | private void jTextField1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField1KeyReleased
530 | // TODO add your handling code here:
531 | search();
532 | }//GEN-LAST:event_jTextField1KeyReleased
533 |
534 | /**
535 | * @param args the command line arguments
536 | */
537 | public static void main(String args[]) {
538 | FlatMacDarkLaf.setup();
539 | java.awt.EventQueue.invokeLater(new Runnable() {
540 | public void run() {
541 | new customer_register().setVisible(true);
542 | }
543 | });
544 | }
545 |
546 | // Variables declaration - do not modify//GEN-BEGIN:variables
547 | private javax.swing.JButton jButton1;
548 | private javax.swing.JButton jButton2;
549 | private javax.swing.JButton jButton3;
550 | private javax.swing.JComboBox jComboBox1;
551 | private javax.swing.JLabel jLabel1;
552 | private javax.swing.JLabel jLabel2;
553 | private javax.swing.JLabel jLabel3;
554 | private javax.swing.JLabel jLabel4;
555 | private javax.swing.JLabel jLabel5;
556 | private javax.swing.JLabel jLabel6;
557 | private javax.swing.JPanel jPanel1;
558 | private javax.swing.JPanel jPanel2;
559 | private javax.swing.JPanel jPanel3;
560 | private javax.swing.JPanel jPanel4;
561 | private javax.swing.JPanel jPanel5;
562 | private javax.swing.JScrollPane jScrollPane2;
563 | private javax.swing.JTable jTable2;
564 | private javax.swing.JTextField jTextField1;
565 | private javax.swing.JTextField jTextField2;
566 | private javax.swing.JTextField jTextField3;
567 | private javax.swing.JTextField jTextField4;
568 | private javax.swing.JTextField jTextField5;
569 | // End of variables declaration//GEN-END:variables
570 | }
571 |
--------------------------------------------------------------------------------