Professional Documents
Culture Documents
I P Project Hotel Report Class Xii PDF
I P Project Hotel Report Class Xii PDF
DISSERTATION SUBMITTED
AS PARTIAL FULFILLMENT OF THE REQUIREMENT OF THE SUBJECT
INFORMATICS PRACTICES
OF
CLASS XII
OF
CENTRAL BOARD OF SECONDARY EDUCATION
SESSION 2015 – 16
Submitted by
Rishab Thakur
(REG. NO. : )
SUNITA DEKA
Computer Teacher,
Opp. To ram Mandir, Basistha Road,
Guwahati – 781 029, Assam.
Certificate
This is to certify that Rishab Thakur student of Class – XII of CBSE, successfully
carried out the project work entitled “Hotel Management System” at Delhi Public
School, Guwahati, Ahomgaon, Guwahati, Assam – 29
for the session 2015-16, under my guidance.
This project report has been prepared as a partial fulfillment of the subject Informatics
Practices of Class – XII under Central Board of Secondary Education the session 2008-
09.
Sunita Deka
Computer Teacher,
Ahomgaon,
Guwahati – 781 029, Assam.
Delhi Public School, Guwahati Phone :(0361)2
Ahomgaon,
Guwahati – 781 029, Assam.
Date:………….…
Certificate
This is to certify that Rishab(Reg. No.) a student of Class – XII of CBSE, successfully
carried out the project work entitled “Hotel Management System” at Delhi Public
School, Ahomgaon, Guwahati, Assam – 29
for the session 2015-16, under my guidance.
This project report has been prepared as a partial fulfillment of the subject Informatics
Practices of Class – XII under Central Board of Secondary Education the session 2008-
09.
I am very much grateful to Delhi Public Shool, Guwahati for giving us the chance to
carry out our Class – XII project work at its premises (Ahomgaon, Guwahati, Assam –
(Rishab)
1. Introductions
1.1 Introduction to RDBMS
1.2 Introduction to NetBeans IDE 6.7.1
4. Tools/Environment used
5. System Analysis
6. System Design
6.1 Description of the System Modules
6.2 Description of the Table/Relation
6.3 Data Dictionary
7. Report
7.1 Input Form
***
INTRODUCTIONS
RDBMS store the data into collection of tables, which might be related by common
fields (database table columns). RDBMS also provide relational operators to
manipulate the data stored into the database tables. Most RDBMS use SQL as
database query language.
Edgar Codd introduced the relational database model. Many modern DBMS do not
conform to the Codd’s definition of a RDBMS, but nonetheless they are still
considered to be RDBMS.
The most popular RDBMS are MS SQL Server, DB2, Oracle and MySQL.
NetBeans IDE 6.7 is integrated with Project Kenai, a collaborative environment for
developers to host open-source projects. With Kenai and the NetBeans IDE, a team of
developers is able to create projects, check out, edit, debug, build, discuss, and
commit code, all through one easy-to-use interface!
The release also builds on the success of NetBeans 6.5 with native support for
Maven; GlassFish, issue tracker and Hudson integrations; and enhancements to Java,
PHP, Ruby, Groovy and C/C++. Highlights of the 6.7 release include support for
JavaScript 1.7, Ruby Remote Debugging, and integration of the Java ME SDK 3.0.
***
OVERVIEW OF THE SYSTEM
Hotel Management System – Rooms are the entities of real world system that contains
fields and its respective values in it. Collections of these related information makes a
database. An interface is selected to interact with the user and store the information
passed by them.
another. So, in this system few procedures are prepared to accept the values into the
attributes, manipulate the entities to maintain the information in respective tables and to
*********************
OBJECTIVE OF THE PROPOSED SYSTEM
Interface known as NetBeans IDE 6.7.1. The concept of fields/Attributes, records, tables,
Entities/ Database, RDBMS, package, package interacting with tables, relation between
entities etc is been used. We have already been introduced to spreadsheets, databases,
word processors and presentation software earlier. That familiarly is been used to
introduce the idea of how the software can be designed by modeling it as operations
**************
TOOLS/ENVIRONMENT USED
My SQL(RDBMS)
**************
SYSTEM ANALYSIS
System analysis is a set of technique and graphical tools that allow the analyst to
develop a new kind of system specification that easily understandable to the user. The
goal of system development is to deliver system in line with the user requirement.
The data in this system were collected from an organization through interviews,
questionnaires, on-site observation, procedure manuals, and the like, after analysis some
of the fields were selected and used for calculation of profit of the organization.
***************
SYSTEM DESIGN
Main Menu:
Search Interface:
Display Interface:
This module displays the information of all the occupied rooms in the
hotel.
***
Hotel:
***
CODE
package jefferson;
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
/**
*
* @author Student
*/
public class HotelManagementForm extends javax.swing.JFrame {
Connection con;
Statement stmt;
DefaultTableModel model;
int flag;
public HotelManagementForm() {
initComponents();
model=(DefaultTableModel)tbhotel.getModel();
show1();
disable1();
updatepanel.setVisible(false);
}
void OpenConnection()
{
try{
Class.forName("com.mysql.jdbc.Driver");
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/JEFFERSON","root","");
stmt = con.createStatement();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
void show1()
{
delete();
try{
OpenConnection();
model.addRow(new Object[]
{name,phoneno,roomno,roomtype,noofdays,noofadults,noofchildren});
}
rs.close();
stmt.close();
con.close();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
void disable1()
{
txtname.setEditable(false);
txtphone.setEditable(false);
txtroomno.setEditable(false);
txtadultno.setEditable(false);
txtchildno.setEditable(false);
}
void enable1()
{
txtname.setEditable(true);
txtphone.setEditable(true);
txtroomno.setEditable(true);
txtadultno.setEditable(true);
txtchildno.setEditable(true);
}
void clear()
{
txtname.setText("");
txtphone.setText("");
txtroomno.setText("");
txtadultno.setText("");
txtchildno.setText("");
}
void delete()
{
int rows=model.getRowCount();
if(rows>0){
for(int i=0;i<rows;i++)
{
model.removeRow(0);
}
}
}
void setdata(String x)
{
try
{
OpenConnection();
txtname.setText(name);
txtphone.setText(phoneno);
txtroomno.setText(roomno);
txtadultno.setText(noofadults);
txtchildno.setText(noofchildren);
}
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}
} /**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
pguest.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFact
ory.createLineBorder(new java.awt.Color(0, 0, 0)), "Guest Information"));
pguest.setToolTipText("");
jLabel2.setText("Enter Name:");
jLabel3.setText("Phone No.:");
txtname.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
txtnameActionPerformed(evt);
}
});
jLabel4.setText("Room No.:");
.addGroup(pguestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEA
DING)
.addGroup(pguestLayout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtname))
.addGroup(pguestLayout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(pguestLayout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtphone))
.addGroup(pguestLayout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(txtroomno)))
.addContainerGap())
);
pguestLayout.setVerticalGroup(
pguestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pguestLayout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pguestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(jLabel2)
.addComponent(txtname, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(pguestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(jLabel3)
.addComponent(txtphone, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
20, Short.MAX_VALUE)
.addGroup(pguestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BAS
ELINE)
.addComponent(jLabel4)
.addComponent(txtroomno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
prate.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactor
y.createLineBorder(new java.awt.Color(0, 0, 0)), "Rate Information"));
buttonGroup1.add(rbSuite);
rbSuite.setText("Suite");
buttonGroup1.add(rbSingle);
rbSingle.setText("Single");
buttonGroup1.add(rbDeluxe);
rbDeluxe.setText("Deluxe");
jLabel5.setText("Room Type:");
jLabel6.setText("No. of days:");
jLabel7.setText("No. of adults:");
jLabel8.setText("No. of children:");
prateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(prateLayout.createSequentialGroup()
.addContainerGap()
.addGroup(prateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD
ING)
.addComponent(jLabel5)
.addComponent(rbSingle)
.addComponent(rbSuite)
.addComponent(rbDeluxe))
.addGap(41, 41, 41)
.addGroup(prateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD
ING)
.addGroup(prateLayout.createSequentialGroup()
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtchildno,
javax.swing.GroupLayout.PREFERRED_SIZE, 29,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(prateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAI
LING, false)
.addGroup(prateLayout.createSequentialGroup()
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtadultno))
.addGroup(prateLayout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(comboday,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(36, Short.MAX_VALUE))
);
prateLayout.setVerticalGroup(
prateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(prateLayout.createSequentialGroup()
.addContainerGap()
.addGroup(prateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(comboday, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(prateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEAD
ING)
.addGroup(prateLayout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(rbSuite)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(rbSingle))
.addGroup(prateLayout.createSequentialGroup()
.addGap(19, 19, 19)
.addGroup(prateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(jLabel7)
.addComponent(txtadultno,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(prateLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASE
LINE)
.addComponent(rbDeluxe)
.addComponent(jLabel8)
.addComponent(txtchildno, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(27, Short.MAX_VALUE))
);
printpanel.setBorder(javax.swing.BorderFactory.createLineBorder(new
java.awt.Color(0, 0, 0)));
btnPrint.setText("Print");
btnPrint.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnPrintActionPerformed(evt);
}
});
btnEdit.setText("Edit");
btnEdit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnEditActionPerformed(evt);
}
});
btnDelete.setText("Delete");
btnDelete.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnDeleteActionPerformed(evt);
}
});
btnCheckout.setText("Check Out");
btnCheckout.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCheckoutActionPerformed(evt);
}
});
printpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(printpanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(btnPrint)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnEdit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnDelete)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCheckout)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
printpanelLayout.setVerticalGroup(
printpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(printpanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(printpanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.B
ASELINE)
.addComponent(btnPrint)
.addComponent(btnEdit)
.addComponent(btnDelete)
.addComponent(btnCheckout))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
updatepanel.setBorder(javax.swing.BorderFactory.createLineBorder(new
java.awt.Color(0, 0, 0)));
btnUpdate.setText("Update");
btnUpdate.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnUpdateActionPerformed(evt);
}
});
btnCancel.setText("Cancel");
btnCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelActionPerformed(evt);
}
});
updatepanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
)
.addGroup(updatepanelLayout.createSequentialGroup()
.addGap(14, 14, 14)
.addComponent(btnUpdate)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
updatepanelLayout.setVerticalGroup(
updatepanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING
)
.addGroup(updatepanelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(updatepanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment
.BASELINE)
.addComponent(btnUpdate)
.addComponent(btnCancel))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
tbhotel.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null}
},
new String [] {
"Name", "Phone No.", "Room No.", "Room Type", "No. of days", "No. of
adults", "No. of children"
}
));
jScrollPane1.setViewportView(tbhotel);
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(printpanel,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 144,
Short.MAX_VALUE)
.addComponent(updatepanel,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(pguest, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(prate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(34, 34, 34))
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane1)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(27, 27, 27)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pguest, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(prate, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(printpanel, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(updatepanel,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
89, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(21, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
{if(x!=0)
{
try
{OpenConnection();
String query="Delete from hotel where Roomno=" +
Integer.parseInt(txtroomno.getText()) + ";";
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(null,"Record deleted!!!");
show1();
clear();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional)
">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look
and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(HotelManagementForm.class.getName()).log(java.uti
l.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(HotelManagementForm.class.getName()).log(java.uti
l.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(HotelManagementForm.class.getName()).log(java.uti
l.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(HotelManagementForm.class.getName()).log(java.uti
l.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/**
*
* @author Student
*/
public class HotelSearch extends javax.swing.JFrame {
Connection con;
Statement stmt;
DefaultTableModel model;
/**
* Creates new form HotelSearch
*/
public HotelSearch() {
initComponents();
model=(DefaultTableModel)tbhotel.getModel();
}
void OpenConnection()
{
try{
Class.forName("com.mysql.jdbc.Driver");
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/JEFFERSON","root","");
stmt = con.createStatement();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
void show1()
{
delete();
try{
OpenConnection();
model.addRow(new Object[]
{name,phoneno,roomno,roomtype,noofdays,noofadults,noofchildren});
}
rs.close();
stmt.close();
con.close();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
void delete()
{
int rows=model.getRowCount();
if(rows>0){
for(int i=0;i<rows;i++)
{
model.removeRow(0);
}
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jPanel1.setEnabled(false);
jPanel1.setPreferredSize(new java.awt.Dimension(522, 200));
jPanel1.setLayout(null);
btnSearch.setText("Search");
btnSearch.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSearchActionPerformed(evt);
}
});
jPanel1.add(btnSearch);
btnSearch.setBounds(225, 190, 130, 23);
tbhotel.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null}
},
new String [] {
"Name", "Phone No.", "Room No.", "Room Type", "No. of days", "No. of
adults", "No. of children"
}
));
jScrollPane1.setViewportView(tbhotel);
jPanel1.add(jScrollPane1);
jScrollPane1.setBounds(30, 230, 590, 91);
jLabel1.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Student\\Desktop\\background\\003-wood-melamine-
subttle-pattern-background-pat.jpg")); // NOI18N
jPanel1.add(jLabel1);
jLabel1.setBounds(0, -30, 640, 400);
pack();
}// </editor-fold>
delete();
ResultSet rs=stmt.executeQuery(query);
while(rs.next())
{
String name=rs.getString("Name");
String phoneno=rs.getString("Phoneno");
String roomno=rs.getString("Roomno");
String roomtype=rs.getString("Roomtype");
String noofdays=rs.getString("Noofdays");
String noofadults=rs.getString("Noofadults");
String noofchildren=rs.getString("Noofchildren");
model.addRow(new Object[]
{name,phoneno,roomno,roomtype,noofdays,noofadults,noofchildren});
}
}
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.getMessage());
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional)
">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look
and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(HotelSearch.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(HotelSearch.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(HotelSearch.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(HotelSearch.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
}
//</editor-fold>
Display Interface:
package jefferson;
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
/**
*
* @author Student
*/
public class HotelDisplay extends javax.swing.JFrame {
Connection con;
Statement stmt;
DefaultTableModel model;
/**
* Creates new form HotelDisplay
*/
public HotelDisplay() {
initComponents();
model=(DefaultTableModel)tbhotel.getModel();
}
void OpenConnection()
{
try{
Class.forName("com.mysql.jdbc.Driver");
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/JEFFERSON","root","");
stmt = con.createStatement();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
void show1()
{
delete();
try{
OpenConnection();
model.addRow(new Object[]
{name,phoneno,roomno,roomtype,noofdays,noofadults,noofchildren});
}
rs.close();
stmt.close();
con.close();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
void delete()
{
int rows=model.getRowCount();
if(rows>0){
for(int i=0;i<rows;i++)
{
model.removeRow(0);
}
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
tbhotel.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null}
},
new String [] {
"Name", "Phone No.", "Room No.", "Room Type", "No. of days", "No. of
adults", "No. of children"
}
));
jScrollPane1.setViewportView(tbhotel);
jLabel1.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Student\\Desktop\\background\\lobby.jpg")); //
NOI18N
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(btnDisplay,
javax.swing.GroupLayout.PREFERRED_SIZE, 328,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel1))
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 621,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 9, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
92, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(47, 47, 47)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btnDisplay, javax.swing.GroupLayout.PREFERRED_SIZE,
0, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional)
">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look
and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(HotelDisplay.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(HotelDisplay.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(HotelDisplay.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(HotelDisplay.class.getName()).log(java.util.logging.L
evel.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new HotelDisplay().setVisible(true);
}
});
}
Main Menu:
package jefferson;
/**
*
* @author Student
*/
public class HotelMain extends javax.swing.JFrame {
HotelManagementForm hm1 = new HotelManagementForm();
HotelSearch hs1 = new HotelSearch();
HotelDisplay hd1 = new HotelDisplay();
/**
* Creates new form HotelMain
*/
public HotelMain() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jMenu1.setText("jMenu1");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/jefferson/newpackage/hotel.jpg"))); //
NOI18N
jMenu2.setText("Hotel");
jMenuItem1.setText("Entry Form");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem1);
jMenuItem2.setText("Search");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem2);
jMenuItem3.setText("View");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
jMenu2.add(jMenuItem3);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional)
">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look
and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(HotelMain.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(HotelMain.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(HotelMain.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(HotelMain.class.getName()).log(java.util.logging.Lev
el.SEVERE, null, ex);
}
//</editor-fold>
Main Menu:
Display Interface:
***