Anda di halaman 1dari 50

Project Report 2014-2015

Hotel Management System

ABSTRACT

The Hotel Management system improves the efficiency of


a hotel room booking system. It simplifies the job of hotel
staff and it removes the duplication of data. It contains
booking & billing. So number of employee can be reduced.

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

Project Report 2014-2015

Hotel Management System

ACKNOWLEDGEMENT
I express my sincere thanks to Mr. Khalid K. A,
respected Principal of JDT Islam Polytechnic & Mr. Manuel
George, Head of Computer Department for giving
permission to conduct the project and giving lot of
encouragement.
It is very pleasure to extend the deep gratitude to our
internal project guides Mr. Muhammad Akbar M and Mrs.
Remya M K, who gives their valuable guidance and support
to continuously promote us for the progress of the project.
I am thankful to each and every friend of mine and the
faculty members in Computer department who helped me
directly or indirectly. At last, but not the least I would like to
express my thanks to omnipotent God give the strength to
conduct the project.

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

Project Report 2014-2015

Hotel Management System

CONTENTS
1. INTRODUCTION
2. SYSTEM ANALYSIS
2.1
Existing System
2.2
Proposed System
2.3
Feasibility Study
2.3.1 Technical feasibility
2.3.2 Operational Feasibility
2.3.3 Economic Feasibility
3. SYSTEM DEVELOPMENT
3.1 Hardware Specification
3.2 Software Specification
3.3 System Study
4. SYSTEM DESIGN
4.1 Design Development Process
4.2 Data Base Design
5. TESTING
5.1 Testing Methodology
6. FORMS USED
7. PROJECT CODES
8. CONCLUSION
9. REFERENCE

INTRODUCTION
This project help the hotels to simplify the job of
Receptionist.
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

Project Report 2014-2015

Hotel Management System

The project is made for Room Booking System only. So it


has limitations. By using this project the data entering,
updating, billing is easy. The project is programed using Net
Beans.
Present the hotels the data recorded in books. So there is
repeating & updating of data is a problem. This project avoid
the problems.

SYSTEM ANALYSIS
2.1

Existing System

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

Project Report 2014-2015

Hotel Management System

For the successful designing of the system it is necessary


to study and analyse the present working mode of the
existing system.
In the existing system data recorded in registers. So it is
difficult to update the record and billing. The duplication of
data is another problem that occur when the data write in
different record.

2.2

Proposed System

The aim of the project is to reduce the effort of the job in


Hotel Room Booking System and improve the efficiency of a
hotel room booking system. This system allows to book a
room, update, search a person & billing.

2.3

Feasibility Study

Feasibility is a test of system proposed according to


workability, impact on organization ability to meet user
needs, and effective use of resources.
Following are the feasibility study employed

2.3.1 Technical feasibility:


This software is designed using JAVA language, which is
platform independent.
This system is technically feasible. The proposed system
is a windows application it must satisfy the specified
hardware and software configuration. The existing personal
computer can accommodate the proposed system without
changing hardware and software.

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

Project Report 2014-2015

2.3.2

Hotel Management System

Operational Feasibility:

Some basic knowledge about the system will be given to


the users. Technical knowledge is not required, moreover for
the user to use the system. This system is easy to use, so it
is operationally feasible.

2.3.3

Economic Feasibility:

Economic analysis is the most frequently used method for


evaluating the effectiveness of the system. Most commonly
known as cost/benefit analysis. Here only the cost required
for installing printer. It is benefited individually. Hence this
project is economical.

SYSTEM DEVELOPMENT
3.1

Hardware Specification

Processor
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

: Clock speed greater than 1 GHZ


6

Project Report 2014-2015

Hotel Management System

Hard disk

: 40 GB

RAM

: 512 MB

3.2

Software Specification

Platform

: Windows XP

Language used

: JAVA

Editor

3.3

: NetBeans

System Study

In this phase, the problem is defined and solution are


made about committing the resources required to design the
new system. This is most critical phase of the system life
cycle. An efficient and careful study should be made and a
master plan details of steps to be taken are submitted during
this phase. So in this phase we have done a detailed study
about the existing System and have understood its working
and limitations.
During the study phase, we have gathered all the relevant
data. Based on the study, the proposed System will be
developed. A preliminary analysis is carried out in sufficient
depth to permit a technical and economic evaluation of
proposed system.

* NetBeans Overview
NetBeans is an integrated development environment (IDE)
for developing primarily with java. NetBeans IDE is written in
Java and can run on Windows, OS X, Linux, Solaris and other
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

Project Report 2014-2015

Hotel Management System

platforms supporting a compatible JVM. The NetBeans


Platform is a generic framework for Swing applications. It
provides the plumbing that, before, every developer had to
write themselvessaving state, connecting actions to menu
items, toolbar items and keyboard shortcuts; window
management, and so on.
The NetBeans Platform provides all of these out of the
box. You don't need to manually code these or other basic
features, yourself, anymore. See what some NetBeans-based
applications look like.

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

Project Report 2014-2015

Hotel Management System

SYSTEM DESIGN
4.1

Design Development Process

A software design is a meaningful engineering


representation of some software product that is to be built. A
design can be assessed for quality against predefined
criteria.
During the designing process the software requirements
model is transformed into design models that describe the
details of the data structures, system architecture, interface
and components. Each design product is reviewed for quality
before moving to the next phase of the software
development

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

Project Report 2014-2015

Hotel Management System

Database
Design

Table New user

Table Room Type

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

10

Project Report 2014-2015

Hotel Management System

Table Room Number

Table Bill

Table Visitor Entry

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

11

Project Report 2014-2015

Hotel Management System

