Beruflich Dokumente
Kultur Dokumente
INFORMATIC
S
PRACTICES
Acknowledgement
In the progression of completing this project
successfully, many people have bestowed upon us
their blessings and concrete support. We would like to
thank all the people who have been concerned with
this project.
Primarily, we would like to thank our principal Mr.
A.K. Sinha and our Informatics Practices teacher,
Mrs. Archana and express our earnest gratitude for
their imperative support, supervision and
encouragement without the aid of which this project
would not have come into view.
Additionally, we would like express a heartfelt thanks
to the technical staff for their perpetual support
during the making of this project.
Last but not the least we thank our benevolent friends
and parents for their persistent backing without which
we could not have overcome the impediments in the
assembly of this project.
TO DISPLAY DATE AND TIME ON LOGIN
PAGE:
getRootPane().setDefaultButton(jButton1);
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
{Calendar cal = Calendar.getInstance();
cal.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("hh:mm:ss");
time.setText(sdf.format(cal.getTime()));}
{Date now = new Date();
SimpleDateFormat formatter = new
SimpleDateFormat("dd/MM/yyyy");
date.setText( formatter.format( now ) );}
boolean
b=Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_
CAPS_LOCK);
if(b==true)
jLabel6.setText("CAPS LOCK IS ON");
else
jLabel6.setText("");}
}, 0, 1);
setLocationRelativeTo(null);
public splashscreen() {
initComponents();
setLocationRelativeTo(null);
p1.setValue(0);
final Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
p1.setValue(p1.getValue()+10);
if(p1.getValue()==100)
{timer.cancel();
dispose();
new access().setVisible(true);
} }}, 0, 100);
SNIPPET FOR GIVING ACCESS TO VARIOUS
USERS:
int ac=0;
String eno="";
public access() {
{ int x=0;
initComponents();setLocationRelativeTo(null);
admin.setEnabled(false);
ac=accessclass.accesscode;
eno=accessclass.eno;
System.out.println(eno);
if(ac==0)
{ JOptionPane.showMessageDialog(null,"SORRY...."+"\n
RIGHT NOW YOU DO NOT HAVE ANY ACCESS");
cm.setEnabled(false);
bill.setEnabled(false);
}
if (ac==1)
admin.setEnabled(true);
if (ac==2)
{}
if (ac==3)
{
cm.setEnabled(false);
}
if(ac==4)
{cm.setEnabled(false);
}
try{
Class.forName("java.sql.Driver");
Connection
con=(Connection)DriverManager.getConnection("jdbc:mysql://l
ocalhost/cnm","root","tiger");
Statement smt=con.createStatement();
String Query="select note from employee where
empid='"+eno+"';";
ResultSet rs=smt.executeQuery(Query);rs.next();
jTextArea1.setText(rs.getString(1));
con.close();
smt.close();
rs.close();
}
catch(Exception e){}}
catch(Exception e){}}
KEYEVENTS FOR PASSWORD FIELD:
try{
Class.forName("java.sql.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost/cnm","root","
tiger");
Statement smt=(Statement)con.createStatement();
String query="Select * from employee where ename like
'%"+name+"%' ;";
ResultSet rs=smt.executeQuery(query);
while(rs.next()){
tm.addRow(new Object[]
{rs.getString(1),rs.getString(2),rs.getLong(3),rs.getString(4),rs.get
String(5),rs.getLong(6),rs.getString(7),rs.getString(8),rs.getString(
9)});
;}}
catch (ClassNotFoundException ex) {
Logger.getLogger(empl.class.getName()).log(Level.SEVERE, null,
ex);
}catch (SQLException ex) {
JOptionPane.showMessageDialog(null,"error in
connectivity");
try{
Class.forName("java.sql.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost/cnm","roo
t","tiger");
Statement smt=(Statement)con.createStatement();
String query="Select * from employee ;";
System.out.println(1);
ResultSet rs=smt.executeQuery(query);
System.out.println(2);
while(rs.next()){
System.out.println(3);
tm.addRow(new Object[]
{rs.getString(1),rs.getString(2),rs.getLong(3),rs.getString(4),rs.
getString(5),rs.getInt(6),rs.getString(7),rs.getString(8),rs.getStri
ng(9),rs.getString(11)});
System.out.println(4);}
System.out.println(5);}
Logger.getLogger(empl.class.getName()).log(Level.SEVERE,
null, ex);
}catch (SQLException ex) {
JOptionPane.showMessageDialog(null,"error in
connectivity"); }
CODING ON UPDATE BUTTON:
try{
Class.forName("java.sql.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost/cnm","roo
t","tiger");
Statement smt=(Statement)con.createStatement();
int a=t1.getRowCount();
int ans=JOptionPane.showConfirmDialog(null,"are you sure you
want to update records");
if(ans==JOptionPane.YES_OPTION){
for(int b=0;b<a;b++)
{
String nam = (String) t1.getValueAt(b, 0);
String id =(String) t1.getValueAt(b, 1);
Object contactno = t1.getValueAt(b, 2);
String job1 =(String) t1.getValueAt(b, 3);
String cl=(String) t1.getValueAt(b, 4);
Object sal =t1.getValueAt(b, 5);
String user =(String) t1.getValueAt(b, 6);
String pwd =(String) t1.getValueAt(b, 7);
String gender=(String) t1.getValueAt(b, 8);
String query="update employee set
ename='"+nam+"',contactno="+contactno+",job='"+job1+"',
class='"+cl+"',payroll="+sal+",euid='"+user+"',epassword='"
+pwd+"',gender='"+gender+"' where empid='"+id+"';";
System.out.println(1);
smt.executeUpdate(query);
System.out.println(2);
}
JOptionPane.showMessageDialog(null, "VOILA RECORDS
UPDATED!!!!");}
System.out.println(5);
smt.close();
con.close();}
catch (ClassNotFoundException ex) {
Logger.getLogger(empl.class.getName()).log(Level.SEVERE,
null, ex);
}catch (SQLException ex) {
JOptionPane.showMessageDialog(null,"error in
connectivity"); }
tm.addRow(new Object[]
{rs.getString(1),rs.getString(2),rs.getLong(3),rs.getString(4),rs.
getString(5),rs.getLong(6),rs.getString(7),rs.getString(8),rs.getS
tring(9)});
System.out.println(4);}
System.out.println(5);}
catch (Exception e) {
}
CODING ON CREATE BUTTON:
String pwd =new String(pwd1.getPassword());
String pwdr =new String(pwd2.getPassword());
String chk =l1.getText();
if(ename.getText().equals("")|| eid.getText().equals("")||
contact_no.getText().equals("")|| job.getText().equals("")||
payroll.getText().equals("")|| userid.getText().equals("")||
pwd.equals("")||pwdr.equals("")||
classq.getSelectedItem().equals(" "))
{JOptionPane.showMessageDialog(null, "please fill all
fields");}
String Gender=(String) gen.getSelectedItem();
String nam =ename.getText();
String id =eid.getText();
long contactno =Long.parseLong(contact_no.getText());
String job1 =job.getText();
String cl=(String) classq.getSelectedItem();
int sal =Integer.parseInt(payroll.getText());
String user =userid.getText();
if(chk.equals("passwords match")) {
try {
Class.forName("java.sql.Driver");
Connection con=
(Connection)DriverManager.getConnection("jdbc:mysql://localh
ost/cnm","root","tiger");
Statement smt=(Statement)con.createStatement();
String query="insert into employee
values('"+nam+"','"+id+"',"+contactno+",'"+job1+"','"+cl+"',"
+sal+",'"+user+"','"+pwd+"','"+Gender+"','',curdate());";
smt.execute(query);
JOptionPane.showMessageDialog(null,"voila new
employee registered");
dispose();
} catch (Exception e) {
JOptionPane.showMessageDialog(null,e);
JOptionPane.showMessageDialog(null,"CONTACT IT
SUPPORT IMMEDIATELY");
}
}
evt.consume(); }
int a=contact_no.getText().length();
if(a<10)
cil.setText("please ensure contact no. is of 10 digits");
else
cil.setText("");
System.out.println(billdet.customername+billdet.customerno);
new billing().setVisible(true);
dispose();
CODING ON CREATE AND PROCEED
BUTTON:
try {
String name = n1.getText();
String conno = n2.getText();
String email = n3.getText();
Connection con =
DriverManager.getConnection("jdbc:mysql://localhost/cnim",
"root", "tiger");
Statement smt = con.createStatement();
smt.executeUpdate("insert into cmtmgmt values('" +
name + "','" + email + "'," + conno + ");");
con.close();
smt.close();
billdet.customername=name;
billdet.customerno=conno;
dispose();
new billing().setVisible(true);
} catch (Exception ex) {System.out.print(ex);}
char c=evt.getKeyChar();
if(!(Character.isDigit(c)||c==KeyEvent.VK_SPACE)||
n2.getText().length()==10){
evt.consume(); }
int a=n2.getText().length();
if(a<10)
cil.setText("please ensure contact no. is of 10 digits");
else
cil.setText("");
CODING ON KEYRELEASED EVENT FOR
NAME TEXTFIELD:
String a=t1.getText();
String b=t2.getText();
DefaultTableModel tm1=(DefaultTableModel)
jTable1.getModel();
while(tm1.getRowCount()>0)
tm1.removeRow(0);
try{
Class.forName("java.sql.Driver");
Connection
conn1=DriverManager.getConnection("jdbc:mysql://localhost/pr
oducts","root","tiger");
Connection
conn2=DriverManager.getConnection("jdbc:mysql://localhost/pr
oducts","root","tiger");
Statement smt1=conn1.createStatement();
Statement smt2=conn2.createStatement();
String query1="show tables ;",query2="";
ResultSet rs1=smt1.executeQuery(query1);
while(rs1.next()){
query2="select*from "+rs1.getString(1)+" where item
like'"+a+"%';";
ResultSet rs2=smt2.executeQuery(query2);
while(rs2.next())
tm1.addRow(new Object[] {rs2.getString(2),rs2.getString(1)});
}
}
catch(Exception e){System.out.print(e);}
try{
Connection
conn1=DriverManager.getConnection("jdbc:mysql://localhost/pr
oducts","root","tiger");
Connection
conn2=DriverManager.getConnection("jdbc:mysql://localhost/pr
oducts","root","tiger");
Statement smt1=conn1.createStatement();
Statement smt2=conn2.createStatement();
String query1="show tables ;",query2="";
ResultSet rs1=smt1.executeQuery(query1);
while(rs1.next()){
query2="select * from "+rs1.getString(1)+" where
ino='"+r+"';";
ResultSet rs2=smt2.executeQuery(query2);
while(rs2.next())
{total1=total1+sss1*rs2.getInt(3);
tm1.addRow(new Object[]
{rs2.getString(2),sss1,rs2.getInt(3),sss1*rs2.getInt(3)});
}}total.setText(""+total1);}
catch(Exception e){System.out.print(e);}
int x=tm1.getRowCount();String
c=billdet.customername;String d=billdet.customerno;
try{
Class.forName("java.sql.Driver");
Connection
con=(Connection)DriverManager.getConnection("jdbc:mysql://l
ocalhost/cnim","root","tiger");
Connection
con1=(Connection)DriverManager.getConnection("jdbc:mysql://
localhost/cnim","root","tiger");
Statement smt=con.createStatement();
Statement smt1=con1.createStatement();
billdet.totalamt=total1;
dispose();
new billpreview().setVisible(true);
}catch(Exception e){
System.out.println(e); }
create table
discussionforum
(discussed varchar(50),
name varchar(25),
empid varchar(10),
date date);
create
database
cnim;
use cnim;
create table
cmtmgmt
(cname
varchar(10),
emailid varchar(30),
cno int(10),
unique(cname,cno));
DATABASE : PRODUCTS
create database products;
use products
TABLE : INDEPENDENT
create table independent
(ino varchar(10) primary key,
item varchar(70) not null,
sellprice int(10),
instock long,
lastsold date);
insert into independent values('i1',"taco 4
piece",50,5000,'2016-01-01');
insert into independent values('i2',"taco 2
piece",30,5000,'2016-01-01');
insert into independent values('i3',"Waffle
Cone",10,5000,'2016-01-01');
insert into independent values('i4',"Waffle Cup",10,5000,'2016-
01-01');
insert into independent values('i5',"Smokey
Biscuit",10,5000,'2016-01-01');
insert into indeoendent values('i6',"Pop corn
icecream",50,5000,'2016-01-01');
insert into independent values('i7',"Cheeseling
icecream",50,5000,'2016-01-01');
insert into independent values('i8',"Foggy Hand
Wash",5,5000,'2016-01-01');
insert into independent values('i9',"Self Expanding
Balloon",10,5000,'2016-01-01');
TABLE : PANICECREAM
TABLE : DRYFRUITROLLS
TABLE : REALFRUITICECREAM
create table Realfruiticecream
(ino varchar(10) primary key,
item varchar(70) not null,
sellprice int(10),
instock long,
lastsold date);
insert into Realfruiticecream
values('rfi1',"Banana",70,5000,'2016-01-01');
insert into Realfruiticecream
values('rfi2',"Apple",80,5000,'2016-01-01');
insert into Realfruiticecream
values('rfi3',"Orange",80,5000,'2016-01-01');
insert into Realfruiticecream
values('rfi4',"Strawberry",80,5000,'2016-01-01');
insert into Realfruiticecream
values('rfi5',"Kiwi",100,5000,'2016-01-01');
insert into Realfruiticecream
values('rfi6',"Mango",100,5000,'2016-01-01');
TABLE : BALLICECREAM
create table ballicecream
(ino varchar(10) primary key,
item varchar(70) not null,
sellprice int(10),
instock long,
lastsold date);
insert into ballicecream values('bice1',"Banana",60,5000,'2016-
01-01');
insert into ballicecream values('bice2',"Cotton
candy",60,5000,'2016-01-01');
insert into ballicecream values('bice3',"Orange",60,5000,'2016-
01-01');
insert into ballicecream
values('bice4',"Strawberry",60,5000,'2016-01-01');
insert into ballicecream
values('bice5',"Raspberry",60,5000,'2016-01-01');
insert into ballicecream values('bice6',"Mango",60,5000,'2016-
01-01');
insert into ballicecream values('bice7',"Black
currant",60,5000,'2016-01-01');
insert into ballicecream
values('bice8',"Chocolate",60,5000,'2016-01-01');
insert into ballicecream
values('bice9',"Vanilla+Oreo",60,5000,'2016-01-01');
insert into ballicecream
values('bice10',"Blueberry",60,5000,'2016-01-01');
TABLE : LIQNITROICECREAM
TABLE : WAFFLE
TABLE : BEVERAGES
BIBLIOGRAPHY:
1.Sumita Arora Cbse Class XI
2. Sumita Arora Cbse Class XII
3.stackoverflow.com