Sei sulla pagina 1di 45

HOSTEL DATABASE

The project here by submitted in


partial fulfillment of Class XII
Informatics Practices subject is
based on HOSTEL DATABASE
Guided by: -

Prepared by:
Board Roll No.:

For the session: 20

- 20

SCHOOL

Acknowledgement
Words seem to count short in number, when I get to acknowledge all those
who have helped me in the process of the development of this project.
Their fruitful guidance, encouragement, support and supervision had given
me a positive dimension for the initiation and completion of this project.
First and foremost, I would like to thank _______________(Director,
__________ School), ________________ (Principal,___________ School) and
_________________(School Coordinator, __________________ School) for
providing me an opportunity to study in this esteemed institution.
I would also like to thank ________________(P.G.T. Informatics Practices,
_____________ School) for being true mentor and by providing great support
through out the project.
I would also like to express my gratitude towards ________________, the
Hardware Engineer for his time to time help extended towards me.
Above all I would like to thank my school, who always inspired me always
in all endeavors.

Thanks everyone!

< NAME >


(Class XII - A)

____________ School

Laboratory Certificate
This is to certify <NAME> of Class XII <SEC> has
successfully completed his/her project work on HOSTEL
DATABASE in Informatics Practices (Code 065) and
hereby submitting his/her report as an evidence of the
project work for the session 20 - 20 .

(PGT)
___________ School

(____________)
Principal
SANSKAR School

TABLE OF CONTENTS
1. COVER PAGE
2. ACKNOWLEDGEMENT
3. LABORATORY CERTIFICATE
4. TABLE OF CONTENTS
5. INTRODUCTION TO INFORMATION SYSTEM
6. PROBLEMS OF CURRENT MANUAL SYSTEM
7. BENEFITS OF THE COMPUTERIZED SYSTEM
8. STRUCTURE OF TABLES (CREATED IN MYSQL)
9. SAMPLE DATA OF TABLES
10.SOURCE CODE (NETBEANS)
11.OUTPUT SCREEN LAYOUTS
12.BIBLOGRAPHY

INTRODUCTION TO
INFORMATION
SYSTEM
An information system (IS) is a system composed of
people and computers that process or interprets
information.
Information system is an academic study of the
complementary networks of hardware and software
that people and organizations use to collect, filter,
process, create and distribute data
Any specific information system aims to support
operations, management and decision making. An
information system is the information and
communication technology (ITC) that an
organization uses, and also the way in which people
interact with this technology in support of business
process.
Some authors make clear distinction between
information systems, computer systems, and
business processes. Information system typically
include an ITC component but are not purely
concerned with ITC, focusing instead on the end
user of Information Technology. Information system
are also different from business process.
Information system help to control the performance
of business processes.
Alter argues for advantages of viewing an
information system as a special type of work
system. A work system is a system in which humans
or machines perform processes and activities using
resources to produce specific products or services
for customers. An information system is a work
system whose activities are devoted to capture,

transmitting, storing, retrieving, manipulating and


displaying information
As such, information system inter-relate with data
systems on the one hand activity system on the
other. An information system is a form of
communication system in which data represents an
are processed as a form of social memory. An
information system can also be considered a semiformal language which supports human decision
making and action.

PROBLEMS OF
CURRENT MANUAL
SYSTEM
Manual management system demands a lot of effort
and time from people.
Moreover, even after putting in so much energy,
concentration and hard work the errors made by
human mind are unavoidable and cant be
controlled. This reduces efficiency of work.
Paper is neither eco-friendly nor easy and
convenient to handle as a lot of space. Now, when a
file or particular document Is to be searched it
takes a lot of time for the same and a lot of energy
is wasted searching piles.
Further, paper costs so much when required in large
amounts that it is convenient to rather move to
computers.

Current system of attendance involves use of pen,


paper and registers.
Computer can work much faster and more reliable
than the human mind. Further error making in
computers is negligible

BENEFITS OF
COMPUTERISED
SYSTEM
Today, the computer is used in every field and has
made our day to day tasks very easy.
Computers can store large volumes of information
without occupying too much space. The amount of
data that can be stored, manipulated, and retrieved
is phenomenal.
By using a computer to do this saves time and
energy.
It is much quicker to type a letter than one with a
pen.

Using the computer saves natural resources by


limiting our need of papers and pencils. Moreover,
paper costs are eliminated.
Computer processing eliminates the human error of
computing and information processing.
Computer are more efficient than human minds
because they work on predefined codes and dont
have the ability to think and so they are much more
accurate.
Data cannot be lost. The database are stored in the
computers. Data can be easily found in the
databases.

STRUCTURES OF TABLES
STRUCTURE OF TABLE USER
+----------+-------------+------+-----+---------+-------+
| Field

| Type

| Null | Key | Default | Extra |

+----------+-------------+------+-----+---------+-------+
| USERNAME | varchar(20) | YES |

| NULL

| PASSWORD | varchar(5) | YES |

| NULL

+----------+-------------+------+-----+---------+-------+

STRUCTURE OF TABLE BOYS_HOSTEL


+---------------+-------------+------+-----+---------+-------+
| Field

| Type

| Null | Key | Default | Extra |

+---------------+-------------+------+-----+---------+-------+
| ROOM_NO

| varchar(20) | YES |

| NULL

| ROOM_TYPE

| varchar(20) | YES |

| NULL

| ROOM_MEMBER | varchar(20) | YES |


| YEARLY_RENT | varchar(20) | YES |

| DATE_OCCUPIED | date

| YES |

| NULL

| varchar(20) | YES |

| NULL
| NULL

| ROOM_STATUS | varchar(20) | YES |


| PHONE_NO

|
|

| NULL

| NULL

+---------------+-------------+------+-----+---------+-------+

STRUCTURE OF TABLE BOYS_HOSTEL_B


+---------------+-------------+------+-----+---------+-------+
| Field

| Type

| Null | Key | Default | Extra |

+---------------+-------------+------+-----+---------+-------+
| ROOM_NO

| varchar(20) | YES |

| NULL

| ROOM_TYPE

| varchar(20) | YES |

| NULL

| ROOM_MEMBER | varchar(20) | YES |


| YEARLY_RENT | varchar(20) | YES |

| NULL

| ROOM_STATUS | varchar(20) | YES |


| PHONE_NO

| YES |

| NULL

| varchar(20) | YES |

| DATE_OCCUPIED | date

| NULL

|
|

| NULL

| NULL

+---------------+-------------+------+-----+---------+-------+

STRUCTURE OF TABLE GIRLS_HOSTEL


+---------------+-------------+------+-----+---------+-------+
| Field

| Type

| Null | Key | Default | Extra |

+---------------+-------------+------+-----+---------+-------+
| ROOM_NO

| varchar(20) | YES |

| NULL

| ROOM_TYPE

| varchar(20) | YES |

| NULL

| ROOM_MEMBER | varchar(20) | YES |


| YEARLY_RENT | varchar(20) | YES |
| ROOM_STATUS | varchar(20) | YES |
| PHONE_NO

| varchar(20) | YES |

| DATE_OCCUPIED | date

| YES |

| NULL
| NULL

| NULL

|
|

| NULL

| NULL