TESTING
Testing is the process of creating a program with the
explicit intention of finding error that is making the program
fail. Successful test then, is one that finds and as yet
undiscovered error. As an additional benefit, Testing
demonstrates that software functions appear to be working
to the specifications.
Testing has several purpose
* To affirm the quality of project.
* To find and eliminate any errors from previous stage.
* To
validate the software and to eliminate the
operational reliability of the system.

5.1

Testing Methodology

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

12

Project Report 2014-2015

Hotel Management System

- Unit Testing
In this phase the program modules is individually tested.
During the unit testing the functions of the program unit
validation and the limitations are tested.

- Integration Testing
Integration testing is the complete testing of the set of
modules which makes up the product. It is a systematic
technique for the construction of program structure.

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

13

Project Report 2014-2015

Hotel Management System

FORMS USED

Login page

Home page
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

14

Project Report 2014-2015

Hotel Management System

New Entry

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

15

Project Report 2014-2015

Hotel Management System

Search Result

Extra Bill

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

16

Project Report 2014-2015

Hotel Management System

Bill Preview

Daily Report
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

17

Project Report 2014-2015

Hotel Management System

Admin
Create New User

Add Room Type


Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

18

Project Report 2014-2015

Hotel Management System

Update Rent

Monthly Report
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

19

Project Report 2014-2015

Hotel Management System

Add Room Number

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

20

Project Report 2014-2015

Hotel Management System

PROJECT CODES

Login Page
package forms;

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

21

Project Report 2014-2015

import
import
import
import
import

Hotel Management System

dbconnection.LoadData;
java.sql.*;
java.util.logging.Level;
java.util.logging.Logger;
javax.swing.JOptionPane;

public class FrmLogin extends javax.swing.JFrame {


public FrmLogin() {
initComponents();
}
private void txtPswdActionPerformed(java.awt.event.ActionEvent
evt) {
}
private
void
btnLogCanActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0 }
private
void
btnLoginActionPerformed(java.awt.event.ActionEvent evt) {
try {
Connection
cnn
=
dbconnection.DBConnection.getConnection();
String sql="select * from tbluser where username=? and
password=?";
PreparedStatement ps=cnn.prepareStatement(sql);
ps.setString(1,txtUname.getText());
ps.setString(2, txtPswd.getText());
ResultSet rs= ps.executeQuery();
if(rs.next())
{
LoadData.user=rs.getString("username");
FrmHome h1 = new FrmHome();
this.dispose();
h1.show();
}
else
{
lbl_error.setText("Invalid Username or Password");
}

} catch (Exception ex) {


Logger.getLogger(FrmLogin.class.getName()).log(Level.SE
VERE, null, ex);
}
}
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

22

Project Report 2014-2015

Hotel Management System

private void txtUnameKeyPressed(java.awt.event.KeyEvent


evt) {
if(evt.getKeyCode()==10)
{
txtPswd.requestFocus();
}
}
private void txtPswdKeyPressed(java.awt.event.KeyEvent evt)
{
if(evt.getKeyCode()==10)
{
btnLogin.doClick();
}
private void btnLogCanKeyPressed(java.awt.event.KeyEvent
evt) {
if(evt.getKeyCode()==10)
{
btnLogCan.doClick();
}
}

public static void main(String args[]) {


java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FrmLogin().setVisible(true);
}
};

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

23

Project Report 2014-2015

Hotel Management System

Home Page
package forms;
import
import
import
import
import
import
import
import
import
import

dbconnection.LoadData;
java.sql.Connection;
java.sql.PreparedStatement;
java.sql.ResultSet;
java.text.SimpleDateFormat;
java.util.logging.Level;
java.util.logging.Logger;
javax.swing.DefaultListModel;
javax.swing.JOptionPane;
javax.swing.table.DefaultTableModel;

