1、PROJECT IONStudentInformationManagementSystemDeveloped by Group Name: Water Star Reg.No:R3P3000005Sylvia Reg.No:R3P3000045June Reg.No:R3P3000050NIITStudent Management System SoftwareBatch Code: Start Date: 08/03/2013Name of the Coordinator:Shahnawaz Ahmad KhanName of the Developer: Ms.WaterEnglish N
2、ame: WaterName (Chinese 2)stat=con.prepareStatement(“insert into useinfo values(?,?,?,?)“);3) ResultSet rs = stmt.executeQuery(“SELECT * FROM useinfo“);4) stat=con.prepareStatement(“delete from studentinfor where sid=?“);Interface Design for Student_Information Manager_As the development of the comp
3、uter, more and more management depend on the computer.For this reason,we group Water design a student information management for the student information management system.It is convenient for the manager to overview ,add, update,delete student information.ConfigurationHardware: Intel (R) Pentium(R)
4、Dual E2180 2.1G Hz1.20G Hz 3.00GB RAM250GB 7200 RPM Hard Disk10/100NICOptical MouseKeyboard17“Color MonitorOperating System: Microsoft Windows 07Software: Netbeans IDE 7.2.1、Microsoft SQL Server 2008SrNo Activity DescriptionPlanned date of CompletionActual Date Remarks1 Create Database 09/03/2013 09
5、/03/2013 No Problem2 Interface Design 09/03/2013 09/03/2013 No Problem3 Interface Implementation11/03/2013 11/03/2013 No problem4 Function Implementation13/03/2013 11/03/2013 No problem5 Debugging 13/03/2013 13/03/2013 Many Problems had been solved67891011Individual Project Schedule/login GUI and th
6、e main function/StudentMain.javapackage studentinformationmanagementsystem;import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;import javax.swing.UIManager;public class StudentMain extends JFrame implements ActionListenerJLabel Ltitle,Lname,Lpassword;JButton Blogin,Bexit
7、,Lregister;JTextField TFname;JPasswordField TFpassword;GridBagLayout gbl;GridBagConstraints gbc;GridLayout gl;Font f1,f2,f3;JPanel p1,p2;Connection con;PreparedStatement stat;Statement stmt;ResultSet rs;public String name;public StudentMain(boolean flag)/boolean f=fsuper(“StudentInformationManagemen
8、tSystem“);this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);f1=new Font(“宋体“,1,25);f2=new Font(“宋体“,1,20);f3=new Font(“宋体“,1,18);Ltitle=new JLabel(“Student Information Management System“,JLabel.CENTER);Ltitle.setVerticalAlignment(JLabel.CENTER);Ltitle.setForeground(Color.red);Lname=new JL
9、abel(“UserName“,JLabel.CENTER);Lpassword=new JLabel(“UserPassword“,JLabel.CENTER);Lregister=new JButton(“Register“);Ltitle.setFont(f1);Lname.setFont(f2);Source CodeLpassword.setFont(f2);Lregister.setFont(f2);TFname=new JTextField(15);/TFname.setBounds(0,0,150,40);TFname.setFont(f2);TFpassword=new JP
10、asswordField(15);TFpassword.setFont(f2);TFpassword.setEchoChar(*);Blogin=new JButton(“Login“);Blogin.setFont(f2);Bexit=new JButton(“Exit“);Bexit.setFont(f2);p1=new JPanel();p2=new JPanel();gbl=new GridBagLayout();gbc=new GridBagConstraints();gl=new GridLayout(3,1);p1.setLayout(gbl);gbc.fill=GridBagC
11、onstraints.NONE;gbc.insets=new Insets(0,0,11,10);gbc.anchor=GridBagConstraints.CENTER;gbc.gridwidth=1;gbl.setConstraints(Lname, gbc);p1.add(Lname);gbc.gridwidth = GridBagConstraints.REMAINDER;gbc.anchor=GridBagConstraints.LINE_START;gbl.setConstraints(TFname, gbc);p1.add(TFname);gbc.gridwidth=1;gbc.
12、anchor=GridBagConstraints.CENTER;gbl.setConstraints(Lpassword, gbc);p1.add(Lpassword);gbc.gridwidth = GridBagConstraints.REMAINDER;gbc.anchor=GridBagConstraints.CENTER;gbl.setConstraints(TFpassword, gbc);p1.add(TFpassword);p2.setLayout(new FlowLayout(FlowLayout.CENTER,20,0);p2.add(Blogin);p2.add(Bex
13、it);p2.add(Lregister);this.setLayout(gl);this.add(Ltitle);this.add(p1);this.add(p2);Blogin.addActionListener(this);Bexit.addActionListener(this);Lregister.addActionListener(this);Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();setBounds(screenSize.width-365)/2, (screenSize.height-
14、449)/2, 550, 350);this.setVisible(flag);public void actionPerformed(ActionEvent ae)if(ae.getActionCommand()=“Exit“)System.exit(0);if(ae.getActionCommand()=“Login“)name=TFname.getText();String password=TFpassword.getText();if(name.equals(“)|password.equals(“)JOptionPane.showMessageDialog(null,“UserNa
15、me,UserPassword is not null“);elsetryClass.forName(“sun.jdbc.odbc.JdbcOdbcDriver“);con=DriverManager.getConnection(“jdbc:odbc:DataSource“,“,“);Statement stmt=con.createStatement();ResultSet rs = stmt.executeQuery(“SELECT * FROM useinfo“);boolean isfind=false;while(rs.next()if(name.equals(rs.getStrin
16、g(2)isfind=true;if(password.equals( rs.getString(3)this.dispose();new Function(name);TFname.setText(“);TFpassword.setText(“);elseJOptionPane.showMessageDialog(null,“Password is worng!“);break;if( isfind=false)JOptionPane.showMessageDialog(null,“Not Exsit the User,Please Register!“);con.close();catch
17、(Exception e)System.out.println(“Error “+e.getMessage();if(ae.getActionCommand()=“Register“)new AddUser(); public static void main(String args) / TODO code application logic heretryUIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel();catch(Exception e) new StudentMain(tr
18、ue);/Function GUI/Function.javapackage studentinformationmanagementsystem;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.sql.*;import javax.swing.table.*;import java.util.*;public class Function extends JFrame implements ActionListenerJMenu funmenu1,funmenu2,funmenu3;JMen
19、uItem menuitempwd,menulogout,menuexit,menuoverview;JPanel funpl1,funpl2,funpl3,funpl4,funpl5,funpl6;JLabel funlb1,funlb2;JButton funjbadd,funjbdelete,funjbupdate,funjboverview,funjbok,funjbcancel;JMenuBar funmenubar;JComboBox funjcb1;JTextField funjtf1,funjtf2;Font funf1;JScrollPane jsp;JTable funjt
20、b;JScrollPane funjsp;Connection con;Statement stmt;PreparedStatement stat;ResultSet rs;ResultSetMetaData rsmd;public String ss;Function(String str)super(“StudentManagementSystem“);this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);ss=str;setLayout(null);funjsp=new JScrollPane();funf1=new F
21、ont(“Arial“,Font.BOLD|Font.ITALIC,20);funjcb1=new JComboBox();funjcb1.addItem(“select by ID“);funjcb1.addItem(“select by name“);funjcb1.addActionListener(this);funpl2=new JPanel();funpl2.setLayout(new FlowLayout(FlowLayout.CENTER,0,3);funpl3=new JPanel();funpl3.setLayout(new FlowLayout(FlowLayout.LE
22、FT,20,3);funpl4=new JPanel();funpl4.setLayout(new FlowLayout(FlowLayout.CENTER,20,3);funpl5=new JPanel();funpl5.setLayout(new GridLayout(4,1);funpl6=new JPanel();funpl6.setLayout(new FlowLayout();funmenubar=new JMenuBar();funmenubar.setBounds(0,0,490,30);funlb1=new JLabel(“Welcome To The System! “,J
23、Label.CENTER);funlb1.setFont(funf1);Object tablesize=new Object208;for(int i=0;i20;i+)for(int j=0;j8;j+)tablesizeij=null;String column=“sid“,“sname“,“sgender“,“sbirth“,“smobil“,“semil“,“sacademy“,“smajor“;funjtb=new JTable(tablesize,column);funjtb.setShowGrid(true);funjtf1=new JTextField(25);funjtf1
24、.addActionListener(this);funjbadd=new JButton(“Add“);funjbadd.addActionListener(this);funjbdelete=new JButton(“Delete“);funjbdelete.addActionListener(this);funjboverview=new JButton(“Overview“);funjboverview.addActionListener(this);funjbupdate=new JButton(“Update“);funjbupdate.addActionListener(this
25、);funjbok=new JButton(“OK“);funjbok.addActionListener(this);funjbcancel=new JButton(“Cancel“);funjbcancel.addActionListener(this);funmenu1=new JMenu(“user management“);funmenu2=new JMenu(“ overview“);funmenu3=new JMenu(“ help“);menuoverview=new JMenuItem(“check my infomation“,JMenuItem.CENTER);menuo
26、verview.addActionListener(this);menuitempwd=new JMenuItem(“password management“,JMenuItem.CENTER);menuitempwd.addActionListener(this);funmenu1.add(menuoverview);funmenu1.add(menuitempwd);menulogout=new JMenuItem(“Log Out“,JMenuItem.CENTER);menulogout.addActionListener(this);funmenu1.add(menulogout);
27、menuexit=new JMenuItem(“Exit“,JMenuItem.CENTER);menuexit.addActionListener(this);funmenu1.add(menuexit);funmenubar.add(funmenu1);funmenubar.add(funmenu2);funmenubar.add(funmenu3);funpl2.add(funlb1);funpl3.add(funjcb1);funpl3.add(funjtf1);funpl3.add(funjbok);funpl3.add(funjbcancel);funpl4.add(funjbov
28、erview);funpl4.add(funjbadd);funpl4.add(funjbdelete);funpl4.add(funjbupdate);funpl5.add(funpl2);funpl5.add(funpl3);funpl5.add(funpl4);funpl5.setBounds(0,50,475,120);funpl6.add(new JScrollPane(funjtb);funpl6.setBounds(10,165,455,500);add(funmenubar);add(funpl5);add(funpl6);this.setVisible(true);Dimen
29、sion screenSize = Toolkit.getDefaultToolkit().getScreenSize();setBounds(screenSize.width-450)/2, (screenSize.height-550)/2,490,580);public void actionPerformed(ActionEvent ae)/update passwordString s=ae.getActionCommand();TableModel mdl=funjtb.getModel();if(ae.getSource().equals(menuitempwd)tryUpdat
30、ePassword up=new UpdatePassword();up.TFuname.setText(ss);catch(Exception e)System.out.println(“Error: “+e);else if(ae.getSource().equals(funjboverview)tryClass.forName(“sun.jdbc.odbc.JdbcOdbcDriver“);con=DriverManager.getConnection(“jdbc:odbc:DataSource“);stmt=con.createStatement();rs=stmt.executeQu
31、ery(“select * from studentinfor“);String rows=“,“,“,“,“,“,“,“;while(rs.next()for(int i=0;i8;i+)rowsi=rs.getString(i+1);mdl.setValueAt(rowsi, rs.getRow()-1, i);con.close();funjtb.repaint();catch(Exception e)System.out.println(“Error:“+e);else if(ae.getSource().equals(menuoverview)trycon=DriverManager
32、.getConnection(“jdbc:odbc:DataSource“);stmt=con.createStatement();rs=stmt.executeQuery(“select uid,uname,urealname,umobil from useinfo where uname=“+ss+“);rs.next();String id=Integer.toString(rs.getInt(1);String name=rs.getString(2);String realname=rs.getString(3);String mobil=rs.getString(4);UserIn
33、formation ui=new UserInformation(true);ui.TFuid.setText(id);ui.TFuname.setText(name);ui.TFurealname.setText(realname);ui.TFumobil.setText(mobil);con.close();catch(Exception e)System.out.println(“Error: “+e);else if(ae.getSource().equals(menulogout)this.dispose();new StudentMain(true);else if(ae.getS
34、ource().equals(menuexit)System.exit(1);else if(ae.getSource() = funjbok)if(funjtf1.getText().equals(“)JOptionPane.showMessageDialog(null, “Please Input The StudentID or StudentName“);else if (funjcb1.getSelectedItem().equals(“select by ID“)int sid=Integer.parseInt(funjtf1.getText();trycon=DriverMana
35、ger.getConnection(“jdbc:odbc:DataSource“);stmt=con.createStatement();rs=stmt.executeQuery(“select * from studentinfor where sid=“+sid);String rows=“,“,“,“,“,“,“,“;if(rs.next()int id=rs.getInt(1);String ID=Integer.toString(id);String name=rs.getString(2);String gender=rs.getString(3);String birth=rs.
36、getString(4);String mobil=rs.getString(5);String email=rs.getString(6);String academy=rs.getString(7);String major=rs.getString(8);StudentInformation si=new StudentInformation();si.TFid.setText(ID);si.TFname.setText(name);si.TFsex.setText(gender);si.TFbirthday.setText(birth);si.TFmobil.setText(mobil
37、);si.TFemail.setText(email);si.TFacademy.setText(academy);si.TFmajor.setText(major);elseJOptionPane.showMessageDialog(null, “Check The ID Again!“);con.close();catch(Exception e)System.out.println(“Error:“+e);else if (funjcb1.getSelectedItem().equals(“select by name“)trycon=DriverManager.getConnectio
38、n(“jdbc:odbc:DataSource“);stmt=con.createStatement();rs=stmt.executeQuery(“select * from studentinfor where sname=“+funjtf1.getText()+“);String rows=“,“,“,“,“,“,“,“;rsmd=rs.getMetaData();if(rs.next()int id=rs.getInt(1);String ID=Integer.toString(id);String name=rs.getString(2);String gender=rs.getSt
39、ring(3);String birth=rs.getString(4);String mobil=rs.getString(5);String email=rs.getString(6);String academy=rs.getString(7);String major=rs.getString(8);StudentInformation si=new StudentInformation();si.TFid.setText(ID);si.TFname.setText(name);si.TFsex.setText(gender);si.TFbirthday.setText(birth);
40、si.TFmobil.setText(mobil);si.TFemail.setText(email);si.TFacademy.setText(academy);si.TFmajor.setText(major);elseJOptionPane.showMessageDialog(null, “Check The Name Again!“);con.close();funjtb.repaint();funjtb.updateUI();catch(Exception e)System.out.println(“Error:“+e); else if (ae.getSource().equals
41、(funjbcancel)funjtf1.setText(null);else if(ae.getActionCommand()=“Add“)new AddInformation();else if(ae.getActionCommand()=“Delete“)tryif(funjcb1.getSelectedItem().equals(“select by ID“)if(funjtf1.getText().equals(“)JOptionPane.showMessageDialog(null,“Please Input StudentID!“);elsecon=DriverManager.g
42、etConnection(“jdbc:odbc:DataSource“);stmt=con.createStatement();rs=stmt.executeQuery(“select * from studentinfor where sid=“+Integer.parseInt(funjtf1.getText();if(rs.next()con.close();con=DriverManager.getConnection(“jdbc:odbc:DataSource“);stat=con.prepareStatement(“delete from studentinfor where si
43、d=?“);String s1=funjtf1.getText();int n=Integer.parseInt(s1);stat.setInt(1, n);stat.executeUpdate();JOptionPane.showMessageDialog(null,“Student has been Deleted!“);con.close();elseJOptionPane.showMessageDialog(null,“The Stufdent not Exist!“);else if(funjcb1.getSelectedItem().equals(“select by name“)
44、if(funjtf1.getText().equals(“)JOptionPane.showMessageDialog(null,“Please Input StudentName!“);elsecon=DriverManager.getConnection(“jdbc:odbc:DataSource“);stmt=con.createStatement();rs=stmt.executeQuery(“select * from studentinfor where sname=“+funjtf1.getText()+“);if(rs.next()con.close();con=DriverM
45、anager.getConnection(“jdbc:odbc:DataSource“);stat=con.prepareStatement(“delete from studentinfor where sname=?“);String s1=funjtf1.getText();stat.setString(1, s1);stat.executeUpdate();JOptionPane.showMessageDialog(null,“Student has been Deleted!“);con.close();elseJOptionPane.showMessageDialog(null,“
46、The Stufdent not Exist!“); catch(Exception e)System.out.println(“Error: “+e);else if(ae.getSource().equals(funjbupdate)tryif(funjcb1.getSelectedItem().equals(“select by ID“)if(funjtf1.getText().equals(“)JOptionPane.showMessageDialog(null,“Please Input StudentID!“);elsecon=DriverManager.getConnection
47、(“jdbc:odbc:DataSource“);stmt=con.createStatement();rs=stmt.executeQuery(“select * from studentinfor where sid=“+Integer.parseInt(funjtf1.getText();if(rs.next()String sss=funjtf1.getText();int sd=Integer.parseInt(sss);UpdateInformation ui=new UpdateInformation();con=DriverManager.getConnection(“jdbc
48、:odbc:DataSource“);stmt=con.createStatement();rs=stmt.executeQuery(“select * from studentinfor where sid=“+sd);rs.next();String sr=rs.getString(1);String sr1=rs.getString(2);ui.TFid.setText(sr);ui.TFname.setText(sr1);con.close();elseJOptionPane.showMessageDialog(null,“The Stufdent not Exist!“); if(funjcb1.getSelectedItem().equals(“select by name“)if(funjtf1.getText().equals(“)JOptionPane.showMessageDialog(null,“Please Input StudentName!“);elsecon=DriverManager.getConnection(“jdbc:odbc:DataSource“);stmt=con.createStatement();rs=stmt.executeQuery(“select * from studentinfor wh