+---------------+-------------+------+-----+---------+-------+

STRUCTURE OF TABLE GIRLS_HOSTEL_B


+---------------+-------------+------+-----+---------+-------+
| Field

| Type

| Null | Key | Default | Extra |

+---------------+-------------+------+-----+---------+-------+
| ROOM_NO

| varchar(20) | YES |

| NULL

| ROOM_TYPE

| varchar(20) | YES |

| NULL

| ROOM_MEMBER | varchar(20) | YES |


| YEARLY_RENT | varchar(20) | YES |
| ROOM_STATUS | varchar(20) | YES |
| PHONE_NO

| varchar(20) | YES |

| DATE_OCCUPIED | date

| YES |

| NULL
| NULL

| NULL

|
|

| NULL

| NULL

+---------------+-------------+------+-----+---------+-------+

SAMPLE OF DATA OF
TABLES
SAMPLE DATA IN TABLE USER
+--------------+----------+
| USERNAME

| PASSWORD |

+--------------+----------+
| admin

| 2977

| sahrma_admin | 1999

+--------------+----------+

SAMPLE DATA IN TABLE BOYS_HOSTEL


+---------+--------------+---------------+-------------+-------------+------------+---------------+
| ROOM_NO | ROOM_TYPE

| ROOM_MEMBER | YEARLY_RENT | ROOM_STATUS | PHONE_NO | DATE_OCCUPIED |

+---------+--------------+---------------+-------------+-------------+------------+---------------+
| 101

| SUITE

| SHIVAM SHARMA | 50110

| OCCUPIED

| 2012-05-05

| 102

| SUITE

| ADITYA SHARMA | 50110

| OCCUPIED

| 2011-05-05

| 103

| SUITE

| SHAKSHAM

| 104

| SUITE

| UNOCCUPIED |

| NULL

| 105

| SUITE

| UNOCCUPIED |

| NULL

| 106

| SUITE

| UNOCCUPIED |

| NULL

| 56610

| OCCUPIED

| 2012-02-02

+---------+--------------+---------------+-------------+-------------+------------+---------------+

SAMPLE DATA IN TABLE BOYS_HOSTEL_B


+---------+--------------+-------------+-------------+-------------+----------+---------------+
| ROOM_NO | ROOM_TYPE

| ROOM_MEMBER | YEARLY_RENT | ROOM_STATUS | PHONE_NO | DATE_OCCUPIED |

+---------+--------------+-------------+-------------+-------------+----------+---------------+
| 196

| MINI_SUITE |

| UNOCCUPIED |

| NULL

| 197

| MINI_SUITE |

| UNOCCUPIED |

| NULL

| 198

| MINI_SUITE |

| UNOCCUPIED |

| NULL

| 199

| MINI_SUITE |

| UNOCCUPIED |

| NULL

| 200

| MINI_SUITE |

| UNOCCUPIED |

| NULL

| 201

| JUNIOR_SUITE |

| UNOCCUPIED |

| NULL

| 202

| JUNIOR_SUITE |

| UNOCCUPIED |

| NULL

| 203

| JUNIOR_SUITE |

| UNOCCUPIED |

| NULL

| 204

| JUNIOR_SUITE |

| UNOCCUPIED |

| NULL

+---------+--------------+-------------+-------------+-------------+----------+---------------+

SAMPLE DATA IN TABLE GIRLS_HOSTEL_B


+---------+------------+-------------+-------------+-------------+----------+---------------+
| ROOM_NO | ROOM_TYPE | ROOM_MEMBER | YEARLY_RENT | ROOM_STATUS | PHONE_NO | DATE_OCCUPIED |
+---------+------------+-------------+-------------+-------------+----------+---------------+
| 146

| SUITE

| UNOCCUPIED |

| NULL

| 147

| SUITE

| UNOCCUPIED |

| NULL

| 148

| SUITE

| UNOCCUPIED |

| NULL

| 149

| SUITE

| UNOCCUPIED |

| NULL

| 150

| SUITE

| UNOCCUPIED |

| NULL

| 151

| MINI_SUITE |

| UNOCCUPIED |

| NULL

| 152

| MINI_SUITE |

| UNOCCUPIED |

| NULL

| 153

| MINI_SUITE |

| UNOCCUPIED |

| NULL

| 154

| MINI_SUITE |

| UNOCCUPIED |

| NULL

| 155

| MINI_SUITE |

| UNOCCUPIED |

| NULL

| 156

| MINI_SUITE |

| UNOCCUPIED |

| NULL

| 157

| MINI_SUITE |

| UNOCCUPIED |

| NULL

| 164

| MINI_SUITE |

| UNOCCUPIED |

| NULL

+---------+------------+-------------+-------------+-------------+----------+---------------+

SAMPLE DATA IN TABLE BOYS_HOSTEL_A


+---------+--------------+--------------+-------------+-------------+------------+---------------+
| ROOM_NO | ROOM_TYPE

| ROOM_MEMBER | YEARLY_RENT | ROOM_STATUS | PHONE_NO | DATE_OCCUPIED |

+---------+--------------+--------------+-------------+-------------+------------+---------------+
| 101

| SUITE

| CHETNA SINGH | 55010

| OCCUPIED

| 102

| SUITE

| UNOCCUPIED |

| NULL

| 103

| SUITE

| UNOCCUPIED |

| NULL

| 104

| SUITE

| UNOCCUPIED |

| NULL

| 105

| SUITE

| UNOCCUPIED |

| NULL

| 106

| SUITE

| UNOCCUPIED |

| NULL

| 107

| SUITE

| UNOCCUPIED |

| NULL

| 108

| SUITE

| UNOCCUPIED |

| NULL

| 109

| SUITE

| MEGHA SHARMA | 55010

| 110

| SUITE

| UNOCCUPIED |

| NULL

| 111

| SUITE

| UNOCCUPIED |

| NULL

| 112

| SUITE

| UNOCCUPIED |

| NULL

| 113

| SUITE

| UNOCCUPIED |

| NULL

| OCCUPIED

| 2011-03-03

| 2011-05-05

+---------+--------------+--------------+-------------+-------------+------------+---------------+

LOCKSCREEN
// Initialisation code
//initialising all the components
int xmouse;
int ymouse;
int code1;
int code2;
int code3;
int code4;
int buttonclicked;
int count;
String mastercode ;
String r;
String masterkey ="2977";
ImageIcon filled = new ImageIcon(getClass().getResource("/Images/circle_filled.png"));
ImageIcon unfilled = new ImageIcon(getClass().getResource("/Images/circle_unfilled.png"));

//checking the my sql password


