├── manifest.mf
├── nbproject
├── genfiles.properties
├── project.xml
├── project.properties
└── build-impl.xml
├── .gitignore
├── src
└── com
│ └── railway
│ └── reservation
│ ├── constants
│ └── Constants.java
│ ├── models
│ └── Ticket.java
│ ├── PreviousTicketForm.form
│ ├── Login.form
│ ├── PreviousTicketForm.java
│ ├── Login.java
│ ├── Registration.form
│ ├── Registration.java
│ ├── TicketFrame.form
│ └── TicketFrame.java
├── README.md
└── LICENSE
/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=d3d50624
2 | build.xml.script.CRC32=efb9e3d0
3 | build.xml.stylesheet.CRC32=f85dc8f2@1.92.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=d3d50624
7 | nbproject/build-impl.xml.script.CRC32=e008e812
8 | nbproject/build-impl.xml.stylesheet.CRC32=3a2fa800@1.92.0.48
9 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # NetBeans specific #
23 | nbproject/private/
24 | build/
25 | nbbuild/
26 | dist/
27 | nbdist/
28 | nbactions.xml
29 | nb-configuration.xml
30 |
31 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
32 | hs_err_pid*
33 |
--------------------------------------------------------------------------------
/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | RailwayReservation
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/com/railway/reservation/constants/Constants.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package com.railway.reservation.constants;
7 |
8 | /**
9 | *
10 | * @author kriticalflare
11 | */
12 | public class Constants {
13 |
14 | public static final String url = "jdbc:postgresql://localhost:5432/railway";
15 | public static final String user = "postgres";
16 | public static final String password = "123";
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RailwayReservation
2 |
3 | A quick and simple project for college java subject.
4 |
5 | ## Setting up the project
6 |
7 | For now clone the project and create a postgres database named "railway" with relevant tables
8 |
9 | run the following psql query for that
10 |
11 | create table userlogin ( username varchar(30) Primary key, fname varchar(30), age integer, address varchar(30), pass varchar(30) )
12 |
13 | create table stations(id integer, sname varchar(30));
14 |
15 | INSERT INTO stations VALUES(1,'Virar');
16 |
17 | INSERT INTO stations VALUES(2,'Vasai');
18 |
19 | INSERT INTO stations VALUES(3,'Bhayander');
20 |
21 | INSERT INTO stations VALUES(4,'Borivali');
22 |
23 | INSERT INTO stations VALUES(5,'Andheri');
24 |
25 | And so on , for however many stations one wants.
26 |
27 | CREATE TABLE ticket
28 | (
29 | usernamet varchar(30),
30 | boardingstation varchar(30),
31 | deboardingstation varchar(30),
32 | berthtype varchar(30),
33 | quantity integer,
34 | amount integer
35 | )
36 |
37 | ## Credits
38 |
39 | @Mithil467 and @barath121 for helping me out.
40 | ~ @kriticalflare
41 |
--------------------------------------------------------------------------------
/src/com/railway/reservation/models/Ticket.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 kriticalflare.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.railway.reservation.models;
17 |
18 | /**
19 | *
20 | * @author kriticalflare
21 | */
22 | public class Ticket {
23 |
24 | private String usernameT;
25 | private String boardingStation;
26 | private String deboardingStation;
27 | private String berthtype;
28 | private int quantity;
29 | private int amount;
30 |
31 | public Ticket(String usernameT,
32 | String boardingStation,
33 | String deboardingStation,
34 | String berthtype,
35 | int quantity,
36 | int amount) {
37 |
38 | this.usernameT = usernameT;
39 | this.boardingStation = boardingStation;
40 | this.deboardingStation = deboardingStation;
41 | this.berthtype = berthtype;
42 | this.quantity = quantity;
43 | this.amount = amount;
44 |
45 | }
46 |
47 | public String getUsername() {
48 | return usernameT;
49 | }
50 |
51 | public String getBoarding() {
52 | return boardingStation;
53 | }
54 |
55 | public String getDeboarding() {
56 | return deboardingStation;
57 | }
58 |
59 | public String getBerth() {
60 | return berthtype;
61 | }
62 |
63 | public int getQuantity() {
64 | return quantity;
65 | }
66 |
67 | public int getAmount() {
68 | return amount;
69 | }
70 |
71 | public void setUsername(String usernameT) {
72 | this.usernameT = usernameT;
73 | }
74 |
75 | public void setBoarding(String boardingStation) {
76 | this.boardingStation = boardingStation;
77 | }
78 |
79 | public void setDeboarding(String deboardingStation) {
80 | this.deboardingStation = deboardingStation;
81 | }
82 |
83 | public void setBerth(String berthtype) {
84 | this.berthtype = berthtype;
85 | }
86 |
87 | public void setQuantity(int quantity) {
88 | this.quantity = quantity;
89 | }
90 |
91 | public void setAmount(int amount) {
92 | this.amount = amount;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/src/com/railway/reservation/PreviousTicketForm.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
77 |
--------------------------------------------------------------------------------
/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processors.list=
4 | annotation.processing.run.all.processors=true
5 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
6 | application.title=RailwayReservation
7 | application.vendor=kriticalflare
8 | build.classes.dir=${build.dir}/classes
9 | build.classes.excludes=**/*.java,**/*.form
10 | # This directory is removed when the project is cleaned:
11 | build.dir=build
12 | build.generated.dir=${build.dir}/generated
13 | build.generated.sources.dir=${build.dir}/generated-sources
14 | # Only compile against the classpath explicitly listed here:
15 | build.sysclasspath=ignore
16 | build.test.classes.dir=${build.dir}/test/classes
17 | build.test.results.dir=${build.dir}/test/results
18 | # Uncomment to specify the preferred debugger connection transport:
19 | #debug.transport=dt_socket
20 | debug.classpath=\
21 | ${run.classpath}
22 | debug.modulepath=\
23 | ${run.modulepath}
24 | debug.test.classpath=\
25 | ${run.test.classpath}
26 | debug.test.modulepath=\
27 | ${run.test.modulepath}
28 | # Files in build.classes.dir which should be excluded from distribution jar
29 | dist.archive.excludes=
30 | # This directory is removed when the project is cleaned:
31 | dist.dir=dist
32 | dist.jar=${dist.dir}/RailwayReservation.jar
33 | dist.javadoc.dir=${dist.dir}/javadoc
34 | dist.jlink.dir=${dist.dir}/jlink
35 | dist.jlink.output=${dist.jlink.dir}/RailwayReservation
36 | endorsed.classpath=
37 | excludes=
38 | file.reference.postgresql-42.2.8.jar=lib\\postgresql-42.2.8.jar
39 | includes=**
40 | jar.archive.disabled=${jnlp.enabled}
41 | jar.compress=false
42 | jar.index=${jnlp.enabled}
43 | javac.classpath=\
44 | ${file.reference.postgresql-42.2.8.jar}
45 | # Space-separated list of extra javac options
46 | javac.compilerargs=
47 | javac.deprecation=false
48 | javac.external.vm=true
49 | javac.modulepath=
50 | javac.processormodulepath=
51 | javac.processorpath=\
52 | ${javac.classpath}
53 | javac.source=1.8
54 | javac.target=1.8
55 | javac.test.classpath=\
56 | ${javac.classpath}:\
57 | ${build.classes.dir}
58 | javac.test.modulepath=\
59 | ${javac.modulepath}
60 | javac.test.processorpath=\
61 | ${javac.test.classpath}
62 | javadoc.additionalparam=
63 | javadoc.author=false
64 | javadoc.encoding=${source.encoding}
65 | javadoc.html5=false
66 | javadoc.noindex=false
67 | javadoc.nonavbar=false
68 | javadoc.notree=false
69 | javadoc.private=false
70 | javadoc.splitindex=true
71 | javadoc.use=true
72 | javadoc.version=false
73 | javadoc.windowtitle=
74 | # The jlink additional root modules to resolve
75 | jlink.additionalmodules=
76 | # The jlink additional command line parameters
77 | jlink.additionalparam=
78 | jlink.launcher=true
79 | jlink.launcher.name=RailwayReservation
80 | jnlp.codebase.type=no.codebase
81 | jnlp.descriptor=application
82 | jnlp.enabled=false
83 | jnlp.mixed.code=default
84 | jnlp.offline-allowed=false
85 | jnlp.signed=false
86 | jnlp.signing=
87 | jnlp.signing.alias=
88 | jnlp.signing.keystore=
89 | main.class=com.railway.reservation.Registration
90 | # Optional override of default Application-Library-Allowable-Codebase attribute identifying the locations where your signed RIA is expected to be found.
91 | manifest.custom.application.library.allowable.codebase=
92 | # Optional override of default Caller-Allowable-Codebase attribute identifying the domains from which JavaScript code can make calls to your RIA without security prompts.
93 | manifest.custom.caller.allowable.codebase=
94 | # Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed
95 | manifest.custom.codebase=
96 | # Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions)
97 | manifest.custom.permissions=
98 | manifest.file=manifest.mf
99 | meta.inf.dir=${src.dir}/META-INF
100 | mkdist.disabled=false
101 | platform.active=default_platform
102 | project.license=apache20
103 | run.classpath=\
104 | ${javac.classpath}:\
105 | ${build.classes.dir}
106 | # Space-separated list of JVM arguments used when running the project.
107 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
108 | # To set system properties for unit tests define test-sys-prop.name=value:
109 | run.jvmargs=
110 | run.modulepath=\
111 | ${javac.modulepath}
112 | run.test.classpath=\
113 | ${javac.test.classpath}:\
114 | ${build.test.classes.dir}
115 | run.test.modulepath=\
116 | ${javac.test.modulepath}
117 | source.encoding=UTF-8
118 | src.dir=src
119 | test.src.dir=test
120 |
--------------------------------------------------------------------------------
/src/com/railway/reservation/Login.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
126 |
--------------------------------------------------------------------------------
/src/com/railway/reservation/PreviousTicketForm.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 kriticalflare.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.railway.reservation;
17 |
18 | import com.railway.reservation.constants.Constants;
19 | import com.railway.reservation.models.Ticket;
20 | import java.sql.Connection;
21 | import java.sql.DriverManager;
22 | import java.sql.PreparedStatement;
23 | import java.sql.ResultSet;
24 | import java.sql.SQLException;
25 | import java.sql.Statement;
26 | import java.util.ArrayList;
27 | import java.util.List;
28 | import javax.swing.table.DefaultTableModel;
29 |
30 | /**
31 | *
32 | * @author kriticalflare
33 | */
34 | public class PreviousTicketForm extends javax.swing.JFrame {
35 |
36 | Connection conn = null;
37 | Statement stmt = null;
38 | ResultSet rs = null;
39 |
40 | public String username;
41 | DefaultTableModel ticketModel = new DefaultTableModel();
42 |
43 | /**
44 | * Creates new form PreviousTicketForm
45 | */
46 | public PreviousTicketForm() {
47 | initComponents();
48 | System.out.println(username + " from constructor ptf");
49 | }
50 |
51 | public PreviousTicketForm(String username) {
52 | initComponents();
53 | this.username = username;
54 | List tickets = getAllTickets();
55 | ticketModel.addColumn("Username");
56 | ticketModel.addColumn("Boarding");
57 | ticketModel.addColumn("Deboarding");
58 | ticketModel.addColumn("Berth Type");
59 | ticketModel.addColumn("Quantity");
60 | ticketModel.addColumn("Amount");
61 |
62 | for(Ticket tics : tickets){
63 | ticketModel.addRow(new Object[]{tics.getUsername(),tics.getBoarding(),tics.getDeboarding(),tics.getBerth(),tics.getQuantity(),tics.getAmount()});
64 | }
65 |
66 | }
67 |
68 | /**
69 | * This method is called from within the constructor to initialize the form.
70 | * WARNING: Do NOT modify this code. The content of this method is always
71 | * regenerated by the Form Editor.
72 | */
73 | @SuppressWarnings("unchecked")
74 | // //GEN-BEGIN:initComponents
75 | private void initComponents() {
76 |
77 | jLabel1 = new javax.swing.JLabel();
78 | jScrollPane1 = new javax.swing.JScrollPane();
79 | ticketTable = new javax.swing.JTable();
80 |
81 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
82 |
83 | jLabel1.setText("Previous Tickets");
84 |
85 | ticketTable.setModel(this.ticketModel);
86 | jScrollPane1.setViewportView(ticketTable);
87 |
88 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
89 | getContentPane().setLayout(layout);
90 | layout.setHorizontalGroup(
91 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
92 | .addGroup(layout.createSequentialGroup()
93 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
94 | .addGroup(layout.createSequentialGroup()
95 | .addGap(48, 48, 48)
96 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
97 | .addGroup(layout.createSequentialGroup()
98 | .addGap(227, 227, 227)
99 | .addComponent(jLabel1)))
100 | .addContainerGap(70, Short.MAX_VALUE))
101 | );
102 | layout.setVerticalGroup(
103 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
104 | .addGroup(layout.createSequentialGroup()
105 | .addGap(44, 44, 44)
106 | .addComponent(jLabel1)
107 | .addGap(18, 18, 18)
108 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
109 | .addContainerGap(54, Short.MAX_VALUE))
110 | );
111 |
112 | pack();
113 | }// //GEN-END:initComponents
114 |
115 | public List getAllTickets() {
116 | List tick = new ArrayList<>();
117 | try {
118 | int i = 0;
119 | conn = DriverManager.getConnection(Constants.url, Constants.user, Constants.password);
120 | PreparedStatement stmt = conn.prepareStatement("select * from ticket where usernamet = ?");
121 | stmt.setString(1, username);
122 | rs = stmt.executeQuery();
123 | while (rs.next()) {
124 | String usernameT = rs.getString("usernameT");
125 | String boardingStation = rs.getString("boardingStation");
126 | String deboardingStation = rs.getString("deboardingStation");
127 | String berthtype = rs.getString("berthtype");
128 | int quantity = rs.getInt("quantity");
129 | int amount = rs.getInt("amount");
130 | Ticket t = new Ticket(usernameT, boardingStation, deboardingStation, berthtype, quantity, amount);
131 | tick.add(t);
132 | }
133 | stmt.close();
134 | conn.close();
135 |
136 | } catch (SQLException e) {
137 | System.out.println(e.getMessage());
138 | }
139 | return tick;
140 | }
141 |
142 | /**
143 | * @param args the command line arguments
144 | */
145 | public static void main(String args[]) {
146 | /* Set the Nimbus look and feel */
147 | //
148 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
149 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
150 | */
151 | try {
152 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
153 | if ("Nimbus".equals(info.getName())) {
154 | javax.swing.UIManager.setLookAndFeel(info.getClassName());
155 | break;
156 | }
157 | }
158 | } catch (ClassNotFoundException ex) {
159 | java.util.logging.Logger.getLogger(PreviousTicketForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
160 | } catch (InstantiationException ex) {
161 | java.util.logging.Logger.getLogger(PreviousTicketForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
162 | } catch (IllegalAccessException ex) {
163 | java.util.logging.Logger.getLogger(PreviousTicketForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
164 | } catch (javax.swing.UnsupportedLookAndFeelException ex) {
165 | java.util.logging.Logger.getLogger(PreviousTicketForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
166 | }
167 | //
168 |
169 | /* Create and display the form */
170 | java.awt.EventQueue.invokeLater(new Runnable() {
171 | public void run() {
172 | new PreviousTicketForm().setVisible(true);
173 | }
174 | });
175 | }
176 |
177 | // Variables declaration - do not modify//GEN-BEGIN:variables
178 | private javax.swing.JLabel jLabel1;
179 | private javax.swing.JScrollPane jScrollPane1;
180 | private javax.swing.JTable ticketTable;
181 | // End of variables declaration//GEN-END:variables
182 | }
183 |
--------------------------------------------------------------------------------
/src/com/railway/reservation/Login.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 kriticalflare.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.railway.reservation;
17 |
18 | import com.railway.reservation.constants.Constants;
19 | import java.sql.Connection;
20 | import java.sql.DriverManager;
21 | import java.sql.PreparedStatement;
22 | import java.sql.ResultSet;
23 | import java.sql.SQLException;
24 | import java.sql.Statement;
25 | import javax.swing.JOptionPane;
26 |
27 | /**
28 | *
29 | * @author kriticalflare
30 | */
31 | public class Login extends javax.swing.JFrame {
32 |
33 | Connection conn = null;
34 | Statement stmt = null;
35 | ResultSet rs = null;
36 | String username;
37 |
38 | /**
39 | * Creates new form Login
40 | */
41 | public Login() {
42 | initComponents();
43 | }
44 |
45 | /**
46 | * This method is called from within the constructor to initialize the form.
47 | * WARNING: Do NOT modify this code. The content of this method is always
48 | * regenerated by the Form Editor.
49 | */
50 | @SuppressWarnings("unchecked")
51 | // //GEN-BEGIN:initComponents
52 | private void initComponents() {
53 |
54 | loginHeader = new javax.swing.JLabel();
55 | textLoginUserName = new javax.swing.JTextField();
56 | lablelLoginUserName = new javax.swing.JLabel();
57 | labelLoginPassword = new javax.swing.JLabel();
58 | buttonLogin = new javax.swing.JButton();
59 | buttonLoginBack = new javax.swing.JButton();
60 | textLoginPassword = new javax.swing.JPasswordField();
61 |
62 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
63 |
64 | loginHeader.setFont(new java.awt.Font("Tahoma", 0, 48)); // NOI18N
65 | loginHeader.setText("Login");
66 |
67 | lablelLoginUserName.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
68 | lablelLoginUserName.setText("Username");
69 |
70 | labelLoginPassword.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
71 | labelLoginPassword.setText("Password");
72 |
73 | buttonLogin.setText("Login");
74 | buttonLogin.addActionListener(new java.awt.event.ActionListener() {
75 | public void actionPerformed(java.awt.event.ActionEvent evt) {
76 | buttonLoginActionPerformed(evt);
77 | }
78 | });
79 |
80 | buttonLoginBack.setText("Back");
81 | buttonLoginBack.addActionListener(new java.awt.event.ActionListener() {
82 | public void actionPerformed(java.awt.event.ActionEvent evt) {
83 | buttonLoginBackActionPerformed(evt);
84 | }
85 | });
86 |
87 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
88 | getContentPane().setLayout(layout);
89 | layout.setHorizontalGroup(
90 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
91 | .addGroup(layout.createSequentialGroup()
92 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
93 | .addGroup(layout.createSequentialGroup()
94 | .addGap(59, 59, 59)
95 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
96 | .addComponent(labelLoginPassword)
97 | .addComponent(lablelLoginUserName)))
98 | .addGroup(layout.createSequentialGroup()
99 | .addGap(161, 161, 161)
100 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
101 | .addComponent(textLoginUserName, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)
102 | .addComponent(textLoginPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)
103 | .addComponent(loginHeader)))
104 | .addGroup(layout.createSequentialGroup()
105 | .addGap(125, 125, 125)
106 | .addComponent(buttonLogin)
107 | .addGap(101, 101, 101)
108 | .addComponent(buttonLoginBack)))
109 | .addContainerGap(44, Short.MAX_VALUE))
110 | );
111 | layout.setVerticalGroup(
112 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
113 | .addGroup(layout.createSequentialGroup()
114 | .addGap(78, 78, 78)
115 | .addComponent(loginHeader)
116 | .addGap(67, 67, 67)
117 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
118 | .addComponent(lablelLoginUserName)
119 | .addComponent(textLoginUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
120 | .addGap(49, 49, 49)
121 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
122 | .addComponent(labelLoginPassword)
123 | .addComponent(textLoginPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
124 | .addGap(46, 46, 46)
125 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
126 | .addComponent(buttonLogin)
127 | .addComponent(buttonLoginBack))
128 | .addContainerGap(172, Short.MAX_VALUE))
129 | );
130 |
131 | pack();
132 | }// //GEN-END:initComponents
133 |
134 | private void buttonLoginBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonLoginBackActionPerformed
135 | setVisible(false);
136 | new Registration().setVisible(true);
137 | }//GEN-LAST:event_buttonLoginBackActionPerformed
138 |
139 | private void buttonLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonLoginActionPerformed
140 | try {
141 | int count = 0;
142 | char[] enteredPassC = textLoginPassword.getPassword();
143 | String enteredPass = new String(enteredPassC);
144 | username = textLoginUserName.getText();
145 | conn = DriverManager.getConnection(Constants.url, Constants.user, Constants.password);
146 | PreparedStatement stmt = conn.prepareStatement("select * from userlogin where username = ?");
147 | stmt.setString(1, username);
148 | rs = stmt.executeQuery();
149 | if (rs.next() == false && count == 0) {
150 | JOptionPane.showMessageDialog(buttonLogin, "Enter a valid id/password");
151 | stmt.close();
152 | conn.close();
153 | } else {
154 |
155 | String pass = rs.getString("pass");
156 | if (pass.equals(enteredPass)) {
157 | openTicketFrame();
158 | }else{
159 | JOptionPane.showMessageDialog(buttonLogin, "Enter a valid id/password");
160 | }
161 | stmt.close();
162 | conn.close();
163 | }
164 |
165 | } catch (SQLException e) {
166 | System.out.println(e.getMessage());
167 | }
168 |
169 | }//GEN-LAST:event_buttonLoginActionPerformed
170 |
171 | /**
172 | * @param args the command line arguments
173 | */
174 | public static void main(String args[]) {
175 | /* Set the Nimbus look and feel */
176 | //
177 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
178 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
179 | */
180 | try {
181 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
182 | if ("Nimbus".equals(info.getName())) {
183 | javax.swing.UIManager.setLookAndFeel(info.getClassName());
184 | break;
185 | }
186 | }
187 | } catch (ClassNotFoundException ex) {
188 | java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
189 | } catch (InstantiationException ex) {
190 | java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
191 | } catch (IllegalAccessException ex) {
192 | java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
193 | } catch (javax.swing.UnsupportedLookAndFeelException ex) {
194 | java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
195 | }
196 | //
197 |
198 | /* Create and display the form */
199 | java.awt.EventQueue.invokeLater(new Runnable() {
200 | public void run() {
201 | new Login().setVisible(true);
202 | }
203 | });
204 | }
205 | private void openTicketFrame() {
206 | setVisible(false);
207 | new TicketFrame(username).setVisible(true);
208 | }
209 |
210 | // Variables declaration - do not modify//GEN-BEGIN:variables
211 | private javax.swing.JButton buttonLogin;
212 | private javax.swing.JButton buttonLoginBack;
213 | private javax.swing.JLabel labelLoginPassword;
214 | private javax.swing.JLabel lablelLoginUserName;
215 | private javax.swing.JLabel loginHeader;
216 | private javax.swing.JPasswordField textLoginPassword;
217 | private javax.swing.JTextField textLoginUserName;
218 | // End of variables declaration//GEN-END:variables
219 | }
220 |
--------------------------------------------------------------------------------
/src/com/railway/reservation/Registration.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
190 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/src/com/railway/reservation/Registration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 kriticalflare.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.railway.reservation;
17 |
18 | import com.railway.reservation.constants.Constants;
19 | import java.awt.event.ActionEvent;
20 | import java.awt.event.ActionListener;
21 | import java.sql.Connection;
22 | import java.sql.DriverManager;
23 | import java.sql.PreparedStatement;
24 | import java.sql.ResultSet;
25 | import java.sql.SQLException;
26 | import java.sql.Statement;
27 | import javax.swing.JButton;
28 | import javax.swing.JLabel;
29 | import javax.swing.JOptionPane;
30 | import javax.swing.JPasswordField;
31 | import javax.swing.JTextField;
32 |
33 | /**
34 | *
35 | * @author kriticalflare
36 | */
37 | public class Registration extends javax.swing.JFrame {
38 |
39 | Integer s3;
40 | String s1, s2, s5, pass;
41 | Connection conn = null;
42 | Statement stmt = null;
43 | ResultSet rs = null;
44 |
45 | /**
46 | * Creates new form Registration
47 | */
48 | public Registration() {
49 | initComponents();
50 |
51 | }
52 |
53 | /**
54 | * This method is called from within the constructor to initialize the form.
55 | * WARNING: Do NOT modify this code. The content of this method is always
56 | * regenerated by the Form Editor.
57 | */
58 | @SuppressWarnings("unchecked")
59 | // //GEN-BEGIN:initComponents
60 | private void initComponents()
61 | {
62 |
63 | signUpHeader = new javax.swing.JLabel();
64 | labelUserName = new javax.swing.JLabel();
65 | labelName = new javax.swing.JLabel();
66 | labelAge = new javax.swing.JLabel();
67 | labelAddress = new javax.swing.JLabel();
68 | labelPassword = new javax.swing.JLabel();
69 | buttonSignUp = new javax.swing.JButton();
70 | buttonLogIn = new javax.swing.JButton();
71 | textUserName = new javax.swing.JTextField();
72 | textName = new javax.swing.JTextField();
73 | textAge = new javax.swing.JTextField();
74 | textAddress = new javax.swing.JTextField();
75 | textPassword = new javax.swing.JPasswordField();
76 | buttonUpdate = new javax.swing.JButton();
77 | buttonClear = new javax.swing.JButton();
78 |
79 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
80 |
81 | signUpHeader.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
82 | signUpHeader.setText("Login/Signup");
83 |
84 | labelUserName.setText("Username");
85 |
86 | labelName.setText("Name");
87 |
88 | labelAge.setText("Age");
89 |
90 | labelAddress.setText("Address");
91 |
92 | labelPassword.setText("Password");
93 |
94 | buttonSignUp.setText("Sign up");
95 | buttonSignUp.addActionListener(new java.awt.event.ActionListener()
96 | {
97 | public void actionPerformed(java.awt.event.ActionEvent evt)
98 | {
99 | buttonSignUpActionPerformed(evt);
100 | }
101 | });
102 |
103 | buttonLogIn.setText("Login");
104 | buttonLogIn.addActionListener(new java.awt.event.ActionListener()
105 | {
106 | public void actionPerformed(java.awt.event.ActionEvent evt)
107 | {
108 | buttonLogInActionPerformed(evt);
109 | }
110 | });
111 |
112 | textName.addActionListener(new java.awt.event.ActionListener()
113 | {
114 | public void actionPerformed(java.awt.event.ActionEvent evt)
115 | {
116 | textNameActionPerformed(evt);
117 | }
118 | });
119 |
120 | buttonUpdate.setText("Update");
121 | buttonUpdate.addActionListener(new java.awt.event.ActionListener()
122 | {
123 | public void actionPerformed(java.awt.event.ActionEvent evt)
124 | {
125 | buttonUpdateActionPerformed(evt);
126 | }
127 | });
128 |
129 | buttonClear.setText("Clear");
130 | buttonClear.addActionListener(new java.awt.event.ActionListener()
131 | {
132 | public void actionPerformed(java.awt.event.ActionEvent evt)
133 | {
134 | buttonClearActionPerformed(evt);
135 | }
136 | });
137 |
138 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
139 | getContentPane().setLayout(layout);
140 | layout.setHorizontalGroup(
141 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
142 | .addGroup(layout.createSequentialGroup()
143 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
144 | .addGroup(layout.createSequentialGroup()
145 | .addGap(51, 51, 51)
146 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
147 | .addComponent(labelName)
148 | .addComponent(labelUserName)
149 | .addComponent(labelAge)
150 | .addComponent(labelAddress)
151 | .addComponent(labelPassword))
152 | .addGap(52, 52, 52)
153 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
154 | .addComponent(textPassword, javax.swing.GroupLayout.DEFAULT_SIZE, 286, Short.MAX_VALUE)
155 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
156 | .addComponent(textAddress)
157 | .addComponent(textAge, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
158 | .addComponent(textUserName)
159 | .addComponent(textName)
160 | .addGroup(layout.createSequentialGroup()
161 | .addGap(33, 33, 33)
162 | .addComponent(signUpHeader)))))
163 | .addGroup(layout.createSequentialGroup()
164 | .addGap(46, 46, 46)
165 | .addComponent(buttonSignUp)
166 | .addGap(51, 51, 51)
167 | .addComponent(buttonLogIn)
168 | .addGap(44, 44, 44)
169 | .addComponent(buttonUpdate)
170 | .addGap(34, 34, 34)
171 | .addComponent(buttonClear)))
172 | .addContainerGap(50, Short.MAX_VALUE))
173 | );
174 | layout.setVerticalGroup(
175 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
176 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
177 | .addGap(38, 38, 38)
178 | .addComponent(signUpHeader)
179 | .addGap(45, 45, 45)
180 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
181 | .addComponent(labelUserName)
182 | .addComponent(textUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
183 | .addGap(18, 18, 18)
184 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
185 | .addComponent(labelName)
186 | .addComponent(textName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
187 | .addGap(18, 18, 18)
188 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
189 | .addComponent(labelAge)
190 | .addComponent(textAge, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
191 | .addGap(18, 18, 18)
192 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
193 | .addComponent(labelAddress)
194 | .addComponent(textAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
195 | .addGap(18, 18, 18)
196 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
197 | .addComponent(labelPassword)
198 | .addComponent(textPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
199 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
200 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
201 | .addComponent(buttonSignUp)
202 | .addComponent(buttonLogIn)
203 | .addComponent(buttonUpdate)
204 | .addComponent(buttonClear))
205 | .addGap(21, 21, 21))
206 | );
207 |
208 | pack();
209 | }// //GEN-END:initComponents
210 |
211 | private void buttonSignUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSignUpActionPerformed
212 | insert();
213 | }//GEN-LAST:event_buttonSignUpActionPerformed
214 |
215 | private void buttonLogInActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonLogInActionPerformed
216 | openLoginFrame();
217 | }//GEN-LAST:event_buttonLogInActionPerformed
218 |
219 | private void buttonUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUpdateActionPerformed
220 | update();
221 | }//GEN-LAST:event_buttonUpdateActionPerformed
222 |
223 | private void buttonClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonClearActionPerformed
224 | clear();
225 | }//GEN-LAST:event_buttonClearActionPerformed
226 |
227 | private void textNameActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_textNameActionPerformed
228 | {//GEN-HEADEREND:event_textNameActionPerformed
229 | // TODO add your handling code here:
230 | }//GEN-LAST:event_textNameActionPerformed
231 |
232 | /**
233 | * @param args the command line arguments
234 | */
235 | public static void main(String args[]) {
236 | /* Set the Nimbus look and feel */
237 | //
238 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
239 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
240 | */
241 | try {
242 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
243 | if ("Nimbus".equals(info.getName())) {
244 | javax.swing.UIManager.setLookAndFeel(info.getClassName());
245 | break;
246 | }
247 | }
248 | } catch (ClassNotFoundException ex) {
249 | java.util.logging.Logger.getLogger(Registration.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
250 | } catch (InstantiationException ex) {
251 | java.util.logging.Logger.getLogger(Registration.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
252 | } catch (IllegalAccessException ex) {
253 | java.util.logging.Logger.getLogger(Registration.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
254 | } catch (javax.swing.UnsupportedLookAndFeelException ex) {
255 | java.util.logging.Logger.getLogger(Registration.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
256 | }
257 | //
258 |
259 | /* Create and display the form */
260 | java.awt.EventQueue.invokeLater(new Runnable() {
261 | public void run() {
262 | new Registration().setVisible(true);
263 | }
264 | });
265 | }
266 |
267 | // Variables declaration - do not modify//GEN-BEGIN:variables
268 | private javax.swing.JButton buttonClear;
269 | private javax.swing.JButton buttonLogIn;
270 | private javax.swing.JButton buttonSignUp;
271 | private javax.swing.JButton buttonUpdate;
272 | private javax.swing.JLabel labelAddress;
273 | private javax.swing.JLabel labelAge;
274 | private javax.swing.JLabel labelName;
275 | private javax.swing.JLabel labelPassword;
276 | private javax.swing.JLabel labelUserName;
277 | private javax.swing.JLabel signUpHeader;
278 | private javax.swing.JTextField textAddress;
279 | private javax.swing.JTextField textAge;
280 | private javax.swing.JTextField textName;
281 | private javax.swing.JPasswordField textPassword;
282 | private javax.swing.JTextField textUserName;
283 | // End of variables declaration//GEN-END:variables
284 |
285 | public void insert() {
286 | int x = 0;
287 | s1 = textUserName.getText();
288 | s2 = textName.getText();
289 | s3 = Integer.parseInt(textAge.getText());
290 | s5 = textAddress.getText();
291 | char[] pass = textPassword.getPassword();
292 | String s8 = new String(pass);
293 | try {
294 | System.out.println(Constants.password);
295 | Connection con = DriverManager.getConnection(Constants.url, Constants.user, Constants.password);
296 | PreparedStatement ps = con.prepareStatement("insert into userLogin values (?,?,?,?,?)");
297 | ps.setString(1, s1);
298 | ps.setString(2, s2);
299 | ps.setInt(3, s3);
300 | ps.setString(4, s5);
301 | ps.setString(5, s8);
302 | ps.executeUpdate();
303 | JOptionPane.showMessageDialog(buttonSignUp, "Data Saved Successfully");
304 | clear();
305 | } catch (Exception ex) {
306 | System.out.println(ex);
307 | }
308 | }
309 |
310 | public void search(int id) {
311 | try {
312 | conn = DriverManager.getConnection(Constants.url, Constants.user, Constants.password);
313 | stmt = conn.createStatement();
314 | rs = stmt.executeQuery("select * from userLogin where username =" + id);
315 | while (rs.next()) {
316 | textUserName.setText("" + rs.getString("username"));
317 | textName.setText(rs.getString("fname"));
318 | textAge.setText("" + rs.getInt("age"));
319 | textAddress.setText(rs.getString("address"));
320 | }
321 | stmt.close();
322 | conn.close();
323 | } catch (SQLException e) {
324 | System.out.println(e.getMessage());
325 | }
326 |
327 | }
328 |
329 | public void update() {
330 | s1 = textUserName.getText();
331 | s2 = textName.getText();
332 | s3 = Integer.parseInt(textAge.getText());
333 | s5 = textAddress.getText();
334 | char[] pass = textPassword.getPassword();
335 | String s8 = new String(pass);
336 | try {
337 | conn = DriverManager.getConnection(Constants.url, Constants.user, Constants.password);
338 | System.out.println("Connected to the PostgreSQL server successfully.");
339 | stmt = conn.createStatement();
340 | PreparedStatement ps = conn.prepareStatement("update userLogin set fname=?,age=?,address=?,pass=? where username = ?");
341 | ps.setString(1, s2);
342 | ps.setInt(2, s3);
343 | ps.setString(3, s5);
344 | ps.setString(4, pass.toString());
345 | ps.setString(5, s1);
346 | ps.executeUpdate();
347 | stmt.close();
348 | conn.close();
349 | } catch (SQLException e) {
350 | System.out.println(e.getMessage());
351 | }
352 | JOptionPane.showMessageDialog(buttonUpdate, "Data Saved");
353 | clear();
354 | }
355 |
356 | public void clear() {
357 | textUserName.setText("");
358 | textName.setText("");
359 | textAge.setText("");
360 | textAddress.setText("");
361 | textPassword.setText("");
362 | }
363 |
364 | private void openLoginFrame() {
365 | setVisible(false);
366 | new Login().setVisible(true);
367 | }
368 | }
369 |
--------------------------------------------------------------------------------
/src/com/railway/reservation/TicketFrame.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
310 |
--------------------------------------------------------------------------------
/src/com/railway/reservation/TicketFrame.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 kriticalflare.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.railway.reservation;
17 |
18 | import com.railway.reservation.constants.Constants;
19 | import java.awt.event.ActionEvent;
20 | import java.sql.Connection;
21 | import java.sql.DriverManager;
22 | import java.sql.PreparedStatement;
23 | import java.sql.ResultSet;
24 | import java.sql.SQLException;
25 | import java.sql.Statement;
26 | import java.util.Vector;
27 | import javax.swing.JButton;
28 | import java.awt.event.ActionEvent;
29 | import java.awt.event.ActionListener;
30 |
31 | import javax.swing.JOptionPane;
32 | import javax.swing.JRadioButton;
33 |
34 | /**
35 | *
36 | * @author kriticalflare
37 | */
38 | public class TicketFrame extends javax.swing.JFrame implements ActionListener {
39 |
40 | String s1, s2, s3, s4;
41 | int s5,s6;
42 | ResultSet rs;
43 | public String username;
44 | PreviousTicketForm pf;
45 | Vector arr = new Vector();
46 | String FinalFromStation = "";
47 | String FinalToStation = "";
48 | int fromStationIndex = -1;
49 | int toStationIndex = -1;
50 | int ticketQuantity = -1;
51 | int amount = -1;
52 | int berthCost = 0; // should be non zero only for first class
53 |
54 | /**
55 | * Creates new form TicketFrame
56 | */
57 | public TicketFrame() {
58 | initComponents();
59 | System.out.println(username + " from tf construct");
60 |
61 | }
62 |
63 | public TicketFrame(String username){
64 | initComponents();
65 | OkLeftButton.addActionListener(this);
66 | buttonBookTicket.addActionListener(this);
67 | RightSelectButton.addActionListener(this);
68 | try {
69 | Connection conn = DriverManager.getConnection(Constants.url, Constants.user, Constants.password);
70 | String URL = "Select id, sname FROM stations";
71 | rs = conn.createStatement().executeQuery(URL);
72 | while (rs.next()) {
73 | String str = rs.getString("sname");
74 | arr.add(str);
75 | }
76 | FromList.setListData(arr);
77 | ToList.setListData(arr);
78 | } catch (SQLException e) {
79 | System.out.println("Error at Ticketframe select from table stations");
80 | }
81 | this.username = username;
82 | }
83 |
84 | public void actionPerformed(ActionEvent e) {
85 | System.out.println(((JButton) e.getSource()).getText());
86 | if ("Select From".equals(((JButton) e.getSource()).getText())) {
87 | FinalFromStation = (String) FromList.getSelectedValue();
88 | fromStationIndex = FromList.getSelectedIndex();
89 | FromStationLabelField.setText(FinalFromStation);
90 | } else if ("Select To".equals(((JButton) e.getSource()).getText())) {
91 | FinalToStation = (String) ToList.getSelectedValue();
92 | toStationIndex = ToList.getSelectedIndex();
93 | ToStationLabelField.setText(FinalToStation);
94 | } else if ("Book it!".equals(((JButton) e.getSource()).getText())) {
95 | if (radioBerthType.isSelected()) {
96 | berthCost = 50;
97 | }
98 | int cost = calculateTicketAmount();
99 | if (cost != -1) {
100 | TotalCostLabel.setText(String.valueOf(cost));
101 | insert();
102 | } else {
103 | JOptionPane.showMessageDialog(null, "Complete all the fields!");
104 | }
105 | // System.exit(0);
106 | }
107 |
108 | }
109 |
110 | /**
111 | * This method is called from within the constructor to initialize the form.
112 | * WARNING: Do NOT modify this code. The content of this method is always
113 | * regenerated by the Form Editor.
114 | */
115 | @SuppressWarnings("unchecked")
116 | // //GEN-BEGIN:initComponents
117 | private void initComponents() {
118 |
119 | ticketsHeader = new javax.swing.JLabel();
120 | labelBoarding = new javax.swing.JLabel();
121 | labelAlighting = new javax.swing.JLabel();
122 | labelBerth = new javax.swing.JLabel();
123 | labelQuantity = new javax.swing.JLabel();
124 | buttonBookTicket = new javax.swing.JButton();
125 | fromLabel = new javax.swing.JLabel();
126 | ToLabel = new javax.swing.JLabel();
127 | jScrollPane1 = new javax.swing.JScrollPane();
128 | FromList = new javax.swing.JList<>();
129 | jScrollPane2 = new javax.swing.JScrollPane();
130 | ToList = new javax.swing.JList<>();
131 | FromStationLabelField = new javax.swing.JLabel();
132 | ToStationLabelField = new javax.swing.JLabel();
133 | jLabel1 = new javax.swing.JLabel();
134 | OkLeftButton = new javax.swing.JButton();
135 | RightSelectButton = new javax.swing.JButton();
136 | TotalCostLabel = new javax.swing.JLabel();
137 | textTicketQuantity = new javax.swing.JTextField();
138 | radioBerthType = new javax.swing.JRadioButton();
139 | buttonPreviousTicket = new javax.swing.JButton();
140 |
141 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
142 |
143 | ticketsHeader.setText("Book Tickets");
144 |
145 | labelBoarding.setText("Boarding Station");
146 |
147 | labelAlighting.setText("Alighting Station");
148 |
149 | labelBerth.setText("First Class");
150 |
151 | labelQuantity.setText("Quantity");
152 |
153 | buttonBookTicket.setText("Book it!");
154 | buttonBookTicket.addActionListener(new java.awt.event.ActionListener() {
155 | public void actionPerformed(java.awt.event.ActionEvent evt) {
156 | buttonBookTicketActionPerformed(evt);
157 | }
158 | });
159 |
160 | fromLabel.setText("From");
161 |
162 | ToLabel.setText("To");
163 |
164 | FromList.setModel(new javax.swing.AbstractListModel() {
165 | String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
166 | public int getSize() { return strings.length; }
167 | public String getElementAt(int i) { return strings[i]; }
168 | });
169 | jScrollPane1.setViewportView(FromList);
170 |
171 | ToList.setModel(new javax.swing.AbstractListModel() {
172 | String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
173 | public int getSize() { return strings.length; }
174 | public String getElementAt(int i) { return strings[i]; }
175 | });
176 | jScrollPane2.setViewportView(ToList);
177 |
178 | jLabel1.setText("Total Cost");
179 |
180 | OkLeftButton.setText("Select From");
181 | OkLeftButton.addActionListener(new java.awt.event.ActionListener() {
182 | public void actionPerformed(java.awt.event.ActionEvent evt) {
183 | OkLeftButtonActionPerformed(evt);
184 | }
185 | });
186 |
187 | RightSelectButton.setText("Select To");
188 |
189 | TotalCostLabel.setText("0");
190 |
191 | textTicketQuantity.addActionListener(new java.awt.event.ActionListener() {
192 | public void actionPerformed(java.awt.event.ActionEvent evt) {
193 | textTicketQuantityActionPerformed(evt);
194 | }
195 | });
196 |
197 | radioBerthType.setText("Yes");
198 |
199 | buttonPreviousTicket.setText("View previous tickets");
200 | buttonPreviousTicket.addActionListener(new java.awt.event.ActionListener() {
201 | public void actionPerformed(java.awt.event.ActionEvent evt) {
202 | buttonPreviousTicketActionPerformed(evt);
203 | }
204 | });
205 |
206 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
207 | getContentPane().setLayout(layout);
208 | layout.setHorizontalGroup(
209 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
210 | .addGroup(layout.createSequentialGroup()
211 | .addGap(58, 58, 58)
212 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
213 | .addGap(18, 18, 18)
214 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
215 | .addGroup(layout.createSequentialGroup()
216 | .addGap(34, 34, 34)
217 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
218 | .addComponent(FromStationLabelField)
219 | .addComponent(RightSelectButton)
220 | .addComponent(ToStationLabelField)))
221 | .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))
222 | .addContainerGap(36, Short.MAX_VALUE))
223 | .addGroup(layout.createSequentialGroup()
224 | .addGap(81, 81, 81)
225 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
226 | .addGroup(layout.createSequentialGroup()
227 | .addGap(1, 1, 1)
228 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
229 | .addGroup(layout.createSequentialGroup()
230 | .addComponent(labelQuantity)
231 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
232 | .addComponent(textTicketQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE))
233 | .addGroup(layout.createSequentialGroup()
234 | .addComponent(jLabel1)
235 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
236 | .addComponent(TotalCostLabel)
237 | .addGap(38, 38, 38))
238 | .addGroup(layout.createSequentialGroup()
239 | .addComponent(labelBerth)
240 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
241 | .addComponent(radioBerthType)
242 | .addGap(22, 22, 22))))
243 | .addGroup(layout.createSequentialGroup()
244 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
245 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
246 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
247 | .addComponent(labelAlighting)
248 | .addGroup(layout.createSequentialGroup()
249 | .addGap(78, 78, 78)
250 | .addComponent(buttonBookTicket)))
251 | .addGroup(layout.createSequentialGroup()
252 | .addComponent(labelBoarding)
253 | .addGap(60, 60, 60)))
254 | .addComponent(OkLeftButton))
255 | .addGap(0, 0, Short.MAX_VALUE)))
256 | .addGap(46, 46, 46))
257 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
258 | .addGap(0, 0, Short.MAX_VALUE)
259 | .addComponent(buttonPreviousTicket)
260 | .addGap(117, 117, 117))
261 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
262 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
263 | .addComponent(ticketsHeader)
264 | .addGap(157, 157, 157))
265 | .addGroup(layout.createSequentialGroup()
266 | .addGap(104, 104, 104)
267 | .addComponent(fromLabel)
268 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
269 | .addComponent(ToLabel)
270 | .addGap(102, 102, 102))
271 | );
272 | layout.setVerticalGroup(
273 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
274 | .addGroup(layout.createSequentialGroup()
275 | .addContainerGap()
276 | .addComponent(ticketsHeader)
277 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
278 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
279 | .addComponent(fromLabel)
280 | .addComponent(ToLabel))
281 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
282 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
283 | .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE)
284 | .addComponent(jScrollPane1))
285 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
286 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
287 | .addComponent(RightSelectButton)
288 | .addComponent(OkLeftButton))
289 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
290 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
291 | .addComponent(labelBoarding)
292 | .addComponent(FromStationLabelField))
293 | .addGap(13, 13, 13)
294 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
295 | .addComponent(labelAlighting)
296 | .addComponent(ToStationLabelField))
297 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
298 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
299 | .addComponent(labelBerth)
300 | .addComponent(radioBerthType))
301 | .addGap(10, 10, 10)
302 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
303 | .addComponent(labelQuantity)
304 | .addComponent(textTicketQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
305 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
306 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
307 | .addComponent(jLabel1)
308 | .addComponent(TotalCostLabel))
309 | .addGap(24, 24, 24)
310 | .addComponent(buttonBookTicket)
311 | .addGap(34, 34, 34)
312 | .addComponent(buttonPreviousTicket)
313 | .addGap(125, 125, 125))
314 | );
315 |
316 | pack();
317 | }// //GEN-END:initComponents
318 |
319 | private void buttonBookTicketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonBookTicketActionPerformed
320 |
321 | // TODO add your handling code here:
322 | }//GEN-LAST:event_buttonBookTicketActionPerformed
323 |
324 | private void OkLeftButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_OkLeftButtonActionPerformed
325 | {//GEN-HEADEREND:event_OkLeftButtonActionPerformed
326 | // TODO add your handling code here:
327 | }//GEN-LAST:event_OkLeftButtonActionPerformed
328 |
329 | private void textTicketQuantityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textTicketQuantityActionPerformed
330 | // TODO add your handling code here:
331 | }//GEN-LAST:event_textTicketQuantityActionPerformed
332 |
333 | private void buttonPreviousTicketActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPreviousTicketActionPerformed
334 | openPrevTicketFrame();
335 | }//GEN-LAST:event_buttonPreviousTicketActionPerformed
336 |
337 | private void openPrevTicketFrame() {
338 | setVisible(false);
339 | new PreviousTicketForm(username).setVisible(true);
340 | }
341 | private int calculateTicketAmount() {
342 | if (fromStationIndex == -1 || toStationIndex == -1 || textTicketQuantity.getText().equals("")) {
343 | System.out.println(fromStationIndex + " " + toStationIndex + " " + ticketQuantity + " " + textTicketQuantity.getText());
344 | return -1;
345 | } else {
346 | ticketQuantity = Integer.parseInt(textTicketQuantity.getText());
347 | int difference = fromStationIndex - toStationIndex;
348 | amount = ticketQuantity * ((Math.abs(difference)) * 5 + berthCost);
349 | return amount;
350 | }
351 | }
352 |
353 | /**
354 | * @param args the command line arguments
355 | */
356 | public static void main(String args[]) {
357 |
358 | java.awt.EventQueue.invokeLater(new Runnable() {
359 | public void run() {
360 | new TicketFrame().setVisible(true);
361 | }
362 | });
363 | }
364 |
365 | public void insert() {
366 | int x = 0;
367 | s1=username;
368 | s2 = FromStationLabelField.getText();
369 | s3 = ToStationLabelField.getText();
370 | if(berthCost == 50){
371 | s4 = "First Class";
372 | } else {
373 | s4 = "Second Class";
374 | }
375 | s5 = Integer.parseInt(textTicketQuantity.getText());
376 | s6 = Integer.parseInt(TotalCostLabel.getText());
377 |
378 | try {
379 | System.out.println(Constants.password);
380 | Connection con = DriverManager.getConnection(Constants.url, Constants.user, Constants.password);
381 | PreparedStatement ps = con.prepareStatement("insert into ticket values (?,?,?,?,?,?)");
382 | ps.setString(1, s1);
383 | ps.setString(2, s2);
384 | ps.setString(3, s3);
385 | ps.setString(4,s4);
386 | ps.setInt(5, s5);
387 | ps.setInt(6,s6);
388 | ps.executeUpdate();
389 | } catch (Exception ex) {
390 | System.out.println(ex);
391 | }
392 | }
393 |
394 | // Variables declaration - do not modify//GEN-BEGIN:variables
395 | private javax.swing.JList FromList;
396 | public javax.swing.JLabel FromStationLabelField;
397 | private javax.swing.JButton OkLeftButton;
398 | private javax.swing.JButton RightSelectButton;
399 | private javax.swing.JLabel ToLabel;
400 | private javax.swing.JList ToList;
401 | public javax.swing.JLabel ToStationLabelField;
402 | private javax.swing.JLabel TotalCostLabel;
403 | private javax.swing.JButton buttonBookTicket;
404 | private javax.swing.JButton buttonPreviousTicket;
405 | private javax.swing.JLabel fromLabel;
406 | private javax.swing.JLabel jLabel1;
407 | private javax.swing.JScrollPane jScrollPane1;
408 | private javax.swing.JScrollPane jScrollPane2;
409 | private javax.swing.JLabel labelAlighting;
410 | private javax.swing.JLabel labelBerth;
411 | private javax.swing.JLabel labelBoarding;
412 | private javax.swing.JLabel labelQuantity;
413 | private javax.swing.JRadioButton radioBerthType;
414 | private javax.swing.JTextField textTicketQuantity;
415 | private javax.swing.JLabel ticketsHeader;
416 | // End of variables declaration//GEN-END:variables
417 | }
418 |
--------------------------------------------------------------------------------
/nbproject/build-impl.xml:
--------------------------------------------------------------------------------
1 |
2 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 | Must set src.dir
304 | Must set test.src.dir
305 | Must set build.dir
306 | Must set dist.dir
307 | Must set build.classes.dir
308 | Must set dist.javadoc.dir
309 | Must set build.test.classes.dir
310 | Must set build.test.results.dir
311 | Must set build.classes.excludes
312 | Must set dist.jar
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 | Must set javac.includes
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 | No tests executed.
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 |
754 |
755 |
756 |
757 |
758 |
759 |
760 |
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 |
776 |
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
800 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 |
811 |
812 |
813 |
814 |
815 |
816 |
817 |
818 |
819 |
820 |
821 |
822 |
823 |
824 |
825 |
826 |
827 |
828 |
829 |
830 |
831 |
832 |
833 |
834 |
835 |
836 |
837 |
838 |
839 |
840 |
841 |
842 |
843 |
844 |
845 | Must set JVM to use for profiling in profiler.info.jvm
846 | Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
847 |
848 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
859 |
860 |
861 |
862 |
863 |
864 |
865 |
866 |
867 |
868 |
869 |
870 |
871 |
872 |
873 |
874 |
875 |
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 |
884 |
885 |
886 |
887 |
888 |
889 |
890 |
891 |
892 |
893 |
894 |
895 |
896 |
897 |
898 |
899 |
900 |
901 |
902 |
903 |
904 |
905 |
906 |
907 |
908 |
909 |
910 |
911 |
912 |
913 |
914 |
915 |
916 |
917 |
918 |
919 |
920 |
921 |
922 |
923 |
924 |
925 |
926 |
927 |
928 |
929 |
930 |
931 |
932 |
933 |
934 |
935 |
936 |
937 |
938 |
939 |
940 |
941 |
942 |
943 |
944 |
945 |
946 |
947 |
948 |
949 |
950 |
951 |
952 |
953 |
954 |
955 |
956 |
957 |
958 |
959 |
960 |
961 |
962 |
963 |
964 |
965 |
966 |
967 |
968 |
969 |
970 |
971 |
972 |
973 |
974 |
975 |
976 |
977 |
978 |
979 |
980 |
981 |
982 |
983 |
984 |
985 |
986 |
987 |
988 |
989 |
990 |
991 |
992 |
993 |
994 |
995 |
996 |
997 |
998 |
999 |
1000 |
1001 |
1002 |
1003 |
1004 |
1005 |
1006 |
1007 |
1008 |
1009 |
1010 |
1011 |
1012 |
1013 |
1014 |
1015 |
1016 |
1017 |
1018 |
1019 |
1020 |
1021 |
1022 |
1023 |
1024 |
1025 |
1026 |
1027 |
1028 |
1029 |
1030 |
1031 |
1032 |
1033 |
1034 |
1035 |
1036 |
1037 |
1038 |
1039 |
1040 |
1041 |
1042 |
1043 |
1044 |
1045 |
1046 |
1047 |
1048 |
1049 |
1050 |
1051 |
1052 |
1053 |
1054 |
1055 |
1056 |
1057 |
1058 |
1059 |
1060 |
1061 |
1062 |
1067 |
1068 |
1069 |
1070 |
1071 |
1072 |
1073 |
1074 |
1075 |
1076 |
1077 |
1078 |
1079 |
1080 |
1081 |
1082 |
1083 |
1084 |
1085 |
1086 |
1087 |
1088 |
1089 |
1090 |
1091 |
1092 |
1093 |
1094 |
1095 |
1096 |
1097 |
1098 |
1099 |
1100 |
1101 |
1102 |
1103 |
1104 |
1105 |
1106 |
1107 |
1108 |
1109 |
1110 |
1111 |
1112 |
1113 |
1114 |
1115 |
1116 |
1117 |
1118 |
1119 |
1120 |
1121 |
1122 |
1123 |
1124 |
1125 |
1126 |
1127 |
1128 |
1129 | Must select some files in the IDE or set javac.includes
1130 |
1131 |
1132 |
1133 |
1134 |
1135 |
1136 |
1137 |
1138 |
1143 |
1144 |
1145 |
1146 |
1147 |
1148 |
1149 |
1150 |
1151 |
1152 |
1153 |
1154 |
1155 |
1156 |
1157 |
1158 |
1159 |
1160 |
1161 |
1162 |
1163 |
1164 |
1165 |
1166 |
1167 |
1168 |
1169 |
1170 |
1171 |
1172 |
1173 |
1174 |
1175 |
1176 |
1177 |
1178 |
1179 |
1180 |
1181 |
1182 |
1183 |
1184 |
1185 |
1186 |
1187 |
1188 |
1189 |
1190 |
1191 |
1192 |
1193 |
1194 |
1195 |
1196 |
1197 |
1198 | To run this application from the command line without Ant, try:
1199 |
1200 | java -jar "${dist.jar.resolved}"
1201 |
1202 |
1203 |
1204 |
1205 |
1206 |
1207 |
1208 |
1209 |
1210 |
1211 |
1212 |
1213 |
1214 |
1215 |
1216 |
1217 |
1218 |
1219 |
1220 |
1221 |
1222 |
1223 |
1224 |
1225 |
1226 |
1227 |
1228 |
1229 |
1230 |
1231 |
1232 |
1233 |
1234 |
1235 |
1236 |
1237 |
1238 |
1239 |
1240 |
1241 |
1242 |
1243 |
1244 |
1245 |
1246 |
1247 |
1248 |
1249 |
1250 |
1251 |
1252 |
1253 |
1254 |
1255 |
1256 |
1257 |
1262 |
1263 |
1264 |
1265 |
1266 |
1267 |
1268 |
1269 |
1270 |
1271 |
1272 |
1273 |
1274 |
1275 |
1276 |
1277 |
1278 |
1279 |
1280 |
1281 |
1282 |
1283 |
1284 |
1285 |
1286 |
1287 |
1288 |
1289 |
1290 |
1291 |
1292 |
1293 |
1294 |
1295 |
1296 |
1297 |
1298 |
1299 |
1300 |
1301 |
1302 |
1303 |
1304 |
1305 |
1306 |
1307 |
1308 |
1309 |
1310 |
1311 |
1312 |
1313 |
1314 |
1315 |
1316 |
1317 |
1318 |
1319 |
1320 |
1321 |
1322 |
1327 |
1328 |
1329 |
1330 |
1331 |
1332 |
1333 |
1334 |
1335 |
1336 |
1337 |
1338 | Must select one file in the IDE or set run.class
1339 |
1340 |
1341 |
1342 | Must select one file in the IDE or set run.class
1343 |
1344 |
1345 |
1350 |
1351 |
1352 |
1353 |
1354 |
1355 |
1356 |
1357 |
1358 |
1359 |
1360 |
1361 |
1362 |
1363 |
1364 |
1365 |
1366 |
1367 |
1368 |
1369 | Must select one file in the IDE or set debug.class
1370 |
1371 |
1372 |
1373 |
1374 | Must select one file in the IDE or set debug.class
1375 |
1376 |
1377 |
1378 |
1379 | Must set fix.includes
1380 |
1381 |
1382 |
1383 |
1384 |
1385 |
1386 |
1391 |
1394 |
1395 | This target only works when run from inside the NetBeans IDE.
1396 |
1397 |
1398 |
1399 |
1400 |
1401 |
1402 |
1403 |
1404 | Must select one file in the IDE or set profile.class
1405 | This target only works when run from inside the NetBeans IDE.
1406 |
1407 |
1408 |
1409 |
1410 |
1411 |
1412 |
1413 |
1414 | This target only works when run from inside the NetBeans IDE.
1415 |
1416 |
1417 |
1418 |
1419 |
1420 |
1421 |
1422 |
1423 |
1424 |
1425 |
1426 |
1427 | This target only works when run from inside the NetBeans IDE.
1428 |
1429 |
1430 |
1431 |
1432 |
1433 |
1434 |
1435 |
1436 |
1437 |
1438 |
1439 |
1440 |
1441 |
1442 |
1443 |
1444 |
1445 |
1448 |
1449 |
1450 |
1451 |
1452 |
1453 |
1454 |
1455 |
1456 |
1457 |
1458 |
1459 |
1460 |
1461 | Must select one file in the IDE or set run.class
1462 |
1463 |
1464 |
1465 |
1466 |
1467 | Must select some files in the IDE or set test.includes
1468 |
1469 |
1470 |
1471 |
1472 | Must select one file in the IDE or set run.class
1473 |
1474 |
1475 |
1476 |
1477 | Must select one file in the IDE or set applet.url
1478 |
1479 |
1480 |
1481 |
1486 |
1487 |
1488 |
1489 |
1490 |
1491 |
1492 |
1493 |
1494 |
1495 |
1496 |
1497 |
1498 |
1499 |
1500 |
1501 |
1502 |
1503 |
1504 |
1505 |
1506 |
1507 |
1508 |
1509 |
1510 |
1511 |
1512 |
1513 |
1514 |
1515 |
1516 |
1517 |
1518 |
1519 |
1520 |
1521 |
1522 |
1523 |
1524 |
1525 |
1526 |
1527 |
1528 |
1529 |
1530 |
1531 |
1532 |
1537 |
1538 |
1539 |
1540 |
1541 |
1542 |
1543 |
1544 |
1545 |
1546 |
1547 |
1548 |
1549 |
1550 |
1551 |
1552 |
1553 |
1554 |
1555 |
1556 |
1557 |
1558 |
1559 |
1560 |
1561 |
1562 |
1563 |
1564 |
1565 |
1566 |
1567 |
1568 |
1569 |
1570 |
1571 |
1572 |
1573 |
1574 |
1575 |
1576 |
1577 |
1578 |
1579 |
1580 |
1581 |
1582 |
1583 |
1584 |
1585 |
1586 |
1587 |
1588 |
1589 |
1590 |
1591 |
1592 |
1593 |
1594 |
1595 |
1596 |
1597 |
1598 |
1599 |
1600 |
1601 |
1602 |
1603 |
1604 |
1605 |
1606 |
1607 |
1608 |
1609 |
1610 |
1611 |
1612 |
1613 |
1614 |
1615 | Must select some files in the IDE or set javac.includes
1616 |
1617 |
1618 |
1619 |
1620 |
1621 |
1622 |
1623 |
1624 |
1625 |
1626 |
1627 |
1628 |
1629 |
1630 |
1631 |
1636 |
1637 |
1638 |
1639 |
1640 |
1641 |
1642 |
1643 | Some tests failed; see details above.
1644 |
1645 |
1646 |
1647 |
1648 |
1649 |
1650 |
1651 |
1652 | Must select some files in the IDE or set test.includes
1653 |
1654 |
1655 |
1656 | Some tests failed; see details above.
1657 |
1658 |
1659 |
1660 | Must select some files in the IDE or set test.class
1661 | Must select some method in the IDE or set test.method
1662 |
1663 |
1664 |
1665 | Some tests failed; see details above.
1666 |
1667 |
1668 |
1673 |
1674 | Must select one file in the IDE or set test.class
1675 |
1676 |
1677 |
1678 | Must select one file in the IDE or set test.class
1679 | Must select some method in the IDE or set test.method
1680 |
1681 |
1682 |
1683 |
1684 |
1685 |
1686 |
1687 |
1688 |
1689 |
1690 |
1691 |
1696 |
1697 | Must select one file in the IDE or set applet.url
1698 |
1699 |
1700 |
1701 |
1702 |
1703 |
1704 |
1709 |
1710 | Must select one file in the IDE or set applet.url
1711 |
1712 |
1713 |
1714 |
1715 |
1716 |
1717 |
1718 |
1723 |
1724 |
1725 |
1726 |
1727 |
1728 |
1729 |
1730 |
1731 |
1732 |
1733 |
1734 |
1735 |
1736 |
1737 |
1738 |
1739 |
1740 |
1741 |
1742 |
1743 |
1744 |
1745 |
1746 |
1747 |
1748 |
1749 |
1750 |
1751 |
1752 |
1753 |
1754 |
1755 |
1756 |
1757 |
1758 |
1759 |
1760 |
1761 |
1762 |
1763 |
1764 |
1765 |
1766 |
1767 |
1768 |
1769 |
--------------------------------------------------------------------------------