Sei sulla pagina 1di 61

ON

Submitted To: MAHARISHI MARKANDESHWAR ENGINEERING COLLEGE, MULLANA (Academic session: 2006-2010) Submitted By: VINAYAK Roll_no: 1106124 Branch: CSE-A

Semester: 5th

Certificate Acknowledgements Preface Objective About JAVA Introduction Features Packages Frames Project Selection Operational Requirements

About the Project Source Code Future Scope of Project Conclusions Bibliography

Words often fail to express ones inner feelings of gratitude to his benefactors and mentors. I express my deep sense of gratitude to the Faculty of Engineering and Technology, for giving me an opportunity to do my project for the partial fulfillment of the requirements for the degree of B.TECH. in MMEC,MULLANA. I am highly thankful to Miss RUBY of NIIT Delhi(cp) for providing me opportunities and facilities to carry out this project work and for his valuable guidance that helped me in completing the project. Finally our thanks are due to all those who helped us in completing our project successfully.

vinayak(1106124)

Like any human language, Java provides a way to express concepts. If successful, this medium of expression will be significantly easier and more flexible than the alternatives as problems grow larger and more complex. You cant just look at java as a collection of features; some of the features make no sense in isolation. You can only use the sum of the parts if you are thinking about design, not simply coding. And to understand Java in this

way you must understand the problems with Java and with programming in general.I have tried to understand these problems very deeply and after that made this project named ST. I have done my best to complete this project. Java is important for another reason: it has altered the course of computer language development. Knowledge of Java opens the door to the latest innovations in programming. So we can say that java is one of the worlds most important computer languages.

This project will ensure that the learner uses the programming concepts and features of Java in a real-life application. The idea of the project is to make a person aware about that how we register the student in an institute or employee in company with no file record maintanence with easy user interface.

Todays life is completely computerized and file work has become obsolete.So for fast processing data is stored in computer now a days. It is user friendly and just asks the user to follow the operations by giving him little option. It is fast & register the forms of student.

HISTORY Java was conceived by James Gosling, Patric Naughton, Chris Warth, and MikSheridan at Sun Microsystems, in 1991. It took 18

months to develop 1st working version. This language firstly called OAK but renamed as JAVA in 1995. From 1995 it is being used by people. OAK is not used by the people. From 1991 to 1995 Java is people. not used by

Java is related to C++, which is direct dependent to C. Much of the character of JAVA is taken from these two languages. From C, Java drives its syntax. Many of Javas object oriented features were influenced by C++. Java is mainly used for internet. It is object oriented programming language. It includes the feature of both C and C++. Java does not use pointer but its compiler use pointer. In Java we use both compiler and interpreter. For Java, we use JDK i.e. Java Development Kit. All things related to Java present in it. In Java we use a word Bin. Java compiler put in it. Java compiler is called JAVAC.

A Java program is saved with the main class name. In a Java program when we add any new class it is compulsory to create their object. If we do not save our program with main class name that can not be interpreted but must be compile. Java is a case sensitive language.

Rules to assign class & method Class:


1.

One word class (First Letter is capital only) 2. Multiword class (First Letter of each word is capital ) Example: class Hello class HelloSir Method

1.

One word method (all Letters are small )

2. Multiword method (First Letter of each word is capital except 1st Example: setActionCommand word)

1.It is object oriented Programming language. 2.It does not use pointer. 3.It is multithreaded programming language (To perform two or more programs or to perform two or more parts of different program in same program). 4.It is a platform independent language (It runs its same program on every System). 5.It provides exception handling.

6.It provides APPLET (programs that run in any Java enabled browser) 7. Java is simple, familiar, and small. 8. Java is dynamic and extensible. 9. Java supports packages. 10. Java does not support the concept of Multiple Inheritance. Multiple Inheritance in Java is implemented through Interfaces. 11. Java is secure, platform neutral language. 12. Java is freeform language. Data Types In Java we use many type of data type as in C & C++.
1.

Integer

Byte: 8bits Short: 16bits Int: 32bits Long: 64bits

2.Float

3.

Double: 64bits Float: 32bits

Character : 16bits

