0% found this document useful (0 votes)
36 views

Informatics Practices Project On Topic Railway Reservation System

This document describes a student project on a railway reservation system. It includes sections describing the login page coding, homepage coding, booking ticket coding, train details coding, and reservation status coding in Java and MySQL. Code snippets are provided for functions like validating the login, booking a ticket, retrieving train details, and checking reservation status. The project uses technologies like Java Swing, JDBC, and MySQL to develop a basic software that allows booking and viewing railway tickets and reservations.

Uploaded by

rhythm narang
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Informatics Practices Project On Topic Railway Reservation System

This document describes a student project on a railway reservation system. It includes sections describing the login page coding, homepage coding, booking ticket coding, train details coding, and reservation status coding in Java and MySQL. Code snippets are provided for functions like validating the login, booking a ticket, retrieving train details, and checking reservation status. The project uses technologies like Java Swing, JDBC, and MySQL to develop a basic software that allows booking and viewing railway tickets and reservations.

Uploaded by

rhythm narang
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 30

INFORMATICS PRACTICES

PROJECT ON TOPIC

RAILWAY RESERVATION
SYSTEM

SUBMITTED TO
Mr. Sahil Monga
TABLE OF CONTENT
1. ACKNOWLEDGEMENT
2. CERTIFICATE
3. WORKING DESCRIPTION OF
PROJECT
4. HEADER FILES
5. OUTPUT AND CODING FOR JAVA
6. OUTPUT AND CODING FOR MYSQL
ACKNOWLEDGEMENT
It would be my utmost pleasure to express
my sincere thanks to my computer teacher
Mr. Sahil Monga in providing a helping
hand in this project.
His unflagging patience,creativity and
immense knowledge that he shared with
me have proved highly beneficial to me and
have made my project both possible and
successful.

+2 non_medical
Roll no. :-
CERTIFICATE

This is to certify that of class 12 has


completed this project titled “ RAILWAY
RESERVATION SYSTEM” under my
guidance and this project may be
considered as the part of the practical
examination of AISSCE conducted by
CBSE.

Mr. Sahil Monga


INFORMATIC PRACTICES
D.C MODEL INTERNATIONAL SCHOOL
WORKING DESCRIPTION OF
PROJECT

This project deals with a working model of a


software which can be used for various
purposes like :
1. Booking Railway Ticket
2. Display Train Details
3. Check Reservation Status
HEADER FILES

1. import javax.swing.JOptionPane;
2. import java.sql.*;
3. import jave.text.SimpleDateFormat;
import javax.swing.table.DefaultTableModel
LOGIN PAGE

CODING FOR LOGIN PAGE :-


package project_sr;

import javax.swing.JOptionPane;
import java.sql.*

private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String n = new String(jPasswordField1.getPassword());
String m = jTextField1.getText();
if(m.equalsIgnoreCase("sr")&&n.equals("1"))
{
DETAILS s = new DETAILS();
s.setVisible(true);
}
else
{JOptionPane.showMessageDialog(null,"INCORRECT
USERNAME OR PASSWORD");
}
}

private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
jPasswordField1.setText("");
jTextField1.setText("");// TODO add your handling code here:
}

private void
jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0); }
HOMEPAGE

CODING FOR HOMEPAGE :-


private void jButton1ActionPerformed(java.awt.event.ActionEvent
evt) {
bookticket m = new bookticket();
m.setVisible(true);// TODO add your handling code here:
}
private void
jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
traindetails n = new traindetails();
n.setVisible(true);// TODO add your handling code here:
}

private void
jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0); // TODO add your handling code here:
}

private void
jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
reservation o = new reservation();
o.setVisible(true);
BOOK TICKET

CODING FOR BOOK TICKET :-

