Advertisment

Search related to Life

Search related to Tech

Post Page Advertisement [Top]

Chapter 6: Database Connectivity (XII-IP) project on placing order from BurgerKing Co.Ltd. with code

Complete Project on Database Connectivity,IP Class-12 Ch-6

Image result for database connectivity in java

Code for Login Page


Enter this code for Login button : new WelcomePage().setVisible(true);
Enter this code for new customer button : new  BurgerKingSignUp().setVisible(true);

Code for SignUp Page

Enter this code for SignUp button : 
new WelcomePage().setVisible(true);

Enter this code for already a registered customer button : 
new BurgerKingLogin().setVisible(true);

Code for Welcome Page


Enter this code for new purchase button : new Project1().setVisible(true);
Enter this code for new customer button : new BurgerKingSignUp().setVisible(true);
Enter this code delete past record button : new UserForm().setVisible(true);
Enter this code for rectify entries button : new UserForm().setVisible(true);
Enter this code for exit button : System.exit(0);

Code for BurgerKing Page


Enter this code for Calculate button :
int i,j,k=1,l=0,m,n,o,p;
i=Integer.parseInt(a.getText());


j=Integer.parseInt(d.getText());
if (r1.isSelected())
k=15;
else if (r2.isSelected())
k=30;
else if (r3.isSelected())
k=45;
else if (r4.isSelected())
k=90; 
else
     JOptionPane.showMessageDialog(this,"Please choose a Type");
if (r5.isSelected())
l=10;
else if (r6.isSelected())
l=20;
else if (r7.isSelected())
l=15;
else if (r8.isSelected())
l=5;
else
    l=0;
m=k*j;
n=m+(l*j);
if (ch1.isSelected())
o=n*8/100;
else
    o=0;
p=n-o;
b.setText(n+" ");
c.setText(p+" ");


Create Database in MySQl  before order button in order to save all the transactions.

1. Open MySql> Create database name ; > Enter to continue
2.Type> use name ; > Enter to continue
3.Now create table type> Create table BugerKing (
OrderNo. int (10),
Quantity int (10),
Type int(5),
Topings  int(5), 
Amount int(100),
NetAmount int(100)
);
>Enter to continue
4.now database and table created
5.Type desc BurgerKing; to confirm your table creation.
6. Exit MySQL after confirmation of table creation.

Enter this code at the top of the code window :

import java.sql.*;

import javax.swing.JOptionPane;


Enter this code for Order button :
try {
Class.forName("java.sql.Driver");
Connection con=DriverManager.getConnection("");
Statement stmt=con.createStatement();


int i,j,k=1,l=0,m,n,o,p;
i=Integer.parseInt(a.getText());
j=Integer.parseInt(d.getText());

if (r1.isSelected())
k=15;
else if (r2.isSelected())
k=30;
else if (r3.isSelected())
k=45;
else if (r4.isSelected())
k=90; 
else
     JOptionPane.showMessageDialog(this,"Please choose a Type");
if (r5.isSelected())
l=10;
else if (r6.isSelected())
l=20;
else if (r7.isSelected())
l=15;
else if (r8.isSelected())
l=5;
else
    l=0;
m=j*k;
n=m+(l*j);
if (ch1.isSelected())
o=n*8/100;
else
    o=0;
p=n-o;
b.setText(n+" ");
c.setText(p+" ");
String q="Insert Into BurgerKing Values("+i+","+j+","+k+","+l+","+n+","+p+");";
stmt.executeUpdate(q);
}
catch (Exception e)
{}

Enter this code for back button :
new WelcomePage().setVisible(true);

Enter this code for Clear button :
a.setText("");
b.setText("");
c.setText("");
r1.setSelected(false);
r2.setSelected(false);
r3.setSelected(false);
r4.setSelected(false);
r5.setSelected(false);
r6.setSelected(false);
r7.setSelected(false);
r8.setSelected(false);
ch1.setSelected(false);
buttonGroup1.clearSelection();
buttonGroup2.clearSelection();

Code for User Portal Page



Enter this code for delete button :
 try {
Class.forName("java.sql.Driver");
Connection con=DriverManager.getConnection("");
Statement stmt=con.createStatement();


String q;
q="Delete from BugerKing where (" +t1.getText()+ ");";
stmt.executeUpdate(q);
}
catch (Exception e)
{}

Enter this code for show button :
try {
Class.forName("java.sql.Driver");
Connection con=DriverManager.getConnection("");
Statement stmt=con.createStatement();


String q;
q="Select * from BurgerKing where OrderNo.(" +t1.getText()+ ");";
stmt.executeUpdate(q);
ResultSet rs=stmt.executeQuery(q);
if (rs.next())
{
int i=rs.getInt("Quantity");
int j=rs.getInt("Type");
int k=rs.getInt("Topings");
int l=rs.getInt("Amount");
int m=rs.getInt("NetAmount");
}
else {
    JOptionPane.showMessageDialog(this,"Record not found");
}
}
catch (Exception e)
{}

Enter this code for update button : 
 try {
Class.forName("java.sql.Driver");
Connection con=DriverManager.getConnection("");
Statement stmt=con.createStatement();


String q;
int i,j,k,l,m;
i=Integer.parseInt(t2.getText());
j=Integer.parseInt(t3.getText());
k=Integer.parseInt(t4.getText());
l=Integer.parseInt(t5.getText());
m=Integer.parseInt(t6.getText());
q="Update BurgerKing set("+i+","+k+","+l+","+m+") where OrderNo.(" +t1.getText()+ ");";
stmt.executeUpdate(q);
ResultSet rs=stmt.executeQuery(q);

}
catch (Exception e)
{}

Enter this code for reset button :
t1.setText(" ");
t2.setText(" ");
t3.setText(" ");
t4.setText(" ");
t5.setText(" ");
t6.setText(" ");

Enter this code for exit button :
System.exit(0);

Enter this code for back button : 
new WelcomePage().setVisible(true);

No comments:

Post a Comment

Bottom Ad [Post Page]

| Designed by AnswerPicker