Width of data types is very widely than data types in C & C++. We use all the operators which are use in C & C++, like Arithmetic Operators, Modulus Operator, Increment & decrement Operators, Relational, Bitwise operators, etc. Java does not support hybrid Inheritance. Inheritance is a property in which reusability of existing class is done to a new class. If in any Java program, we want to change a string type object in int, char or float we use Intenger.parseInt or Float.parseFloat and so on. JDK is java development toolkit. JDK is a package in which Java is a package in which AWT is a package in which EVENT is a package. AWT is Abstract Window Toolkit. You need to

have JDK installed on your system in order to run any Java program. JAVA Programs In Java, one can do programming in two domains: application domain and Internet programming. Application Domain involves the formation of programs pertaining to some applications, while Internet programming involves the use of applets for some useful work.

Java 2 Platform Packages Provides the classes necessary to create an applet and the classes an applet uses to communicate with its applet context. Contains all of the classes for creating user interfaces and for painting graphics and images. Provides classes for color spaces.

java.applet

java.awt

java.awt.color

Provides interfaces and classes java.awt.even for dealing with different types t of events fired by AWT components. java.io Provides for system input and output through data streams, serialization and the file system. Provides the classes for implementing networking applications. Provides a set of "lightweight" (all-Java language) components that, to the maximum degree possible,

java.net javax.swing

work the same on all platforms.

We have two types of Frames constructor: Frame() Frame(String title) First one is used to create a slandered window that does not contain title. Second one is used to create a window with a specific title. There are several the methods that will use The set working with frame window. These are:
1.

Setting

windows

dimensions: used for

setSize( ) method is dimensions of window.

void setSize(int newWidth, int newHeight) void setSize(Dimension newSize) The new size of the window is specified by newWidth & newHeight. The dimensions are specified in term of pixels. 2.The getSize( ) method is used to obtain the current size of window. Example: Dimension getSize( ) After a frame window has been created, it will not visible until we call setVisible(). void setVisible(boolean visibleFlag) The component is visible if argument to this method is true otherwise it is hidden. 3.Setting a window title: We can set the title of a frame window using setTitle( ). void setTitle (String newTitle)

Here newTitle is the new title for window. Closing a Frame window: When using a frame window our program must remove that window from screen when it is closed , by calling setVisible(false)

4.

Software selection is a critical aspect of system development. Although, reliable software is a desirable goal, limited progress has been made towards improving it in the last decades. Software is classified to controlling computer operations and application software for solving user-oriented problems. In general,

software allows concurrence of operations, resource and , modularity and multiplexed operations. In the world of HI-TECH, where everything is moving around Information Technology, this whole world has become a global village. We would certainly not like to be left behind in this competitive world. So keeping this in view, we during this course, and as a part of our curriculum, attempted to develop such an application software. To select an ought project from the environment is not an easy task. As rightly

said - "Good start is a half way to success". So we decided to engage the project - "Student Registration". Encouraged by the fast processing in this competitive world, we are prompted to take up this project. We started working on this project. After discussing every feature of this project

with our guide, we are quite confident to work on this project. The project management is the application of planning, organizing, and control concepts to critical one-of-a-kind projects. The fundamental objective of a project work is to demonstrate how tedious manual work can easily be done by using the computer capabilities.

In order to run this application software of OLJE developed under Java, your computer should meet the following Hardware & Software requirements: Hardware Requirements RAM of 128 MB or above. Hard disk of min. 500 MB. Keyboard. Monitor.

Software Requirements Operating System: Windows 2000 or XP. Editor of Java: Text pad or Notepad. Java packages.

JDK 1.5

The idea of the project is to simply to do the registration of student & employee in institute & company. It can work on any O.S. & on any machine. It is simple to understand and be used by any one who is not familiar with any computer language or even computers. It is user friendly. It stores & search information in database at brisk rate. It can be used in any business firms or institute.

import import import import import

java.awt.*; java.awt.event.*; javax.swing.*; javax.swing.JOptionPane.*; java.sql.*;