1.BOOK TICKET
private void jButton1ActionPerformed(java.awt.event.ActionEvent
evt) {
try{
String tr_no = (String)jComboBox3.getSelectedItem();
String tr_name = jTextField1.getText();
String tr_from = (String)jComboBox1.getSelectedItem();
String tr_to = (String)jComboBox2.getSelectedItem();
String m1=jTextField9.getText();
String m2=jTextField10.getText();
String m3=jTextField11.getText();
Class.forName("com.mysql.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/S
R","root","root");
Statement stmt=con.createStatement();
String m="select * from booking;";
ResultSet rs=stmt.executeQuery(m);
int ti=0;
while(rs.next())
{
ti=rs.getInt(3);
}
ti=ti+1;
String s="insert into booking
values("+tr_no+",'"+tr_name+"',"+ti+",'"+tr_from+"','"+tr_to+"',"+me
m+",'"+m1+"','"+m2+"','"+m3+"',"+rent+");";
stmt.executeUpdate(s);
JOptionPane.showMessageDialog(null,"Ticket Confirmed");
}catch(Exception e)
{
JOptionPane.showMessageDialog(null,e.getMessage());
}

2. RADIO BUTTON CODING :-


private void
jRadioButton1ItemStateChanged(java.awt.event.ItemEvent evt) {
if(jRadioButton1.isSelected())
{
jTextField9.setEditable(true);
jTextField6.setText(""+rent);
mem=1;
}
else
{
jTextField9.setEditable(false);
}
}
private void
jRadioButton2ItemStateChanged(java.awt.event.ItemEvent evt) {
if(jRadioButton2.isSelected())
{
jTextField9.setEditable(true);
jTextField10.setEditable(true);
jTextField6.setText(""+(2*rent));
mem=2;
}
else
{
jTextField9.setEditable(false);
jTextField10.setEditable(false);
}
}

private void
jRadioButton3ItemStateChanged(java.awt.event.ItemEvent evt) {
if (jRadioButton3.isSelected())
{ jTextField9.setEditable(true);
jTextField10.setEditable(true);
jTextField11.setEditable(true);
jTextField6.setText(""+(3*rent));
mem=3;
}
else
{
jTextField9.setEditable(false);
jTextField10.setEditable(false);
jTextField11.setEditable(false);
}
}

3. COMBO BOX CODING:-


private void
jComboBox2ItemStateChanged(java.awt.event.ItemEvent evt)
{
int a=jComboBox1.getSelectedIndex();
int b=jComboBox2.getSelectedIndex();

if(a==1 && b==1)


{
rent=200;
}
if(a==1 && b==2)
{
rent=400;
}
if(a==1 && b==3)
{
rent=600;
}
if(a==2 && b==2)
{
rent=250;
}
if(a==2 && b==3)
{
rent=450;
}
if(a==3 && b==3)
{
rent=300;
}

}
private void
jComboBox3ItemStateChanged(java.awt.event.ItemEvent evt)
{
{
int c = jComboBox3.getSelectedIndex();
if (c==1)
{
jTextField1.setText("Punjab Mail");
}
if(c==2)
{
jTextField1.setText("Janta Express");

}
if(c==3)
{jTextField1.setText("Intercity Express");
}

}
}
4. CODING FOR RESET BUTTON :-
private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText("");
jTextField9.setText("");
jTextField10.setText("");
jTextField11.setText("");
jTextField6.setText("");
jComboBox1.setSelectedIndex(0);
jComboBox2.setSelectedIndex(0);
jComboBox3.setSelectedIndex(0);
buttonGroup1.clearSelection();

5.CODING FOR CLOSE BUTTON :-


private void
jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
DETAILS d=new DETAILS();
d.setVisible(true);
dispose();

TRAIN DETAILS
1.CODING FOR SHOW RENT
BUTTON :-
private void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int a=jComboBox2.getSelectedIndex();
int b=jComboBox3.getSelectedIndex();
if(a==1 && b==1)
{
rent=200; }
if(a==1 && b==2)
{
rent=400; }
if(a==1 && b==3)
{
rent=600; }
if(a==2 && b==2)
{
rent=250; }
if(a==2 && b==3)
{
rent=450; }
if(a==3 && b==3)
{
rent=300;}
jTextField5.setText(""+ rent);
}
private void
jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {
try{
int c = jComboBox1.getSelectedIndex();
if (c==1)
{
jTextField4.setText("Punjab Mail");
}
if(c==2)
{
jTextField4.setText("Janta Express"); }
if(c==3)
{jTextField4.setText("Intercity Express");
} }catch (Exception e){
JOptionPane.showMessageDialog(null,e.getMessage());
}
}
private void
jComboBox2ItemStateChanged(java.awt.event.ItemEvent evt) {
}

2.CODING FOR CLOSE BUTTON :-


private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
DETAILS d=new DETAILS();
d.setVisible(true);
dispose();
RESERVATION STATUS
1.CODING FOR SUBMIT BUTTON :-
private void jButton1ActionPerformed(java.awt.event.ActionEvent
evt) {
DefaultTableModel m=(DefaultTableModel)jTable1.getModel();
try{
m.setRowCount(0);
Class.forName("com.mysql.jdbc.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/SR"
,"root","root");

Statement stmt=con.createStatement();
int c = jComboBox1.getSelectedIndex();
int no=Integer.parseInt(jTextField2.getText());
String s="";
if (c==1)
{
s="select * from booking where ticket_no="+no+";";
}
if(c==2)
{
s="select * from booking where Tr_no="+no+";";
}
ResultSet rs=stmt.executeQuery(s);
while(rs.next())
{
int tr_no=rs.getInt(1);
String nm=rs.getString(2);
int ti_no=rs.getInt(3);
String fr=rs.getString(4);
String to=rs.getString(5);
double re=rs.getDouble(10);
m.addRow(new Object[]{tr_no,nm,ti_no,fr,to,re});
}
rs.close();
stmt.close();
con.close();

} catch (Exception e)
{
JOptionPane.showMessageDialog(null,e.getMessage());
}
}

2.CODING FOR CLOSE BUTTON :-


private void
jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
DETAILS d=new DETAILS();
d.setVisible(true); dispose();
MYSQL SCREENSHOT
-- MySQL dump 10.13 Distrib 5.5.27, for Win32 (x86)
--
-- Host: localhost Database: sr
-- ------------------------------------------------------
-- Server version 5.5.27

/*!40101 SET
@OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_C
LIENT */;
/*!40101 SET
@OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET
_RESULTS */;
/*!40101 SET
@OLD_COLLATION_CONNECTION=@@COLLATION_CONNE
CTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET
@OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS,
UNIQUE_CHECKS=0 */;
/*!40014 SET
@OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECK
S, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE,
SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES,
SQL_NOTES=0 */;

--
-- Table structure for table `booking`
--

DROP TABLE IF EXISTS `booking`;


/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `booking` (
`tr_no` int(10) DEFAULT NULL,
`tr_name` varchar(30) DEFAULT NULL,
`ticket_no` int(10) DEFAULT NULL,
`tr_from` varchar(30) DEFAULT NULL,
`tr_to` varchar(30) DEFAULT NULL,
`no_members` varchar(30) DEFAULT NULL,
`1member` varchar(30) DEFAULT NULL,
`2member` varchar(30) DEFAULT NULL,
`3member` varchar(40) DEFAULT NULL,
`tr_rent` double(10,2) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `booking`
--

LOCK TABLES `booking` WRITE;


/*!40000 ALTER TABLE `booking` DISABLE KEYS */;
INSERT INTO `booking` VALUES (1001,'Punja
Mail',1001,'Ferozepur','Agra','2','Ajay','Vijay','',400.00),(1001,'Punj
ab
Mail',1002,'Ferozepur','Bhopal','1','ABC','','',600.00),(1001,'Punjab
Mail',1003,'Ferozepur','Bhopal','1','ABC','','',600.00),(1002,'Janta
Express',1004,'Ferozepur','Bhopal','2','e65t','ryry','',600.00),(1002,'
Janta
Express',1005,'Agra','Bhopal','1','i9o','','',300.00),(1002,'Janta
Express',1006,'New Delhi','Bhopal','2','','','',450.00),(1002,'Janta
Express',1007,'New Delhi','Bhopal','3','','','',450.00),(1001,'Punjab
Mail',1008,'Ferozepur','Agra','2','','','',400.00),(1001,'Punjab
Mail',1009,'Ferozepur','New Delhi','1','aj','','',200.00),(1001,'Punjab
Mail',1010,'Ferozepur','New
Delhi','3','AJAY','VIJAY','JAY',200.00),(1001,'Punjab
Mail',1011,'Ferozepur','New Delhi','3','AJAY','VIJAY','JAY',200.00);
/*!40000 ALTER TABLE `booking` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;


/*!40014 SET
FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET
CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIE
NT */;
/*!40101 SET
CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RE
SULTS */;
/*!40101 SET
COLLATION_CONNECTION=@OLD_COLLATION_CONNECTI
ON */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2019-02-07 11:03:35

You might also like