public class FrmHome extends javax.swing.JFrame {


public FrmHome() {
try {
initComponents();
lstLiveName.setVisible(false);
java.util.Date d1= new java.util.Date();
SimpleDateFormat sdf= new SimpleDateFormat("dd-MMyyyy");
String mydate=sdf.format(d1);
jLabel14.setText(mydate);
jLabel5.setText(LoadData.user);
Connection
cnn
=
dbconnection.DBConnection.getConnection();
String sqlshow = "select `room_type`,`no_of_rooms` from
tblavail";
PreparedStatement
pss
=
cnn.prepareStatement(sqlshow);
ResultSet rs = pss.executeQuery();
DefaultTableModel tb = (DefaultTableModel)
tblAvail.getModel();
tb.setRowCount(0);
while (rs.next()) {
Object o[] = {rs.getString("room_type"),
rs.getInt("no_of_rooms")};
tb.addRow(o);
}
}
catch (Exception ex) {
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

24

Project Report 2014-2015

Hotel Management System

Logger.getLogger(FrmHome.class.getName()).log(Level.SE
VERE, null, ex);
}
};
private
void
jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
FrmNewEntry fne=new FrmNewEntry();
this.dispose();
fne.show();
LoadData.check=0;
}
private
void
jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
FrmReport fr=new FrmReport();
this.dispose();
fr.show();
}
private
void
jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
FrmAdmin fa=new FrmAdmin();
this.dispose();
fa.show();
}
private
void
btnSrchByNoActionPerformed(java.awt.event.ActionEvent evt) {
try {
Connection
cnn
=
dbconnection.DBConnection.getConnection();
String sql="select * from tblvisitorentry where slno=?";
PreparedStatement ps=cnn.prepareStatement(sql);
ps.setInt(1, Integer.parseInt(txtSrchByNo.getText()));
ResultSet rs = ps.executeQuery();
if(rs.next())
{
LoadData.slno=rs.getInt("slno");
LoadData.name=rs.getString("name");
LoadData.addr=rs.getString("address");
LoadData.from=rs.getString("comming_from");
LoadData.rno=rs.getString("room_no");
LoadData.adnvc=rs.getInt("advance");
LoadData.rtype=rs.getString("room_type");
LoadData.d=rs.getDate("date_checkin");
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

25

Project Report 2014-2015

Hotel Management System

FrmSearch f=new FrmSearch();


this.dispose();
f.show();
}
else
{
}

} catch (Exception ex) {


Logger.getLogger(FrmHome.class.getName()).log(Level.SE
VERE, null, ex);
}
}
private void txtSrchByNoKeyPressed(java.awt.event.KeyEvent
evt) {
if(evt.getKeyCode()==10)
btnSrchByNo.doClick();
}
private
txtSrchByNameKeyPressed(java.awt.event.KeyEvent evt) {
try {
if(txtSrchByName.getText().equals(""))
{
lstLiveName.setVisible(false);
}

void

if(evt.getKeyCode()==40)
{
lstLiveName.requestFocus();
lstLiveName.setSelectedIndex(0);
}
else
{
String s=txtSrchByName.getText()+evt.getKeyChar();
Connection
cnn=dbconnection.DBConnection.getConnection();
String sql="Select name from tblvisitorentry where name
like ?";
PreparedStatement ps= cnn.prepareStatement(sql);
ps.setString(1, s+"%");
ResultSet rs=ps.executeQuery();
DefaultListModel
ls=(DefaultListModel)lstLiveName.getModel();
ls.removeAllElements();
while(rs.next())
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

26

Project Report 2014-2015

Hotel Management System

{
ls.addElement(rs.getString(1));
}
lstLiveName.setVisible(true);
}
if(evt.getKeyCode()==10)
{
btnSrchByName.doClick();
}
} catch (Exception ex) {
Logger.getLogger(NewJFrame.class.getName()).log(Level.
SEVERE, null, ex);
}
}
private
void
btnSrchByNameActionPerformed(java.awt.event.ActionEvent evt)
{
try {
Connection
cnn
=
dbconnection.DBConnection.getConnection();
String sql="select * from tblvisitorentry where name=?";
PreparedStatement ps=cnn.prepareStatement(sql);
ps.setString(1, txtSrchByName.getText());
ResultSet rs = ps.executeQuery();
if(rs.next())
{
LoadData.slno=rs.getInt("slno");
LoadData.name=rs.getString("name");
LoadData.addr=rs.getString("address");
LoadData.from=rs.getString("comming_from");
LoadData.rno=rs.getString("room_no");
LoadData.adnvc=rs.getInt("advance");
LoadData.rtype=rs.getString("room_type");
LoadData.d=rs.getDate("date_checkin");
FrmSearch f=new FrmSearch();
this.dispose();
f.show();
}
else
{
}
} catch (Exception ex) {
Logger.getLogger(FrmHome.class.getName()).log(Level.SE
VERE, null, ex);
}
}
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

27

Project Report 2014-2015

Hotel Management System

private void lstLiveNameKeyPressed(java.awt.event.KeyEvent


evt) {
if(evt.getKeyCode()==10)
{
txtSrchByName.setText(lstLiveName.getSelectedValue().to
String());
txtSrchByName.requestFocus();
}
}
private
void
txtSrchByNameKeyReleased(java.awt.event.KeyEvent evt) {
if(txtSrchByName.getText().equals(""))
{
lstLiveName.setVisible(false);
}
}

New entry
package forms;
import
import
import
import
import
import
import
import

dbconnection.LoadData;
java.awt.Color;
java.sql.*;
java.text.SimpleDateFormat;
java.util.logging.Level;
java.util.logging.Logger;
javax.swing.DefaultComboBoxModel;
javax.swing.JOptionPane;

