Informatics Practices Project Class 12
Informatics Practices Project Class 12
Prepared by:
Board Roll No.:
- 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!
____________ 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,
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.
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.
STRUCTURES OF TABLES
STRUCTURE OF TABLE USER
+----------+-------------+------+-----+---------+-------+
| Field
| Type
+----------+-------------+------+-----+---------+-------+
| USERNAME | varchar(20) | YES |
| NULL
| NULL
+----------+-------------+------+-----+---------+-------+
| Type
+---------------+-------------+------+-----+---------+-------+
| ROOM_NO
| varchar(20) | YES |
| NULL
| ROOM_TYPE
| varchar(20) | YES |
| NULL
| DATE_OCCUPIED | date
| YES |
| NULL
| varchar(20) | YES |
| NULL
| NULL
|
|
| NULL
| NULL
+---------------+-------------+------+-----+---------+-------+
| Type
+---------------+-------------+------+-----+---------+-------+
| ROOM_NO
| varchar(20) | YES |
| NULL
| ROOM_TYPE
| varchar(20) | YES |
| NULL
| NULL
| YES |
| NULL
| varchar(20) | YES |
| DATE_OCCUPIED | date
| NULL
|
|
| NULL
| NULL
+---------------+-------------+------+-----+---------+-------+
| Type
+---------------+-------------+------+-----+---------+-------+
| ROOM_NO
| varchar(20) | YES |
| NULL
| ROOM_TYPE
| varchar(20) | YES |
| NULL
| varchar(20) | YES |
| DATE_OCCUPIED | date
| YES |
| NULL
| NULL
| NULL
|
|
| NULL
| NULL
+---------------+-------------+------+-----+---------+-------+
| Type
+---------------+-------------+------+-----+---------+-------+
| ROOM_NO
| varchar(20) | YES |
| NULL
| ROOM_TYPE
| varchar(20) | YES |
| NULL
| 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
+--------------+----------+
+---------+--------------+---------------+-------------+-------------+------------+---------------+
| 101
| SUITE
| OCCUPIED
| 2012-05-05
| 102
| SUITE
| OCCUPIED
| 2011-05-05
| 103
| SUITE
| SHAKSHAM
| 104
| SUITE
| UNOCCUPIED |
| NULL
| 105
| SUITE
| UNOCCUPIED |
| NULL
| 106
| SUITE
| UNOCCUPIED |
| NULL
| 56610
| OCCUPIED
| 2012-02-02
+---------+--------------+---------------+-------------+-------------+------------+---------------+
+---------+--------------+-------------+-------------+-------------+----------+---------------+
| 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
+---------+--------------+-------------+-------------+-------------+----------+---------------+
| 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
+---------+------------+-------------+-------------+-------------+----------+---------------+
+---------+--------------+--------------+-------------+-------------+------------+---------------+
| 101
| SUITE
| 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
| 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"));
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);
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);
}
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);
ta1.append("CREATING USERS"+"\n");
stmt14.execute(query14);
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+"");
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");
}
break;
case 4:Code4.setIcon(filled);code4=buttonclicked;
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();
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);
}
}
}
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 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();
}
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");
}
}
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();
}
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();
}
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);
}
}
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();
}
TCLR();
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
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");
}
}
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();
}
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();
}
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);