Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


akash kumar pal
program
3 Answer(s)      4 years ago
Posted in : Java Beginners


any program of hotel or school management


Advertisement
View Answers

November 19, 2010 at 2:50 PM


Hello Friend,

We have created a student Information application.Here is the code:

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;

class StudentInformation{
JFrame f;
JPanel p1,p2,p3,p4;
JTabbedPane tp;
ImageIcon btnimg1,btnimg2;
JLabel l1, l2, l3, l4,l5,l6,l7,l8,l9,l10,l11;
JTextField tf1,tf2,tf3,tf4,tf5,tf6,tf7,tf8,tf9,tf10,tf11;
JScrollPane sp1;
JButton savebtn,resetbtn,editbtn1,editbtn2,viewbtn,delbtn ;
StudentInformation(){
f=new JFrame("Form");
p1=new JPanel(new GridLayout(5,2));
p2=new JPanel(new GridLayout(5,2));
p3=new JPanel(new GridLayout(2,2));
p4=new JPanel(new GridLayout(2,2));
tp=new JTabbedPane();
l1=new JLabel("Student ID:");
l2=new JLabel("First Name:");
l3=new JLabel("Last Name:");
l4=new JLabel("Address:");
l5=new JLabel("Enter Employee ID to view Record:");

l7=new JLabel("Student ID:");
l8=new JLabel("First Name:");
l9=new JLabel("Last Name:");
l10=new JLabel("Address:");
l11=new JLabel("Enter ID:");
tf1=new JTextField(12);
tf2=new JTextField(12);
tf3=new JTextField(12);
tf4=new JTextField(12);
tf5=new JTextField(12);
tf6=new JTextField(12);
tf7=new JTextField(12);
tf8=new JTextField(12);
tf9=new JTextField(12);
tf10=new JTextField(12);
tf11=new JTextField(12);
savebtn=new JButton(" Add "); 
resetbtn=new JButton(" Reset");
editbtn1=new JButton(" Edit ");
editbtn2=new JButton(" Save");
viewbtn=new JButton("view");
delbtn=new JButton("Delete");
p1.add(l1);
p1.add(tf1);
p1.add(l2);
p1.add(tf2);
p1.add(l3);
p1.add(tf3);
p1.add(l4);
p1.add(tf4);
p1.add(savebtn);
p1.add(resetbtn);
p2.add(l7);
p2.add(tf7);
p2.add(l8);
p2.add(tf8);
p2.add(l9);
p2.add(tf9);
p2.add(l10);
p2.add(tf10);
p2.add(editbtn1);
p2.add(editbtn2);
p3.add(l5);
p3.add(tf5);
p3.add(viewbtn);

p4.add(l11);
p4.add(tf11);
p4.add(delbtn);
resetbtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
tf1.setText("");
tf2.setText("");
tf3.setText("");
tf4.setText("");
}

});



November 19, 2010 at 2:51 PM


continue..

savebtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String value1=tf1.getText();
String value2=tf2.getText();
String value3=tf3.getText();
String value4=tf4.getText();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:access");
PreparedStatement st=con.prepareStatement("insert into student(id, FirstName,LastName,Address) values(?,?,?,?)");
st.setString(1,value1);
st.setString(2,value2);
st.setString(3,value3);
st.setString(4,value4);
st.executeUpdate();
JOptionPane.showMessageDialog(p1,"Data is successfully inserted into database.");
con.close();
}
catch(Exception e){
JOptionPane.showMessageDialog(p1,"Error in submitting data!");
}
}
});
viewbtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
JTextField text1,text2,text3,text4;
JLabel label1,label2,label3,label4;
JPanel panel;
text1=new JTextField();
text2=new JTextField();
text3=new JTextField();
text4=new JTextField();
label1=new JLabel("ID");
label2=new JLabel("First Name");
label3=new JLabel("Last Name");
label4=new JLabel("Address");
panel=new JPanel(new GridLayout(4,2));
String value1=tf5.getText();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:access");
PreparedStatement st=con.prepareStatement("Select * from student where id=?");
st.setString(1,value1);
ResultSet rs=st.executeQuery();
while(rs.next()){
text1.setText(Integer.toString(rs.getInt(1)));
text2.setText(rs.getString(2));
text3.setText(rs.getString(3));
text4.setText(rs.getString(4));
}
panel.add(label1);
panel.add(text1);
panel.add(label2);
panel.add(text2);
panel.add(label3);
panel.add(text3);
panel.add(label4);
panel.add(text4);
JFrame frame=new JFrame();
frame.add(panel);
frame.setSize(300,200);
frame.setVisible(true);
con.close();
}
catch(Exception exp3){}
}
});
editbtn1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
String value=tf7.getText();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:access");
PreparedStatement st=con.prepareStatement("select * from student where id=?");
st.setString(1,value);
ResultSet res=st.executeQuery();
res.next();
tf7.setText(Integer.toString(res.getInt(1)));
tf8.setText(res.getString(2));
tf9.setText(res.getString(3));
tf10.setText(res.getString(4));
con.close();
}
catch(Exception e){
JOptionPane.showMessageDialog(p2,"Can not edit data");
}
}
});