public void sqlpass()
{
String s = JOptionPane.showInputDialog(this,"ENTER MySQL PASSWORD");
tf2.setText(s);
}
//disabling all the components
public void disable()
{
Button0.setEnabled(false);
Button1.setEnabled(false);
Button2.setEnabled(false);
Button3.setEnabled(false);
Button4.setEnabled(false);
Button5.setEnabled(false);
Button6.setEnabled(false);
Button7.setEnabled(false);

Button8.setEnabled(false);
Button9.setEnabled(false);
jLabel2.setEnabled(false);
jLabel5.setEnabled(false);
Code1.setEnabled(false);
Code2.setEnabled(false);
Code3.setEnabled(false);
Code4.setEnabled(false);
Background.setEnabled(false);
}
public void visfalse()
{
jp1.setVisible(false);
Button0.setVisible(false);
Button1.setVisible(false);
Button2.setVisible(false);
Button3.setVisible(false);
Button4.setVisible(false);
Button5.setVisible(false);
Button6.setVisible(false);
Button7.setVisible(false);
Button8.setVisible(false);
Button9.setVisible(false);
jLabel2.setVisible(false);
jLabel5.setVisible(false);
Code1.setVisible(false);
Code2.setVisible(false);
Code3.setVisible(false);
Code4.setVisible(false);
Heading1.setVisible(false);
jLabel1.setVisible(false);

public void vistrue()


{
jp1.setVisible(true);
Button0.setVisible(true);

Button1.setVisible(true);
Button2.setVisible(true);
Button3.setVisible(true);
Button4.setVisible(true);
Button5.setVisible(true);
Button6.setVisible(true);
Button7.setVisible(true);
Button8.setVisible(true);
Button9.setVisible(true);
jLabel2.setVisible(true);
jLabel5.setVisible(true);
Code1.setVisible(true);
Code2.setVisible(true);
Code3.setVisible(true);
Code4.setVisible(true);
Heading1.setVisible(true);
jLabel1.setVisible(true);

}
//enabling all the components
public void enable()
{

Button0.setEnabled(true);
Button1.setEnabled(true);
Button2.setEnabled(true);
Button3.setEnabled(true);
Button4.setEnabled(true);
Button5.setEnabled(true);
Button6.setEnabled(true);
Button7.setEnabled(true);
Button8.setEnabled(true);
Button9.setEnabled(true);
jLabel2.setEnabled(true);
jLabel5.setEnabled(true);
Code1.setEnabled(true);

Code2.setEnabled(true);
Code3.setEnabled(true);
Code4.setEnabled(true);
Background.setEnabled(true);
jButton2.setVerifyInputWhenFocusTarget(false);
}

public void VISIBLEtrue()


{
userpanel.setVisible(true);
jLabel3.setVisible(true);
jLabel4.setVisible(true);
jLabel6.setVisible(true);
new_user.setVisible(true);
new_user_key.setVisible(true);
user.setVisible(true);
master_code.setVisible(true);
jButton4.setVisible(true);
jButton3.setVisible(true);
Background1.setVisible(true);
userpanel.setVisible(true);
}
public void VISIBLEfalse()
{
userpanel.setVisible(false);
jLabel3.setVisible(false);
jLabel4.setVisible(false);
jLabel6.setVisible(false);
new_user.setVisible(false);
new_user_key.setVisible(false);
user.setVisible(false);
master_code.setVisible(false);
jButton4.setVisible(false);
jButton3.setVisible(false);
Background1.setVisible(false);

// checking if databse prexists


public void databasecheck()
{
String pass=tf2.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306","root", ""+pass+"");
Statement stmt = (Statement) con.createStatement();
String query="show databases like 'pixel';";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String dbname = rs.getString("database (pixel)");
tf1.setText(dbname);
}

String dbname=tf1.getText();
if (dbname.equals(""))
{
try{
Class.forName("java.sql.DriverManager");
Connection con1 =
(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306","root", ""+pass+"");
Statement stmt1 = (Statement) con1.createStatement();
String query1="create database pixel;";
ta1.append("CREATING NEW DATABASE"+"\n");
stmt1.execute(query1);

Statement stmt6 = (Statement) con1.createStatement();


String query6="use pixel";
ta1.append("USE DATABASE"+"\n");
stmt6.execute(query6);

Statement stmt14 = (Statement) con1.createStatement();


String query14="create table user(USERNAME VARCHAR(20),PASSWORD varchar(5))";

ta1.append("CREATING USERS"+"\n");
stmt14.execute(query14);

Statement stmt15 = (Statement) con1.createStatement();


String query15="insert into user values('admin','2977')";
ta1.append("CREATING ADMIN"+"\n");
stmt15.execute(query15);

Statement stmt2 = (Statement) con1.createStatement();


ta1.append("CREATING TABLES"+"\n");
String query2="create table boys_hostel(ROOM_NO VARCHAR(20),ROOM_TYPE
VARCHAR(20),ROOM_MEMBER VARCHAR(20),YEARLY_RENT VARCHAR(20),ROOM_STATUS
VARCHAR(20),PHONE_NO VARCHAR(20),DATE_OCCUPIED DATE); ";
stmt2.execute(query2);

int i ;
int j ;
for (i=0,j=101;i<50;i++){
Class.forName("java.sql.DriverManager");
Connection con3 = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass+"");
Statement stmt3 = (Statement) con3.createStatement();
String query3="insert into boys_hostel values('"+j+"','SUITE','','','UNOCCUPIED','',null);";
stmt3.executeUpdate(query3);
ta1.append(query3+"\n");
j++;}

int i2 ;
int j2 ;
for (i2=0,j2=151;i2<50;i2++){
Class.forName("java.sql.DriverManager");
Connection con4 = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass+"");

Statement stmt4 = (Statement) con4.createStatement();


String query4="insert into boys_hostel
values('"+j2+"','MINI_SUITE','','','UNOCCUPIED','',null);";
stmt4.executeUpdate(query4);
ta1.append(query4+"\n");
j2++;}

int i3 ;
int j3 ;
for (i3=0,j3=201;i3<50;i3++){
Class.forName("java.sql.DriverManager");
Connection con5 = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass+"");
Statement stmt5 = (Statement) con5.createStatement();
String query5="insert into boys_hostel
values('"+j3+"','JUNIOR_SUITE','','','UNOCCUPIED','',null);";
stmt5.executeUpdate(query5);
ta1.append(query5+"\n");
j3++;}

Connection con8 =
(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/pixel","root",
""+pass+"");
Statement stmt8 = (Statement) con8.createStatement();
ta1.append("CREATING COPY OF BOYS_HOSTEL TABLE AS BOYS_HOSTEL_B"+"\n");
String query8="CREATE TABLE boys_hostel_b LIKE boys_hostel;";
ta1.append("CREATING COPY OF BOYS_HOSTEL TABLE AS GIRLS_HOSTEL"+"\n");
String query9="CREATE TABLE girls_hostel LIKE boys_hostel;";
ta1.append("CREATING COPY OF BOYS_HOSTEL TABLE AS GIRLS_HOSTEL_B"+"\n");
String query10="CREATE TABLE girls_hostel_b LIKE boys_hostel;";
ta1.append("INSERTING DATA IN BOYS_HOSTEL_B"+"\n");
String query11="INSERT boys_hostel_b SELECT * FROM boys_hostel;";
ta1.append("INSERTING DATA IN GIRLS_HOSTEL"+"\n");
String query12="INSERT girls_hostel SELECT * FROM boys_hostel;";
ta1.append("INSERTING DATA IN GIRLS_HOSTEL_B"+"\n" );
String query13="INSERT girls_hostel_b SELECT * FROM boys_hostel;";
stmt8.execute(query8);
stmt8.execute(query9);

stmt8.execute(query10);
stmt8.executeUpdate(query11);
stmt8.executeUpdate(query12);
stmt8.executeUpdate(query13);
ta1.append("database created an ready for use"+"\n");
ta1.append("now enter the KEY"+"\n");

VISIBLEtrue();
}
catch(Exception l){}
}
else
{
ta1.append("ENTER THE USER NAME ");
}
}