public class project implements ActionListener { JFrame f; JPanel pan; TextField usname,pas; JButton login; JLabel l1,l2,inf; public project() { f=new JFrame("login page");

f.setDefaultCloseOperation(JFrame.EXIT_ON_CL OSE); f.setSize(800,800); pan=new JPanel(); f.add(pan); pan.setBackground(Color.yellow); usname=new TextField("",12); pas=new TextField("",12); pas.setEchoChar('*'); l1=new JLabel("Username"); l2=new JLabel("Password"); inf=new JLabel("login information"); login=new JButton("Submit"); pan.setLayout(null); inf.setBounds(300,150,200,30); l1.setBounds(250,200,100,30); usname.setBounds(400,200,150,30); l2.setBounds(250,250,100,30); pas.setBounds(400,250,150,30); login.setBounds(350,300,100,30); pan.add(inf); pan.add(l1); pan.add(usname); pan.add(l2); pan.add(pas); pan.add(login); f.setVisible(true); login.addActionListener(this);

} public void actionPerformed(ActionEvent ae) { String str=ae.getActionCommand(); String name=usname.getText(); String word=pas.getText(); if(str.equals("Submit")&& name.equals("vinayak")&& word.equals("garg")) { f.setVisible(false); option o1=new option(); } else { JOptionPane.showMessageDialog(null,"Please check your username & password","Login error",JOptionPane.PLAIN_MESSAGE); } } public static void main(String arg[]) { project p1=new project(); //p1.lJFrame(); //p1.SetDefaultCloseOperation(f.EXIT_O N_CLOSE); } }

class option implements ActionListener { JFrame f1; JPanel pan1; JButton add,updte,delt,back,srh; JLabel l3,l4,l5,lbl,search; Font fo,fo1; public option() { f1=new JFrame("choice page"); f1.setSize(800,800); pan1=new JPanel(); f1.add(pan1); pan1.setBackground(Color.yellow); pan1.setLayout(null); lbl=new JLabel("click on choice"); l3=new JLabel("To Add Student Information" ); l4=new JLabel("To Update Student Information"); l5=new JLabel("To Delete Student Information"); search=new JLabel("To Search Student Information"); add=new JButton("Add"); updte=new JButton("Update"); delt=new JButton("Delete"); back=new JButton("Logout"); srh=new JButton("Search"); lbl.setBounds(250,150,400,30); l3.setBounds(150,250,300,30);

l4.setBounds(150,300,300,30); l5.setBounds(150,350,300,30); search.setBounds(150,400,300,30); add.setBounds(450,250,100,30); updte.setBounds(450,300,100,30); delt.setBounds(450,350,100,30); srh.setBounds(450,400,100,30); back.setBounds(300,500,100,30); fo=new Font("Comic Sans",Font.BOLD| Font.ITALIC,30); fo1=new Font("Comic Sans",Font.BOLD|Font.ITALIC,15); l3.setFont(fo1); l4.setFont(fo1); l5.setFont(fo1); search.setFont(fo1); loption(); } public void loption() { lbl.setFont(fo); pan1.add(lbl); pan1.add(l3); pan1.add(add); pan1.add(l4); pan1.add(updte); pan1.add(l5); pan1.add(delt); pan1.add(search); pan1.add(srh); pan1.add(back);

} public void actionPerformed(ActionEvent ae) { String str=ae.getActionCommand(); if(str.equals("Logout")) { f1.setVisible(false); project p2=new project(); } if(str.equals("Add")) { f1.setVisible(false); information1 obj=new information1(); } if(str.equals("Update")) { f1.setVisible(false); ucbox obj=new ucbox(); } if(str.equals("Search")) {

f1.setVisible(true); back.addActionListener(this); add.addActionListener(this); updte.addActionListener(this); delt.addActionListener(this); srh.addActionListener(this);

f1.setVisible(false); scbox obj=new scbox(); } if(str.equals("Delete")) { f1.setVisible(false); dcbox obj=new dcbox(); } }

} class information1 implements ActionListener { static int Comp=1106101; static int It=1106201; static int Ece=1106301; static int Mech=1106401; static int Instru=1106501; static int Elect=1106601; static int Civil=1106701; JFrame f2; JPanel pan2; TextField fname,lname,pno,eid; JTextArea addr; JButton str,rest,bck; JLabel stu,fn,ln,ad,ph,ed; JLabel slct,dob; JComboBox brch,dt,mnth,yr;

String brnch[]={"IT","computer","Electrical","Mechani cal","civil"}; String date[]={"1","2","3","4","5","6","7","8","9","10", "11","12","13","14","15","16","17","18","19","2 0","21","22","23","24","25","26","27","28","29", "30","31"}; String month[]={"jan","feb","march","Arpil","May","Ju ne","July","August","September","october","nov ember","December"}; String year[]={"1980","1981","1982","1983","1984"," 1985","1986","1987","1988","1989","1990","19 91","1992","1993","1994","1995","1996","1997 ","1998","1999","2000"}; Font fo,fo1; public information1() { f2=new JFrame("Student Information"); f2.setDefaultCloseOperation(JFrame.EXIT_ON_C LOSE); f2.setSize(800,800); pan2=new JPanel(); pan2.setLayout(null); f2.add(pan2); pan2.setBackground(Color.yellow);

fname=new TextField("",12); lname=new TextField("",12); pno=new TextField("",12); eid=new TextField("",30); addr=new JTextArea(30,90); stu=new JLabel("Enter the Student Information"); fn=new JLabel("First name"); ln=new JLabel("Last name"); ad=new JLabel("Address"); ph=new JLabel("Phone no"); ed=new JLabel("Email_id"); str=new JButton("ADD"); rest=new JButton("Reset"); bck=new JButton("Back"); slct=new JLabel("Select Branch"); dob=new JLabel("D.O.B"); brch=new JComboBox(brnch); dt=new JComboBox(date); mnth=new JComboBox(month); slct=new JLabel("Select Branch"); dob=new JLabel("D.O.B"); brch=new JComboBox(brnch); dt=new JComboBox(date); mnth=new JComboBox(month); yr=new JComboBox(year);

fo=new Font("Comic Sans",Font.BOLD|Font.ITALIC,30); fo1=new Font("Comic Sans",Font.BOLD|Font.ITALIC,15); stu.setFont(fo); fn.setFont(fo1); ln.setFont(fo1); ad.setFont(fo1); ph.setFont(fo1); ed.setFont(fo1); linf(); } public void linf() { stu.setBounds(150,50,500,50); fn.setBounds(100,200,150,30); ln.setBounds(100,250,150,30); dob.setBounds(100,300,150,30); slct.setBounds(100,350,150,30); ad.setBounds(100,400,150,30); ph.setBounds(100,530,150,30); ed.setBounds(100,580,150,30); fname.setBounds(300,200,150,30) ; lname.setBounds(300,250,150,30) ; dt.setBounds(300,300,70,30); mnth.setBounds(400,300,100,30); yr.setBounds(530,300,100,30); brch.setBounds(300,350,200,30); addr.setBounds(300,400,200,80);

pno.setBounds(300,530,150,30); eid.setBounds(300,580,150,30); str.setBounds(100,630,150,30); rest.setBounds(300,630,150,30); bck.setBounds(500,630,150,30); pan2.add(stu); pan2.add(fn); pan2.add(fname); pan2.add(ln); pan2.add(lname); pan2.add(ad); pan2.add(addr); pan2.add(ph); pan2.add(pno); pan2.add(ed); pan2.add(eid); pan2.add(slct); pan2.add(brch); pan2.add(dob); pan2.add(dt); pan2.add(mnth); pan2.add(yr); pan2.add(str); pan2.add(rest); pan2.add(bck); bck.addActionListener(this); str.addActionListener(this); rest.addActionListener(this); f2.setVisible(true); } public void actionPerformed(ActionEvent ae1)

{ String str1=ae1.getActionCommand(); if(str1.equals("Back")) { f2.setVisible(false); option o2=new option(); } if(str1.equals("Reset")) { fname.setText(""); lname.setText(""); pno.setText(""); eid.setText(""); addr.setText(""); } if(str1.equals("ADD")) { String fstname=fname.getText(); String lstname=lname.getText(); String phno=pno.getText(); String eml=eid.getText(); String trd=(String)brch.getSelectedItem(); String date=(String)dt.getSelectedItem(); String month=(String)mnth.getSelectedItem(); String year=(String)yr.getSelectedItem(); String adrs=addr.getText();

if(fstname.equals("")|| lstname.equals("")||phno.equals("")|| adrs.equals("")) { JOptionPane.showMessageDialog(null,"Enter complete information ","Error",JOptionPane.PLAIN_MESSAGE); } else { try { Class.forName("sun.jdbc.odbc.JdbcOdbc Driver"); String myDB = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\Study\\raman\\java project\\student registration project\\DB"; Connection con=DriverManager.getConnection(myDB,"","") ; Statement st=con.createStatement(ResultSet.TYPE_SCRO LL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); ResultSet res=st.executeQuery("select * from "+trd); if(res.next()) {

res.last(); int c=res.getInt("rollno"); if(c==0) { } else { if(trd.equals("computer")) Comp=c+1; if(trd.equals("civil")) Civil=c+1; if(trd.equals("Electrical")) Elect=c+1; if(trd.equals("IT")) It=c+1; if(trd.equals("Mechanical")) Mech=c+1; } } PreparedStatement ps=con.prepareStatement("insert into "+trd+" (rollno,firstname,lastname,dob,address,email,p honeno) values(?,?,?,?,?,?,?)"); if(trd.equals("computer")) ps.setInt(1,Comp); if(trd.equals("civil")) ps.setInt(1,Civil); if(trd.equals("Electrical"))

ps.setInt(1,Elect); if(trd.equals("IT")) ps.setInt(1,It); if(trd.equals("Mechanical")) ps.setInt(1,Mech); ps.setString(2,fstname); ps.setString(3,lstname); ps.setString(4,date+month+year); ps.setString(5,adrs); ps.setString(6,eml); ps.setString(7,phno); ps.executeUpdate(); PreparedStatement ps1=con.prepareStatement("select rollno from "+trd+" where phoneno=?"); ps1.setString(1,phno); ResultSet rs1=ps1.executeQuery(); if(rs1.next()) { JOptionPane.showMessageDialog(null,"Roll of student is "+rs1.getInt("rollno")+"\n Resistration Successfull","Roll_no",JOptionPane.PLAIN_MESS AGE); } fname.setText(""); lname.setText(""); pno.setText("");

eid.setText(""); addr.setText(""); con.close(); Comp++; It++; Mech++; Instru++; Civil++; Ece++; Elect++; } catch(Exception e) { } } } } System.out.println(e);

class ucbox implements ActionListener{ JFrame f4; JPanel pan4; JLabel slct,roll; JTextField rno; JComboBox brch; JButton go,back; String brnch[]={"IT","computer","Electrical","Mechani cal","civil"}; public ucbox() { f4=new JFrame("select"); f4.setSize(800,800); pan4=new JPanel(); f4.add(pan4); pan4.setBackground(Color.yellow); pan4.setLayout(null); slct=new JLabel("Select Branch"); roll=new JLabel("Enter roll_no"); brch=new JComboBox(brnch); go=new JButton("Next"); back=new JButton("Back"); rno=new JTextField("",12); slct.setBounds(200,150,150,30); brch.setBounds(400,150,150,30); roll.setBounds(200,200,150,30); rno.setBounds(400,200,150,30); go.setBounds(300,280,150,30); back.setBounds(300,360,150,30);

pan4.add(slct); pan4.add(brch); pan4.add(go); pan4.add(back); pan4.add(roll); pan4.add(rno); f4.setVisible(true); go.addActionListener(this); back.addActionListener(this); } public void actionPerformed(ActionEvent ae) { String str=ae.getActionCommand(); if(str.equals("Back")) { f4.setVisible(false); option o1=new option(); } if(str.equals("Next")) { f4.setVisible(false); updt u1=new updt((String)brch.getSelectedItem(), (String)rno.getText()); //JOptionPane.showMessageDialog(nul l,"Data cant be Updated","Update",JOptionPane.PLAIN_MESSAG E); } } }

class dcbox implements ActionListener{ JFrame f4; JPanel pan4; JLabel slct,roll; JTextField rno; JComboBox brch; JButton go,back; String brnch[]={"IT","computer","Electrical","Mechani cal","civil"}; public dcbox() { f4=new JFrame("select"); f4.setSize(800,800); pan4=new JPanel(); f4.add(pan4); pan4.setBackground(Color.yellow); pan4.setLayout(null); slct=new JLabel("Select Branch"); roll=new JLabel("Enter roll_no"); brch=new JComboBox(brnch); go=new JButton("Delete"); back=new JButton("Back"); rno=new JTextField("",12); slct.setBounds(200,150,150,30);

brch.setBounds(400,150,150,30); roll.setBounds(200,200,150,30); rno.setBounds(400,200,150,30); go.setBounds(300,280,150,30); back.setBounds(300,360,150,30); pan4.add(slct); pan4.add(brch); pan4.add(go); pan4.add(back); pan4.add(roll); pan4.add(rno); f4.setVisible(true); go.addActionListener(this); back.addActionListener(this); } public void actionPerformed(ActionEvent ae) { int x; x=0; String str=ae.getActionCommand(); if(str.equals("Back")) { f4.setVisible(false); option o1=new option(); } if(str.equals("Delete")) { String rno1=rno.getText(); String trd=(String)brch.getSelectedItem(); try

{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ; String myDB = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\Study\\raman\\java project\\student registration project\\DB"; Connection con=DriverManager.getConnection(myDB,"","") ; PreparedStatement ps1=con.prepareStatement("delete * from "+trd+" where rollno=?"); ps1.setString(1,rno1); int i=ps1.executeUpdate(); if(i!=0) {

JOptionPane.showMessageDialog(null,"Informat ion Deleted","Delete",JOptionPane.PLAIN_MESSAGE ); } else {

JOptionPane.showMessageDialog(null,"Deletion Faliure","Delete",JOptionPane.PLAIN_MESSAGE) ; }

con.close(); } catch(Exception e) { JOptionPane.showMessageDialog(null,"Deletion Faliure","Delete",JOptionPane.PLAIN_MESSAGE) ; System.out.println(e); } } } } class scbox implements ActionListener{ JFrame f4; JPanel pan4; JLabel slct,roll; JTextField rno; JComboBox brch; JButton go,back;

String brnch[]={"IT","computer","Electrical","Mechani cal","civil"}; public scbox() { f4=new JFrame("select"); f4.setSize(800,800); pan4=new JPanel(); f4.add(pan4); pan4.setBackground(Color.yellow); pan4.setLayout(null); slct=new JLabel("Select Branch"); roll=new JLabel("Enter roll_no"); brch=new JComboBox(brnch); go=new JButton("Search"); back=new JButton("Back"); rno=new JTextField("",12); slct.setBounds(200,150,150,30); brch.setBounds(400,150,150,30); roll.setBounds(200,200,150,30); rno.setBounds(400,200,150,30); go.setBounds(300,280,150,30); back.setBounds(300,360,150,30); pan4.add(slct); pan4.add(brch); pan4.add(go); pan4.add(back); pan4.add(roll); pan4.add(rno); f4.setVisible(true); go.addActionListener(this);

back.addActionListener(this); } public void actionPerformed(ActionEvent ae) { String str=ae.getActionCommand(); if(str.equals("Back")) { f4.setVisible(false); option o1=new option(); } if(str.equals("Search")) { String rno1=rno.getText(); String trd=(String)brch.getSelectedItem(); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ; String myDB = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\Study\\raman\\java project\\student registration project\\DB"; Connection con=DriverManager.getConnection(myDB,"","") ;

PreparedStatement ps1=con.prepareStatement("select * from "+trd+" where rollno=?"); ps1.setString(1,rno1); ResultSet rs1=ps1.executeQuery(); if(rs1.next()) { JOptionPane.showMessageDialog(null,"First name of student is "+rs1.getString("firstname") +"\nLast name of student is "+rs1.getString("lastname")+"\nDate of Birth of student is :"+rs1.getString("dob") +"\nAddress of student is: "+rs1.getString("address")+"\nEmail ID of student is :"+rs1.getString("email")+"\nPhone no of student is "+rs1.getString("phoneno"),"Search",JOptionPa ne.PLAIN_MESSAGE); } else { JOptionPane.showMessageDialog(null,"Unregist ered Entry","Search",JOptionPane.PLAIN_MESSAGE); } con.close();

} catch(Exception e) { System.out.println(e); } } } }

class updt implements ActionListener { String branch; int rollnumber; JFrame f2; JPanel pan2; TextField fname,lname,pno,eid; JTextArea addr; JButton str,rest,bck; JLabel stu,fn,ln,ad,ph,ed; JLabel dob; JComboBox dt,mnth,yr; String date[]={"1","2","3","4","5","6","7","8","9","10", "11","12","13","14","15","16","17","18","19","2

0","21","22","23","24","25","26","27","28","29", "30","31"}; String month[]={"jan","feb","march","Arpil","May","Ju ne","July","August","September","october","nov ember","December"}; String year[]={"1980","1981","1982","1983","1984"," 1985","1986","1987","1988","1989","1990","19 91","1992","1993","1994","1995","1996","1997 ","1998","1999","2000"}; Font fo,fo1; public updt(String brch,String rnumber) { rollnumber=Integer.parseInt(rnumber); branch=brch; f2=new JFrame("New Information"); f2.setDefaultCloseOperation(JFrame.EXIT_ON_C LOSE); f2.setSize(800,800); pan2=new JPanel(); pan2.setLayout(null); f2.add(pan2); pan2.setBackground(Color.yellow); fname=new TextField("",12); lname=new TextField("",12); pno=new TextField("",12); eid=new TextField("",30); addr=new JTextArea(30,90);

stu=new JLabel("Enter the New Information"); fn=new JLabel("First name"); ln=new JLabel("Last name"); ad=new JLabel("Address"); ph=new JLabel("Phone no"); ed=new JLabel("Email_id"); str=new JButton("Update"); rest=new JButton("Reset"); bck=new JButton("Back"); dob=new JLabel("D.O.B"); dt=new JComboBox(date); mnth=new JComboBox(month); dob=new JLabel("D.O.B"); dt=new JComboBox(date); mnth=new JComboBox(month); yr=new JComboBox(year); fo=new Font("Comic Sans",Font.BOLD|Font.ITALIC,30); fo1=new Font("Comic Sans",Font.BOLD|Font.ITALIC,15); stu.setFont(fo); fn.setFont(fo1); ln.setFont(fo1); ad.setFont(fo1); ph.setFont(fo1); ed.setFont(fo1); linf(); }

); );

public void linf() { stu.setBounds(150,50,500,50); fn.setBounds(100,200,150,30); ln.setBounds(100,250,150,30); dob.setBounds(100,300,150,30); ad.setBounds(100,400,150,30); ph.setBounds(100,530,150,30); ed.setBounds(100,580,150,30); fname.setBounds(300,200,150,30 lname.setBounds(300,250,150,30 dt.setBounds(300,300,70,30); mnth.setBounds(400,300,100,30); yr.setBounds(530,300,100,30); addr.setBounds(300,400,200,80); pno.setBounds(300,530,150,30); eid.setBounds(300,580,150,30); str.setBounds(100,630,150,30); rest.setBounds(300,630,150,30); bck.setBounds(500,630,150,30); pan2.add(stu); pan2.add(fn); pan2.add(fname); pan2.add(ln); pan2.add(lname); pan2.add(ad); pan2.add(addr); pan2.add(ph); pan2.add(pno);

pan2.add(ed); pan2.add(eid); pan2.add(dob); pan2.add(dt); pan2.add(mnth); pan2.add(yr); pan2.add(str); pan2.add(rest); pan2.add(bck); bck.addActionListener(this); str.addActionListener(this); rest.addActionListener(this); f2.setVisible(true); } public void actionPerformed(ActionEvent ae1) { String str1=ae1.getActionCommand(); if(str1.equals("Back")) { f2.setVisible(false); ucbox o2=new ucbox(); } if(str1.equals("Reset")) { fname.setText(""); lname.setText(""); pno.setText(""); eid.setText(""); addr.setText("");

} if(str1.equals("Update")) { String fstname=fname.getText(); String lstname=lname.getText(); String phno=pno.getText(); String eml=eid.getText(); String date=(String)dt.getSelectedItem(); String month=(String)mnth.getSelectedItem(); String year=(String)yr.getSelectedItem(); String adrs=addr.getText(); if(fstname.equals("")|| lstname.equals("")||phno.equals("")|| adrs.equals("")) { JOptionPane.showMessageDialog(null,"Enter complete information ","Error",JOptionPane.PLAIN_MESSAGE); } else { try { Class.forName("sun.jdbc.odbc.JdbcOdb cDriver");

String myDB = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\Study\\raman\\java project\\student registration project\\DB"; Connection con=DriverManager.getConnection(myDB,"","") ; PreparedStatement ps=con.prepareStatement("update "+branch+" set firstname=? where rollno=?"); ps.setString(1,fstname); ps.setInt(2,rollnumber); int p=ps.executeUpdate(); ps=con.prepareStatement("update "+branch+" set lastname=? where rollno=?"); ps.setString(1,lstname); ps.setInt(2,rollnumber); p=ps.executeUpdate(); ps=con.prepareStatement("update "+branch+" set dob=? where rollno=?"); ps.setString(1,date+month+year); ps.setInt(2,rollnumber); p=ps.executeUpdate(); ps=con.prepareStatement("update "+branch+" set address=? where rollno=?"); ps.setString(1,adrs); ps.setInt(2,rollnumber);

p=ps.executeUpdate(); ps=con.prepareStatement("update "+branch+" set email=? where rollno=?"); ps.setString(1,eml); ps.setInt(2,rollnumber); p=ps.executeUpdate(); ps=con.prepareStatement("update "+branch+" set phoneno=? where rollno=?"); ps.setString(1,phno); ps.setInt(2,rollnumber); p=ps.executeUpdate(); if(p!=0) { JOptionPane.showMessageDialog(null,"Informat ionn Updated ","Updation",JOptionPane.PLAIN_MESSAGE); } else { JOptionPane.showMessageDialog(null,"Input Type ERROR\nEnter Roll_no Again & Continue....","Informattion Error",JOptionPane.PLAIN_MESSAGE); }

fname.setText(""); lname.setText(""); pno.setText(""); eid.setText(""); addr.setText(""); con.close(); } catch(Exception e) { System.out.println(e); } } } }}

As you all know that we are going to be an engineer and we will have to face many selection procedures conducted by good companies. So its better to get prepared for that kind of atmosphere with great speed and accuracy which is demanded by all. With the help of this project we can easily get familiar with the student registration with no file maintenence . In future we can improve it in many ways. We can have the options: To check the ones information.

To add more information To delete ones record To update database .

Computers have become an essential part of organizational information processing because of the power of the technology and the volume of data to be processed. The application of computers to information processing began in 1954 when one of the first computers was programmed to process. There are a few major advantages of the employment of the computer system. First of all, it is fast and does the job more efficiently with no error. Secondly, it saves lot of time that would in course of manual system, have gone in getting the reports made and their verifications. A computer system also eliminates a major amount of paper work with virtually memory to store records and files in. The retrieval process is also quicker and to the point it is more efficient too. Despite the best of efforts, every software is bound to contain errors. This project was developed as Registration" for the

companies or ones own use. Although we prepared this system with all care and knowledge that we possessed, yet we cant claim for being complete and fully efficient. No system is claimed to be perfect. In every system one can suggest for and make improvement. In fact, it is an unending process.

The Complete Reference: Java 2, Fourth Edition By: Herbert Schildt

Programming with Java- a primer by E. Balagurusamy, 2/e. The Java Handbook by Naughton, Patrick, Osborne McGraw-Hill, 1996. Guide to Java Programming by Norton, Peter and William Stanek, Sams.net. 1996.

Java Programming Explorer by Bartlett, Leslie and Simkin, Coriolis Group Books, 1996.

Potrebbero piacerti anche