November 19, 2010 at 2:52 PM


continue..

editbtn2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
try{
int x=JOptionPane.showConfirmDialog(p2,"Confirm edit? All data will be replaced");
if(x==0){
try{
String value1=tf7.getText();
String value2=tf8.getText();
String value3=tf9.getText();
String value4=tf10.getText();
int id=Integer.parseInt(value1);
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:access");
Statement st=con.createStatement();
st.executeUpdate("update student set FirstName='"+value2+"', LastName='"+value3+"', Address='"+value4+"' where id="+id+"");
JOptionPane.showMessageDialog(p2,"Updated successfully");
con.close();
}
catch(Exception ex){
JOptionPane.showMessageDialog(p2,"Error in updating edit fields");
}
}
}
catch(Exception ex){
JOptionPane.showMessageDialog(p2,"Error");
}
}
});
delbtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){

String value1=tf5.getText();
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:access");
PreparedStatement st=con.prepareStatement("DELETE FROM student WHERE id = ?");
st.setString(1,value1);
st.executeUpdate();
JOptionPane.showMessageDialog(p3,"Record is deleted successfully.");
con.close();
}
catch(Exception exp3)
{
JOptionPane.showMessageDialog(p3,"Error in deleting record.");
}
}
});
}
void dis(){
f.getContentPane().add(tp);
tp.addTab("View Record",p3);
tp.addTab("Add Record",p1);
tp.addTab("Edit Record",p2);
tp.addTab("Delete Record",p4);
f.setSize(450,180);
f.setVisible(true);
f.setResizable(true);
}
public static void main(String z[]){
StudentInformation pro=new StudentInformation();
pro.dis();
}
}

Hope that it will be helpful for you. Thanks



Related Tutorials/Questions & Answers:
program
program  any program of hotel or school management
program
program  write a program different between to dates in terms of days in java
Advertisements
program
program  write a html program in show table and this word in box
program
program  write a javascript program to create a application form with validation
program
program  program of jdbc using ms access for creating table
program
program  WAP a java program to form 1/2+3/4+5/6+7/8 series
program
program  develop a servlet to insert the data in the database from our program in the table stored in the database
program
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
program
program   Write a program to find the difference between sum of the squares and the square of the sums of n numbers
program
program   An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus $.50 per attendee. Develop the program calculateTotalProfit that consumes
program
program  write a java program to input a no. and print wheather the no. is a special no or not. (special no. are those no whose factorial of the sum of digit of the no is same as the original
program
program  Develop the program calculateCylinderArea, which accepts radius of the cylinder's base disk and its height and computes surface area of the cylinder
program
program  explanation of program on extending thread class   Hi Friend, Please go through the following link: Java Threads Thanks
Program
Program  a program to create two classes Commercial and Domestic. Override the method calculatebill() of Commercial class(Rs.8 per unit) into Domestic class(Rs 6 per unit) to compute electricity bill for both classes
Program
Program  a program to prove that default constructor of super class is available to subclass by default. Define a parameterize constructor for super class to store name = ‚??Tommy‚?? age=‚??23‚?? and call this constructor
program
program  how to improve programming skills plss tell some tips..i am understanding concepts but unable to write program so,pls give some guideness plsss
program
program  Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time, and the Pythagorean
program
program  no i want a program that shows how merge sort algorithm works in graphical representations like numbers are taken in circles and computation... in rectangles or circles wat ever it may be. the theme of program is to show algorithm
program
program  i want a progra in java to print a sentence in alphabetic order, taking the input from the user.the program should writen without using the array for example : if input= this is a cat then output sould = a cat
program
program  Write a JSP Program, which displays a web page containing the name of the Courses, Courses being offered currently, number of students enrolled in each course, new courses to be offered, eligibility criteria for taking
program
program  . Develop a program that accepts an initial amount of money (called the principal), a simple annual interest rate, and a number of months will compute the balance at the end of that time. Assume that no additional
program
program  Write a program to print details of a week for a particular day using array of objects Integer and String. OUTPUT: First Day of Week is Monday Second Day of Week is Tuesday Third Day of Week is Wednesday Forth Day
program
program  Write a JSP Program, which displays a web page containing two web links one for your profiling and other for the schedule of theory of practical classes of your Batch. When one click on link for getting your profile
program
program  Utopias tax accountants always use programs that compute income taxes even though the tax rate is a solid, never-changing 15%. Define the program calculateTax which determines the tax on the gross pay. Define
program calculateCylinderVolume
program calculateCylinderVolume  program calculateCylinderVolume
java program for
java program for   java program for printing documents,images and cards
program of c
program of c  write a program in c to display a to z without using printf or scanf statements or header files
string program
string program  write a program to print the pattern p r o program r a m
program in java
program in java  a program to develop a client, server application to satisfy the requests from multiple clients
program in java
program in java  a program to develop a client, server application to satisfy the requests from multiple clients
a Java program
a Java program    Write a Java program to print even numbers from 2 to 1024? Write a Java program to print ? My Name is Mirza? 100 times? Write a Java program to print Fibonacci Series? Write a Java program to reverse a number
 

 

 

DMCA.com