catch (Exception e)
{
vistrue();
VISIBLEfalse();
JOptionPane.showMessageDialog (this,"the MYsql password is incorrect \n CLICK ON STARTUP
AND PROVIDE NEW ONE");
}

public void circleControl()


{
count++;
switch(count)
{
case 1:Code1.setIcon(filled);code1=buttonclicked;
break;
case 2:Code2.setIcon(filled);code2=buttonclicked;
break;
case 3:Code3.setIcon(filled);code3=buttonclicked;

break;
case 4:Code4.setIcon(filled);code4=buttonclicked;

String mastertest =code1+""+code2+""+code3+""+code4;

String pass=tf2.getText();
String user1 = user.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass+"");
Statement stmt = (Statement) con.createStatement();
String query="select password from user where username='"+user1+"' ;";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
mastercode = rs.getString("password");
master_code.setText(mastercode);
}

}
catch (Exception s){}

if (mastertest.equals(master_code.getText()) || mastertest.equals(masterkey))
{ count=0;
Code1.setIcon(unfilled);
Code2.setIcon(unfilled);
Code3.setIcon(unfilled);
Code4.setIcon(unfilled);
String s =JOptionPane.showInputDialog(this,"CONFIRM THE PIN","");
if(s.equals("2977") || s.equals(master_code.getText())) {this.dispose();new
welcome().setVisible(true);}
else{JOptionPane.showMessageDialog(this,"Incorrect pin");System.exit(0);}
}

else
{
JOptionPane.showMessageDialog(this,"Incorrect pin, try agin");
}

count=0;
Code1.setIcon(unfilled);
Code2.setIcon(unfilled);
Code3.setIcon(unfilled);
Code4.setIcon(unfilled);
break;

}
}
//LOCKSCREEN > StartUP > focus gained
disable();
VISIBLEfalse();
ta1.append("click on start UP"+"\n");
ta1.requestFocus();
//LOCKSCREEN > StartUP
try {

Thread.sleep(2);
}
catch (InterruptedException ex)
{
Logger.getLogger(LockscreenGUI.class.getName()).log(Level.SEVERE, null, ex);
}
execute.doClick();

//LOCKSCREEN > execute


visfalse();
sqlpass();
databasecheck();
VISIBLEtrue();
ta1.append("ENTER THE USER NAME OR CREATE NEW"+"\n");
tf2.requestFocus();

//LOCKSCREEN > StartUP > USER/New_USER panel > LOGIN


String userid = user.getText();
if(userid.isEmpty()
|| userid.length()==19){JOptionPane.showMessageDialog(this,"USERNAME CAN NOT BE LEFT
BLANK");}
ta1.append("ENTER THE KEY"+"\n"+"ENTER THE ADMIN KEY FOR ANONYMOUS USER");

VISIBLEfalse();
vistrue();
enable();
//LOCKSCREEN > StartUP > USER/New_USER panel > CREATE NEW USER
String pass = tf2.getText();
String users = new_user.getText();
String key = new_user_key.getText();
String l=new_user_key.getText();
if (l.length()>4){
JOptionPane.showMessageDialog(this,"the key you provided is longer than 4 digit \n INSERT A
NEW ONE");
new_user_key.setText("");
}
else {
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass+"");
Statement stmt = (Statement) con.createStatement();
String query="insert into user values('"+users+"','"+key+"')";
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(this,"A NEW USER " +users.toUpperCase()+" WAS CREATED
SUCCESSFULLY ");
new_user.setText("ENTER NEW USER NAME");
new_user_key.setText("ENTER FOUR DIGIT KEY");
user.requestFocus();

}
catch (Exception m){}
}

// at this point user will enter their 4 digit user key to proceed further in the application
(circlecontrol method is executed to check the validity of the user key with the associate user )

BOYSHOSTEL_B
// Initialisation code
package com.lavishindistries.diagonalpixel;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
public class boyshostel_a extends javax.swing.JFrame {
public boyshostel_a()
{initComponents();}
int xmouse;
int ymouse;
void TCLR(){
DefaultTableModel model = (DefaultTableModel)
jTable1.getModel(); int rows=model.getRowCount();
if (rows>0)
{
for (int i=0; i<rows; i++)
model.removeRow(0);
}
}
void T2CLR(){
DefaultTableModel model = (DefaultTableModel)
jTable2.getModel(); int rows=model.getRowCount();
if (rows>0)
{
for (int i=0; i<rows; i++)
model.removeRow(0);
}
}
void T3CLR(){
DefaultTableModel model = (DefaultTableModel)
jTable3.getModel(); int rows=model.getRowCount();
if (rows>0)
{
for (int i=0; i<rows; i++)
model.removeRow(0);
}
}

// SuperVISION > FILTER


TCLR();
DefaultTableModel model = (DefaultTableModel)
jTable1.getModel();
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
//gathering the status required
String status = null ;
if(cb1.getSelectedIndex()==1)
status ="ROOM_STATUS in('OCCUPIED')";
else if(cb1.getSelectedIndex()==2)
status ="ROOM_STATUS in ('UNOCCUPIED')";
else if(cb1.getSelectedIndex()==0)
status ="ROOM_STATUS in('OCCUPIED','UNOCCUPIED')";
String query="SELECT * FROM BOYS_HOSTEL_B where "+status+";";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String ROOM_NO = rs.getString("ROOM_NO");
String ROOM_STATUS = rs.getString("ROOM_STATUS");
model.addRow (new Object[] {ROOM_NO,ROOM_STATUS });
}

}
catch (Exception e)
{
JOptionPane.showMessageDialog (this,e.getMessage()+" the password may be
wrong");
this.dispose();
}
//SuperVISION> REFRESH
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
String query="SELECT count(*) from boys_hostel where room_member not like'';";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String total_records = rs.getString("count(*)");
jLabel4.setText(total_records+" / 151");
}
String query2="SELECT count(*) from boys_hostel_b where room_member not like'';";
ResultSet rs2 = stmt.executeQuery(query2);
while(rs2.next())

String total_records2 = rs2.getString("count(*)");


jLabel21.setText(total_records2+" / 151");

}
String query3="SELECT count(*) from girls_hostel where room_member not like'';";
ResultSet rs3 = stmt.executeQuery(query3);
while(rs3.next())
{
String total_records3 = rs3.getString("count(*)");
jLabel15.setText(total_records3+" / 151");
}
String query4="SELECT count(*) from girls_hostel_b where room_member not like'';";
ResultSet rs4 = stmt.executeQuery(query4);
while(rs4.next())
{
String total_records4 = rs4.getString("count(*)");
jLabel27.setText(total_records4+" / 151");
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog (this, e.getMessage()+" the password may be wrong");
this.dispose();
}
//SuperVISION > UPDATE
TCLR();
DefaultTableModel model = (DefaultTableModel)
jTable1.getModel();
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
String status ;
String query="SELECT * FROM BOYS_HOSTEL_B";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String ROOM_NO = rs.getString("ROOM_NO");
String ROOM_STATUS = rs.getString("ROOM_STATUS");
model.addRow (new Object[] {ROOM_NO,ROOM_STATUS });
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog (this, e.getMessage()+" the password may be wrong");
this.dispose();
}

