Escolar Documentos
Profissional Documentos
Cultura Documentos
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. : )
Phone:(0361)2
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 200809.
Sunita Deka
Computer Teacher,
Ahomgaon,
Guwahati 781 029, Assam.
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 200809.
ACKNOWLEDGEMENT
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
781 029) for the session 2015-16.
Sunita Deka,
Computer Teacher, Delhi Public School, Guwahati for her constant inspiration, valuable
suggestions and construction criticism at every stage of the present work.
(Rishab)
Class XII, Info. Sc.
Ahomgaon,Guwahati 781
029, Assam.
CONTENTS
Chapters
Page No.
1. Introductions
1.1 Introduction to RDBMS
1.2 Introduction to NetBeans IDE 6.7.1
2. Overview of the System
3. Objective of the Proposed System
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
1.1 Introduction to RDBMS:
RDBMS stands for Relational Database Management System. RDBMS data is
structured in database tables, fields and records. Each RDBMS table consists of
database table rows. Each database table row consists of one or more database table
fields.
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 Codds 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.
1.2 Introduction to NetBeans IDE 6.7.1 :
The NetBeans IDE is an award-winning integrated development environment
available for Windows, Mac, Linux, and Solaris. The NetBeans project consists of an
open-source IDE and an application platform that enable developers to rapidly create
web, enterprise, desktop, and mobile applications using the Java platform, as well as
JavaFX, PHP, JavaScript and Ajax, Ruby and Ruby on Rails, Groovy and Grails, and
C/C++.
The NetBeans project is supported by a vibrant developer community and offers
extensive documentation and training resources as well as a diverse selection of thirdparty plugins.
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.
***
*********************
**************
TOOLS/ENVIRONMENT USED
**************
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
6.1 Description of the System Modules:
Main Menu:
This module displays the information of all the occupied rooms in the
hotel.
***
6.2 Description of Tables/relations:
Hotel:
Name
Name
Phoneno
Roomno
Roomtype
Noofdays
Noofadults
Noofchildren
Data Type(Size)
varchar(30)
int
varchar(30)
varchar(30)
int
int
int
***
Index
Not Null
Not Null
Primary Key
Not Null
Not Null
Not Null
Not Null
CODE
The following is the code for the process ::
Hotel Management(Entry) Form :
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();
String query="select * from hotel;";
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});
}
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();
String query="select * from hotel where roomno ="+x+";";
ResultSet rs=stmt.executeQuery(query);
if(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");
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() {
buttonGroup1 = new javax.swing.ButtonGroup();
pguest = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
pguestLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pguestLayout.createSequentialGroup()
.addContainerGap()
.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:");
comboday.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1",
"2", "3", "4", "5", "6", "7" }));
jLabel6.setText("No. of days:");
jLabel7.setText("No. of adults:");
jLabel8.setText("No. of children:");
javax.swing.GroupLayout prateLayout = new javax.swing.GroupLayout(prate);
prate.setLayout(prateLayout);
prateLayout.setHorizontalGroup(
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);
}
});
javax.swing.GroupLayout printpanelLayout = new
javax.swing.GroupLayout(printpanel);
printpanel.setLayout(printpanelLayout);
printpanelLayout.setHorizontalGroup(
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);
}
});
javax.swing.GroupLayout updatepanelLayout = new
javax.swing.GroupLayout(updatepanel);
updatepanel.setLayout(updatepanelLayout);
updatepanelLayout.setHorizontalGroup(
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);
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.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>
private void btnPrintActionPerformed(java.awt.event.ActionEvent evt) {
updatepanel.setVisible(true);
printpanel.setVisible(false);
enable1();
flag = 1;
}
private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {
String x = JOptionPane.showInputDialog("Enter the room number:");
if(x.compareTo("")!=0)
{
setdata(x);
updatepanel.setVisible(true);
printpanel.setVisible(false);
flag = 2;
}
enable1();
}
private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {
try{
String query=null;
if((txtname.getText()).compareTo("")!=0 &&
(txtphone.getText()).compareTo("")!=0 && (txtroomno.getText()).compareTo("")!=0 &&
(txtadultno.getText()).compareTo("")!=0)
{
OpenConnection();
if(flag==1){
query="insert into hotel values ('" + txtname.getText() + "'," +
Integer.parseInt(txtphone.getText()) + "," + Integer.parseInt(txtroomno.getText()) + ",
'dummy',"+ comboday.getSelectedItem() +"," + Integer.parseInt(txtadultno.getText()) +
"," + Integer.parseInt(txtchildno.getText()) +");";
stmt.executeUpdate(query);
if(rbSuite.isSelected())
{query="update hotel set Roomtype='Suite' where Roomtype='dummy';";}
else if(rbSingle.isSelected())
{query="update hotel set Roomtype='Single' where Roomtype='dummy';";}
else if(rbDeluxe.isSelected())
{query="update hotel set Roomtype='Deluxe' where Roomtype='dummy';";}
}
else if(flag==2){
query="update hotel set Name='" + txtname.getText() + "', Phoneno=" +
Integer.parseInt(txtphone.getText()) + ", Roomno=" +
Integer.parseInt(txtroomno.getText()) + ",Roomtype='dummy', Noofdays="+
comboday.getSelectedItem() +", Noofadults="+ Integer.parseInt(txtadultno.getText()) + ",
Noofchildren=" + Integer.parseInt(txtchildno.getText()) + " where Roomno=" +
Integer.parseInt(txtroomno.getText()) + ";";
stmt.executeUpdate(query);
if(rbSuite.isSelected())
{query="update hotel set Roomtype='Suite' where Roomtype='dummy';";}
else if(rbSingle.isSelected())
{query="update hotel set Roomtype='Single' where Roomtype='dummy';";}
else if(rbDeluxe.isSelected())
{query="update hotel set Roomtype='Deluxe' where Roomtype='dummy';";}
}
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(null, "Record inserted!!!");
show1();
stmt.close();
con.close();
printpanel.setVisible(true);
updatepanel.setVisible(false);
clear();
// disable1();
}
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e.getMessage());
}
}
private void txtnameActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
Search Interface:
package jefferson;
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
/**
*
* @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();
String query="select * from hotel;";
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});
}
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() {
jPanel1 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
combo1 = new javax.swing.JComboBox();
txtvalue = new javax.swing.JTextField();
btnSearch = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
tbhotel = new javax.swing.JTable();
jLabel4 = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jPanel1.setEnabled(false);
));
jScrollPane1.setViewportView(tbhotel);
jPanel1.add(jScrollPane1);
jScrollPane1.setBounds(30, 230, 590, 91);
jLabel4.setBackground(new java.awt.Color(0, 102, 0));
jLabel4.setFont(new java.awt.Font("Vivaldi", 1, 36)); // NOI18N
jLabel4.setForeground(new java.awt.Color(0, 102, 51));
jLabel4.setText("Search Interface");
jPanel1.add(jLabel4);
jLabel4.setBounds(200, 40, 257, 45);
jLabel1.setIcon(new
javax.swing.ImageIcon("C:\\Users\\Student\\Desktop\\background\\003-wood-melaminesubttle-pattern-background-pat.jpg")); // NOI18N
jPanel1.add(jLabel1);
jLabel1.setBounds(0, -30, 640, 400);
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 640,
javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 340,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void combo1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void btnSearchActionPerformed(java.awt.event.ActionEvent evt) {
String x = txtvalue.getText();
String x1=(String)combo1.getSelectedItem();
OpenConnection();
try{
String query=null;
if(x.compareTo("")!=0)
{
query="select * from hotel where "+combo1.getSelectedItem()
+"='"+txtvalue.getText()+"';";
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;
}
}
*
* @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();
String query="select * from hotel;";
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});
}
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() {
jScrollPane1 = new javax.swing.JScrollPane();
tbhotel = new javax.swing.JTable();
btnDisplay = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
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);
btnDisplay.setBackground(new java.awt.Color(255, 153, 153));
btnDisplay.setFont(new java.awt.Font("Comic Sans MS", 1, 24)); // NOI18N
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void btnDisplayActionPerformed(java.awt.event.ActionEvent evt) {
show1();
}
/**
* @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>
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
hm1.show();
}
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
hs1.show();
}
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {
hd1.show();
}
/**
* @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);
REPORT
7.1 Input forms ::
Main Menu:
Search Interface:
Display Interface:
***