BOOK MY SHOW
DATABASE STRUCTURE
Create database ticket;
Use ticket;
Create table login(uid varchar(20),username varchar(20));
CREATE TABLE `movie` (
`movName` varchar(200) DEFAULT NULL,`fromDate` date
DEFAULT NULL,`toDate` date DEFAULT NULL ) ;
CREATE TABLE `bookmovies` (
`movname` varchar(200) DEFAULT NULL,
`selectdate` date DEFAULT NULL,
`selectTime` varchar(200) DEFAULT NULL,
`screen` varchar(20) DEFAULT NULL,
`seats` varchar(200) DEFAULT NULL,
`amt` int(11) DEFAULT NULL,
`bookId` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`bookId`));
Tables in database -:
Login table-
Movie table-
Book Movies table-
[Link] Form
Source Code
1) Login button
try {
String user="root";
String pwd="";
String url="jdbc:mysql://localhost:3306/ticket";
String uid=[Link]();
String pw = new String([Link]());
[Link]("[Link]");
Connection con = (Connection) [Link](url, user,
pwd);
Statement stmt = (Statement) [Link]();
String cnt="select uId,username from login";
ResultSet rs=[Link](cnt);
if([Link]()){
String u=[Link]("uId");
String p=[Link]("username");
if([Link](uid)&& ([Link](pw))){
dispose();
new MainForm().setVisible(true);
else{
[Link](null,"incorrect userId or
password");
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch (SQLException ex) {
[Link]([Link]()).log([Link], null,
ex);
}
2) Reset Password button
try {
String user="root";
String pwd="";
String url="jdbc:mysql://localhost:3306/ticket";
String uid=[Link]();
String pw = new String([Link]());
// TODO add your handling code here:
[Link]("[Link]");
Connection con = (Connection) [Link](url, user,
pwd);
Statement stmt = (Statement) [Link]();
String sql="update login set username='"+pw+"'where uid='admin'";
[Link](sql);
[Link](null,"password updated successfully");
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch (SQLException ex) {
[Link]([Link]()).log([Link], null,
ex);
}
OUTPUT
[Link]
Source code
1)Addmovie button
new addmovie().setVisible(true);
dispose();
2)Bookmovie button
new bookmovie().setVisible(true);
dispose();
[Link] Form
Source code
String cdate1="",cdate2="";
String user = "root";
String pwd = "";
String url = "jdbc:mysql://localhost:3306/ticket";
Methods
1)void loadCurDate(){
try {
[Link]("[Link]");
Connection con = (Connection) [Link](url, user,
pwd);
Statement stmt = (Statement) [Link]();
String sql="select curdate() as cd,date(curdate()+1) as c;";
ResultSet rs= [Link](sql);
if([Link]()){
cdate1=[Link]("cd");
[Link]([Link]("c"));
[Link](cdate1);
} catch (SQLException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null,
ex);
2) void checkDate(){
try {
int days=0;
[Link]("[Link]");
Connection con = (Connection) [Link](url, user,
pwd);
Statement stmt = (Statement) [Link]();
String q1="select datediff('"+[Link]()+"','"+[Link]()+"') as c";
ResultSet r=[Link](q1);
if([Link]()){
days=[Link]("c");
if(days<0){
[Link](null, "From date can not be greater
than To date");
return;
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch (SQLException ex) {
[Link]([Link]()).log([Link], null,
ex);
addMovies();
3) void addMovies(){
try {
[Link]("[Link]");
Connection con = (Connection) [Link](url, user,
pwd);
Statement stmt = (Statement) [Link]();
String sql="insert into movie
values('"+[Link]()+"','"+[Link]()+"','"+[Link]()
+"')";
[Link](sql);
[Link](null,"record added successfully");
} catch (SQLException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null,
ex);
new MainForm().setVisible(true);
dispose();
1) Submit button
if([Link]().isEmpty()){
[Link](null,"PLEASE ENTER MOVIE NAME");
return;
}
checkDate();
OUTPUT
[Link] Form
Source code
String cdate1="",cdate2="";
String user = "root";
String pwd = "";
String url = "jdbc:mysql://localhost:3306/ticket";
fillmovies();
Methods
1) void fillitem(){
String user="root",pwd="";
String url="jdbc:mysql://localhost:3306/ticket";
try {
// Connect to MySQL database
[Link]("[Link]").newInstance();
Connection con = (Connection)
[Link](url,user,pwd);
// Create SQL statement and execute query.
String query="Select * from movie";
Statement stmt =
[Link](ResultSet.TYPE_SCROLL_INSENSITIVE,[Link]
UR_UPDATABLE);
rs = [Link](query);
// Iterate through the result and display on screen
[Link]();
[Link](""+[Link]("movName"));
fillmovies();
} catch (Exception e) {
[Link](this, [Link]());
1) void fillmovies(){
[Link]();
int days=0;
try {
String user = "root";
String pwd = "";
String url = "jdbc:mysql://localhost:3306/ticket";
[Link]("[Link]");
Connection con = (Connection) [Link](url, user,
pwd);
Statement stmt = (Statement) [Link]();
String q1="select datediff(todate,fromdate) as c from movie where
movName='"+ [Link]()+"'";
ResultSet r=[Link](q1);
if([Link]()){
days=[Link]("c");
int i=0;
while(i!=days+1){
String q2="select date(fromdate+"+i+") as d from movie where
movName='"+ [Link]()+"'";
ResultSet r2=[Link](q2);
while([Link]()){
[Link](""+[Link]("d"));
i++;
} catch (ClassNotFoundException ex) {
[Link]([Link]()).log([Link], null,
ex);
} catch (SQLException ex) {
[Link]([Link]()).log([Link], null,
ex);
1)> button
int i=0,b=10;
String user="root",pwd="";
String url="jdbc:mysql://localhost:3306/ticket";
try {
// Connect to MySQL database
if(rs==null)
fillitem();
if(rs!=null){
if([Link]()){
[Link](""+[Link]("MOVNAME"));
fillmovies();
else{
rs=null;
} catch (Exception e) {
[Link](this, [Link]());
2)< button
int i=1,b=10;
String user="root",pwd="";
String url="jdbc:mysql://localhost:3306/ticket";
try {
// Connect to MySQL database
if(rs==null)
fillitem();
if(rs!=null){
if([Link]()){
[Link](""+[Link]("MOVNAME"));
fillmovies();
else{
rs=null;
// Iterate through the result and display on screen
} catch (Exception e) {
[Link](this, [Link]());
3)Next button
if([Link]()==0){
[Link](null,"PLEASE SELECT SCREEN");
return;
String screen="";
if([Link]()==1){
screen="screen 1";
else if([Link]()==2){
screen="screen 2";
}
else if([Link]()==3){
screen="screen 3";
dispose();
[Link]=screen;
[Link]=[Link]();
[Link]=[Link]().toString();
[Link]=[Link]().toString();
new selected().setVisible(true);
4)Cancel button
new MainForm().setVisible(true);
dispose();
OUTPUT
[Link] selection Form
Source code
Methods
int pamt=0,samt=0,gamt=0,totamt=0;
int lstamt=0;
int amt=0;
static String movName="",scType="",shTime="",shDate="";
String sst1="",sst2="",sst3="",pst1="",pst2="",pst3="",gst1="",gst2="",gst3=""
,sst4="",sst5="",
sst6="",pst4="",pst5="",pst6="",gst4="",gst5="",gst6="";
StringBuffer strseat=new StringBuffer();
ResultSet rs;
String user="root";
String pass="";
String dburl="jdbc:mysql://localhost:3306/ticket";
String getseats="";
int bid=0;
fillseats(movName,scType,shTime,shDate);
1) void fillseats(String mname,String sc,String shT,String shd){
try {
[Link]("[Link]");
Connection con = [Link](dburl, user, pass);
Statement stmt = [Link]();
String sql = "Select bookid,seats,amt from bookmovies where
movName='"+mname+"' and screen='"+sc+"' and selecttime='"+shT+
"' and selectdate='"+shd+"'";
rs = [Link](sql);
if([Link]()){
getseats=[Link]("seats");
lstamt=[Link]("amt");
String [] twoStringArray= [Link](",");
int len=[Link];
for(int i=0;i<len;i++){
if(twoStringArray[i].equals("S1")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
else if(twoStringArray[i].equals("S2")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
else if(twoStringArray[i].equals("S3")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
else if(twoStringArray[i].equals("P1")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
else if(twoStringArray[i].equals("P2")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
else if(twoStringArray[i].equals("P3")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
else if(twoStringArray[i].equals("G1")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
}
else if(twoStringArray[i].equals("G2")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
else if(twoStringArray[i].equals("G3")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
else if(twoStringArray[i].equals("G4")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
else if(twoStringArray[i].equals("G5")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
else if(twoStringArray[i].equals("G6")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
else if(twoStringArray[i].equals("P4")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
else if(twoStringArray[i].equals("P5")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
else if(twoStringArray[i].equals("P6")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
else if(twoStringArray[i].equals("S4")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
else if(twoStringArray[i].equals("S5")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
else if(twoStringArray[i].equals("S6")){
[Link](true);
[Link](false);
[Link](new Color(255,0,0));
bid=[Link]("bookid")
} catch (Exception ex) {
[Link]([Link]());
2) void gettotAmt(){
totamt=pamt+samt+gamt;
[Link](""+totamt);
1)P1 Togglebutton
if([Link]()){
pamt+=150;
pst1=",P1";
gettotAmt();
} else{
pamt-=150;
pst1="";
gettotAmt();
2)P2 Togglebutton
if([Link]()){
pamt+=150;
pst2=",P2";
gettotAmt();
} else{
pamt-=150;
pst2="";
gettotAmt();
3)P3 Togglebutton
if([Link]()){
pamt+=150;
pst3=",P3";
gettotAmt();
} else{
pamt-=150;
pst3="";
gettotAmt();
4)P2 Togglebutton
if([Link]()){
pamt+=150;
pst4=",P4";
gettotAmt();
} else{
pamt-=150;
pst4="";
gettotAmt();
5)P5 Togglebutton
if([Link]()){
pamt+=150;
pst5=",P5";
gettotAmt();
} else{
pamt-=150;
pst5="";
gettotAmt();
6)P6 Togglebutton
if([Link]()){
pamt+=150;
pst6=",P6";
gettotAmt();
} else{
pamt-=150;
pst6="";
gettotAmt();
7)S1 Togglebutton
if([Link]()){
pamt+=150;
sst1=",S1";
gettotAmt();
} else{
pamt-=150;
sst1="";
gettotAmt();
8)S2 Togglebutton
if([Link]()){
pamt+=150;
sst2=",S2";
gettotAmt();
} else{
pamt-=150;
sst2="";
gettotAmt();
9)S3 Togglebutton
if([Link]()){
pamt+=150;
sst3=",S3";
gettotAmt();
} else{
pamt-=150;
sst3="";
gettotAmt();
}
10)S4 Togglebutton
if([Link]()){
pamt+=150;
sst4=",S4";
gettotAmt();
} else{
pamt-=150;
sst4="";
gettotAmt();
11)S5 Togglebutton
if([Link]()){
pamt+=150;
sst5=",S5";
gettotAmt();
} else{
pamt-=150;
sst5="";
gettotAmt();
12)S6 Togglebutton
if([Link]()){
pamt+=150;
sst6=",S6";
gettotAmt();
} else{
pamt-=150;
sst6="";
gettotAmt();
13)G1 Togglebutton
if([Link]()){
pamt+=150;
gst1=",G1";
gettotAmt();
} else{
pamt-=150;
gst1="";
gettotAmt();
14)G2 Togglebutton
if([Link]()){
pamt+=150;
gst2=",G2";
gettotAmt();
} else{
pamt-=150;
gst2="";
gettotAmt();
15)G3 Togglebutton
if([Link]()){
pamt+=150;
gst13=",G3";
gettotAmt();
} else{
pamt-=150;
gst3="";
gettotAmt();
16)G4 Togglebutton
if([Link]()){
pamt+=150;
gst4=",G4";
gettotAmt();
} else{
pamt-=150;
gst4="";
gettotAmt();
17)G5 Togglebutton
if([Link]()){
pamt+=150;
gst5=",G5";
gettotAmt();
} else{
pamt-=150;
gst5="";
gettotAmt();
18)G6 Togglebutton
if([Link]()){
pamt+=150;
gst6=",G6";
gettotAmt();
} else{
pamt-=150;
gst6="";
gettotAmt();
19)Book button
String seatss=pst1+pst2+pst3+sst1+sst2+sst3+gst1+gst2+gst3
+pst4+pst5+pst6+gst4+gst5+gst6+sst4+sst5+sst6;
String bookedseat=seatss;
if([Link]()>0){
seatss=seatss+","+getseats;
if([Link](",")==0)
seatss=[Link](1);
totamt+=lstamt;
try {
[Link]("[Link]");
Connection con=[Link](dburl,user, pass);
Statement stmt=[Link]();
String sql="";
if(bid==0){
sql="insert into
bookmovies(movName,selectdate,selecttime,screen,seats,amt) values('"+
movName+"','"+shDate+"','"+
shTime+"','"+scType+"','"+seatss+"',"+totamt+")";
} else{
sql="update bookmovies set seats='"+seatss+"',amt="+totamt+" where
bid="+bid;
[Link](sql);
[Link]();
[Link]();
[Link](null, "Seat booked successfully..");
dispose();
if([Link](",")==0)
bookedseat=[Link](1);
[Link]=movName;
[Link]=shTime;
[Link]=shDate;
[Link]=bookedseat;
[Link]=totamt;
new Receipt().setVisible(true);
} catch(Exception ex){
[Link]([Link]());
20)Back button
dispose();
new bookmovie().setVisible(true);
OUTPUT
[Link] Form
Source code
static String movname="",scType="",shTime="",shDate="";
static String getseats="";
static int amt=0;
genBill();
[Link](false);
1) void genBill(){
[Link]("-------------------------------------\n");
[Link]("-------------------------------------\n");
[Link]("Movie Name: "+movname+"\n");
[Link]("Show Timing: "+shTime+"\n");
[Link]("Show Date: "+shDate+"\n");
[Link]("Booked Seats: "+getseats+"\n");
[Link]("Total Amount: Rs."+amt+"\n");
[Link]("-------------------------------------\n");
[Link]("Thank You visit again...\n");
[Link]("-------------------------------------\n");
[Link]("-------------------------------------");
OUTPUT