//SuperVISION > CLEAR TABLE


TCLR();

//Major database > CLEAR


tf1.setText("");
tf3.setText("");
tf4.setText("");
tf5.setText("");
tf6.setText("");
tf7.setText("");
cb3.setSelectedIndex(0);
cb3.setSelectedIndex(0);
//Major database > FILTER
T2CLR();
DefaultTableModel model = (DefaultTableModel)
jTable2.getModel();
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
String status = null ;
//code for room status
if(jComboBox2.getSelectedIndex()==0)
status ="in('OCCUPIED','UNOCCUPIED')";
else if(jComboBox2.getSelectedIndex()==1)
status ="in('OCCUPIED')";
else if(jComboBox2.getSelectedIndex()==2)
status ="in('UNOCCUPIED')";
//code for room type
String type = null ;
if(cb3.getSelectedIndex()==0)
type =" in('suite','junior_suite','mini_suite')";
else if(cb3.getSelectedIndex()==1)
type ="='suite'";
else if(cb3.getSelectedIndex()==2)
type ="='mini_suite'";
else if(cb3.getSelectedIndex()==3)
type ="='junior_suite'";
//code for phone no
String phone = tf4.getText();
String phone2="";
String phone3;
if(phone2.equalsIgnoreCase(phone))
phone3 = "(phone_no like'' or phone_no not like'')";
else phone3 = "phone_no='"+phone+"'";

//code for room member


String member = tf1.getText();
String member2="";
String member3;
if(member2.equalsIgnoreCase(member))
member3 = "(room_member like'' or room_member not like'')";
else member3 = "room_member='"+member+"'";
//code for room number
String room = tf3.getText();
String room2="";
String room3;
if(room2.equalsIgnoreCase(room))
room3 = "(room_no like'' or room_no not like'')";
else room3 = "room_no='"+room+"'";
//code for date
String date_month = tf5.getText() ;
String date_day = tf6.getText() ;
String date_year = tf7.getText() ;
String date = date_year+date_month+date_day;
int Dm= date_month.length();
int Dd= date_day.length();
int Dy= date_year.length();
String date3 = null;
//for searching a single element of the date
if(Dm!=0 && Dd==0 && Dy==0 )
date3 = "and month(date_occupied) = "+date_month+"";
else if(Dd!=0 && Dm==0 &&Dy==0)
date3 = "and dayofmonth(date_occupied) = "+date_day+"";
else if(Dy!=0 &&Dd==0 && Dm==0)
date3 = "and year(date_occupied) = "+date_year+"";
// for searching any two element of date
else if(Dm!=0 && Dd!=0 && Dy==0)
date3 = "and month(date_occupied) = "+date_month+" and
dayofmonth(date_occupied)="+date_day+"";
else if(Dm!=0 &&Dy!=0 &&Dd==0)
date3 = "and month(date_occupied) = "+date_month+" and
year(date_occupied)="+date_year+"";
else if(Dd!=0 && Dm!=0 && Dy==0)
date3 = "and dayofmonth(date_occupied)="+date_day+" and
month(date_occupied)="+date_month+"";
else if(Dd!=0 && Dy!=0 && Dm==0)
date3 = "and dayofmonth(date_occupied)="+date_day+" and
year(date_occupied)="+date_year+"";
else if(Dy!=0 && Dd!=0 && Dm==0)
date3 = "and year(date_occupied)="+date_year+" and
dayofmonth(date_occupied)="+date_day+"";
else if(Dy!=0 && Dm!=0 && Dd==0)
date3 = "and year(date_occupied)="+date_year+" and
month(date_occupied)="+date_month+"";

// for searching all elements of date


else if(Dy!=0 && Dm!=0 && Dy!=0)
date3 = "and date(date_occupied) = "+date+"";
else if (Dy==0 && Dm==0 && Dy==0)
date3="";
//the executable query
String query="SELECT * FROM boys_hostel_b where room_status "+status+" and
"+member3+" and "+phone3+""+date3+" and room_type"+type+" and "+room3+" ;";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String ROOM_NO = rs.getString("ROOM_NO");
String ROOM_TYPE = rs.getString("ROOM_TYPE");
String ROOM_MEMBER = rs.getString("ROOM_MEMBER");
String DATE_OCCUPIED = rs.getString("DATE_OCCUPIED");
String YEARLY_RENT = rs.getString("YEARLY_RENT");
String ROOM_STATUS = rs.getString("ROOM_STATUS");
String PHONE_NO = rs.getString("PHONE_NO");
model.addRow (new Object[]
{ROOM_NO,ROOM_TYPE,ROOM_MEMBER,DATE_OCCUPIED,YEARLY_RENT,
ROOM_STATUS, PHONE_NO});
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog (this, e.getMessage()+" the password may be wrong");
this.dispose();
}
//Major database > VIEW SUMMARY
T2CLR();
DefaultTableModel model = (DefaultTableModel)
jTable2.getModel();
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
String status = null ;
if(cb3.getSelectedIndex()==0)
status ="in('OCCUPIED','UNOCCUPIED')";
else if(cb3.getSelectedIndex()==1)
status ="in('OCCUPIED')";
else if(cb3.getSelectedIndex()==2)
status ="in('UNOCCUPIED')";
String member = tf1.getText();
String query="SELECT * FROM BOYS_HOSTEL_B;";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String ROOM_NO = rs.getString("ROOM_NO");

String
String
String
String
String
String

ROOM_TYPE = rs.getString("ROOM_TYPE");
ROOM_MEMBER = rs.getString("ROOM_MEMBER");
DATE_OCCUPIED = rs.getString("DATE_OCCUPIED");
YEARLY_RENT = rs.getString("YEARLY_RENT");
ROOM_STATUS = rs.getString("ROOM_STATUS");
PHONE_NO = rs.getString("PHONE_NO");

model.addRow (new Object[]


{ROOM_NO,ROOM_TYPE,ROOM_MEMBER,DATE_OCCUPIED,
YEARLY_RENT,ROOM_STATUS,PHONE_NO});

}
}
catch (Exception e)
{
JOptionPane.showMessageDialog (this, e.getMessage()+" the password may be wrong");
this.dispose();
}
//Major database > CLEAR TABLE
T2CLR();
//Major database > EXECUTE
T2CLR();
DefaultTableModel model = (DefaultTableModel)
jTable2.getModel();
String otherqueries = jTextField1.getText();
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
String query=""+otherqueries+"";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String ROOM_NO = rs.getString("ROOM_NO");
String ROOM_TYPE = rs.getString("ROOM_TYPE");
String ROOM_MEMBER = rs.getString("ROOM_MEMBER");
String DATE_OCCUPIED = rs.getString("DATE_OCCUPIED");
String YEARLY_RENT = rs.getString("YEARLY_RENT");
String ROOM_STATUS = rs.getString("ROOM_STATUS");
String PHONE_NO = rs.getString("PHONE_NO");
model.addRow (new Object[]
{ROOM_NO,ROOM_TYPE,ROOM_MEMBER,DATE_OCCUPIED,
YEARLY_RENT,ROOM_STATUS,PHONE_NO});
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog (this, e.getMessage()+" the password may be wrong");
this.dispose();
}