public class FrmNewEntry extends javax.swing.JFrame {


public FrmNewEntry() {
initComponents();
lblUser.setText(LoadData.user);
java.util.Date d1=new java.util.Date();
SimpleDateFormat sdf= new SimpleDateFormat("dd-MMyyyy");
String mydate=sdf.format(d1);
lblDateDisp.setText(mydate);
try {
Connection
dbconnection.DBConnection.getConnection();
String sql="select slno from tblvisitorentry";
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

cnn

28

Project Report 2014-2015

Hotel Management System

PreparedStatement ps=cnn.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
if(rs.next())
{
rs.last();
lblSLno.setText(rs.getInt("slno")+1+"");
}
String sqlshow="select room_type from tblroomtype";
PreparedStatement
pss=cnn.prepareStatement(sqlshow);
ResultSet rss = pss.executeQuery();
DefaultComboBoxModel
c=(DefaultComboBoxModel)cmbRT.getModel();
c.removeAllElements();
while(rss.next())
{
c.addElement(rss.getString("room_type"));
}

String sqlrt="select room_no from tblroomno where


room_type=? and status = 0 ";
PreparedStatement ps2=cnn.prepareStatement(sqlrt);
ps2.setString(1, cmbRT.getSelectedItem().toString());
ResultSet rs2 = ps2.executeQuery();
DefaultComboBoxModel
cr=(DefaultComboBoxModel)cmbrno.getModel();
cr.removeAllElements();
while(rs2.next())
{
cr.addElement(rs2.getString("room_no"));
}
spnrDurtn.setValue(1);
spnrNOP.setValue(1);
if(LoadData.check==1)
{
String sqledit="select
name,address,pin,comming_from,purpose_of_visit,
duration,no_of_persons,room_type,room_no,id_proof,id_no,
advance,
balance,date_checkin from tblvisitorentry where slno=?";
PreparedStatement
ps3=cnn.prepareStatement(sqledit);
ps2.setString(1,LoadData.sslno);
ResultSet rs3= ps3.executeQuery();
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

29

Project Report 2014-2015

Hotel Management System

if(rs3.next())
{
lblSLno.setText(LoadData.sslno);
txtName.setText(rs2.getString("name"));
textAddress.setText(rs2.getString("address"));
txtPin.setText(rs2.getString("pin"));
txtComFrom.setText(rs2.getString("comming_from"));
textPOV.setText(rs2.getString("purpose_of_visit"));
spnrDurtn.setValue(rs2.getInt("duration"));
spnrNOP.setValue(rs2.getInt("no_of_persons"));
cmbRT.setSelectedItem(rs2.getString("room_type").to
String());
cmbrno.setSelectedItem(rs2.getString("room_no").to
String());
cmbIDP.setSelectedItem(rs2.getString("id_proof").toS
tring());
txtIDno.setText(rs2.getString("id_no"));
txtAdvnc.setText(rs2.getString("advance"));
lblBlnc.setText(rs2.getString("balance"));
lblDateDisp.setText(rs2.getString("date_checkin"));
}
}
} catch (Exception ex) {
Logger.getLogger(FrmNewEntry.class.getName()).log(Le
vel.SEVERE, null, ex);
}
}
private
void
btnChkCanActionPerformed(java.awt.event.ActionEvent evt) {
FrmHome fh = new FrmHome();
this.dispose();
fh.show();
}
private
void
btnCheckInActionPerformed(java.awt.event.ActionEvent evt) {
String status="Checked IN";
try {
Connection
cnn
=
dbconnection.DBConnection.getConnection();
if(txtName.getText().equals("")||
textAddress.getText().equals("")||txtPin.getText().equals("")||
txtComFrom.getText().equals("")||textPOV.getText().equals("")||
txtIDno.getText().equals(""))
{
JOptionPane.showMessageDialog(this, "Plese Fill all
Fields...");
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

30

Project Report 2014-2015

Hotel Management System

}
else
{
String sql="Insert into tblvisitorentry
(`name`,`address`,`pin`,`comming_from`,`purpose_of_visit`,`du
ration`,`no_of_persons`,`room_type`,`room_no`,`id_proof`,`id_n
o`,`advance`,`balance`,`date_checkin`,`status`)
values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
PreparedStatement ps=cnn.prepareStatement(sql);
ps.setString(1, txtName.getText());
ps.setString(2, textAddress.getText());
ps.setInt(3, Integer.parseInt(txtPin.getText()));
ps.setString(4, txtComFrom.getText());
ps.setString(5, textPOV.getText());
ps.setInt(6,
Integer.parseInt(spnrDurtn.getValue().toString()));
ps.setInt(7,
Integer.parseInt(spnrNOP.getValue().toString()));
ps.setString(8, cmbRT.getSelectedItem().toString());
ps.setString(9, cmbrno.getSelectedItem().toString());
ps.setString(10, cmbIDP.getSelectedItem().toString());
ps.setString(11, txtIDno.getText() );
ps.setInt(12, Integer.parseInt(txtAdvnc.getText()));
lblBlnc.setText("8888");
ps.setInt(13, Integer.parseInt(lblBlnc.getText()));
java.util.Date d=new java.util.Date();
lblDateDisp.setText(d.toString());
java.sql.Date d1=new java.sql.Date(d.getTime());
ps.setDate(14, d1);
ps.setString(15, status);
ps.executeUpdate();
JOptionPane.showMessageDialog(this,"Data inserted");
}
String sqlAvail ="update tblavail set no_of_rooms
=no_of_rooms -1 where room_type=? ";
PreparedStatement
ps2=cnn.prepareStatement(sqlAvail);
ps2.setString(1, cmbRT.getSelectedItem().toString());
ps2.executeUpdate();
txtName.setText("");
textAddress.setText("");
txtPin.setText("");
txtComFrom.setText("");
txtAdvnc.setText("");
textPOV.setText("");
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

31

Project Report 2014-2015

Hotel Management System

txtIDno.setText("");
lblBlnc.setText("XXXX");
String sqlrno ="update tblroomno set status = 1 where
room_no=? ";
PreparedStatement
ps3=cnn.prepareStatement(sqlrno);
ps3.setString(1, cmbrno.getSelectedItem().toString());
ps3.executeUpdate();
}
catch (Exception ex) {
Logger.getLogger(FrmLogin.class.getName()).log(Level.
SEVERE, null, ex);
JOptionPane.showMessageDialog(this, ex);
}
}
private
void
cmbRTActionPerformed(java.awt.event.ActionEvent evt) {
try {
Connection
cnn
=
dbconnection.DBConnection.getConnection();
String sqlrt="select * from tblroomno where room_type=?
and status = 0";
PreparedStatement ps2=cnn.prepareStatement(sqlrt);
ps2.setString(1, cmbRT.getSelectedItem().toString());
ResultSet rs2 = ps2.executeQuery();
DefaultComboBoxModel
cr=(DefaultComboBoxModel)cmbrno.getModel();
cr.removeAllElements();
while(rs2.next())
{
cr.addElement(rs2.getString("room_no"));
}

} catch (Exception ex) {


Logger.getLogger(FrmNewEntry.class.getName()).log(Le
vel.SEVERE, null, ex);
}
}
private void txtAdvncKeyReleased(java.awt.event.KeyEvent
evt) {
try {
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

32

Project Report 2014-2015

Hotel Management System

Connection
dbconnection.DBConnection.getConnection();

cnn

String sqlshow="select room_rent from tblroomtype


where room_type=?";
PreparedStatement
pss=cnn.prepareStatement(sqlshow);
pss.setString(1, cmbRT.getSelectedItem().toString());
ResultSet rs = pss.executeQuery();
if(rs.next())
{
int amount = rs.getInt("room_rent");
int
price=
amount*Integer.parseInt(spnrDurtn.getValue().toString());
int b=(Integer.parseInt(txtAdvnc.getText()))-price;
if(b<0)
{
lblBlnc.setForeground(Color.red);
}
else
{
lblBlnc.setForeground(Color.blue);
}
lblBlnc.setText(b+"");

}
} catch (Exception ex) {
Logger.getLogger(FrmNewEntry.class.getName()).log(Le
vel.SEVERE, null, ex);
}
}
private
formWindowClosed(java.awt.event.WindowEvent evt) {
FrmHome f=new FrmHome();
f.show();
}

void

private void txtPinKeyTyped(java.awt.event.KeyEvent evt) {


if(!Character.isDigit(evt.getKeyChar()))
{
evt.consume();
}

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

33

Project Report 2014-2015

Hotel Management System

Search
package forms;
import
import
import
import
import
import
import
import
import
import

dbconnection.LoadData;
java.awt.Color;
java.sql.Connection;
java.sql.PreparedStatement;
java.sql.ResultSet;
java.text.SimpleDateFormat;
java.util.logging.Level;
java.util.logging.Logger;
javax.swing.DefaultComboBoxModel;
javax.swing.JOptionPane;

public class FrmSearch extends javax.swing.JFrame {


public FrmSearch() {
initComponents();
java.util.Date d1= new java.util.Date();
SimpleDateFormat sdf= new SimpleDateFormat("ddMM-yyyy");
String mydate=sdf.format(d1);
lblDateDisp.setText(mydate);
lblUser.setText(LoadData.user);

lblsSlNo.setText (LoadData.slno+"");
lblsName.setText (LoadData.name+"");
lblsAddr.setText (LoadData.addr+"");
lblsFrom.setText (LoadData.from+"");
lblsRno.setText (LoadData.rno+"");
java.util.Date dd=new java.util.Date();
long x =Math.abs(dd.getTime()- LoadData.d.getTime());
long day =x/(24*60*60*1000);
lblsNOD.setText(day+"");
if(0==Integer.parseInt(lblsNOD.getText()))
{
lblsNOD.setText("1");
}

try {
Connection
dbconnection.DBConnection.getConnection();
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

cnn

=
34

Project Report 2014-2015

Hotel Management System

String sqlstatus="select status from tblvisitorentry


where slno=?";
PreparedStatement
ps=cnn.prepareStatement(sqlstatus);
ps.setInt(1, Integer.parseInt(lblsSlNo.getText()));
ResultSet rs = ps.executeQuery();
if(rs.next())
{
String st=rs.getString("status");
if(st.equals("Checked IN"))
{
lblsSts.setText(st);
lblsSts.setForeground(Color.GREEN);
}
else
{
lblsSts.setText("Checked Out");
lblsSts.setForeground(Color.RED);
btnsChkOut.setVisible(false);
btnsEdit.setVisible(false);
}
}
} catch (Exception ex) {
Logger.getLogger(FrmSearch.class.getName()).log(Level
.SEVERE, null, ex);
JOptionPane.showMessageDialog(this, ex);
}
}
private
void
btnsEditActionPerformed(java.awt.event.ActionEvent evt) {
LoadData.sslno=lblsSlNo.getText();
LoadData.check=1;
FrmNewEntry fne=new FrmNewEntry();
this.dispose();
fne.show();
}
private
void
btnsChkOutActionPerformed(java.awt.event.ActionEvent evt) {
FrmExtra eb=new FrmExtra();
this.dispose();
eb.show();
}
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

35

Project Report 2014-2015

Hotel Management System

private
void
btnsCanActionPerformed(java.awt.event.ActionEvent evt) {
FrmHome fh= new FrmHome();
this.dispose();
fh.show();
}

Report
package forms;
import
import
import
import
import
import
import
import
import

dbconnection.LoadData;
java.sql.Connection;
java.sql.PreparedStatement;
java.sql.ResultSet;
java.text.SimpleDateFormat;
java.util.logging.Level;
java.util.logging.Logger;
javax.swing.JOptionPane;
javax.swing.table.DefaultTableModel;

public class FrmReport extends javax.swing.JFrame {


public FrmReport() {
initComponents();
lblUser.setText(LoadData.user);
java.util.Date d2=new java.util.Date();
SimpleDateFormat sdf= new SimpleDateFormat("dd-MMyyyy");
String mydate=sdf.format(d2);
lblDateDisp.setText(mydate);
try {
Connection
cnn
=
dbconnection.DBConnection.getConnection();
String sqlshow = "select
`room_type`,count(room_type),sum(total_amount) from tblbill
where date=? group by`room_type` ";
PreparedStatement pss =
cnn.prepareStatement(sqlshow);
java.util.Date d=new java.util.Date();
java.sql.Date d1=new java.sql.Date(d.getTime());
pss.setDate(1, d1);
ResultSet rs = pss.executeQuery();
DefaultTableModel tb =
(DefaultTableModel)tbldreport.getModel();
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

36

Project Report 2014-2015

Hotel Management System

tb.setRowCount(0);
while (rs.next()) {
Object o[] = {rs.getString("room_type"),
rs.getString(2),rs.getInt(3)};
tb.addRow(o);
}
String sqltotal="select sum(total_amount) from
tblbill where date=?";
PreparedStatement ps2=
cnn.prepareStatement(sqltotal);
ps2.setDate(1, d1);
ResultSet rs2 = ps2.executeQuery();
if(rs2.next())
{
lbDRTA.setText(rs2.getString(1));
}

} catch (Exception ex) {


Logger.getLogger(FrmHome.class.getName()).log(Level.
SEVERE, null, ex);
}
}
private
void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
FrmHome fh = new FrmHome();
this.dispose();
fh.show();
}

Admin
package forms;
import
import
import
import
import
import
import
import
import
import

dbconnection.LoadData;
java.sql.Connection;
java.sql.PreparedStatement;
java.sql.ResultSet;
java.text.SimpleDateFormat;
java.util.logging.Level;
java.util.logging.Logger;
javax.swing.DefaultComboBoxModel;
javax.swing.JOptionPane;
javax.swing.table.DefaultTableModel;

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

37

Project Report 2014-2015

Hotel Management System

public class FrmAdmin extends javax.swing.JFrame {


public FrmAdmin() {
try {
initComponents();
jPanel3.setVisible(true);
java.util.Date d1 = new java.util.Date();
SimpleDateFormat sdf = new SimpleDateFormat("ddMM-yyyy");
String mydate = sdf.format(d1);
lblDateDisp.setText(mydate);
lblUser.setText(LoadData.user);
Connection
dbconnection.DBConnection.getConnection();

cnn

String sqlshow = "select room_type from tblroomtype";


PreparedStatement
pss
=
cnn.prepareStatement(sqlshow);
ResultSet rs = pss.executeQuery();
DefaultComboBoxModel c = (DefaultComboBoxModel)
cmbAdUpRT.getModel();
c.removeAllElements();
while (rs.next()) {
c.addElement(rs.getString("room_type"));
}

String sqlrno = "select room_type from tblroomtype";


PreparedStatement
ps3
=
cnn.prepareStatement(sqlrno);
ResultSet rs3 = ps3.executeQuery();
DefaultComboBoxModel c3 = (DefaultComboBoxModel)
cmbRT.getModel();
c3.removeAllElements();
while (rs3.next()) {
c3.addElement(rs3.getString("room_type"));
}

} catch (Exception ex) {


Logger.getLogger(FrmAdmin.class.getName()).log(Level
.SEVERE, null, ex);
}
panAdCNU.setVisible(false);
panAdRT.setVisible(false);
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

38

Project Report 2014-2015

Hotel Management System

panAdUpR.setVisible(false);
jPanel4.setVisible(false);
panRno.setVisible(false);
}
private
void
btnAdUpdateActionPerformed(java.awt.event.ActionEvent evt)
{
try {
Connection
cnn
=
dbconnection.DBConnection.getConnection();
String sql = "update tblroomtype set room_rent =?
where room_type =?";
PreparedStatement ps = cnn.prepareStatement(sql);
ps.setInt(1, Integer.parseInt(txtAdUpRnt.getText()));
ps.setString(2,
cmbAdUpRT.getSelectedItem().toString());
ps.executeUpdate();
JOptionPane.showMessageDialog(this, "update ok");
txtAdUpRnt.setText("");
} catch (Exception ex) {
Logger.getLogger(FrmAdmin.class.getName()).log(Level
.SEVERE, null, ex);
JOptionPane.showMessageDialog(this, ex);
}
}
private
void
btnAdUsrCreateActionPerformed(java.awt.event.ActionEvent
evt) {

if (pwdAdPswd.getText().equals(pwdAdRePswd.getText()))
{
try {
Connection
dbconnection.DBConnection.getConnection();

cnn

String sql = "insert into tbluser values (?,?,?)";


PreparedStatement ps = cnn.prepareStatement(sql);
ps.setString(1, txtAdUserName.getText());
ps.setString(2, (pwdAdPswd.getText()));
ps.setString(3, (txtAdAddr.getText()));
ps.executeUpdate();
JOptionPane.showMessageDialog(this, "User added");
txtAdUserName.setText("");
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

39

Project Report 2014-2015

Hotel Management System

txtAdAddr.setText("");
pwdAdPswd.setText("");
pwdAdRePswd.setText("");
} catch (Exception ex) {
Logger.getLogger(FrmAdmin.class.getName()).log(Le
vel.SEVERE, null, ex);
}
} else {
JOptionPane.showMessageDialog(this, "Password Does
Not Match");
}
}
private
void
btnAdAddActionPerformed(java.awt.event.ActionEvent evt) {
try {
Connection
cnn
=
dbconnection.DBConnection.getConnection();
String sql = "Insert into tblroomtype
(`room_type`,`no_of_rooms`) values (?,?)";
PreparedStatement ps = cnn.prepareStatement(sql);
ps.setString(1, txtAdRT.getText());
ps.setInt(2, Integer.parseInt(txtAdNOR.getText()));
ps.executeUpdate();
sql = "Insert into tblavail (`room_type`,`no_of_rooms`)
values (?,?)";
PreparedStatement ps2 = cnn.prepareStatement(sql);
ps2.setString(1, txtAdRT.getText());
ps2.setInt(2, Integer.parseInt(txtAdNOR.getText()));
ps2.executeUpdate();
String sqlshow = "select `room_type`,`no_of_rooms`
from tblroomtype";
PreparedStatement
pss
=
cnn.prepareStatement(sqlshow);
ResultSet rs = pss.executeQuery();
DefaultTableModel tb = (DefaultTableModel)
tblAdRT.getModel();
tb.setRowCount(0);
while (rs.next()) {
Object o[] = {rs.getString("room_type"),
rs.getInt("no_of_rooms")};
tb.addRow(o);
}
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

40

Project Report 2014-2015

Hotel Management System

pss.executeUpdate();
JOptionPane.showMessageDialog(this, "Insert ok");
} catch (Exception ex) {
Logger.getLogger(FrmAdmin.class.getName()).log(Level
.SEVERE, null, ex);
}
}
private
void
btnAdCNUActionPerformed(java.awt.event.ActionEvent evt) {
txtAdUserName.setText("");
txtAdAddr.setText("");
pwdAdPswd.setText("");
pwdAdRePswd.setText("");
panAdCNU.setVisible(true);
panAdRT.setVisible(false);
panAdUpR.setVisible(false);
jPanel4.setVisible(false);
}
private
void
btnAdARTActionPerformed(java.awt.event.ActionEvent evt) {
panAdCNU.setVisible(false);
panAdRT.setVisible(true);
panAdUpR.setVisible(false);
jPanel4.setVisible(false);
panRno.setVisible(false);
try {
Connection
dbconnection.DBConnection.getConnection();

cnn

String sqlshow = "select `room_type`,`no_of_rooms`


from tblroomtype";
PreparedStatement
pss
=
cnn.prepareStatement(sqlshow);
ResultSet rs = pss.executeQuery();
DefaultTableModel tb = (DefaultTableModel)
tblAdRT.getModel();
tb.setRowCount(0);
while (rs.next()) {
Object o[] = {rs.getString("room_type"),
rs.getInt("no_of_rooms")};
tb.addRow(o);

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

41

Project Report 2014-2015

Hotel Management System

} catch (Exception ex) {


Logger.getLogger(FrmAdmin.class.getName()).log(Level
.SEVERE, null, ex);
}

}
private
void
btnAdURRActionPerformed(java.awt.event.ActionEvent evt) {
panAdCNU.setVisible(false);
panAdRT.setVisible(false);
panAdUpR.setVisible(true);
jPanel4.setVisible(false);
panRno.setVisible(false);
}
private
void
btnAdUsrCrtCanActionPerformed(java.awt.event.ActionEvent
evt) {
panAdCNU.setVisible(false);
panAdRT.setVisible(false);
panAdUpR.setVisible(false);
jPanel4.setVisible(false);
panRno.setVisible(false);
}
private
btnAdDeleteActionPerformed(java.awt.event.ActionEvent
{

void
evt)

tblAdRT.getSelectedRow();
}
private
void
jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
panAdCNU.setVisible(false);
panAdRT.setVisible(false);
panAdUpR.setVisible(false);
jPanel4.setVisible(true);
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

42

Project Report 2014-2015

Hotel Management System

panRno.setVisible(false);
}
private
void
btnAdRokActionPerformed(java.awt.event.ActionEvent evt) {
try {
Connection
cnn
=
dbconnection.DBConnection.getConnection();
String
sqlshow
=
"select
`room_type`,count(room_type),sum(total_amount) from tblbill
where date>=? and date<=? group by`room_type` ";
PreparedStatement
pss
=
cnn.prepareStatement(sqlshow);
java.util.Date c1 = dtAdRFrom.getDate();
java.sql.Date d1 = new java.sql.Date(c1.getTime());
pss.setDate(1, d1);
java.util.Date c2 = dtAdRTo.getDate();
java.sql.Date d2 = new java.sql.Date(c2.getTime());
pss.setDate(2, d2);
ResultSet rs = pss.executeQuery();
DefaultTableModel tb = (DefaultTableModel)
tblAdreport.getModel();
tb.setRowCount(0);
while (rs.next()) {
Object o[] = {rs.getString("room_type"),
rs.getString(2), rs.getInt(3)};
tb.addRow(o);
}
String sqltotal = "select sum(total_amount) from tblbill
where date>=? and date<=?";
PreparedStatement
ps2
=
cnn.prepareStatement(sqltotal);
java.util.Date c3 = dtAdRFrom.getDate();
java.sql.Date d3 = new java.sql.Date(c3.getTime());
ps2.setDate(1, d3);
java.util.Date c4 = dtAdRTo.getDate();
java.sql.Date d4 = new java.sql.Date(c4.getTime());
ps2.setDate(2, d4);
ResultSet rs2 = ps2.executeQuery();
if (rs2.next()) {
lbAdRTA.setText(rs2.getString(1));
}

} catch (Exception ex) {


Logger.getLogger(FrmHome.class.getName()).log(Level.
SEVERE, null, ex);
}
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

43

Project Report 2014-2015

Hotel Management System

}
private
void
jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
panRno.setVisible(true);
panAdCNU.setVisible(false);
panAdRT.setVisible(false);
panAdUpR.setVisible(false);
jPanel4.setVisible(false);
}
private
void
btnAddActionPerformed(java.awt.event.ActionEvent evt) {
try {
int tno = 0, no = 0;
Connection
cnn
=
dbconnection.DBConnection.getConnection();
String sqlcheck = "Select no_of_rooms from tblroomtype
where room_type=?";
PreparedStatement
ps1
=
cnn.prepareStatement(sqlcheck);
ps1.setString(1, cmbRT.getSelectedItem().toString());
ResultSet rs1 = ps1.executeQuery();
if (rs1.next()) {
no = Integer.parseInt(rs1.getString("no_of_rooms"));
}
String sqlc = "select count(*) from tblroomno where
room_type=?";
PreparedStatement ps2 = cnn.prepareStatement(sqlc);
ps2.setString(1, cmbRT.getSelectedItem().toString());
ResultSet rs2 = ps2.executeQuery();
while (rs2.next()) {
tno = Integer.parseInt(rs2.getString(1));
}
if (tno < no) {
String sql = "Insert into tblroomno
(`room_type`,`room_no`,`status`) values (?,?,0)";
PreparedStatement ps = cnn.prepareStatement(sql);
ps.setString(1, cmbRT.getSelectedItem().toString());
ps.setString(2, txtRno.getText());
ps.executeUpdate();
txtRno.setText("");
// JOptionPane.showMessageDialog(this, "Room
Added");
txtRno.requestFocus();
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

44

Project Report 2014-2015

Hotel Management System

} else {
JOptionPane.showMessageDialog(this, "error... rooms
exparied");
}
} catch (Exception ex) {
Logger.getLogger(FrmAdmin.class.getName()).log(Level
.SEVERE, null, ex);
JOptionPane.showConfirmDialog(this, "Room No already
exists");
}

}
private void txtRnoKeyReleased(java.awt.event.KeyEvent
evt) {
if (evt.getKeyCode() == 10) {
btnAdd.doClick();
}
}
private
void
jFrame1WindowClosed(java.awt.event.WindowEvent evt) {
FrmHome f = new FrmHome();
f.show();
}
private
formWindowClosed(java.awt.event.WindowEvent evt) {
FrmHome f = new FrmHome();
f.show();
}

void

Bill Preview
package forms;
import
import
import
import
import
import
import
import

dbconnection.LoadData;
java.sql.Connection;
java.sql.PreparedStatement;
java.sql.ResultSet;
java.util.logging.Level;
java.util.logging.Logger;
javax.swing.JOptionPane;
java.text.SimpleDateFormat;

public class FrmBillPrev extends javax.swing.JFrame {

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

45

Project Report 2014-2015

Hotel Management System

public FrmBillPrev() {
try {
initComponents();
java.util.Date d=new java.util.Date();
java.sql.Date d1=new java.sql.Date(d.getTime());
SimpleDateFormat sdf= new SimpleDateFormat("ddMM-yyyy");
String mydate=sdf.format(d);
lblbDate.setText(mydate);
lblDateDisp.setText(mydate);
lblUser.setText(LoadData.user);
Connection
cnn
=
dbconnection.DBConnection.getConnection();
String sql="select bilno from tblbill";
PreparedStatement ps=cnn.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
if(rs.next())
{
rs.last();
lblbBillno.setText(rs.getInt("bilno")+1+"");
}
lblbslno.setText (LoadData.slno+"");
lblbName.setText (LoadData.name+"");
lblbRno.setText (LoadData.rno+"");
lblbAdvnc.setText (LoadData.adnvc+"");
lblbTOA.setText (LoadData.d+"");
lblbAdvnc.setText(LoadData.adnvc+"");
lblbRT.setText(LoadData.rtype+"");
lblExtraBill.setText(LoadData.extra+"");
java.util.Date dd=new java.util.Date();
long x =Math.abs(dd.getTime()- LoadData.d.getTime());
long day =x/(24*60*60*1000);
lblbNOD.setText(day+"");
String sqlshow="select room_rent from tblroomtype
where room_type=?";
PreparedStatement
pss=cnn.prepareStatement(sqlshow);
pss.setString(1,lblbRT.getText());
ResultSet rs2 = pss.executeQuery();
if(rs2.next())
{
int amount = rs2.getInt("room_rent");
if(0==Integer.parseInt(lblbNOD.getText()))
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

46

Project Report 2014-2015

Hotel Management System

{
lblbNOD.setText("1");
}
int

price=

(amount*Integer.parseInt(lblbNOD.getText())+
(Integer.parseInt(lblExtraBill.getText())));
lblbTot.setText(price+"");
int b=Integer.parseInt( lblbAdvnc.getText())-price;
lblbBncRorR.setText(b+"");
}
} catch (Exception ex) {
Logger.getLogger(FrmBillPrev.class.getName()).log(Lev
el.SEVERE, null, ex);
}
}
private
void
btnBilConfActionPerformed(java.awt.event.ActionEvent evt) {
int x= JOptionPane.showConfirmDialog(this, "Are You Sure
to Check Out??", "Confirm", JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);
if(x==0)
{
try {
java.util.Date d=new java.util.Date();
java.sql.Date d1=new java.sql.Date(d.getTime());
Connection
cnn
=
dbconnection.DBConnection.getConnection();
String sql="Insert into tblBill
values(?,?,?,?,?,?,?,?,?,?,?)";
PreparedStatement ps=cnn.prepareStatement(sql);
ps.setInt(1, Integer.parseInt(lblbBillno.getText()));
ps.setInt(2, Integer.parseInt(lblbslno.getText()));
ps.setString(3, lblbRno.getText());
ps.setInt(4, Integer.parseInt(lblbAdvnc.getText()));
ps.setInt(5, Integer.parseInt(lblbNOD.getText()));
ps.setInt(6, Integer.parseInt(lblbTot.getText()));
ps.setInt(7, Integer.parseInt(lblbBncRorR.getText()));
ps.setDate(8,d1);
ps.setString(9,lblbTOA.getText());
ps.setString(10, lblbRT.getText());
ps.setInt(11, Integer.parseInt(lblExtraBill.getText()));
ps.executeUpdate();
JOptionPane.showMessageDialog(this,"Ckecked Out");
String status="Checked Out";
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

47

Project Report 2014-2015

Hotel Management System

String sqlup="update tblvisitorentry set status=?


where slno=?";
PreparedStatement
ps2=cnn.prepareStatement(sqlup);
ps2.setString(1,status );
ps2.setInt(2,
Integer.parseInt(lblbslno.getText().toString()));
ps2.executeUpdate();
String sqlAvail ="update tblavail set no_of_rooms
=no_of_rooms +1 where room_type=? ";
PreparedStatement
ps3=cnn.prepareStatement(sqlAvail);
ps3.setString(1, lblbRT.getText());
ps3.executeUpdate();
String sqlrno ="update tblroomno set status = 0 where
room_no=? ";
PreparedStatement
ps4=cnn.prepareStatement(sqlrno);
ps4.setString(1, lblbRno.getText().toString());
ps4.executeUpdate();
FrmSearch fs= new FrmSearch();
this.dispose();
fs.show();
}
catch (Exception ex) {
Logger.getLogger(FrmBillPrev.class.getName()).log(L
evel.SEVERE, null, ex);
}
}
}
private
void
btnBilCanActionPerformed(java.awt.event.ActionEvent evt) {
FrmSearch fs= new FrmSearch();
this.dispose();
fs.show();
}

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

48

Project Report 2014-2015

Hotel Management System

CONCLUSION
The output of the project is successfully executed. This
software allows to book rooms in the hotel with the help of
receptionist. And it also reduce the work of receptionist.
This application works in windows XP or its latest versions.
It is user friendly to software users.

REFERENCES
Stackoverflow.com
W3schools.com
Toutorialspoint.com
Dept. Of Computer Engg.
J.D.T.Islam Polytechnic

49

Project Report 2014-2015

Hotel Management System

Youtube.com

Dept. Of Computer Engg.


J.D.T.Islam Polytechnic

50

Anda mungkin juga menyukai