学生学籍管理系统(含java源代码)
- 格式:docx
- 大小:132.09 KB
- 文档页数:16
学生学籍管理详细设计学号:____________姓名:____________班级:____________一、设计题目:学生学籍管理二:设计内容:设计GUI学生学籍管理界面,用户可以加入学生信息,并对基本信息进行修改,添加,查询,删除。
三:设计要求:进行简单的学生信息管理。
四:总体设计(1)登陆界面的设计(2)主窗体的设计(3)添加学生信息窗体(4)查询学生信息窗体(5)修改学生信息窗体(6)删除学生信息窗体(7)事件响应的处理五:具体设计(1)程序结构的说明:A.入口程序:student.java;B.登陆界面程序:mainframe.java;C.主窗体程序:interfac.java;D.添加信息窗口程序:tj.java;E.修改信息窗口程序:xg.java;F.查询信息窗口程序:cx.java;G.删除信息窗口程序:sc.java;H.程序数据连接:DatabaseConn.java;(2)程序代码及分析说明A.程序源代码(已提交)B.Student.java是程序的入口。
使登录窗口位于窗口中间,并且不可改变窗口大小。
C.mainframe.java是程序的登陆窗体。
输入用户名和密码(用户名和密码在数据库的password表中)点击“进入系统”,然后登陆界面消失;出现要操作的界面(屏幕左上角)。
D.tj.java是添加信息界面。
添加基本信息后,点击“添加信息”按钮,将信息加入xinxi表中。
E.xg.java是修改信息界面。
输入要修改的学号或姓名(两者数其一或全部输入),并输入所有信息,点击“修改信息”按钮(如果数据库中不存在此学号,则弹出对话框“无此学生信息”),若有则修改。
F.sc.java是删除信息界面。
输入要删除的学生的学号,点击“删除信息”按钮,弹出确认删除对话框,即可删除该生信息。
G.cx.java是查询信息界面。
输入要查询的学生学号,点击“信息查询”按钮,在相应的文本区里显示查询的信息。
学生信息管理系统JAVA源代码package stumanage;import javax.swing.*;import java.awt.*;import sun.awt.image.*;import java.awt.event.*;/*** <p>Title: </p>* <p>Description: </p>* <p>Copyright: Copyright (c) 2003</p>* <p>Company: </p>* @author not attributable* @version 1.0*/public class WelcomeFrameextends JFrame {JPanel jPanel1 = new MyPanel();ImageIcon imageIcon1 = new ImageIcon("beautiful.jpg"); BorderLayout borderLayout1 = new BorderLayout();JPanel jPanel2 = new JPanel();GridBagLayout gridBagLayout1 = new GridBagLayout(); JButton jButton1 = new JButton();JButton jButton2 = new JButton();JButton jButton3 = new JButton();JButton jButton4 = new JButton();JButton jButton5 = new JButton();public WelcomeFrame() {try {jbInit();}catch (Exception e) {e.printStackTrace();}}public static void main(String[] args) {WelcomeFrame welcomeFrame = new WelcomeFrame();welcomeFrame.pack();welcomeFrame.show();}private void jbInit() throws Exception {imageIcon1.setDescription("beautiful.jpg");imageIcon1.setImageObserver(this);jPanel1.setLayout(borderLayout1);jPanel1.setMinimumSize(new Dimension(600, 400));jPanel1.setPreferredSize(new Dimension(600, 420));this.setLocale(java.util.Locale.getDefault());this.setResizable(true);this.setSize(new Dimension(747, 396));this.setState(Frame.NORMAL);jPanel2.setBackground(UIManager.getColor("RadioButtonMenuItem.selectionBackgro und"));jPanel2.setForeground(Color.black);jPanel2.setMinimumSize(new Dimension(100, 30));jPanel2.setPreferredSize(new Dimension(100, 400));jPanel2.setLayout(gridBagLayout1);jButton1.setToolTipText(" 个人信息管理");jButton1.setText(" 个人信息管理");jButton1.addActionListener(new WelcomeFrame_jButton1_actionAdapter(this));jButton2.setToolTipText(" 选课信息管理");jButton2.setText(" 选课信息管理");jButton2.addActionListener(new WelcomeFrame_jButton2_actionAdapter(this));jButton3.setToolTipText("奖励信息管理");jButton3.setText("奖励信息管理");jButton3.addActionListener(new WelcomeFrame_jButton3_actionAdapter(this));jButton4.setToolTipText("职务信息管理");jButton4.setText("职务信息管理");jButton4.addActionListener(new WelcomeFrame_jButton4_actionAdapter(this));jButton5.setToolTipText("退出系统");jButton5.setText("退出系统");jButton5.addActionListener(new WelcomeFrame_jButton5_actionAdapter(this));this.getContentPane().add(jPanel1, BorderLayout.CENTER);jPanel1.add(jPanel2, BorderLayout.EAST);jPanel2.add(jButton1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));jPanel2.add(jButton2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(9, 0, 0, 21), 0, 0));jPanel2.add(jButton3, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 0, 0, 10), 0, 0));jPanel2.add(jButton5, new GridBagConstraints(0, 4, 2, 1, 0.0, 0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 11), 21, 0));jPanel2.add(jButton4, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(9, 0, 13, 0), 12, 0));}class MyPanelextends JPanel {public void paintComponent(Graphics g) {super.paintComponent(g);imageIcon1.paintIcon(this, g, 0, 0);}}void jButton4_actionPerformed(ActionEvent e) {MainFrame.main( null );this.hide();MainFrame.jTabbedPane1.setSelectedComponent( MainFrame.jPanel4);}void jButton1_actionPerformed(ActionEvent e) {MainFrame.main( null );this.hide();}void jButton3_actionPerformed(ActionEvent e) {MainFrame.main( null );this.hide();MainFrame.jTabbedPane1.setSelectedComponent( MainFrame.jPanel3);}void jButton2_actionPerformed(ActionEvent e) {MainFrame.main( null );this.hide();MainFrame.jTabbedPane1.setSelectedComponent( MainFrame.jPanel2); }void jButton5_actionPerformed(ActionEvent e) {System.exit(0);}}class WelcomeFrame_jButton4_actionAdapter implementsjava.awt.event.ActionListener {WelcomeFrame adaptee;WelcomeFrame_jButton4_actionAdapter(WelcomeFrame adaptee) {this.adaptee = adaptee;}public void actionPerformed(ActionEvent e) {adaptee.jButton4_actionPerformed(e);}}class WelcomeFrame_jButton1_actionAdapter implementsjava.awt.event.ActionListener {WelcomeFrame adaptee;WelcomeFrame_jButton1_actionAdapter(WelcomeFrame adaptee) { this.adaptee = adaptee;}public void actionPerformed(ActionEvent e) {adaptee.jButton1_actionPerformed(e);}}class WelcomeFrame_jButton3_actionAdapter implementsjava.awt.event.ActionListener {WelcomeFrame adaptee;WelcomeFrame_jButton3_actionAdapter(WelcomeFrame adaptee) { this.adaptee = adaptee;}public void actionPerformed(ActionEvent e) {adaptee.jButton3_actionPerformed(e);}}class WelcomeFrame_jButton2_actionAdapter implementsjava.awt.event.ActionListener {WelcomeFrame adaptee;WelcomeFrame_jButton2_actionAdapter(WelcomeFrame adaptee) { this.adaptee = adaptee;}public void actionPerformed(ActionEvent e) {adaptee.jButton2_actionPerformed(e);}}class WelcomeFrame_jButton5_actionAdapter implementsjava.awt.event.ActionListener {WelcomeFrame adaptee;WelcomeFrame_jButton5_actionAdapter(WelcomeFrame adaptee) { this.adaptee = adaptee;}public void actionPerformed(ActionEvent e) {adaptee.jButton5_actionPerformed(e);}}。
javaweb学生管理系统源代码介绍简介本文档将介绍一个基于JavaWeb的学生管理系统的源代码。
该系统通过使用Java语言编写,结合了Web开发技术,实现了学生信息的录入、查询、修改和删除等功能。
该系统具有良好的用户界面和功能模块,可以方便地进行学生信息管理。
系统结构该学生管理系统主要由以下几个主要模块组成:1.用户登录模块:该模块实现了用户的登录功能,将验证用户输入的用户名和密码与数据库中已注册用户的信息进行匹配,以确定用户是否能够成功登录系统。
2.学生信息录入模块:该模块提供了一个用户界面,用户可以在界面上输入学生的基本信息,如学号、姓名、性别、年龄等,并将这些信息存储到数据库中。
3.学生信息查询模块:该模块允许用户根据学号或姓名等信息进行学生信息的查询,系统将根据用户输入的条件在数据库中查询相应的学生信息,并将查询结果返回给用户。
4.学生信息修改模块:该模块允许用户修改已录入的学生信息,在界面上展示当前学生的信息,并允许用户进行修改操作,修改后的信息将被保存到数据库中。
5.学生信息删除模块:该模块允许用户删除已录入的学生信息,用户可以根据学号或姓名等条件选择要删除的学生信息,被删除的学生信息将从数据库中移除。
技术细节该学生管理系统的源代码主要使用了以下技术进行开发:1.Java语言:系统的后端主要由Java编写,通过使用Java的面向对象特性和类库函数,实现了系统的各种功能模块。
2.Servlet:Servlet是JavaWeb开发中的一种组件技术,用于处理HTTP请求和响应。
系统中的各个功能模块都通过Servlet进行处理,提供了合适的响应和数据处理操作。
3.JSP:JSP是JavaServer Pages的缩写,是一种在HTML页面中嵌入Java代码的技术。
在本系统中,JSP主要用于生成用户界面,通过嵌入Java代码和引用系统的Java类,实现了用户界面与后端业务逻辑的交互。
4.JDBC:JDBC是Java数据库连接的简称,用于与数据库进行交互。
java学⽣信息管理系统源代码本⽂实例为⼤家分享了java学⽣信息管理系统的具体代码,实现学⽣信息:增加 int[] a=new int[9] 、删除、查找、更改,供⼤家参考,具体内容如下/*学⽣信息管理系统,实现学⽣信息:*增加 int[] a=new int[9]*删除*查找*更改*/import java.util.Scanner;//导⼊java输⼊流import ng.*;import java.io.*;class Student{private static Student[] s=new Student[2];int n=0;private String name;private int num;private String classAge;public void judge()throws IOException{int i;char ch;String str;Scanner In=new Scanner(System.in);if(n==0){System.out.print("你还没有录⼊任何学⽣,是否录⼊(Y/N):");str=In.next();ch=str.charAt(0);while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n'){System.out.print("输⼊有误,请重新输⼊:");str=In.next();ch=str.charAt(0);}if(ch=='Y'||ch=='y'){this.add();}if(ch=='N'||ch=='n'){this.menu();}}}public void menu()throws IOException//定义菜单函数{int a;//定义switch语句变量Scanner in=new Scanner(System.in);//实例化输⼊流对象System.out.println("*********学⽣信息管理系统功能表*********");System.out.println("***** 1.增加 *****");System.out.println("***** 2.显⽰ *****");System.out.println("***** 3.修改 *****");System.out.println("***** 4.删除 *****");System.out.println("***** 5.查看 *****");System.out.println("***** 0.退出 *****");System.out.println("****************************************");System.out.print("请选择(0~5):");a=in.nextInt();while(a<0||a>5){System.out.print("输⼊超出范围,请重新输⼊:");a=in.nextInt();}switch(a){case 1:this.add();break;case 4:this.delete();break;case 5:this.look();break;case 0:System.exit(0);break;}}public void add()throws IOException//定义增加函数{String str,str1,str2;int i,num1,t=1;char ch,ch1;FileWriter fw=new FileWriter("F://javaFile//student.txt",true); fw.write(" 录⼊的学⽣信息列表\r\n\r\n学号姓名班级\r\n"); Scanner In=new Scanner(System.in);while(t==1){System.out.print("请输⼊学⽣学号:");num1=In.nextInt();for(i=0;i<n;i++){while(s[i].num==num1){System.out.println("已存在此学号,请重新输⼊");System.out.print("请输⼊学号:");num1=In.nextInt();}}s[n].num=num1;str2=String.valueOf(num1);fw.write(str2+" ");System.out.println();System.out.print("请输⼊学⽣姓名:");s[n].name=In.next();fw.write(s[n].name+" ");System.out.println();System.out.print("请输⼊学⽣班级:");s[n].classAge=In.next();fw.write(s[n].classAge+"\r\n");++n;fw.close();System.out.println();System.out.print("是否继续添加(Y/N)");str=In.next();ch=str.charAt(0);while(ch!='N'&&ch!='n'&&ch!='Y'&&ch!='y'){System.out.print("输⼊有误,请重新输⼊:");str=In.next();ch=str.charAt(0);}if(ch=='N'||ch=='n'){break;}}System.out.println();System.out.print("是否返回主菜单(Y/N)");str1=In.next();ch1=str1.charAt(0);while(ch1!='Y'&&ch1!='y'&&ch1!='N'&&ch1!='n'){System.out.print("输⼊有误,请重新输⼊:");str1=In.next();ch1=str1.charAt(0);}if(ch1=='Y'||ch1=='y'){this.menu();}if(ch1=='N'||ch1=='n'){System.out.println("正在退出...谢谢使⽤!");System.exit(0);}}public void show()throws IOException{int i;this.judge();System.out.println("本次操作共录⼊"+n+"位学⽣!");System.out.println("你录⼊的学⽣信息如下:");System.out.println();System.out.println("学号\t\t姓名\t班级");for(i=0;i<n;i++){System.out.println(s[i].num+" "+s[i].name+" "+s[i].classAge);}System.out.println("系统返回主菜单!");this.menu();}public void delete()throws IOException//删除信息功能实现注:本功能暂时不具备可扩展性 {this.judge();int j=0,t=0,k=0,num1;char ch;String str;Scanner pin=new Scanner(System.in);System.out.print("请输⼊要删除的学号:");num1=pin.nextInt();for(j=0;j<n;j++){if(s[j].num==num1){k=1;t=j;}}if(k==0){System.out.println("对不起!你要删除的学号不存在!");System.out.println("系统将返回主菜单!");this.menu();}if(k==1){System.out.println("你要删除的学⽣信息如下:");//打印管理员要删除的学⽣信息System.out.println("学号\t姓名\t班级");//本功能暂时不备扩展性System.out.println(s[t].num+" "+s[t].name+" "+s[t].classAge);System.out.println();System.out.print("你确定要删除(Y/N):");str=pin.next();ch=str.charAt(0);while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n'){System.out.print("输⼊有误,请重新输⼊:");str=pin.next();ch=str.charAt(0);}if(ch=='N'||ch=='n'){System.out.println();System.out.println("系统返回主菜单!");this.menu();}if(ch=='Y'||ch=='y'){for(j=t;j<n-1;j++){s[j]=s[j+1];}n--;System.out.println("数据成功删除!");System.out.println("系统返回主菜单!");this.menu();}}}public void look()throws IOExceptionFileReader fr=new FileReader("F://javaFile//student.txt");int a;while((a=fr.read())!=-1){System.out.print((char)a);}fr.close();System.out.println("系统返回主菜单!");System.out.println();this.menu();}public void modif()throws IOException{this.judge();int j=0,t=0,k=0,num2,num3,moi,c=1;char ch;String str,str1,str2;Scanner pin=new Scanner(System.in);System.out.print("请输⼊要修改的学号:");num2=pin.nextInt();for(j=0;j<n;j++){if(s[j].num==num2){k=1;t=j;}}if(k==0){System.out.println("对不起!你要修改的学号不存在!");System.out.println("系统将返回主菜单!");this.menu();}if(k==1){System.out.println("你要修改的学⽣信息如下:");//打印管理员要删除的学⽣信息System.out.println("学号\t姓名\t班级");//本功能暂时不备扩展性System.out.println(s[t].num+" "+s[t].name+" "+s[t].classAge);System.out.println();System.out.print("你确定要修改(Y/N):");str=pin.next();ch=str.charAt(0);while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n'){System.out.print("输⼊有误,请重新输⼊:");str=pin.next();ch=str.charAt(0);}if(ch=='N'||ch=='n'){System.out.println();System.out.println("系统返回主菜单!");this.menu();}while(c==1){if(ch=='Y'||ch=='y'){System.out.println("****************************************");System.out.println("***** 1.修改学号 *****");System.out.println("***** 2.修改班级 *****");System.out.println("***** 3.修改姓名 *****");System.out.println("****************************************");System.out.print("请选择:");moi=pin.nextInt();switch(moi){case 1:System.out.print("请输⼊新的学号:");num3=pin.nextInt();s[t].num=num3;break; case 2:System.out.print("请输⼊新的班级:");str1=pin.next();s[t].classAge=str1;break; case 3:System.out.print("请输⼊新的姓名:");str2=pin.next();s[t].name=str2;break;}System.out.println("数据已成功修改!");}str=pin.next();ch=str.charAt(0);System.out.println();while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n'){System.out.print("输⼊有误,请重新输⼊:");str=pin.next();ch=str.charAt(0);}if(ch=='N'||ch=='n'){break;}}}System.out.println();System.out.println("系统返回主菜单!");this.menu();}public static void main(String[] args)throws IOException{Student stu=new Student();for(int i=0;i<2;i++){s[i]=new Student();}stu.menu();}}更多学习资料请关注专题《》。
java学籍管理系统源代码————————————————————————————————作者:————————————————————————————————日期:package zuoye;//主类import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.util.Hashtable;public class ManagerWindow extends JFrame implements ActionListener {InputStudent 基本信息录入=null;ModifySituation 基本信息修改=null;Inquest 基本信息查询=null;Delete 基本信息删除=null;JPanel pCenter,p,p9;TextField txtName,txtPassword;Label lblTitle,lblName,lblPassword;Button btnSubmit,btnReset,guanbi;Panel p1,p11,p12,p2,p13,p14,p15;JMenuBar bar;ImageIcon icon;JMenu fileMenu;JMenuItem 录入,修改,查询,删除,欢迎,退出,关于;Container con=null;Hashtable 基本信息=null;File file=null;CardLayout card=null;JLabel label=null;JLabel label2;public ManagerWindow(){p=new JPanel();lblName=new Label("管理员帐号:");txtName=new TextField(10);lblPassword=new Label("密码:");txtPassword=new TextField(10);txtPassword.setEchoChar('*');btnSubmit = new Button("提交");btnReset = new Button("重置");guanbi=new Button("关闭");p11=new Panel();p12=new Panel();p13=new Panel();p14=new Panel();p15=new Panel();p11.add(lblName);p11.add(txtName);p12.add(lblPassword);p12.add(txtPassword);txtName.addActionListener(this);txtPassword.addActionListener(this);p13.add(btnSubmit);btnSubmit.setBackground(Color.YELLOW);p13.add(btnReset);btnReset.setBackground(Color.YELLOW);p13.add(guanbi);guanbi.setBackground(Color.YELLOW);btnSubmit.addActionListener(this);btnReset.addActionListener(this);guanbi.addActionListener(this);p.setLayout(new GridLayout(10,1));p.add(p14);p.add(p15);p.add(p11);p.add(p12);p.add(p13);p.setBackground(Color.gray);p9=new JPanel();icon=new ImageIcon("123.jpg");label2=new JLabel(icon,JLabel.LEFT);label=new JLabel("欢迎使用学生基本信息管理系统",JLabel.CENTER); label.setFont(new Font("TimesRoman",Font.BOLD,24));label.setForeground(Color.red);p9.setOpaque(true);p9.add(label);p9.add(label2);录入=new JMenuItem("录入学生基本信息");修改=new JMenuItem("修改学生基本信息");查询=new JMenuItem("查询学生基本信息");删除=new JMenuItem("删除学生基本信息");欢迎=new JMenuItem("欢迎界面");退出=new JMenuItem("退出");关于=new JMenuItem("关于我们");bar=new JMenuBar();fileMenu=new JMenu("菜单选项");fileMenu.add(录入);fileMenu.add(修改);fileMenu.add(查询);fileMenu.add(删除);fileMenu.add(欢迎);fileMenu.add(关于);fileMenu.add(退出);fileMenu.enable(false);bar.add(fileMenu);setJMenuBar(bar);基本信息=new Hashtable();录入.addActionListener(this);修改.addActionListener(this);查询.addActionListener(this);删除.addActionListener(this);欢迎.addActionListener(this);退出.addActionListener(this);关于.addActionListener(this);card=new CardLayout();con=getContentPane();pCenter=new JPanel();pCenter.setLayout(card);pCenter.setBackground(Color.black);file=new File("作业.txt");if(!file.exists()){try{FileOutputStream out=new FileOutputStream(file);ObjectOutputStream objectOut=new ObjectOutputStream(out);objectOut.writeObject(基本信息);objectOut.close();out.close();}catch(IOException e){}}基本信息录入=new InputStudent(file);基本信息修改=new ModifySituation(file);基本信息查询=new Inquest(this,file);基本信息删除=new Delete(file);pCenter.add(p,BorderLayout.CENTER);pCenter.add("欢迎语界面",p9);pCenter.add("录入界面",基本信息录入);pCenter.add("修改界面",基本信息修改);pCenter.add("删除界面",基本信息删除);con.add(pCenter,BorderLayout.CENTER);con.validate();addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){System.exit(0);}});setVisible(true);setBounds(500,200,450,400);validate();}public void clear(){txtName.setText("");txtPassword.setText("");}@SuppressWarnings("deprecation")public void submit(){String n=txtName.getText();String paw=txtPassword.getText();if(n.equals("admin") && paw.equals("1234")){JOptionPane.showMessageDialog(this,"合法用户,欢迎进入本系统");card.show(pCenter,"欢迎语界面");fileMenu.enable();}else{JOptionPane.showMessageDialog(this,"非法用户,禁止进入本系统");}}public void actionPerformed(ActionEvent e){if(e.getSource()==录入){card.show(pCenter,"录入界面");}else if(e.getSource()==修改){card.show(pCenter,"修改界面");}else if(e.getSource()==查询){基本信息查询.setVisible(true);}else if(e.getSource()==删除){card.show(pCenter,"删除界面");}else if(e.getSource()==欢迎){card.show(pCenter,"欢迎语界面");}else if(e.getSource()==退出){System.exit(0);}else if(e.getSource()==关于){JOptionPane.showMessageDialog(this,"五块二小组:常永恒,孙东升,李强,吴春亮,涂留定");}String s=e.getActionCommand();if(s.equals("重置")){clear();}else if(s.equals("提交")){submit();}else if(e.getSource()==txtName){txtPassword.requestFocus();}else if(e.getSource()==txtPassword){submit();}else if(s.equals("关闭")){System.exit(0);}}public static void main(String args[]){new ManagerWindow();}}。
JA V A学生管理系统源代码一、程序import java.util.*;public class Test {//主程序public static void main(String[] args){Scanner in = new Scanner(System.in);System.out.println("------请定义学生的人数:------");Student[] stuArr = new Student[in.nextInt()];Admin adminStu = new Admin();while(true){System.out.println("-----请选择你要执行的功能-----");System.out.println("10:添加一个学生");System.out.println("11:查找一个学生");System.out.println("12:根据学生编号更新学生基本信息");System.out.println("13:根据学生编号删除学生");System.out.println("14:根据编号输入学生各门成绩");System.out.println("15:根据某门成绩进行排序");System.out.println("16:根据总分进行排序");System.out.println("99:退出系统");String number = in.next();if(number.equals("10")){System.out.println("请输入学生的编号:");int num = in.nextInt();System.out.println("请输入学生的姓名:");String name = in.next();System.out.println("请输入学生的年龄:");int age = in.nextInt();adminStu.Create(num,name,age,stuArr);//添加学生}else if(number.equals("11")){System.out.println("执行查找学生基本信息的操作");System.out.println("请输入学生的编号进行查找:");int num = in.nextInt();adminStu.find(num,stuArr);//查找学生}else if(number.equals("12")){System.out.println("执行更新学员的基本信息操作");System.out.println("请输入学生的编号:");int num = in.nextInt();System.out.println("请输入学生的姓名:");String name = in.next();System.out.println("请输入学生的年龄:");int age = in.nextInt();adminStu.update(num,name,age,stuArr);//更新学生基本信息}else if(number.equals("13")){System.out.println("执行删除学生操作");System.out.println("请输入学生编号:");int num = in.nextInt();adminStu.delete(num,stuArr);//删除学生}else if(number.equals("14")){System.out.println("执行输入成绩操作");System.out.println("请输入学生编号:");int num = in.nextInt();adminStu.input(num, stuArr);//输入成绩}else if(number.equals("15")){System.out.println("执行根据某科目成绩排序操作");System.out.println("请选择需要排序的科目名(1.java 2.C# 3.html 4.sql):");int num = in.nextInt();adminStu.courseSort(num,stuArr);//按科目排序}else if(number.equals("16")){System.out.println("执行根据总分排序操作");adminStu.sumSort(stuArr);//按总分排序}else if(number.equals("99")){System.out.println("--------程序已退出--------");//break;System.exit(0);}}}}二、学生类public class Student {//学生类private int num;private String name;private int age;private int java;private int C;private int html;private int sql;private int sum;private int avg;public int getNum() {return num;}public void setNum(int num) { this.num = num;}public String getName() {return name;}public void setName(String name) { = name;}public int getAge() {return age;}public void setAge(int age) { this.age = age;}public int getJava() {return java;}public void setJava(int java) { this.java = java;}public int getC() {return C;}public void setC(int c) {C = c;}public int getHtml() {return html;}public void setHtml(int html) { this.html = html;}public int getSql() {return sql;}public void setSql(int sql) { this.sql = sql;}public int getSum() {return sum;}public void setSum() {this.sum = this.java+this.C+this.html+this.sql;}public int getAvg() {return avg;}public void setAvg() {this.avg = this.sum/4;}public String toString(){String str= "\t"+this.num+"\t"++"\t"+this.age+"\t"+this.java+"\t"+this.C+"\t"+this.html+"\t"+this.sql+"\t"+this.sum+"\t"+this.avg;return str;}}三、管理学生类import java.util.*;public class Admin {//用来管理学生的一个类String msg = "\t编号\t姓名\t年龄\tjava\tC#\thtml\tsql\t总分\t 平均分";public void print(Student[] arr){//刷新数据的方法System.out.println(msg);for(int i=0;i<arr.length;i++){if(arr[i]!=null){arr[i].setSum();arr[i].setAvg();System.out.println(arr[i]);}}}public boolean exist(int num,Student stu){//判断学生是否存在的方法if(stu!=null){if(stu.getNum()==num){return true;}else{return false;}}return false;}public void Create(int num,String name,int age,Student[] arr){//添加学生的方法Student stu = new Student();stu.setNum(num);stu.setName(name);stu.setAge(age);int i = this.setIndex(arr);if(i==99999){System.out.println("学生人数已添满,不能再添加了");}else{arr[i]=stu;}this.print(arr);}public int setIndex(Student[] arr){//返回数组为空的下标for(int i=0;i<arr.length;i++){if(arr[i]==null){return i;}}return 99999;}public void find(int num,Student[] arr){//查询学生的方法for(int i=0;i<arr.length;i++){//判断学生是否存在if(this.exist(num,arr[i])==true){System.out.println(msg);System.out.println(arr[i]);return;}}System.out.println("-----没有这个学生的存在-----");}public void update(int num,String name,int age,Student[] arr){//更新学生基本信息的方法for(int i=0;i<arr.length;i++){if(this.exist(num, arr[i])==true){arr[i].setName(name);arr[i].setAge(age);System.out.println("--------更新学生信息成功!-------");this.print(arr);return;}}System.out.println("------没找到这个学生更新信息失败------");}public void delete(int num,Student[] arr){//删除学生的方法for(int i=0;i<arr.length;i++){if(this.exist(num,arr[i])){arr[i] = null;this.print(arr);return;}}System.out.println("您所指定编号的学生不存在");}public void input(int num,Student[] arr){//输入学生成绩的方法for(int i=0;i<arr.length;i++){if(this.exist(num, arr[i])){Scanner in = new Scanner(System.in);System.out.println("请输入"+arr[i].getName()+"java 的成绩:");if(in.hasNextInt()){//输入非整形数则不执行arr[i].setJava(in.nextInt());}else{return;}System.out.println("请输入"+arr[i].getName()+"C#的成绩:");if(in.hasNextInt()){arr[i].setC(in.nextInt());}else{return;}System.out.println("请输入"+arr[i].getName()+"html 的成绩:");if(in.hasNextInt()){arr[i].setHtml(in.nextInt());}else{return;}System.out.println("请输入"+arr[i].getName()+"sql 的成绩:");if(in.hasNextInt()){arr[i].setSql(in.nextInt());}else{return;}this.print(arr);return;}}}public void courseSort(int num,Student[] arr){//根据指定科目排序的方法if(num==1){//这里不能用冒泡排序(因为冒泡排序是相邻的比较,而相邻的可能不存在,那么相隔的两个就不能交换)for(int i=0;i<arr.length;i++){for(int j=i+1;j<arr.length;j++){if(arr[i]!=null&&arr[j]!=null){if(arr[i].getJava()<arr[j].getJava()){Student t = arr[i];arr[i] = arr[j];arr[j] = t;}}}}}else if(num==2){for(int i=0;i<arr.length;i++){for(int j=i+1;j<arr.length;j++){if(arr[i]!=null&&arr[j]!=null){if(arr[i].getC()<arr[j].getC()){Student t = arr[i];arr[i] = arr[j];arr[j] = t;}}}}}else if(num==3){for(int i=0;i<arr.length;i++){for(int j=i+1;j<arr.length;j++){if(arr[i]!=null&&arr[j]!=null){if(arr[i].getHtml()<arr[j].getHtml()){Student t = arr[i];arr[i] = arr[j];arr[j] = t;}}}}}else if(num==4){for(int i=0;i<arr.length;i++){for(int j=i+1;j<arr.length;j++){if(arr[i]!=null&&arr[j]!=null){if(arr[i].getSql()<arr[j].getSql()){Student t = arr[i];arr[i] = arr[j];arr[j] = t;}}}}}this.print(arr);}public void sumSort(Student[] arr){//根据总分排序的方法for(int i=0;i<arr.length;i++){for(int j=i+1;j<arr.length;j++){if(arr[i]!=null&&arr[j]!=null){if(arr[i].getSum()<arr[j].getSum()){Student t = arr[i];arr[i] = arr[j];arr[j] = t;}}}}this.print(arr);}}。
学生信息管理系统java代码以下是一个简单的学生信息管理系统Java代码,包括增删改查等基本功能实现:```javaimport java.util.ArrayList;import java.util.Scanner;class Student{ // 学生类private String sno; // 学号private String name; // 姓名private String sex; // 性别private int age; // 年龄public Student(String sno, String name, String sex, int age) { // 构造函数this.sno = sno; = name;this.sex = sex;this.age = age;}@Overridepublic String toString() { // 输出学生信息return "学号:" + sno + ", 姓名:" + name + ", 性别:" + sex + ", 年龄:" + age;}// Getter和Setter方法public String getSno() {return sno;}public void setSno(String sno) {this.sno = sno;}public String getName() {return name;}public void setName(String name) { = name;}public String getSex() {return sex;}public void setSex(String sex) {this.sex = sex;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}}public class StudentManagementSystem { // 学生信息管理系统static ArrayList<Student> students = new ArrayList<>(); // 学生列表static Scanner scanner = new Scanner(System.in);public static void main(String[] args) {while (true) {System.out.println("请输入命令(1.新增,2.查询,3.修改,4.删除,5.退出):");int command = scanner.nextInt();switch (command) {case 1: // 新增学生addStudent();break;case 2: // 查询学生queryStudent();break;case 3: // 修改学生updateStudent();break;case 4: // 删除学生deleteStudent();break;case 5: // 退出程序return;default:System.out.println("无效命令!");}}}public static void addStudent() { // 新增学生System.out.println("请输入学号:");String sno = scanner.next();System.out.println("请输入姓名:");String name = scanner.next();System.out.println("请输入性别:");String sex = scanner.next();System.out.println("请输入年龄:");int age = scanner.nextInt();Student student = new Student(sno, name, sex, age);students.add(student);System.out.println("新增学生信息成功!");}public static void queryStudent() { // 查询学生System.out.println("请输入学号:");String sno = scanner.next();for (int i = 0; i < students.size(); i++) {if (students.get(i).getSno().equals(sno)) {System.out.println(students.get(i).toString()); return;}}System.out.println("未找到该学生信息!");}public static void updateStudent() { // 修改学生System.out.println("请输入学号:");String sno = scanner.next();for (int i = 0; i < students.size(); i++) {if (students.get(i).getSno().equals(sno)) {System.out.println("请输入新姓名:");String name = scanner.next();System.out.println("请输入新性别:");String sex = scanner.next();System.out.println("请输入新年龄:");int age = scanner.nextInt();students.get(i).setName(name);students.get(i).setSex(sex);students.get(i).setAge(age);System.out.println("修改学生信息成功!");return;}}System.out.println("未找到该学生信息!");}public static void deleteStudent() { // 删除学生System.out.println("请输入学号:");String sno = scanner 。
教学管理系统java源代码_教学管理系统java源代码.doc 教学管理系统java源代码教学管理系统java源代码篇⼀:java学⽣管理系统源代码import java.io.Serializable;public class Course implements Serializable{private String courseName;private int courseGrade;Course(){courseName=null;courseGrade=0;}public void setCourseNameValue(String ss){this.courseName=ss;}public void setCourseGradeValue(int dd){this.courseGrade=dd;}public String getCourseNameValue(){return this.courseName;}public int getCourseGradeValue(){return this.courseGrade;}public boolean equals(Object o) {if (o == null){ return false;}else {if (o instanceof Course) {Course rec = (Course) o;if (this.courseName.equals(rec.getCourseNameValue())) {return true;}}return false;}---------------------------------------------------------------------------------------------------------------import java.io.Serializable;import java.util.Arrays;import java.util.LinkedList;import java.util.List;public class Student implements Serializable, Comparable{private String studentName;private int studentId;//private int studentCourseAmount=4;private LinkedList courseList;Student(){studentName=null;studentId=0;courseList=new LinkedList();}public void setStudentNameValue(String name){//确定学⽣名称this.studentName=name;}public void setStudentIdValue(int id){//确定学⽣学号this.studentId=id;}public void setStudentCourseList(LinkedList list){//传⼊课程链listthis.courseList=list;// System.out.println(例:0916 张磊 语⽂98 数学67); }public void setCourseGrade(Object o){//将与学科o同名的学科的成绩改为o的成绩for(int i=0;ithis.courseList.size();i++){ Course obj=new Course();obj=(Course) this.courseList.get(i);if(obj.equals(o)){Course res=(Course) o;obj.setCourseGradeValue(res.getCourseGradeValue());}public String getStudentNameValue(){//取得学⽣姓名return this.studentName;}public int getStudentId(){//取得学⽣学号return this.studentId;}public LinkedList getstudentCourseList(){//得到成绩链的⾸地址return this.courseList;}public long。
import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;import java.util.*;class Student implements java.io.Serializable{String number,name,specialty,grade,borth,sex;public Student(){};publicvoid setNumber(String number){ this.number=number;}public String getNumber(){ return number;}publicvoid setName(String name){ =name;}public String getName(){ return name;}publicvoid setSex(String sex){ this.sex=sex;}public String getSex(){ return sex;}publicvoid setSpecialty(String specialty){ this.specialty=specialty;} public String getSpecialty(){ return specialty;}publicvoid setGrade(String grade){ this.grade=grade;}public String getGrade(){ return grade;}publicvoid setBorth(String borth){ this.borth=borth;}public String getBorth(){ return borth;}}JFrame{JLabel lb=new JLabel("录入请先输入记录,查询、删除请先输入学号,修改是对查询" +"内容改后的保存!");JTextField 学号,姓名,专业,年级,出生;JRadioButton 男,女;ButtonGroup group=null;JButton 录入,查询,删除,修改,显示;JPanel p1,p2,p3,p4,p5,p6,pv,ph;Student 学生=null;Hashtable学生散列表=null;File file=null;FileInputStream inOne=null;ObjectInputStream inTwo=null;FileOutputStream outOne=null;ObjectOutputStream outTwo=null;public StudentManager(){super("学生基本信息管理系统");学号=new JTextField(10);姓名=new JTextField(10);专业=new JTextField(10);年级=new JTextField(10);出生=new JTextField(10);group=new ButtonGroup();男=new JRadioButton("男",true);女=new JRadioButton("女",false);group.add(男);group.add(女);录入=new JButton("录入");查询=new JButton("查询");删除=new JButton("删除");修改=new JButton("修改");显示=new JButton("显示");录入.addActionListener(new InputAct());查询.addActionListener(new InquestAct()); 修改.addActionListener(new ModifyAct());删除.addActionListener(new DeleteAct());显示.addActionListener(new ShowAct());修改.setEnabled(false);p1=new JPanel();p1.add(new JLabel("学号:",JLabel.CENTER)); p1.add(学号);p2=new JPanel();p2.add(new JLabel("姓名:",JLabel.CENTER)); p2.add(姓名);p3=new JPanel();p3.add(new JLabel("性别:",JLabel.CENTER)); p3.add(男);p3.add(女);p4=new JPanel();p4.add(new JLabel("专业:",JLabel.CENTER)); p4.add(专业);p5=new JPanel();p5.add(new JLabel("年级:",JLabel.CENTER)); p5.add(年级);p6=new JPanel();p6.add(new JLabel("出生:",JLabel.CENTER)); p6.add(出生);pv=new JPanel();pv.setLayout(new GridLayout(6,1));pv.add(p1);pv.add(p2);pv.add(p3);pv.add(p4);pv.add(p5);pv.add(p6);ph=new JPanel();ph.add(录入);ph.add(查询);ph.add(修改);ph.add(删除);ph.add(显示);file=new File("学生信息.txt");学生散列表=new Hashtable();if(!file.exists()){try{FileOutputStream out=new FileOutputStream(file);ObjectOutputStream objectOut=new ObjectOutputStream(out); objectOut.writeObject(学生散列表);objectOut.close();out.close();}catch(IOException e){}}Container con=getContentPane();con.setLayout(new BorderLayout());con.add(lb, BorderLayout.NORTH);con.add(pv, BorderLayout.CENTER);con.add(ph, BorderLayout.SOUTH);setDefaultCloseOperation(EXIT_ON_CLOSE);setBounds(100,100,600,300);setVisible(true);}publicstaticvoid main(String[] args) {new StudentManager();}class InputAct implements ActionListener{publicvoid actionPerformed(ActionEvent e){修改.setEnabled(false);String number="";number=学号.getText();if(number.length()>0){try{inOne=new FileInputStream(file);inTwo=new ObjectInputStream(inOne);学生散列表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exception ee){System.out.println("创建散列表出现问题!");}if(学生散列表.containsKey(number)){String warning="该生信息已存在,请到修改页面修改!";JOptionPane.showMessageDialog(null,warning,"警告", JOptionPane.WARNING_MESSAGE);}//end if1else{String m="该生信息将被录入!";int ok=JOptionPane.showConfirmDialog(null,m,"确认",JOptionPane.YES_NO_OPTION,RMATION_MESSAGE);if(ok==JOptionPane.YES_OPTION){String name=姓名.getText();String specialty=专业.getText();String grade=年级.getText();String borth=出生.getText();String sex=null;if(男.isSelected()){sex=男.getText();}else{sex=女.getText();}学生=new Student();学生.setNumber(number);学生.setName(name);学生.setSpecialty(specialty);学生.setGrade(grade);学生.setBorth(borth);学生.setSex(sex);try{outOne=new FileOutputStream(file);outTwo=new ObjectOutputStream(outOne);学生散列表.put(number,学生);outTwo.writeObject(学生散列表);outTwo.close();outOne.close();}catch(Exception ee){System.out.println("输出散列表出现问题!");}学号.setText(null);姓名.setText(null);专业.setText(null);年级.setText(null);出生.setText(null);}}//end else1}//end if0else{String warning="必须输入学号!";JOptionPane.showMessageDialog(null,warning,"警告",JOptionPane.WARNING_MESSAGE);}//end else0}//end actionPerformed}//end classclass InquestAct implements ActionListener{publicvoid actionPerformed(ActionEvent e){String number="";number=学号.getText();if(number.length()>0){try{inOne=new FileInputStream(file);inTwo=new ObjectInputStream(inOne);学生散列表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exception ee){System.out.println("散列表有问题!");} if(学生散列表.containsKey(number)){修改.setEnabled(true);Student stu=(Student)学生散列表.get(number); 姓名.setText(stu.getName());专业.setText(stu.getSpecialty());年级.setText(stu.getGrade());出生.setText(stu.getBorth());if(stu.getSex().equals("男")){男.setSelected(true);}else{女.setSelected(true);}}else{修改.setEnabled(false);String warning="该学号不存在!";JOptionPane.showMessageDialog(null,warning, "警告",JOptionPane.WARNING_MESSAGE);}}else{修改.setEnabled(false);String warning="必须输入学号!";JOptionPane.showMessageDialog(null,warning, "警告",JOptionPane.WARNING_MESSAGE);}}}class ModifyAct implements ActionListener{publicvoid actionPerformed(ActionEvent e){String number=学号.getText();String name=姓名.getText();String specialty=专业.getText();String grade=年级.getText();String borth=出生.getText();String sex=null;if(男.isSelected()){sex=男.getText();}else{sex=女.getText();}Student 学生=new Student();学生.setNumber(number);学生.setName(name);学生.setSpecialty(specialty);学生.setGrade(grade);学生.setBorth(borth);学生.setSex(sex);try{outOne=new FileOutputStream(file);outTwo=new ObjectOutputStream(outOne);学生散列表.put(number, 学生);outTwo.writeObject(学生散列表);outTwo.close();outOne.close();学号.setText(null);姓名.setText(null);专业.setText(null);年级.setText(null);出生.setText(null);}catch(Exception ee){System.out.println("录入修改出现异常!"); 修改.setEnabled(false);}}}class DeleteAct implements ActionListener{ publicvoid actionPerformed(ActionEvent e){修改.setEnabled(false);String number=学号.getText();if(number.length()>0){try{inOne=new FileInputStream(file);inTwo=new ObjectInputStream(inOne);学生散列表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exception ee){}if(学生散列表.containsKey(number)){Student stu=(Student)学生散列表.get(number);姓名.setText(stu.getName());专业.setText(stu.getSpecialty());年级.setText(stu.getGrade());出生.setText(stu.getBorth());if(stu.getSex().equals("男")){男.setSelected(true);}else{女.setSelected(true);}}String m="确定要删除该学生的记录吗?";int ok=JOptionPane.showConfirmDialog(null,m,"确认",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);if(ok==JOptionPane.YES_OPTION){学生散列表.remove(number);try{outOne=new FileOutputStream(file);outTwo=new ObjectOutputStream(outOne);outTwo.writeObject(学生散列表);outTwo.close();outOne.close();学号.setText(null);姓名.setText(null);专业.setText(null);年级.setText(null);出生.setText(null);}catch(Exception ee){System.out.println(ee);}}elseif(ok==JOptionPane.NO_OPTION){学号.setText(null);姓名.setText(null);专业.setText(null);年级.setText(null);出生.setText(null);}else{String warning="该学号不存在!";JOptionPane.showMessageDialog(null,warning, "警告",JOptionPane.WARNING_MESSAGE);}}else{String warning="必须输入学号!";JOptionPane.showMessageDialog(null,warning,"警告",JOptionPane.WARNING_MESSAGE);}}}class ShowAct implements ActionListener{publicvoid actionPerformed(ActionEvent e){new StudentShow(file);}}class StudentShow extends JDialog{Hashtable学生散列表= null;JTextArea 显示=null;FileInputStream inOne=null;ObjectInputStream inTwo=null;File file=null;public StudentShow(File file){super(new JFrame(),"显示对话框");this.file=file;显示=new JTextArea(16,30);try{inOne=new FileInputStream(file);inTwo=new ObjectInputStream(inOne);学生散列表=(Hashtable)inTwo.readObject();inOne.close();inTwo.close();}catch(Exception ee){}if(学生散列表.isEmpty())显示.append("目前还没有学生的信息记录!\n"); else{显示.setText("学号姓名性别专业年级出生\n");for(Enumeration enm=学生散列表.elements();enm.hasMoreElements();){ Student stu=(Student)enm.nextElement();String sex="";if(stu.getSex().equals("男"))sex="男";else sex="女";Stringstr=stu.getNumber()+","+stu.getName()+","+sex+","+stu.getSpecialty()+","+stu.getGrade()+","+stu.getBorth()+"\n"; 显示.append(str);}}JScrollPane scroll=new JScrollPane(显示);Container con=getContentPane();con.add("Center",scroll);con.validate();setVisible(true);setBounds(200,200,400,300);addWindowListener(new WindowAdapter(){publicvoid windowClosing(WindowEvent e){setVisible(false);} });}}}。
学生学籍管理系统程序源代码目录1.Client.java (2)2.LoginGUI.java (2)3.AdminGUI.java (6)4.StudentGUI.java (14)5.Select.java (17)6.UpdateAndInsert.java (24)7.Delete.java (27)8.Student.java (29)9.Administrator.java (31)1 / 32程序源代码学生学籍管理系统1.Client.java/*程序入口*/ package ms;public class Client {public static void main(String[] args) {LoginGUI lg=new LoginGUI(); lg.login(); } }2.LoginGUI.java/*登陆主窗口*/ package ms; import java.awt.BorderLayout; import java.awt.Choice; import java.awt.GridLayout; import java.awt.TextField; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; importjava.awt.event.WindowEvent; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; importjavax.swing.JLabel;import javax.swing.JOptionPane; import javax.swing.JPanel; public class LoginGUI {JFrame log=null; //登陆主窗口JPanel jPanel1=null; //用于存放用户名、密码、登录方式标签JPanel jPanel2=null; //用于存放用户名、密码输入框和登录方式选择框JPanel jPanel3=null; //用于存放登陆、退出按钮JLabel jLabel1=null; //用于存放用户名标签JLabel jLabel2=null; //用于存放密码标签JLabel jLabel3=null; //用于存放登录方式标签JLabel jLabel4=null; //学生管理系统登陆标签TextField t1=null; //用于存放用户名输入TextField t2=null; //用于存放密码输入2 / 32程序源代码学生学籍管理系统Choice c=null; //用于存放登录方式选择JButton jB1=null; //登陆按钮JButton jB2=null; //退出按钮String UserName=null; //存放用户输入的用户名String UserPassword=null; //存放用户输入的密码int UserLimit=-1; //存放用户选择登陆权限public LoginGUI() { super();桴獩氮杯?渠睥?牆浡?学生学籍管理系统); this.jPanel1=new JPanel(); this.jPanel2=new JPanel(); this.jPanel3=new JPanel(); ?扡汥?敮??扡汥尨用户名); ?扡汥?敮??扡汥尨密码); ?扡汥?敮??扡汥尨登录方式); jLabel4=new JLabel(new ImageIcon(image/login.jpg)); t1=new TextField(); t2=new TextField();c=new Choice(); //创建一个登录方式下拉选择框?摡?学生登陆); ?摡?管理员登陆); ??敮??瑵潴?登陆); //创建登陆按钮??敮??瑵潴?退出); //创建退出按钮} public void login() { BorderLayout border=new BorderLayout(); border.setVgap(15); border.setHgap(10);log.setLayout(border); //设置登陆主窗口布局管理器为BorderLayout log.add(jPanel1, BorderLayout.WEST); log.add(jPanel2, BorderLayout.CENTER); log.add(jPanel3, BorderLayout.SOUTH);log.add(jLabel4,BorderLayout.NORTH); jPanel1.setLayout(new GridLayout(3,1,30,20)); //3行1列jPanel2.setLayout(new GridLayout(3,1,30,20)); jPanel3.setLayout(new GridLayout(1,2,10,30));3 / 32程序源代码学生学籍管理系统jPanel1.add(jLabel1); //添加三个标签用户名、密码、登陆方式jPanel1.add(jLabel2); jPanel1.add(jLabel3); jPanel2.add(t1);//添加用户名、密码输入文本框登陆方式选择框jPanel2.add(t2); jPanel2.add(c); jPanel3.add(jB1); //添加两个按钮jPanel3.add(jB2); jB1.addActionListener(new ActionListener() { @Overridepublic void actionPerformed(ActionEvent e){ erName=LoginGUI.this.t1.getText(); erPassword=LoginGUI.this.t2.getText();erLimit=LoginGUI.this.c.getSelectedIndex();if(erLimit==0) {StudentGUI ll=newStudentGUI(LoginGUI.this.log,erName);Select sel=new Select(); sel.setStudentList();for(int i=0;i<sel.getStudentAllId().size();i++){ if(sel.getStudentAllId().get(i).toString().equals(er Name)&&sel.getStudentAllPassword().get(i).equals(erPa ssword)){log.setVisible(false); ll.studentGo(); }else if(i==sel.getStudentAllId().size()-1) { 佊瑰潩偮湡?桳睯敍獳条?慩潬?潌楧??琮楨?潬?用户名密码错误);} }4 / 32程序源代码学生学籍管理系统}else if(erLimit==1) { AdminGUIadmin=new AdminGUI(LoginGUI.this.log); Select sel=new Select(); sel.setAdminList();for(int i=0;i<sel.getAdminAllId().size();i++){ if(sel.getAdminAllId().get(i).toString().equals(LoginGUI.this.U serName)&&sel.getAdminAllPassword().get(i).equals(er Password)){log.setVisible(false); admin.adminGo(); }else if(i==sel.getAdminAllId().size()-1) { 佊瑰潩偮湡?桳睯敍獳条?慩潬?潌楧??琮楨?潬?用户名密码错误);} } } } });jB2.addActionListener(new ActionListener() { @Overridepublic void actionPerformed(ActionEvent e) {System.exit(0); } }); log.setSize(240,260);log.setLocationRelativeTo(null); log.setResizable(false);log.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) {System.exit(0);5 / 32程序源代码学生学籍管理系统} }); log.setVisible(true); } }3.AdminGUI.java*/ /*管理员登陆图形界面package ms; import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.TextArea; importjava.awt.TextField;import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; importjava.awt.event.WindowEvent; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JDialog; importjavax.swing.JFrame; import javax.swing.JLabel;import javax.swing.JOptionPane; import javax.swing.JPanel; public class AdminGUI {管理员登陆主窗口JDialog log=null;// jp5 用于存放管理员登陆标签和JPanel jp1=null;// 删除按钮增加JPanel jp2=null;// 用于存放查询修改jp5用于存放信息块JPanel jp3=null;//和按钮删除JPanel jp4=null;//用于存放修改插入用于存放请输入学号文本框JPanel jp5=null;// JLabeljadminLog=null; // 管理员登陆标签请输入学号标签JLabel jLabel=null; // 文本框TextField tf=null; //请输入学号JButton jb1=null;//查询按钮JButton jb2=null;//按钮修改按钮增加JButton jb3=null;// 删除按钮JButton jb4=null;// JButton jb5=null; // 列出全部学生信息TextAreata=null;//信息文本框32 / 6程序源代码学生学籍管理系统JLabel jl=null; //用于站位String id=null; // 用于保存用户输入查询学号TextField[] jtf = new TextField[9] ; JDialog jdialog=null;public AdminGUI(JFrame log) {super();桴獩氮杯?渠睥?楄污杯氨杯尬管理员登陆,true); jp1=new JPanel();jp2=new JPanel(); jp3=new JPanel(); jp4=new JPanel(); jp5=new JPanel(); jadminLog=new JLabel(newImageIcon(image/admin.jpg)); ?扡汥渽睥?慌敢?请输入学号); tf=new TextField(); 扪?敮??瑵潴?查询); 扪?敮??瑵潴?修改); 扪?敮??瑵潴?增加); 扪?敮??瑵潴?删除); 扪?敮??瑵潴?列出全部学生信息); 慴渽睥吠硥?敲?点击查询按钮将在此显示查询信息); jl=new JLabel(); } public void adminGo() { BorderLayout bl=new BorderLayout(); bl.setVgap(30); bl.setHgap(30); log.setLayout(bl);log.add(jp1,BorderLayout.NORTH); BorderLayout bl1=new BorderLayout(); bl1.setVgap(20); jp1.setLayout(bl1);jp1.add(jadminLog,BorderLayout.CENTER); jp5.setLayout(newGridLayout(1,2,200,200)); jp5.add(jLabel); jp5.add(tf);32 / 7程序源代码学生学籍管理系统log.add(jp2,BorderLayout.WEST);jp2.setLayout(new GridLayout(2,1,200,300)); jp2.add(jb1);jp2.add(jb5); log.add(jp3,BorderLayout.CENTER);jp3.setLayout(new BorderLayout(10, 10));jp3.add(jp5,BorderLayout.NORTH); jp3.add(ta);jp5.setLayout(new GridLayout(1,5,10,10)); jp5.add(jLabel);jp5.add(tf); log.add(jp4,BorderLayout.SOUTH);jp4.setLayout(new GridLayout(1,3,200,30)); jp4.add(jb2);jp4.add(jb3); jp4.add(jb4); log.addWindowListener(new WindowAdapter() {@Overridepublic void windowClosing(WindowEvent e) {System.exit(0); } }); jb1.addActionListener(new ActionListener() { @Overridepublic void actionPerformed(ActionEvent e) {AdminGUI.this.id=AdminGUI.this.tf.getText(); Select sel=new Select();sel.selectStudent(AdminGUI.this.id); if(sel.getStudent()!=null) {Student student=sel.getStudent();摁業??琮楨?慴献瑥敔瑸尨学号屜屴瑜?姓名屜屴瑜?性别屜屴瑜?出生日期屜屴瑜?民族屜屴瑜?籍贯屜屴瑜?专业屜屴瑜?班级屜屴瑜?联系电话屜屴瑜?密码\t\t); AdminGUI.this.ta.append(\+student.getId()+\ \t+student.getName()+\ \t+student.getSex()+\ \t+student.getBornDate()+\ \t+student.getNationality()+\ \t+student.getNationality()+\ \t+student.getMaj()+\+student.getCla()+\ \t+student.getTelNum()+\ \t+student.getPa8 / 32程序源代码学生学籍管理系统ssword()+\); } else {摁業??琮楨?慴献瑥敔瑸尨查无此人); } } });jb5.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) {Select sel=new Select(); sel.selectAllStudent();摁業??琮楨?慴献瑥敔瑸尨学号屜屴瑜?姓名屜屴瑜?性别屜屴瑜?出生日期屜屴瑜?民族屜屴瑜?籍贯屜屴瑜?专业屜屴瑜?班级屜屴瑜?联系电话屜屴瑜?密码\t\t\n);for(int i=0;i<sel.getAllStudent().size();i++) {Student student=sel.getAllStudent().get(i);AdminGUI.this.ta.append(student.getId()+\ \t+student.getName()+\\t+student.getSex()+\ \t+student.getBornDate()+\ \t+student.getNationality()+\ \t+student.getHometown()+\ \t+student.getMaj()+\ +student.getCla()+\\t+student.getTelNum()+\ \t+student.getPassword()+\); } } }); log.setSize(850,580);log.setLocationRelativeTo(null); log.setResizable(false);jb3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e){ jdialog=new JDialog(AdminGUI.this.log); String[] str=new 瑓楲杮嵛屻姓名?性别?出生日期?民族?籍贯?专业?班级?联系电话?密码};JLabel[] jlabel=new JLabel[9]; for(int i=0;i<9;i++)9 / 32程序源代码学生学籍管理系统{jlabel[i]=new JLabel(str[i]); jtf[i]=new TextField(); }JPanel jpanel1=new JPanel(); JPanel jpanel2=new JPanel(); ?瑵潴?扪瑵潴?渽睥?畂瑴湯尨确定); ?瑵潴?扪瑵潴?渽睥?畂瑴湯尨取消); jdialog.setLayout(new BorderLayout());jdialog.add(jpanel1,BorderLayout.CENTER);jdialog.add(jpanel2,BorderLayout.SOUTH);jpanel1.setLayout(new GridLayout(9,2,10,10)); for(int i=0;i<9;i++) {jpanel1.add(jlabel[i]); jpanel1.add(jtf[i]); } jpanel2.add(jbutton1); jpanel2.add(jbutton2);jbutton1.addActionListener(new ActionListener(){ @Overridepublic void actionPerformed(ActionEvent e) {Student student=new Student();student.setName(AdminGUI.this.jtf[0].getText());student.setSex(AdminGUI.this.jtf[1].getText());student.setBornDate(AdminGUI.this.jtf[2].getText()); student.setNationality(AdminGUI.this.jtf[3].getText()); student.setHometown(AdminGUI.this.jtf[4].getText());student.setMaj(AdminGUI.this.jtf[5].getText()); student.setCla(AdminGUI.this.jtf[6].getText());student.setTelNum(AdminGUI.this.jtf[7].getText()); student.setPassword(AdminGUI.this.jtf[8].getText()); UpdateAndInsert up=new UpdateAndInsert();if(up.insertStudent(student)==true) {32 / 10程序源代码学生学籍管理系统佊瑰潩偮湡?桳睯敍獳条?慩潬?摁業??琮楨?潬?添加成功); } jdialog.dispose(); } });jbutton2.addActionListener(new ActionListener(){ @Overridepublic void actionPerformed(ActionEvent e) {jdialog.dispose(); } });jdialog.setSize(500,400);jdialog.setLocationRelativeTo(null); jdialog.setResizable(false); jdialog.setVisible(true); } }); jb4.addActionListener(new ActionListener() { @Overridepublic void actionPerformed(ActionEvent e) {if(new Delete().delete(AdminGUI.this.tf.getText())==true) {佊瑰潩偮湡?桳睯敍獳条?慩潬?摁業??琮楨?潬?刪除成功);}else 佊瑰潩偮湡?桳睯敍獳条?慩潬?摁業??琮楨?潬?刪除失敗); } }); jb2.addActionListener(new ActionListener(){ @Overridepublic void actionPerformed(ActionEvent e) {Select sel=new Select();AdminGUI.this.id=AdminGUI.this.tf.getText();sel.selectStudent(AdminGUI.this.tf.getText());11 / 32程序源代码学生学籍管理系统Student student=sel.getStudent(); if(student==null) {佊瑰潩偮湡?桳睯敍獳条?慩潬?摁業??琮楨?潬?请检查输入的学号); } else {jdialog=new JDialog(AdminGUI.this.log); String[] str=new瑓楲杮嵛屻姓名?性别?出生日期?民族?籍贯?专业?班级?联系电话?密码};JLabel[] jlabel=new JLabel[9]; for(int i=0;i<9;i++) {jlabel[i]=new JLabel(str[i]); } jtf[0]=new TextField(student.getName()); jtf[1]=newTextField(student.getSex());jtf[2]=new TextField(student.getBornDate()); jtf[3]=new TextField(student.getNationality()); jtf[4]=newTextField(student.getHometown()); jtf[5]=newTextField(student.getMaj()); jtf[6]=new TextField(student.getCla());jtf[7]=new TextField(student.getTelNum()); jtf[8]=new TextField(student.getPassword()); JPanel jpanel1=new JPanel(); JPanel jpanel2=new JPanel(); ?瑵潴?扪瑵潴?渽睥?畂瑴湯尨确定); ?瑵潴?扪瑵潴?渽睥?畂瑴湯尨取消);jdialog.setLayout(new BorderLayout());jdialog.add(jpanel1,BorderLayout.CENTER);jdialog.add(jpanel2,BorderLayout.SOUTH); jpanel1.setLayout(new GridLayout(9,2,10,10)); for(int i=0;i<9;i++) {jpanel1.add(jlabel[i]); jpanel1.add(jtf[i]); }jpanel2.add(jbutton1); jpanel2.add(jbutton2);jbutton1.addActionListener(new ActionListener()12 / 32程序源代码学生学籍管理系统{ @Overridepublic void actionPerformed(ActionEvent e) {Student student=new Student(Integer.parseInt(AdminGUI.this.id), jtf[0].getText(), jtf[1].getText(), jtf[2].getText(), jtf[3].getText(),jtf[4].getText(), jtf[5].getText(), jtf[6].getText(), jtf[7].getText(),jtf[8].getText());UpdateAndInsert up=new UpdateAndInsert();if(up.updateStudent(student)==true) { 佊瑰潩偮湡?桳睯敍獳条?慩潬?摁業??琮楨?潬?更改成功);; }jdialog.dispose(); } });jbutton2.addActionListener(new ActionListener(){ @Overridepublic void actionPerformed(ActionEvent e) {jdialog.dispose(); } });jdialog.setSize(500,400);jdialog.setLocationRelativeTo(null); jdialog.setResizable(false); jdialog.setVisible(true); } } });log.setVisible(true); } }13 / 32程序源代码学生学籍管理系统4.StudentGUI.java*/ /*学生操作图形界面package ms; import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.TextField;import java.awt.event.ActionEvent; import java.awt.event.ActionListener;import java.awt.event.WindowAdapter; importjava.awt.event.WindowEvent; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JDialog; importjavax.swing.JFrame; import javax.swing.JLabel;import javax.swing.JOptionPane; import javax.swing.JPanel; public class StudentGUI {学生登入类主窗口JDialog log=null;// 用于存放登入块JPaneljp1=null;// JPanel jp2=null;// 用于存放信息块用于密码存放修改块JPanel jp3=null;// 用于存放我的信息按钮JPanel jp4=null;// JLabel jl1=null;// 学生登入标签学号标签JLabel jl2=null;// 学生姓名标签JLabeljl3=null;// 性别标签JLabel jl4=null;// 出生日期标签JLabel jl5=null;// JLabel jl6=null;//民族标签JLabel jl7=null;// 籍贯标签JLabel jl8=null;// 专业标签班级标签JLabel jl9=null;// JLabel jl10=null;// 联系电话标签请输入密码标签JLabel jl11=null;// JButton jb1=null;//我的信息按钮JButton jb2=null;//密码修改按钮TextField t1=null;//学号文本框学生姓名文本框TextField t2=null;// TextField t3=null;//性别文本框出生日期文本框TextField t4=null;//32 / 14程序源代码学生学籍管理系统TextField t5=null;//民族文本框籍贯文本框TextField t6=null;//专业文本框TextField t7=null;// TextField t8=null;//班级文本框联系电话文本框TextField t9=null;// TextField t10=null;//密码文本框存放密码输入框JPanel jp5=new JPanel();// String id=null;public StudentGUI(JFrame log,String str) {super();桴獩氮杯?渠睥?楄污杯氨杯尬学生登入,true); jp1=new JPanel();jp2=new JPanel(); jp3=new JPanel(); jp4=new JPanel();jl1=new JLabel(new ImageIcon(image/student.jpg)); :); 汪?敮??扡汥尨学号学生姓名:); 汪?敮??扡汥尨性别:); 汪?敮??扡汥尨出生日期汪?敮??扡汥尨:); 民族:); 汪?敮??扡汥尨汪?敮??扡汥尨籍贯:); 汪?敮??扡汥尨专业:); :); 汪?敮??扡汥尨班级:); 联系电话汪?渽睥?慌敢? :);请输入新密码汪?渽睥?慌敢? ); 我的信息扪?敮??瑵潴? ); 扪?敮??瑵潴? 密码修改t1=new T extField(); t2=new TextField(); t3=new TextField(); t4=new TextField(); t5=new TextField(); t6=new TextField(); t7=new TextField(); t8=new TextField(); t9=new TextField(); t10=new TextField(); this.id=str; } public void studentGo() {BorderLayout bl=new BorderLayout(); bl.setHgap(30);bl.setVgap(30);32 / 15程序源代码学生学籍管理系统log.setLayout(bl);log.add(jp1,BorderLayout.NORTH);//将登入块信息块密码修改块放入主窗口log.add(jp2,BorderLayout.CENTER);log.add(jp3,BorderLayout.SOUTH); log.add(jp4,BorderLayout.WEST);jp1.add(jl1,BorderLayout.CENTER); jp2.setLayout(newGridLayout(5,2,20,10)); jp2.add(jl2); jp2.add(t1); jp2.add(jl3);jp2.add(t2); jp2.add(jl4); jp2.add(t3); jp2.add(jl5); jp2.add(t4);jp2.add(jl6); jp2.add(t5); jp2.add(jl7); jp2.add(t6); jp2.add(jl8); jp2.add(t7); jp2.add(jl9); jp2.add(t8); jp2.add(jl10); jp2.add(t9); jp4.add(jb1); BorderLayout bl1=new BorderLayout();bl1.setHgap(38); jp3.setLayout(bl1);jp3.add(jb2,BorderLayout.WEST);jp3.add(jp5,BorderLayout.CENTER); jp5.setLayout(new GridLayout()); jp5.add(jl11); jp5.add(t10);jb1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) {Select sel=new Select(); sel.selectStudent(id);Student student=sel.getStudent();t1.setText(new Integer(student.getId()).toString());t2.setText(student.getName()); t3.setText(student.getSex());32 / 16程序源代码学生学籍管理系统t4.setText(student.getBornDate());t5.setText(student.getNationality());t6.setText(student.getHometown()); t7.setText(student.getMaj());t8.setText(student.getCla());t9.setText(student.getTelNum()); } });jb2.addActionListener(new ActionListener() { @Overridepublic void actionPerformed(ActionEvent e) {String password=StudentGUI.this.t10.getText(); UpdateAndInsert up=new UpdateAndInsert();if(up.updatePassword(id, password)==true) { 佊瑰潩偮湡?桳睯敍獳条?慩潬?瑓摵湥??琮楨?潬? 修改成功); } } });log.addWindowListener(new WindowAdapter() {@Overridepublic void windowClosing(WindowEvent e) {System.exit(0); } }); log.setSize(550,420);log.setLocationRelativeTo(null); log.setResizable(false);log.setVisible(true); } }5.Select.java/* 查询类包括查询的各种方法*/ package ms;import java.sql.*; import java.util.LinkedList;17 / 32程序源代码学生学籍管理系统public class Select {private LinkedList<Integer> studentAllId=null;private LinkedList<String> studentAllPassword=null; private LinkedList<Integer> adminAllId=null;private LinkedList<String> adminAllPassword=null; private Student student=null;private LinkedList<Student> allStudent=null; // 定义MySQL的数据库驱动程序public static final String DBDRIVER =org.gjt.mm.mysql.Driver ; // 定义MySQL数据库的连接地址public static final String DBURL =jdbc:mysql://localhost:3306/studentMS ; 数据库的连接用户名// MySQLpublic static final String DBUSER =oot ; 数据库的连接密码// MySQLpublic static final String DBPASS = systemout ; public Select() {super();this.studentAllId = new LinkedList<Integer>();this.studentAllPassword = new LinkedList<String>(); this.adminAllId = new LinkedList<Integer>();this.adminAllPassword = new LinkedList<String>();this.allStudent = new LinkedList<Student>(); } public LinkedList<Integer> getStudentAllId() {return studentAllId; } public LinkedList<String> getStudentAllPassword() {return studentAllPassword; }public LinkedList<Integer> getAdminAllId() {return adminAllId; }public LinkedList<String> getAdminAllPassword() {return adminAllPassword; }public Student getStudent() {32 / 18程序源代码学生学籍管理系统return student; }public LinkedList<Student> getAllStudent() {return allStudent; } public void setStudentList() //设置studentAllId 和studentAllPassword {Connection conn = null ; // 数据库连接Statement stmt = null ; // 数据库的操作对象ResultSet rs = null ; // 保存查询结果String sql = select id,password from student; try{Class.forName(DBDRIVER) ; // 加载驱动程序}catch(ClassNotFoundException e){ e.printStackTrace() ; }try{conn =DriverManager.getConnection(DBURL,DBUSER,DBPASS) ; }catch(SQLE xception e){ e.printStackTrace() ; } try {stmt = conn.createStatement() ; //得到stmt对象用于执行sql语句} catch (SQLException e1) { e1.printStackTrace(); } try { rs = stmt.executeQuery(sql) ;//保存sql查询结果} catch (SQLException e1) {e1.printStackTrace(); } try {while(rs.next()) {studentAllId.add(rs.getInt(1));studentAllPassword.add(rs.getString(2)); }} catch (SQLException e1) {e1.printStackTrace();19 / 32程序源代码学生学籍管理系统} try{rs.close() ; stmt.close() ;conn.close() ; // 数据库关闭}catch(SQLExceptione){ e.printStackTrace() ; } } public void setAdminList() { Connection conn = null ; // 数据库连接Statement stmt = null ; // 数据库的操作对象ResultSet rs = null ; // 保存查询结果String sql = select id,password from admin; try{Class.forName(DBDRIVER) ; // 加载驱动程序}catch(ClassNotFoundException e){ e.printStackTrace() ; }try{conn =DriverManager.getConnection(DBURL,DBUSER,DBPASS) ; }catch(SQLE xception e){ e.printStackTrace() ; } try {stmt = conn.createStatement() ; //得到stmt对象用于执行sql语句} catch (SQLException e1) {e1.printStackTrace(); } try {rs = stmt.executeQuery(sql) ;//保存sql查询结果} catch (SQLException e1) {e1.printStackTrace(); } try {while(rs.next()) {adminAllId.add(rs.getInt(1));adminAllPassword.add(rs.getString(2)); }} catch (SQLException e1) {20 / 32程序源代码学生学籍管理系统e1.printStackTrace(); } try{rs.close() ; stmt.close() ;conn.close() ; // 数据库关闭}catch(SQLExceptione){ e.printStackTrace() ; } } public boolean selectStudent(String str) {Connection conn = null ; // 数据库连接PreparedStatement pstmt = null ; // 数据库的操作对象ResultSet rs = null ; // 保存查询结果String sql = selectname,sex,bornDate,nationality,hometown,maj,cla,telNum,password +rom student where id=?; try{Class.forName(DBDRIVER) ; // 加载驱动程序}catch(ClassNotFoundException e){ e.printStackTrace() ; }try{conn =DriverManager.getConnection(DBURL,DBUSER,DBPASS) ; }catch(SQLE xception e){ e.printStackTrace() ; } try {pstmt = conn.prepareStatement(sql) ; //得到stmt对象用于执行sql语句} catch (SQLException e1) { e1.printStackTrace(); } try {pstmt.setString(1, str); } catch (SQLException e2) {e2.printStackTrace(); } try {rs = pstmt.executeQuery() ;//保存sql查询结果} catch (SQLException e1) {e1.printStackTrace(); }21 / 32程序源代码学生学籍管理系统try {while(rs.next()) {student=new Student(Integer.parseInt(str), rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4),rs.getString(5), rs.getString(6), rs.getString(7),rs.getString(8), rs.getString(9)); }} catch (SQLException e1) {e1.printStackTrace(); } try{rs.close() ; pstmt.close() ;conn.close() ; // 数据库关闭}catch(SQLExceptione){ e.printStackTrace() ; }if(student !=null) {return true; } else {return false; } } public void selectAllStudent(){ Connection conn = null ; // 数据库连接PreparedStatement pstmt = null ; // 数据库的操作对象ResultSet rs = null ; // 保存查询结果String sql = select * +rom student; try{Class.forName(DBDRIVER) ; // 加载驱动程序}catch(ClassNotFoundException e){ e.printStackTrace() ; }try{conn=DriverManager.getConnection(DBURL,DBUSER,DBPASS) ;32 / 22程序源代码学生学籍管理系统}catch(SQLException e){ e.printStackTrace() ; } try {pstmt = conn.prepareStatement(sql) ; //得到stmt对象用于执行sql语句} catch (SQLException e1) { e1.printStackTrace(); }try {rs = pstmt.executeQuery() ;//保存sql 查询结果} catch (SQLException e1) {e1.printStackTrace(); } try {while(rs.next()) {student=new Student(rs.getInt(1), rs.getString(2),rs.getString(3), rs.getString(4), rs.getString(5),rs.getString(6), rs.getString(7), rs.getString(8),rs.getString(9), rs.getString(10));allStudent.add(student); }} catch (SQLException e1) {e1.printStackTrace(); } try{rs.close() ; pstmt.close() ;conn.close() ; // 数据库关闭}catch(SQLExceptione){ e.printStackTrace() ; } } }32 / 23程序源代码学生学籍管理系统6.UpdateAndInsert.java/*修改&&插入类定义了修改和插入的所有方法*/ package ms; import java.sql.Connection; import java.sql.DriverManager; importjava.sql.SQLException; import java.sql.Statement; public class UpdateAndInsert {// 定义MySQL的数据库驱动程序public static final String DBDRIVER = org.gjt.mm.mysql.Driver ; // 定义MySQL数据库的连接地址public static final String DBURL = jdbc:mysql://localhost:3306/studentMS ; // MySQL数据库的连接用户名public static final String DBUSER =oot ; // MySQL数据库的连接密码public static final String DBPASS = systemout ; public boolean insertStudent (Student student) { String name=student.getName(); String sex=student.getSex(); String bornDate=student.getBornDate(); Stringnationality=student.getNationality(); Stringhometown=student.getHometown(); String maj=student.getMaj(); String cla=student.getCla();String telNum=student.getTelNum(); Stringpassword=student.getPassword(); Connection conn = null ; // 数据库连接Statement stmt = null ; // 数据库操作try { Class.forName(DBDRIVER) ;} catch (ClassNotFoundException e) {// TODO Auto-generated catch block e.printStackTrace(); } // 加载驱动程序String sql = INSERT INTOstudent(name,sex,bornDate,nationality,hometown,maj,cla,telNum,passw ord) +VALUES24 / 32程序源代码学生学籍管理系统('+name+','+sex+','+bornDate+','+nationality+','+hometown+','+maj+', '+cla+','+telNum+','+password+'); try {conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS) ; } catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace(); }try {stmt = conn.createStatement() ; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace();对象实例化} Statement // try {stmt.executeUpdate(sql) ; } catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace();// } 执行数据库更新操作try {关闭操作// stmt.close() ; conn.close() ;} catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace(); // 数据库关闭} return true; } public boolean updateStudent(Student student) {Select sel=new Select(); if(sel.selectStudent(newInteger(student.getId()).toString())==false) {return false; }数据库连接// Connection conn = null ; // 数据库操作Statement stmt = null ; String name=student.getName(); Stringsex=student.getSex();32 / 25程序源代码学生学籍管理系统String bornDate=student.getBornDate(); Stringnationality=student.getNationality(); String hometown=student.getHometown(); String maj=student.getMaj(); Stringcla=student.getCla();String telNum=student.getTelNum(); Stringpassword=student.getPassword(); String sql=UPDATE student SET name='+name+',sex='+sex+',bornDate='+bornDate+',nationality='+na tionality+',hometown='+hometown+',maj='+maj+',cla='+cla+',telNum ='+telNum+',password='+password+' WHERE id=+student.getId() ;try {= conn DriverManager.getConnection(DBURL,DBUSER,DBPASS) ; } catch (SQLException e1) {// TODO Auto-generated catch block e1.printStackTrace(); }try {stmt = conn.createStatement() ; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace();Statement// 实例化对象} try {stmt.executeUpdate(sql) ; } catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace();// } 执行数据库更新操作try {// 关闭操作stmt.close() ; // 数据库关闭conn.close() ; } catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace(); } return true; }32 / 26程序源代码学生学籍管理系统public boolean updatePassword(String id,String newPassword) { Connection conn = null ; // 数据库连接Statement stmt = null ; // 数据库操作String sql=UPDATE student SETpassword='+newPassword+' WHERE id=+id ; try {conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS) ; } catch (SQLException e1) {// TODO Auto-generated catch block e1.printStackTrace(); }try {stmt = conn.createStatement() ; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace();Statement 对象// 实例化} try {stmt.executeUpdate(sql) ; } catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace();执行数据库更新操作} // try {关闭操作// stmt.close() ; conn.close() ; 数据库关闭// } catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace(); } return true; } }7.Delete.java/* 删除类*/* 定义了删除的所有方法32 / 27程序源代码学生学籍管理系统package ms; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class Delete {// 定义MySQL的数据库驱动程序public static final String DBDRIVER = org.gjt.mm.mysql.Driver ; // 定义MySQL数据库的连接地址public static final String DBURL = jdbc:mysql://localhost:3306/studentMS ; //MySQL数据库的连接用户名public static final String DBUSER =oot ; // MySQL数据库的连接密码public static final String DBPASS = systemout ; public boolean delete (String str) {Select sel=new Select();if(sel.selectStudent(str)==false) {return false; }Connection conn = null ; // 数据库连接Statement stmt = null ; // 数据库操作int id = Integer.parseInt(str) ; try {Class.forName(DBDRIVER) ;} catch (ClassNotFoundException e) {// TODO Auto-generated catch block e.printStackTrace(); } // 加载驱动程序String sql = DELETE FROM student WHERE id=+id ; try {conn = DriverManager.getConnection(DBURL,DBUSER,DBPASS) ; } catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace(); }try {stmt = conn.createStatement() ; } catch (SQLException e) {// TODO Auto-generated catch block28 / 32程序源代码学生学籍管理系统e.printStackTrace();} // 实例化Statement对象try {stmt.executeUpdate(sql) ; } catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace();} // 执行数据库更新操作try {stmt.close() ; // 关闭操作conn.close() ; // 数据库关闭} catch (SQLException e) {// TODO Auto-generated catch block e.printStackTrace(); } return true; }}8.Student.java/*学生类*/ package ms; public class Student {private int id=0; //用于存放学号private String name=null; //用于存放学生姓名private String sex=null; //用于存放性别private String bornDate=null; //出生年日期private String nationality=null; //民族private String hometown=null; //用于存放籍贯private String maj=null; //用于存放专业private String cla=null; //用于存放班级private String telNum=null; //用于存放联系电话private String password=null; //用于存放密码public Student(int id, String name, String sex, String bornDate, String nationality, String hometown, String maj, String cla, String telNum, String password) { this.id = id; = name; this.sex = sex;this.bornDate = bornDate; this.nationality = nationality;this.hometown = hometown; this.maj = maj;。
学生学籍管理详细设计学号:___________姓名:___________班级:___________一、设计题目:学生学籍管理二:设计内容:设计GUI 学生学籍管理界面,用户可以加入学生信息,并对基本信息进行修改,添加,查询,删除。
三:设计要求:进行简单的学生信息管理。
四:总体设计(1)登陆界面的设计(2)主窗体的设计(3)添加学生信息窗体(4)查询学生信息窗体(5)修改学生信息窗体(6)删除学生信息窗体(7)事件响应的处理五:具体设计(1)程序结构的说明:A. 入口程序:;B. 登陆界面程序:;C. 主窗体程序:;D. 添加信息窗口程序:;E. 修改信息窗口程序:;F. 查询信息窗口程序:;G. 删除信息窗口程序:;H. 程序数据连接:;(2)程序代码及分析说明 A.程序源代码(已提交) 是程序的入口。
使登录窗口位于窗口中间,并且不可改变窗口大小。
是程序的登陆窗体。
输入用户名和密码(用户名和密码在数据库的password 表中)点击“进入系统” ,然后登陆界面消失;出现要操作的界面(屏幕左上角) 。
是添加信息界面。
添加基本信息后,点击“添加信息”按钮,将信息加入xinxi 表中。
是修改信息界面。
输入要修改的学号或姓名(两者数其一或全部输入) ,并输入所有信息,点击“修改信息”按钮(如果数据库中不存在此学号,则弹出对话框“无此学生信息”),若有则修改。
是删除信息界面。
输入要删除的学生的学号,点击“删除信息”按钮,弹出确认删除对话框,即可删除该生信息。
是查询信息界面。
输入要查询的学生学号,点击“信息查询”按钮,在相应的文本区里显示查询的信息。
H:源代码import .*; etScreenSize();Dimension frameSize=();if> {} if> {}( (true);}public static void main(String[] args){try{ ()); } catch(Exception e) {();}new student();public class DatabaseConn{private static String user="";private static String password="";private Connection conn=null;private Statement stmt=null;private ResultSet rs=null;static{ try{("");.stmt=createStat(); rs=(sql); return rs;}catch(SQLException e){ return null;}} public void close(){try{ if(rs!=null) ();if(stmt!=null)(); if(conn!=null)();}catch(SQLException ex){();}}}import .*;import .*;public class mainframe extends JFrame implements ActionListener {static mainframe s;static JPanel pan=new JPanel();static JLabel label1 = new JLabel用(" 户");static JLabel label2 = new JLabel密(" 码");static JTextField textField1 = new JTextField();static JPasswordField password = new JPasswordField();static JButton button1 = new JButton("进入系统");static JRadioButton radioButton1=new JRadioButton("管理员",true);quals("syc") && ().equals("123")){interfac b=new interfac();();quals()) || "".equals()) ){(null," 用户名或密码不能为空");}else{(null," 用户名或密码输入有误");}}if())quals("")||().equals("")){ (this,"用户名或密码不可为空!");}else if()){ new interfac();}else{(this," 您的输入有误");}import .*;public class interfac extends JFrame implements ActionListener {static JMenuBar jMenuBar = new JMenuBar();;import .*;import .*;public class tj extends JFrame implements ActionListener {static tj s;static JLabel label1 = new JLabel学(" 号:");static JTextField textField1 = new JTextField("");static JLabel label2 = new JLabel(姓" 名:");static JTextField textField2 = new JTextField(""); static JLabel label3 = newJLabel(性" 别:"); static JTextField textField7=new JTextField(""); static JLabellabel4 = new JLabel(出" 生日期:"); static JTextField textField3 = newJTextField(""); static JLabel label5 = new JLabel(政" 治面貌:"); static JTextField textField8=new JTextField(""); static JLabel label6 = new JLabel籍(" 贯");static JTextField textField4 = new JTextField(""); static JLabel label7 = newJLabel(系" 别:");static JTextField textField9 = new JTextField(""); static JLabel label8 = newJLabel专(" 业:");static JTextField textField5 = new JTextField(""); static JButton button1 = new JButton("增加");public tj(){(" 增加学生信息");(null);(400,400) ; (30, 11, 51, 33); (86, 16, 74, 22); (162, 11, 51, 33); (192, 16, 44,22); (241, 11, 70, 33); (275, 15, 50, 25); (31, 53, 55, 33); (86, 58, 74, 22); (241,53, 70, 33); (296, 57, 72, 25); (163, 53, 26, 33); (191, 58, 44, 22); (30, 94, 50,33);(86,94,74,22) ; (163, 94, 51, 33); (190, 99, 178, 22);(25,241,80,33) ; (this);(label1);(label2);(label3);(label4);(label5);(label6);(label7);(label8);(textField1); (textField2); (textField3); (textField4); (textField5); (textField7);(textField8); (textField9); (button1);(true);}public static void main(String[] args) throws Exception { tj a= new tj();}public void actionPerformed(ActionEvent e);import .*;import .*;public class xg extends JFrame implements ActionListener {static JLabel label1 = new JLabel学(" 号:");static JTextField textField1 = new JTextField("");static JLabel label2 = new JLabel(姓" 名:");static JTextField textField2 = new JTextField("");static JLabel label3 = new JLabel(性" 别:");static JTextField textField7=new JTextField("");static JLabel label4 = new JLabel(出" 生日期:"); static JTextField textField3 = new JTextField("");static JLabel label5 = new JLabel(政" 治面貌:");static JTextField textField8=new JTextField("");static JLabel label6 = new JLabel籍(" 贯");static JTextField textField4 = new JTextField("");static JLabel label7 = new JLabel(系" 别:");static JTextField textField9 = new JTextField(""); static JLabel label8 = new JLabel专(" 业:");static JTextField textField5 = new JTextField(""); static JButton button2=new JButton("修改"); public xg(){(" 修改学生信息");(null);(400,400) ;(30, 11, 51, 33);(86, 16, 74, 22);(162, 11, 51, 33);(192, 16, 44, 22);(241, 11, 70, 33);(275, 15, 50, 25);(31, 53, 55, 33);(86, 58, 74, 22);(241, 53, 70, 33);(296, 57, 72, 25);(163, 53, 26, 33);(191, 58, 44, 22);(30, 94, 50, 33);(86,94,74,22) ;(163, 94, 51, 33);(190, 99, 178, 22);(115,241,80,33) ;(this);(label1);(label2);(label4); (label5); (label6); (label7); (label8); (textField1); (textField2); (textField3); (textField4); (textField5); (textField7); (textField8); (textField9); (button2);(true);}public static void main(String[] args) throws Exception{ xg a=new xg();}public void actionPerformed(ActionEvent e)rim().equals("")){(this,"学号不可为空!");}else if()) {String updateSql="update xinxi set 学号='"+()+"', 姓名='"+()+"',性别='"+()+"',出生日期='"+()+"', 政治面貌='"+()+"',籍贯='"+()+"',系别='"+()+"',专业='"+()+ "'";try{(updateSql);}catch(SQLException se) {(null,"修改成功");}}}catch(SQLException se){(s,());}}import .*;import .*;public class sc extends JFrame implements ActionListener {static sc s;static JLabel label1 = new JLabel学(" 号:");static JTextField textField1 = new JTextField("");static JLabel label2 = new JLabel(姓" 名:");static JTextField textField2 = new JTextField("");static JLabel label3 = new JLabel(性" 别:");static JTextField textField7=new JTextField("");static JLabel label4 = new JLabel(出" 生日期:"); static JTextField textField3 = new JTextField("");static JLabel label5 = new JLabel(政" 治面貌:");static JTextField textField8=new JTextField("");static JLabel label6 = new JLabel籍(" 贯");static JTextField textField4 = new JTextField("");static JLabel label7 = new JLabel(系" 别:");static JTextField textField9 = new JTextField("");static JLabel label8 = new JLabel专(" 业:");static JTextField textField5 = new JTextField(""); static JButton button4=new JButton("删除");public sc() throws Exception{(" 删除学生信息");(null);(400,400) ;(30, 11, 51, 33);(86, 16, 74, 22);(162, 11, 51, 33);(192, 16, 44, 22);(241, 11, 70, 33);(275, 15, 50, 25);(31, 53, 55, 33);(86, 58, 74, 22);(241, 53, 70, 33);(296, 57, 72, 25);(163, 53, 26, 33);(191, 58, 44, 22);(30, 94, 50, 33);(86,94,74,22) ;(163, 94, 51, 33);(190, 99, 178, 22);(295,241,80,33) ;(this);(label1);(label2);(label3);(label4);(label5);(label6);(label7);(label8);(textField1);(textField2);(textField3);(textField4);(textField5);(textField7);(textField8);(textField9);(button4);(true);}public static void main(String[] args) throws Exception{sc a= new sc();}public void actionPerformed(ActionEvent e)rim().equals("")){(this,"学号不可为空!");}else if()){(null," 确定要删除该信息嘛\n 删除的信息将不能恢复,继续","删除确定",;;import .*;import .*;public class cx extends JFrame implements ActionListener{static cx s;static JLabel label1 = new JLabel学(" 号:"); static JTextField textField1 = new JTextField(""); static JLabel label2 = new JLabel(姓" 名:");static JTextField textField2 = new JTextField(""); static JLabel label3 = new JLabel(性" 别:");static JTextField textField7=new JTextField(""); static JLabel label4 = new JLabel(出" 生日期:"); static JTextField textField3 = new JTextField(""); static JLabel label5 = new JLabel(政" 治面貌:"); static JTextField textField8=new JTextField(""); static JLabel label6 = new JLabel籍(" 贯");static JTextField textField4 = new JTextField(""); static JLabel label7 = new JLabel(系" 别:");static JTextField textField9 = new JTextField(""); static JLabel label8 = new JLabel专(" 业:");static JTextField textField5 = new JTextField(""); static JButton button3=new JButton("查询");public cx() throws Exception{(" 查询学生信息");(null);(400,400) ;(30, 11, 51, 33);(86, 16, 74, 22);(162, 11, 51, 33);(192, 16, 44, 22);(241, 11, 70, 33);(275, 15, 50, 25);(31, 53, 55, 33);(86, 58, 74, 22);(241, 53, 70, 33);(296, 57, 72, 25);(163, 53, 26, 33); (191,58, 44, 22);(30, 94, 50, 33);(86,94,74,22) ;(163, 94, 51, 33); (190, 99, 178, 22);(205,241,80,33) ;(this);(label1);(label2);(label3);(label4);(label5);(label6);(label7);(label8);(textField1); (textField2); (textField3); (textField4); (textField5); (textField7);(textField8); (textField9); (button3);(true);}public static void main(String[] args) throws Exception {cx a=new cx();}public void actionPerformed(ActionEvent e){ if()==button3){try{("");}catch (ClassNotFoundException ce){(s,());}try{Connection con = ("jdbc:odbc:stu","sa",""); Statement stmt = ();ResultSet rs=("select * from xinxi where 学号='"+()+"'");if().trim().equals("")){(this,"学号不可为空!");else if()){ ("姓名")); ("性别")); ("出生日期")); ("政治面貌")); ("籍贯"));("系别")); ("专业"));}else{(this,"无此记录!!!");}}catch (SQLException se){(s,());}}}}I. 运行说明在DOS 窗口输入javacjava student 运行程序。