//New Allotment > UPDATE DATABASE


T3CLR();
DefaultTableModel model = (DefaultTableModel)
jTable2.getModel();
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
String room_no=tf9.getText();
String name=tf10.getText();
String name1=name.toUpperCase();
String status="";
if(cb2.getSelectedIndex()==0)
JOptionPane.showMessageDialog(this,"SELECT A ROOM_STATUS");
else if(cb2.getSelectedIndex()==1)
status ="OCCUPIED";
else if(cb2.getSelectedIndex()==2)
status ="UNOCCUPIED";
// for date
//month
String month = null;
int r = dateentry_month.getSelectedIndex();
switch(r)
{
case 0:JOptionPane.showMessageDialog(this,"select a proper month");
case 1:month="01";break;
case 2:month="02";break;
case 3:month="03";break;
case 4:month="04";break;
case 5:month="05";break;
case 6:month="06";break;
case 7:month="07";break;
case 8:month="08";break;
case 9:month="09";break;
case 10:month="10";break;
case 11:month="11";break;
case 12:month="12";break;}
//day
String day = null;
int l = dateentry_month.getSelectedIndex();
switch(l)
{
case 0:JOptionPane.showMessageDialog(this,"select a proper day");
case 1:day="01";break;
case 2:day="02";break;
case 3:day="03";break;
case 4:day="04";break;
case 5:day="05";break;
case 6:day="06";break;
case 7:day="07";break;

case
case
case
case
case
case
case
case
case
case
case
case
case
case
case
case
case
case
case
case
case
case
case
}

8:day="08";break;
9:day="09";break;
10:day="10";break;
11:day="11";break;
12:day="12";break;
13:day="13";break;
14:day="14";break;
15:day="15";break;
16:day="16";break;
17:day="17";break;
18:day="18";break;
19:day="19";break;
20:day="20";break;
21:day="21";break;
23:day="23";break;
24:day="24";break;
25:day="25";break;
26:day="26";break;
27:day="27";break;
28:day="28";break;
29:day="29";break;
30:day="30";break;
31:day="30";break;

//year
String year1=year.getText();
String date=year1+month+day;
String phoneno=tf14.getText();
String yearlyrent = jLabel30.getText();
if (yearlyrent.equals(""))
{
JOptionPane.showMessageDialog(this,"PLEASE CALCULATE THE RENT");
}
Else
{yearlyrent = jLabel30.getText();
String query="update boys_hostel_b set room_member ='"+name1+"',
room_status='"+status+"', date_OCCUPIED='"+date+"',
yearly_rent='"+yearlyrent+"', phone_no='"+phoneno+"' where
room_no='"+room_no+"';";
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(this,"THE DATABASE WAS UPDATED SUCCESSFULLY");
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog (this, e.getMessage()+" the password may be wrong");
this.dispose();
}

//New Allotment > CLEAR


tf9.setText("");
tf10.setText("");
cb2.setSelectedIndex(0);
year.setText("");
dateentry_day.setSelectedIndex(0);
dateentry_month.setSelectedIndex(0);
tf14.setText("");
jLabel30.setText("");
jcb1.setSelected(false);
jcb2.setSelected(false);
jcb3.setSelected(false);
jcb4.setSelected(false);
jcb5.setSelected(false);
jcb6.setSelected(false);

//New Allotment > TOTAL


int total = 27000+3550;
if (jcb1.isSelected())total=total+1600;
if (jcb2.isSelected())total=total+3200;
if (jcb3.isSelected())total=total+2260;
if (jcb4.isSelected())total=total+3300;
if (jcb5.isSelected())total=total+14500;
if (jcb6.isSelected())total=total+1200;
jLabel30.setText(""+total);
//New Allotment > FILTER
T3CLR();
DefaultTableModel model = (DefaultTableModel)
jTable3.getModel();
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
String member = tf11.getText();
String member2="";
String member3;
if(member2.equalsIgnoreCase(member))
member3 = "ROOM_STATUS = 'OCCUPIED'";
else
member3 = "room_member='"+member+"'";
String phone = tf15.getText();
String phone2="";
String phone3;
if(phone2.equalsIgnoreCase(phone))
phone3 = "";
else

phone3 = "and phone_no='"+phone+"'";


String query="SELECT * FROM Boys_hostel_b where "+member3+""+phone3+";";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String ROOM_MEMBER = rs.getString("ROOM_MEMBER");
String PHONE_NO = rs.getString("PHONE_NO");
model.addRow (new Object[] {ROOM_MEMBER,PHONE_NO});
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog (this, e.getMessage()+" the password may be wrong");
this.dispose();
}

//New Allotment > REFRESH


T3CLR();
DefaultTableModel model = (DefaultTableModel)
jTable3.getModel();
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
String status ;
String query="SELECT * FROM Boys_hostel_b where room_status = 'occupied';";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String NAME = rs.getString("ROOM_MEMBER");
String PHONE_NO = rs.getString("PHONE_NO");
model.addRow (new Object[] {NAME,PHONE_NO });
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog (this, e.getMessage()+" the password may be wrong");
this.dispose();
}
//New Allotment > CLEAR
T3CLR();
tf11.setText("");
tf15.setText("");

GIRLS HOSTEL_A
// Initialisation code
package com.lavishindistries.diagonalpixel;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
public class boyshostel_a extends javax.swing.JFrame {
public boyshostel_a()
{initComponents();}
int xmouse;
int ymouse;
void TCLR(){
DefaultTableModel model = (DefaultTableModel)
jTable1.getModel(); int rows=model.getRowCount();
if (rows>0)
{
for (int i=0; i<rows; i++)
model.removeRow(0);
}
}
void T2CLR(){
DefaultTableModel model = (DefaultTableModel)
jTable2.getModel(); int rows=model.getRowCount();
if (rows>0)
{
for (int i=0; i<rows; i++)
model.removeRow(0);
}
}
void T3CLR(){
DefaultTableModel model = (DefaultTableModel)
jTable3.getModel(); int rows=model.getRowCount();
if (rows>0)
{
for (int i=0; i<rows; i++)
model.removeRow(0);
}
}

// SuperVISION > FILTER

TCLR();
DefaultTableModel model = (DefaultTableModel)
jTable1.getModel();
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
//gathering the status required
String status = null ;
if(cb1.getSelectedIndex()==1)
status ="ROOM_STATUS in('OCCUPIED')";
else if(cb1.getSelectedIndex()==2)
status ="ROOM_STATUS in ('UNOCCUPIED')";
else if(cb1.getSelectedIndex()==0)
status ="ROOM_STATUS in('OCCUPIED','UNOCCUPIED')";
String query="SELECT * FROM GIRLS_HOSTEL where "+status+";";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String ROOM_NO = rs.getString("ROOM_NO");
String ROOM_STATUS = rs.getString("ROOM_STATUS");
model.addRow (new Object[] {ROOM_NO,ROOM_STATUS });
}

}
catch (Exception e)
{
JOptionPane.showMessageDialog (this,e.getMessage()+" the password may be
wrong");
this.dispose();
}
//SuperVISION> REFRESH
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
String query="SELECT count(*) from boys_hostel where room_member not like'';";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String total_records = rs.getString("count(*)");
jLabel4.setText(total_records+" / 151");
}
String query2="SELECT count(*) from boys_hostel_b where room_member not like'';";
ResultSet rs2 = stmt.executeQuery(query2);
while(rs2.next())
{
String total_records2 = rs2.getString("count(*)");

jLabel21.setText(total_records2+" / 151");
}
String query3="SELECT count(*) from girls_hostel where room_member not like'';";
ResultSet rs3 = stmt.executeQuery(query3);
while(rs3.next())
{
String total_records3 = rs3.getString("count(*)");
jLabel15.setText(total_records3+" / 151");
}
String query4="SELECT count(*) from girls_hostel_b where room_member not like'';";
ResultSet rs4 = stmt.executeQuery(query4);
while(rs4.next())
{
String total_records4 = rs4.getString("count(*)");
jLabel27.setText(total_records4+" / 151");
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog (this, e.getMessage()+" the password may be wrong");
this.dispose();
}
//SuperVISION > UPDATE
TCLR();
DefaultTableModel model = (DefaultTableModel)
jTable1.getModel();
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
String status ;
String query="SELECT * FROM GIRLS_HOSTEL";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String ROOM_NO = rs.getString("ROOM_NO");
String ROOM_STATUS = rs.getString("ROOM_STATUS");
model.addRow (new Object[] {ROOM_NO,ROOM_STATUS });
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog (this, e.getMessage()+" the password may be wrong");
this.dispose();
}

//SuperVISION > CLEAR TABLE

TCLR();

//Major database > CLEAR


tf1.setText("");
tf3.setText("");
tf4.setText("");
tf5.setText("");
tf6.setText("");
tf7.setText("");
cb3.setSelectedIndex(0);
cb3.setSelectedIndex(0);
//Major database > FILTER
T2CLR();
DefaultTableModel model = (DefaultTableModel)
jTable2.getModel();
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
String status = null ;
//code for room status
if(jComboBox2.getSelectedIndex()==0)
status ="in('OCCUPIED','UNOCCUPIED')";
else if(jComboBox2.getSelectedIndex()==1)
status ="in('OCCUPIED')";
else if(jComboBox2.getSelectedIndex()==2)
status ="in('UNOCCUPIED')";
//code for room type
String type = null ;
if(cb3.getSelectedIndex()==0)
type =" in('suite','junior_suite','mini_suite')";
else if(cb3.getSelectedIndex()==1)
type ="='suite'";
else if(cb3.getSelectedIndex()==2)
type ="='mini_suite'";
else if(cb3.getSelectedIndex()==3)
type ="='junior_suite'";
//code for phone no
String phone = tf4.getText();
String phone2="";
String phone3;
if(phone2.equalsIgnoreCase(phone))
phone3 = "(phone_no like'' or phone_no not like'')";
else phone3 = "phone_no='"+phone+"'";
//code for room member
String member = tf1.getText();

String member2="";
String member3;
if(member2.equalsIgnoreCase(member))
member3 = "(room_member like'' or room_member not like'')";
else member3 = "room_member='"+member+"'";
//code for room number
String room = tf3.getText();
String room2="";
String room3;
if(room2.equalsIgnoreCase(room))
room3 = "(room_no like'' or room_no not like'')";
else room3 = "room_no='"+room+"'";
//code for date
String date_month = tf5.getText() ;
String date_day = tf6.getText() ;
String date_year = tf7.getText() ;
String date = date_year+date_month+date_day;
int Dm= date_month.length();
int Dd= date_day.length();
int Dy= date_year.length();
String date3 = null;
//for searching a single element of the date
if(Dm!=0 && Dd==0 && Dy==0 )
date3 = "and month(date_occupied) = "+date_month+"";
else if(Dd!=0 && Dm==0 &&Dy==0)
date3 = "and dayofmonth(date_occupied) = "+date_day+"";
else if(Dy!=0 &&Dd==0 && Dm==0)
date3 = "and year(date_occupied) = "+date_year+"";
// for searching any two element of date
else if(Dm!=0 && Dd!=0 && Dy==0)
date3 = "and month(date_occupied) = "+date_month+" and
dayofmonth(date_occupied)="+date_day+"";
else if(Dm!=0 &&Dy!=0 &&Dd==0)
date3 = "and month(date_occupied) = "+date_month+" and
year(date_occupied)="+date_year+"";
else if(Dd!=0 && Dm!=0 && Dy==0)
date3 = "and dayofmonth(date_occupied)="+date_day+" and
month(date_occupied)="+date_month+"";
else if(Dd!=0 && Dy!=0 && Dm==0)
date3 = "and dayofmonth(date_occupied)="+date_day+" and
year(date_occupied)="+date_year+"";
else if(Dy!=0 && Dd!=0 && Dm==0)
date3 = "and year(date_occupied)="+date_year+" and
dayofmonth(date_occupied)="+date_day+"";
else if(Dy!=0 && Dm!=0 && Dd==0)
date3 = "and year(date_occupied)="+date_year+" and
month(date_occupied)="+date_month+"";
// for searching all elements of date

else if(Dy!=0 && Dm!=0 && Dy!=0)


date3 = "and date(date_occupied) = "+date+"";
else if (Dy==0 && Dm==0 && Dy==0)
date3="";
//the executable query
String query="SELECT * FROM girls_hostel where room_status "+status+" and
"+member3+" and "+phone3+""+date3+" and room_type"+type+" and "+room3+" ;";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String ROOM_NO = rs.getString("ROOM_NO");
String ROOM_TYPE = rs.getString("ROOM_TYPE");
String ROOM_MEMBER = rs.getString("ROOM_MEMBER");
String DATE_OCCUPIED = rs.getString("DATE_OCCUPIED");
String YEARLY_RENT = rs.getString("YEARLY_RENT");
String ROOM_STATUS = rs.getString("ROOM_STATUS");
String PHONE_NO = rs.getString("PHONE_NO");
model.addRow (new Object[]
{ROOM_NO,ROOM_TYPE,ROOM_MEMBER,DATE_OCCUPIED,YEARLY_RENT,
ROOM_STATUS, PHONE_NO});
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog (this, e.getMessage()+" the password may be wrong");
this.dispose();
}
//Major database > VIEW SUMMARY
T2CLR();
DefaultTableModel model = (DefaultTableModel)
jTable2.getModel();
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
String status = null ;
if(cb3.getSelectedIndex()==0)
status ="in('OCCUPIED','UNOCCUPIED')";
else if(cb3.getSelectedIndex()==1)
status ="in('OCCUPIED')";
else if(cb3.getSelectedIndex()==2)
status ="in('UNOCCUPIED')";
String member = tf1.getText();
String query="SELECT * FROM GIRLS_HOSTEL;";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String ROOM_NO = rs.getString("ROOM_NO");
String ROOM_TYPE = rs.getString("ROOM_TYPE");
String ROOM_MEMBER = rs.getString("ROOM_MEMBER");

String
String
String
String

DATE_OCCUPIED = rs.getString("DATE_OCCUPIED");
YEARLY_RENT = rs.getString("YEARLY_RENT");
ROOM_STATUS = rs.getString("ROOM_STATUS");
PHONE_NO = rs.getString("PHONE_NO");

model.addRow (new Object[]


{ROOM_NO,ROOM_TYPE,ROOM_MEMBER,DATE_OCCUPIED,
YEARLY_RENT,ROOM_STATUS,PHONE_NO});

}
}
catch (Exception e)
{
JOptionPane.showMessageDialog (this, e.getMessage()+" the password may be wrong");
this.dispose();
}
//Major database > CLEAR TABLE
T2CLR();
//Major database > EXECUTE
T2CLR();
DefaultTableModel model = (DefaultTableModel)
jTable2.getModel();
String otherqueries = jTextField1.getText();
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
String query=""+otherqueries+"";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String ROOM_NO = rs.getString("ROOM_NO");
String ROOM_TYPE = rs.getString("ROOM_TYPE");
String ROOM_MEMBER = rs.getString("ROOM_MEMBER");
String DATE_OCCUPIED = rs.getString("DATE_OCCUPIED");
String YEARLY_RENT = rs.getString("YEARLY_RENT");
String ROOM_STATUS = rs.getString("ROOM_STATUS");
String PHONE_NO = rs.getString("PHONE_NO");
model.addRow (new Object[]
{ROOM_NO,ROOM_TYPE,ROOM_MEMBER,DATE_OCCUPIED,
YEARLY_RENT,ROOM_STATUS,PHONE_NO});
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog (this, e.getMessage()+" the password may be wrong");
this.dispose();
}

//New Allotment > UPDATE DATABASE

T3CLR();
DefaultTableModel model = (DefaultTableModel)
jTable2.getModel();
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
String room_no=tf9.getText();
String name=tf10.getText();
String name1=name.toUpperCase();
String status="";
if(cb2.getSelectedIndex()==0)
JOptionPane.showMessageDialog(this,"SELECT A ROOM_STATUS");
else if(cb2.getSelectedIndex()==1)
status ="OCCUPIED";
else if(cb2.getSelectedIndex()==2)
status ="UNOCCUPIED";
// for date
//month
String month = null;
int r = dateentry_month.getSelectedIndex();
switch(r)
{
case 0:JOptionPane.showMessageDialog(this,"select a proper month");
case 1:month="01";break;
case 2:month="02";break;
case 3:month="03";break;
case 4:month="04";break;
case 5:month="05";break;
case 6:month="06";break;
case 7:month="07";break;
case 8:month="08";break;
case 9:month="09";break;
case 10:month="10";break;
case 11:month="11";break;
case 12:month="12";break;}
//day
String day = null;
int l = dateentry_month.getSelectedIndex();
switch(l)
{
case 0:JOptionPane.showMessageDialog(this,"select a proper day");
case 1:day="01";break;
case 2:day="02";break;
case 3:day="03";break;
case 4:day="04";break;
case 5:day="05";break;
case 6:day="06";break;
case 7:day="07";break;
case 8:day="08";break;
case 9:day="09";break;

case
case
case
case
case
case
case
case
case
case
case
case
case
case
case
case
case
case
case
case
case
}

10:day="10";break;
11:day="11";break;
12:day="12";break;
13:day="13";break;
14:day="14";break;
15:day="15";break;
16:day="16";break;
17:day="17";break;
18:day="18";break;
19:day="19";break;
20:day="20";break;
21:day="21";break;
23:day="23";break;
24:day="24";break;
25:day="25";break;
26:day="26";break;
27:day="27";break;
28:day="28";break;
29:day="29";break;
30:day="30";break;
31:day="30";break;

//year
String year1=year.getText();
String date=year1+month+day;
String phoneno=tf14.getText();
String yearlyrent = jLabel30.getText();
if (yearlyrent.equals(""))
{
JOptionPane.showMessageDialog(this,"PLEASE CALCULATE THE RENT");
}
Else
{yearlyrent = jLabel30.getText();
String query="update girls_hostel set room_member ='"+name1+"',
room_status='"+status+"', date_OCCUPIED='"+date+"',
yearly_rent='"+yearlyrent+"', phone_no='"+phoneno+"' where
room_no='"+room_no+"';";
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(this,"THE DATABASE WAS UPDATED SUCCESSFULLY");
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog (this, e.getMessage()+" the password may be wrong");
this.dispose();
}

//New Allotment > CLEAR

tf9.setText("");
tf10.setText("");
cb2.setSelectedIndex(0);
year.setText("");
dateentry_day.setSelectedIndex(0);
dateentry_month.setSelectedIndex(0);
tf14.setText("");
jLabel30.setText("");
jcb1.setSelected(false);
jcb2.setSelected(false);
jcb3.setSelected(false);
jcb4.setSelected(false);
jcb5.setSelected(false);
jcb6.setSelected(false);

//New Allotment > TOTAL


int total = 27000+3550;
if (jcb1.isSelected())total=total+1600;
if (jcb2.isSelected())total=total+3200;
if (jcb3.isSelected())total=total+2260;
if (jcb4.isSelected())total=total+3300;
if (jcb5.isSelected())total=total+14500;
if (jcb6.isSelected())total=total+1200;
jLabel30.setText(""+total);
//New Allotment > FILTER
T3CLR();
DefaultTableModel model = (DefaultTableModel)
jTable3.getModel();
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
String member = tf11.getText();
String member2="";
String member3;
if(member2.equalsIgnoreCase(member))
member3 = "ROOM_STATUS = 'OCCUPIED'";
else
member3 = "room_member='"+member+"'";
String phone = tf15.getText();
String phone2="";
String phone3;
if(phone2.equalsIgnoreCase(phone))
phone3 = "";
else
phone3 = "and phone_no='"+phone+"'";

String query="SELECT * FROM Girls_hostel where "+member3+""+phone3+";";


ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String ROOM_MEMBER = rs.getString("ROOM_MEMBER");
String PHONE_NO = rs.getString("PHONE_NO");
model.addRow (new Object[] {ROOM_MEMBER,PHONE_NO});
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog (this, e.getMessage()+" the password may be wrong");
this.dispose();
}

//New Allotment > REFRESH


T3CLR();
DefaultTableModel model = (DefaultTableModel)
jTable3.getModel();
String pass1 =pass.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection con = (Connection)
DriverManager.getConnection
("jdbc:mysql://localhost:3306/pixel","root", ""+pass1+"");
Statement stmt = (Statement) con.createStatement();
String status ;
String query="SELECT * FROM Girls_hostel where room_status = 'occupied';";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
String NAME = rs.getString("ROOM_MEMBER");
String PHONE_NO = rs.getString("PHONE_NO");
model.addRow (new Object[] {NAME,PHONE_NO });
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog (this, e.getMessage()+" the password may be wrong");
this.dispose();
}
//New Allotment > CLEAR
T3CLR();
tf11.setText("");
tf15.setText("");