学生学籍管理系统(含java源代码)
(完整版)学生学籍管理系统(含java源代码)

学生学籍管理详细设计学号:____________姓名:____________班级:____________一、设计题目:学生学籍管理二:设计内容:设计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源代码

学生信息管理系统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);}}。
Java课程设计-学籍管理系统代码

//Student_Management_System.java//JHelpTextPanel.javaimport java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;import java.io.*;//定义帮助文档类class JHelpTextPanel extends JPanel{Font newSmallTitleFont=new Font("楷体",Font.BOLD,12);JTextArea HelpText=new JTextArea();JHelpTextPanel(){setLayout(null);setBackground(Color.orange);HelpText.setBackground(Color.orange);HelpText.setForeground(Color.red);HelpText.setFont(newSmallTitleFont);HelpText.setBounds(0,0,600,600);add(HelpText);}}//Student_InforPanel .javaimport java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;import java.io.*;class Student_InforPanel extends JPanel implements ActionListener {//四种常用字体的定义Font newTitleFont=new Font("楷体",Font.BOLD,40);Font newSmallTitleFont=new Font("楷体",Font.BOLD,25);Font newCommonFont=new Font("宋体",Font.BOLD,20);Font newSubMenuFont=new Font("宋体",Font.BOLD,15);Font NewSubMenuFont=new Font("宋体",Font.BOLD,10);//性别数组定义String os[]={" 男 "," 女 "};//定义确认对话框图标ImageIcon thinker=new ImageIcon("ICON//thinker.gif");//定义学生信息管理系统面板菜单控件JLabel StudentSno_Clue=new JLabel("学号:");JLabel StudentName_Clue=new JLabel("姓名:");JLabel StudentSex_Clue=new JLabel("性别:");JLabel StudentAge_Clue=new JLabel("年龄:");JLabel StudentClass_Clue=new JLabel("班级:");JLabel StudentDept_Clue=new JLabel("系别:");JTextField StudentSno_Input=new JTextField();JTextField StudentName_Input=new JTextField();ComboBoxModel Othermode=new OtherAModel();JComboBox StudentSex_Input=new JComboBox(Othermode);JTextField StudentAge_Input=new JTextField();JTextField StudentClass_Input=new JTextField();JTextField StudentDept_Input=new JTextField();JTextArea QueryInforShow=new JTextArea();JLabel QueryClue=new JLabel("以下是你要查询的学生信息:"); JButton Add_StudentInformation=new JButton("增加学生信息");JButton Del_StudentInformation=new JButton("删除学生信息");JButton Query_StudentInformation=new JButton("查询学生信息");JButton Modify_StudentInformation=new JButton("修改学生信息");//定义变量int ValidAge;String SnoOrigin;Student_InforPanel(){setBackground(Color.orange);QueryInforShow.setBackground(Color.orange);setLayout(null);StudentSno_Clue.setBounds(270,120,80,30);StudentSno_Clue.setFont(newCommonFont);StudentSno_Input.setBounds(350,120,120,30);StudentName_Clue.setBounds(270,170,80,30);StudentName_Clue.setFont(newCommonFont);StudentName_Input.setBounds(350,170,120,30);StudentSex_Clue.setBounds(270,220,80,30);StudentSex_Clue.setFont(newCommonFont);StudentSex_Input.setBounds(350,220,120,30);StudentAge_Clue.setBounds(270,270,80,30);StudentAge_Clue.setFont(newCommonFont);StudentAge_Input.setBounds(350,270,120,30); StudentClass_Clue.setBounds(270,320,80,30); StudentClass_Clue.setFont(newCommonFont);StudentClass_Input.setBounds(350,320,120,30); StudentDept_Clue.setBounds(270,370,80,30);StudentDept_Clue.setFont(newCommonFont);StudentDept_Input.setBounds(350,370,120,30);Query_StudentInformation.setBounds(80,120,130,30); Query_StudentInformation.setFont(newSubMenuFont);Query_StudentInformation.addActionListener(this); QueryClue.setBounds(80,180,300,50);QueryClue.setFont(newSubMenuFont);QueryInforShow.setBounds(80,220,530,100); QueryInforShow.setFont(newSubMenuFont);Del_StudentInformation.setBounds(80,120,130,30);Del_StudentInformation.setFont(newSubMenuFont);Del_StudentInformation.addActionListener(this);Add_StudentInformation.setBounds(80,170,130,30);Add_StudentInformation.setFont(newSubMenuFont);Add_StudentInformation.addActionListener(this);Modify_StudentInformation.setBounds(80,220,130,30); Modify_StudentInformation.setBounds(80,220,130,30); Modify_StudentInformation.setFont(newSubMenuFont); Modify_StudentInformation.addActionListener(this);add(StudentSno_Clue);add(StudentSno_Input);add(StudentName_Clue);add(StudentName_Input);add(StudentSex_Clue);add(StudentSex_Input);add(StudentAge_Clue);add(StudentAge_Input);add(StudentClass_Clue);add(StudentClass_Input);add(StudentDept_Clue);add(StudentDept_Input);add(QueryClue);add(QueryInforShow);add(Add_StudentInformation);add(Del_StudentInformation);add(Query_StudentInformation);add(Modify_StudentInformation);}public void actionPerformed(ActionEvent e){if(e.getSource()==Add_StudentInformation){if(IsValidAge(StudentAge_Input.getText())){String ***=(String)StudentSex_Input.getSelectedItem();MainMenu.myDatabase.Add_Database_Information(StudentSno_Input.ge tText(),StudentName_Input.getText(),***,ValidAge,StudentClass_Input.getT ext(),StudentDept_Input.getText());emptyInput();}}if(e.getSource()==Del_StudentInformation){QueryInforShow.setText("");if(MainMenu.myDatabase.Query_Database_Information(Studen tSno_Input.getText())){QueryInforShow.setText(DataBaseControl.temptInformation);int result=JOptionPane.showConfirmDialog(null,"你确定要删除该生信息吗?","ConfirmMessage",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE,think er);if(result==JOptionPane.YES_OPTION){if(MainMenu.myDatabase.Del_Database_Information(St udentSno_Input.getText()))JOptionPane.showMessageDialog(null,"删除操作成功!","Happy Message",JOptionPane.PLAIN_MESSAGE);elseJOptionPane.showMessageDialog(null,"数据库操作出现异常,删除操作失败!","Error Message",JOptionPane.ERROR_MESSAGE);}}elseQueryInforShow.setText("对不起,没有找到你要删除的学生信息.");}if(e.getSource()==Query_StudentInformation){QueryInforShow.setText("");if(MainMenu.myDatabase.Query_Database_Information(Stud entSno_Input.getText()))QueryInforShow.setText(DataBaseControl.temptInformatio n);elseQueryInforShow.setText("对不起,没有你想要查询的学生信息");}if(e.getSource()==Modify_StudentInformation){if(IsValidAge(StudentAge_Input.getText()))MainMenu.myDatabase.Modify_Database_Information(SnoOri gin,StudentSno_Input.getText(),StudentName_Input.getText(),ValidAge,StudentClass_Inpu t.getText(),StudentDept_Input.getText());}}public boolean IsValidAge(String StringAge){try{ValidAge=Integer.parseInt(StringAge);}catch(NumberFormatException e){e.printStackTrace();return false;}if(ValidAge<=120&ValidAge>0)return true;else{JOptionPane.showMessageDialog(null,"你输入的年龄不合实际情况\n 请重新输入!","WARNING MESSAGE",JOptionPane.WARNING_MESSAGE);return false;}}class OtherAModel extends DefaultComboBoxModel{OtherAModel(){for(int i=0;i<os.length;i++)addElement(os[i]);}}public void emptyInput(){StudentSno_Input.setText("");StudentAge_Input.setText("");StudentName_Input.setText("");StudentClass_Input.setText("");StudentDept_Input.setText("");}public void OnlyShowSno(){StudentSno_Clue.setVisible(true);StudentSno_Input.setVisible(true);StudentSno_Input.setText("");QueryClue.setVisible(true);QueryInforShow.setVisible(true);StudentName_Clue.setVisible(false);StudentName_Input.setVisible(false);StudentSex_Clue.setVisible(false);StudentSex_Input.setVisible(false);StudentAge_Clue.setVisible(false);StudentAge_Input.setVisible(false);StudentClass_Clue.setVisible(false);StudentClass_Input.setVisible(false);StudentDept_Clue.setVisible(false);StudentDept_Input.setVisible(false);}//显示学生信息的所有面板控件public void ShowWhole(){StudentSno_Clue.setVisible(true);StudentSno_Input.setVisible(true);StudentSno_Input.setText("");QueryClue.setVisible(false);QueryInforShow.setVisible(false);StudentName_Clue.setVisible(true);StudentName_Input.setVisible(true);StudentName_Input.setText("");StudentSex_Clue.setVisible(true);StudentSex_Input.setVisible(true);StudentAge_Clue.setVisible(true);StudentAge_Input.setVisible(true);StudentAge_Input.setText("");StudentClass_Clue.setVisible(true);StudentClass_Input.setVisible(true);StudentClass_Input.setText("");StudentDept_Clue.setVisible(true);StudentDept_Input.setVisible(true);StudentDept_Input.setText("");}}//Student_ScorePanel.javaimport java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;class Student_ScorePanel extends JPanel implements ActionListener {//三种常用字体的定义Font newTitleFont=new Font("楷体",Font.BOLD,40);Font newSmallTitleFont=new Font("楷体",Font.BOLD,25);Font newCommonFont=new Font("宋体",Font.BOLD,20);Font newSubMenuFont=new Font("宋体",Font.BOLD,15);Font NewSubMenuFont=new Font("宋体",Font.BOLD,10);//定义确认对话框图标ImageIcon thinker=new ImageIcon("ICON//thinker.gif");JLabel ScoreSno_Clue=new JLabel("学号:");JLabel ScoreEnglish_Clue=new JLabel("英语:");JLabel ScoreSeniorMath_Clue=new JLabel("高数:");JLabel ScoreC_Clue=new JLabel("C:");JLabel ScoreVC_Clue=new JLabel("VC:");JLabel ScoreJAVA_Clue=new JLabel("JAVA:");JTextField ScoreSno_Input=new JTextField();JTextField ScoreEnglish_Input=new JTextField();JTextField ScoreSeniorMath_Input=new JTextField();JTextField ScoreC_Input=new JTextField();JTextField ScoreVC_Input=new JTextField();JTextField ScoreJAVA_Input=new JTextField();JTextArea ScoreShow=new JTextArea();JLabel ScoreShowClue=new JLabel("你要查询的学生成绩信息为:");JButton Add_ScoreInformation=new JButton("增加学生成绩");JButton Del_ScoreInformation=new JButton("删除学生成绩");JButton Query_ScoreInformation=new JButton("查询学生成绩");JButton Modify_ScoreInformation=new JButton("修改学生成绩");//定义变量int ValidScore;String ScoreSno;Student_ScorePanel(){//学生成绩管理面板设置控件setBackground(Color.orange);ScoreShow.setBackground(Color.orange);setLayout(null);ScoreSno_Clue.setBounds(270,120,80,30);ScoreSno_Clue.setFont(newCommonFont);ScoreSno_Input.setBounds(350,120,120,30);ScoreEnglish_Clue.setBounds(270,170,80,30);ScoreEnglish_Clue.setFont(newCommonFont);ScoreEnglish_Input.setBounds(350,170,120,30);ScoreSeniorMath_Clue.setBounds(270,220,80,30); ScoreSeniorMath_Clue.setFont(newCommonFont); ScoreSeniorMath_Input.setBounds(350,220,120,30);ScoreC_Clue.setBounds(270,270,80,30);ScoreC_Clue.setFont(newCommonFont);ScoreC_Input.setBounds(350,270,120,30);ScoreVC_Clue.setBounds(270,320,80,30);ScoreVC_Clue.setFont(newCommonFont);ScoreVC_Input.setBounds(350,320,120,30);ScoreJAVA_Clue.setBounds(270,370,80,30);ScoreJAVA_Clue.setFont(newCommonFont);ScoreJAVA_Input.setBounds(350,370,120,30);Query_ScoreInformation.setBounds(80,120,130,30);Query_ScoreInformation.setFont(newSubMenuFont);Query_ScoreInformation.addActionListener(this); ScoreShowClue.setFont(newSubMenuFont);ScoreShowClue.setBounds(80,180,300,50);ScoreShow.setFont(newSubMenuFont);ScoreShow.setBounds(80,220,530,100);Del_ScoreInformation.setBounds(80,120,130,30);Del_ScoreInformation.setFont(newSubMenuFont);Del_ScoreInformation.addActionListener(this);Add_ScoreInformation.setBounds(80,170,130,30);Add_ScoreInformation.setFont(newSubMenuFont);Add_ScoreInformation.addActionListener(this);Modify_ScoreInformation.setBounds(80,220,130,30);Modify_ScoreInformation.setFont(newSubMenuFont);Modify_ScoreInformation.addActionListener(this);add(ScoreSno_Clue);add(ScoreSno_Input);add(ScoreEnglish_Clue);add(ScoreEnglish_Input);add(ScoreSeniorMath_Clue);add(ScoreC_Clue);add(ScoreSeniorMath_Input);add(ScoreC_Input);add(ScoreVC_Clue);add(ScoreVC_Input);add(ScoreJAVA_Clue);add(ScoreJAVA_Input);add(ScoreShow);add(ScoreShowClue);add(Add_ScoreInformation);add(Del_ScoreInformation);add(Query_ScoreInformation);add(Modify_ScoreInformation);}public void actionPerformed(ActionEvent e){if(e.getSource()==Query_ScoreInformation)//查询按纽事件触发处理{if(MainMenu.myDatabase.QueryScoreFunction(ScoreSno_Input.getText ())){ScoreShow.setText("");ScoreShow.append("学号\t\t英语\t高数\tC\tVC\tJAVA\n");ScoreShow.append(MainMenu.myDatabase.Student_Score[MainMenu.my Database.NowScoreNum]);}else{ScoreShow.setText("");ScoreShow.setText("对不起,没有你想要查找的学生信息!");}}if(e.getSource()==Add_ScoreInformation)//增加学生成绩信息按纽的时间触发{if(IsValidScore(ScoreEnglish_Input.getText())&&IsValidScore(Scor eSeniorMath_Input.getText())&&IsValidScore(ScoreC_Input.getText())&&IsValidScore(ScoreVC_Input.getText()) &&IsValidScore(ScoreJAVA_Input.getText())){IsValidScore(ScoreEnglish_Input.getText());int englishscore=ValidScore;IsValidScore(ScoreSeniorMath_Input.getText());int seniorscore=ValidScore;IsValidScore(ScoreC_Input.getText());int cscore=ValidScore;IsValidScore(ScoreVC_Input.getText());int vcscore=ValidScore;IsValidScore(ScoreJAVA_Input.getText());int javascore=ValidScore;MainMenu.myDatabase.addStudentScoreInformation(ScoreSno_Inpu t.getText(),englishscore,seniorscore, cscore, vcscore, javascore);emptyInput();}}if(e.getSource()==Del_ScoreInformation)//删除学生成绩信息事件触发处理{if(MainMenu.myDatabase.QueryScoreFunction(ScoreSno_Input.getText ())){ScoreShow.setText("");ScoreShow.append("学号\t\t英语\t高数\tC\tVC\tJAVA\n");ScoreShow.append(MainMenu.myDatabase.Student_Score[MainMenu.my Database.NowScoreNum]);int result=JOptionPane.showConfirmDialog(null,"你真的要删除该学生的成绩信息吗?","Confirm Message",JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,thinker);if(result==JOptionPane.YES_OPTION)MainMenu.myDatabase.DelScoreFunction(ScoreSno_Input.getText( ));}else{ScoreShow.setText("");ScoreShow.setText("对不起,你要删除的学生成绩信息不存在!");}}if(e.getSource()==Modify_ScoreInformation)//修改数据库中学生成绩信息事件的触发{if(IsValidScore(ScoreEnglish_Input.getText())&&IsValidScore(Scor eSeniorMath_Input.getText())&&IsValidScore(ScoreC_Input.getText())&&IsValidScore(ScoreVC_Input.getT ext())&&IsValidScore(ScoreJAVA_Input.getText())){IsValidScore(ScoreEnglish_Input.getText());int englishscore=ValidScore;IsValidScore(ScoreSeniorMath_Input.getText());int seniorscore=ValidScore;IsValidScore(ScoreC_Input.getText());int cscore=ValidScore;IsValidScore(ScoreVC_Input.getText());int vcscore=ValidScore;IsValidScore(ScoreJAVA_Input.getText());int javascore=ValidScore;MainMenu.myDatabase.ModifyStudentScoreInformation(Scor eSno_Input.getText(),ScoreSno,englishscore,seniorscore, cscore, vcscore, javascore);emptyInput();}}}public boolean IsValidScore(String stringAge)//判断成绩输入是否合法{try{ValidScore=Integer.parseInt(stringAge);}catch(NumberFormatException e){JOptionPane.showMessageDialog(null,"成绩输入中含有非法字符!","ERROR MESSAGE",JOptionPane.ERROR_MESSAGE);return false;}if(ValidScore>100||ValidScore<0){JOptionPane.showMessageDialog(null,"分数只能在0~100之间的整数!","ERROR MESSAGE",JOptionPane.ERROR_MESSAGE);return false;}return true;}//只显示学生成绩面板中学号相关控件public void ScoreShowOnlySno(){ScoreSno_Clue.setVisible(true);ScoreSno_Input.setVisible(true);ScoreSno_Input.setText("");ScoreShowClue.setVisible(true);ScoreShow.setVisible(true);ScoreEnglish_Clue.setVisible(false);ScoreEnglish_Input.setVisible(false);ScoreEnglish_Input.setText("");ScoreSeniorMath_Clue.setVisible(false);ScoreSeniorMath_Input.setVisible(false);ScoreSeniorMath_Input.setText("");ScoreC_Clue.setVisible(false);ScoreC_Input.setVisible(false);ScoreC_Input.setText("");ScoreVC_Clue.setVisible(false);ScoreVC_Input.setVisible(false);ScoreVC_Input.setText("");ScoreJAVA_Clue.setVisible(false);ScoreJAVA_Input.setVisible(false);ScoreJAVA_Input.setText("");}public void emptyInput()//清空成绩输入控件{ScoreSno_Input.setText("");ScoreEnglish_Input.setText("");ScoreSeniorMath_Input.setText("");ScoreC_Input.setText("");ScoreVC_Input.setText("");ScoreJAVA_Input.setText("");}//显示学生成绩面板中所有控件public void ScoreShowWhole(){ScoreSno_Clue.setVisible(true);ScoreSno_Input.setVisible(true);ScoreShowClue.setVisible(false);ScoreShow.setVisible(false);ScoreEnglish_Clue.setVisible(true);ScoreEnglish_Input.setVisible(true);ScoreSeniorMath_Clue.setVisible(true);ScoreSeniorMath_Input.setVisible(true);ScoreC_Clue.setVisible(true);ScoreC_Input.setVisible(true);ScoreVC_Clue.setVisible(true);ScoreVC_Input.setVisible(true);ScoreJAVA_Clue.setVisible(true);ScoreJAVA_Input.setVisible(true);}}//DataBaseControl.javaimport java.awt.*;import javax.swing.*;import java.io.*;import java.sql.*;import java.awt.event.*;import java.util.*;//数据库操作class DataBaseControl{//private String s="";//登录用户信息String UserRealName;String UserSex;int UserAge;String UserClass;String UserDept;//类中公有变量类型变量String LoginName="";String PW="";int Rank;final int MaxNum=20;String Student_Information[]=new String[MaxNum];String Student_Score[]=new String[MaxNum];String[] Database_Score={"学号","英语","高数","C","VC","JAVA"}; String[] Database_Information={"学号","姓名","性别","年龄","班级","系别"};int NowScoreNum;int NowInformationNum;static String temptInformation="";private Connection con1;private Statement st1;String str;public void init(String UserName,String PassWord,int i){LoginName=UserName;PW=PassWord;Rank=i;}public boolean ConnectDataBase()//连接数据源{try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundException e){System.out.println("Driver not found!");return false;}try{con1=DriverManager.getConnection("jdbc:odbc:学生管理数据库");st1=con1.createStatement();}catch(SQLException e){System.out.println("Data Source not found!");return false;}return true;}public int QueryUserLogin()//用户身份验证{int i=0;if(ConnectDataBase()){try{ResultSet rs1=st1.executeQuery("select* from UserLogin where 用户名='"+LoginName+"'");while(rs1.next()){if((rs1.getString(3).equals(PW))&&(rs1.getInt(4) ==Rank)){JOptionPane.showMessageDialog(null,"登录成功!\n"+rs1.getString(2)+"欢迎你使用学生管理系统","Happy Message",JOptionPane.PLAIN_MESSAGE);if(Rank==1)return 1;elsereturn 2;}//end-ifi++;}//end-whileif(i==0){JOptionPane.showMessageDialog(null,"该用户不存在!","Error Message",JOptionPane.ERROR_MESSAGE);}else{JOptionPane.showMessageDialog(null,"你的密码或者用户登级有误!","Error Message",JOptionPane.ERROR_MESSAGE);}Close_database();}catch(SQLException e1){System.out.println(e1.toString());return 0;}}//end-ifreturn 0;}public void ChangeUserPW(String newPW)//修改用户密码{if(ConnectDataBase()){try{st1.executeUpdate("UPDATE UserLogin SET 用户密码='"+newPW+"' where 用户名='"+LoginName+"'");Close_database();}catch(SQLException e){System.out.println(e.toString());JOptionPane.showMessageDialog(null,"对数据库操作发生错误!","ERROR MESSAGE",JOptionPane.ERROR_MESSAGE);return;}JOptionPane.showMessageDialog(null,"修改密码成功!\n请记住你的新密码.","SucessfulMessage",JOptionPane.PLAIN_MESSAGE);}}public void ShowUserInformation()//显示用户信息{if(ConnectDataBase()){try{ResultSet sr=st1.executeQuery("select* from UserBasicInformation where 用户名='"+LoginName+"'");while(sr.next()){UserRealName=sr.getString(2);UserSex=sr.getString(3);UserAge=sr.getInt(4);UserClass=sr.getString(5);UserDept=sr.getString(6);}Close_database();}catch(SQLException e){System.out.println("Error!!");}}//end-if}public void DeleteUser()//注销帐户{String str1;if(ConnectDataBase()){try{str1="DELETE FROM UserLogin where 用户名='"+LoginName+"'";str="DELETE FROM UserBasicInformation where 用户名='"+LoginName+"'";st1.executeUpdate(str1);st1.executeUpdate(str);Close_database();//关闭数据库连接}catch(SQLException e){System.out.println("Error!!");}}JOptionPane.showMessageDialog(null,"注销帐户成功!","HappyMessage",JOptionPane.PLAIN_MESSAGE);}///////////////////////////////////////学生信息处理函数//////////////////////////////////////////////////////public void show_DataBase_Information()//显示数据库中学生的个人基本信息{String Information;if(ConnectDataBase()){try{str="SELECT* FROM Student_Basic_Information";ResultSet s1=st1.executeQuery(str);int i=0;while(s1.next()){if(i>MaxNum)break;Information=s1.getString(1)+"\t"+s1.getString(2)+"\t"+s1.g etString(3)+"\t"+s1.getLong(4)+"\t"+s1.getString(5)+"\t"+s1.getString(6)+"\n";Student_Information[i]=Information;i++;}NowInformationNum=i;Close_database();}catch(SQLException e){System.out.println(e.toString());}}}public boolean Query_Database_Information(String sno)//显示查询数据库中学生信息{if(ConnectDataBase()){try{str="select* from Student_Basic_Information where 学号='"+sno+"'";ResultSet s1=st1.executeQuery(str);int i=0;while(s1.next()){temptInformation=s1.getString(1)+"\t"+s1.getString(2)+"\t" +s1.getString(3)+"\t"+s1.getLong(4)+"\t"+s1.getString(5)+"\t"+s1.getString(6)+"\n";i++;}Close_database();if(i>0)return true;}catch(SQLException e){e.printStackTrace();return false;}}return false;}public void Add_Database_Information(String sno,String name,String ***,int age,String classname,String dept){//向数据库中加入新生的基本信息if(ConnectDataBase()){try{str="INSERT INTOStudent_Basic_Information"+"(学号,姓名,性别,年龄,班级,系别)";str=str+"VALUES('"+sno+"','"+name+"',' "+***+"',"+age+",'"+classname+"','"+dept+"')";st1.executeUpdate(str);Close_database();}catch(SQLException e){e.printStackTrace();return;}JOptionPane.showMessageDialog(null,"加入新生记录操作成功!","HAPPY MESSAGE",JOptionPane.PLAIN_MESSAGE);}}public boolean Del_Database_Information(String sno)//删除数据库中某个学生的基本信息{if(ConnectDataBase()){try{str="DELETE FROM Student_Basic_Information WHERE 学号='"+sno+"'";st1.executeUpdate(str);Close_database();}catch(SQLException e){e.printStackTrace();return false;}return true;}return false;}public void Modify_Database_Information(String sno,Stringsno1,String name,int age,String classname,String dept){//修改数据库中学生基本信息if(ConnectDataBase()){try{str="update Student_Basic_Information set 学号='"+sno1+"' where 学号='"+sno+"'";st1.executeUpdate(str);str="update Student_Basic_Information set 姓名='"+name+"' where 学号='"+sno1+"'";st1.executeUpdate(str);str="update Student_Basic_Information set 年龄="+age+" where 学号='"+sno1+"'";st1.executeUpdate(str);str="update Student_Basic_Information set 班级='"+classname+"' where 学号='"+sno1+"'";st1.executeUpdate(str);str="update Student_Basic_Information set 系别='"+dept+"' where 学号='"+sno1+"'";st1.executeUpdate(str);Close_database();}catch(SQLException e){e.printStackTrace();return;}JOptionPane.showMessageDialog(null,"修改学生信息记录操作成功!","HAPPY MESSAGE",JOptionPane.PLAIN_MESSAGE);}}////////////////////////////////////////学生成绩函数///////////////////////////////////////////////public void show_DataBase_Score()//显示数据库中学生的成绩信息{String score;if(ConnectDataBase()){try{int i=0;str="SELECT* FROM StudentScore";ResultSet s2=st1.executeQuery(str);while(s2.next()){if(i>MaxNum)break;score=s2.getString(1)+"\t"+s2.getLong(2)+"\t"+s2.g etLong(3)+"\t"+s2.getLong(4)+"\t"+s2.getLong(5)+"\t"+s2.getLong(6)+"\n";Student_Score[i]=score;i++;}NowScoreNum=i;Close_database();}catch(SQLException e){System.out.println(e.toString());}}}public boolean QueryScoreFunction(String SnoN){//根据学号查询学生的成绩信息String score;boolean find=false;if(ConnectDataBase()){try{str="SELECT* FROM StudentScore WHERE 学号='"+SnoN+"'";ResultSet s2=st1.executeQuery(str);while(s2.next()){find=true;score=s2.getString(1)+"\t"+s2.getLong(2)+"\t"+s2.getLong (3)+"\t"+s2.getLong(4)+"\t"+s2.getLong(5)+"\t"+s2.getLong(6);Student_Score[NowScoreNum]=score;}Close_database();}catch(SQLException e){e.printStackTrace();}}if(find)return true;elsereturn false;}public void addStudentScoreInformation(String sno,int englishscore,int seniorscore,int cscore,int vcscore,int javascore){//加入学生的成绩信息if(ConnectDataBase()){try{str="INSERT INTO StudentScore"+"(学号,英语,高数,C,VC,JAVA)";str=str+"VALUES('"+sno+"',"+englishscore+","+seniorscore+","+cscore+","+vcscore+","+javascore+")";st1.executeUpdate(str);Close_database();}catch(SQLException e){JOptionPane.showMessageDialog(null,"数据库操作发生异常\n加入学生成绩记录操作失败!","ERROR MESSAGE",JOptionPane.ERROR_MESSAGE);return;}JOptionPane.showMessageDialog(null,"加入新生记录操作成功!","HAPPY MESSAGE",JOptionPane.PLAIN_MESSAGE);}}public void DelScoreFunction(String sno){//删除学生的成绩信息if(ConnectDataBase()){try{str="DELETE FROM StudentScore WHERE 学号='"+sno+"'";st1.executeUpdate(str);}catch(SQLException e){JOptionPane.showMessageDialog(null,"数据库操作发生异常\n删除学生成绩记录操作失败!","ERROR MESSAGE",JOptionPane.PLAIN_MESSAGE);return;}JOptionPane.showMessageDialog(null,"删除学生成绩记录操作成功!","HAPPY MESSAGE",JOptionPane.PLAIN_MESSAGE);}}public void ModifyStudentScoreInformation(String sno1,String sno,int englishscore,int seniorscore,int cscore,int vcscore,int javascore)//修改数据库中学生成绩信息{if(ConnectDataBase()){try{str="update StudentScore set 学号='"+sno1+"' where 学号='"+sno+"'";st1.executeUpdate(str);str="update StudentScore set 英语="+englishscore+" where 学号。
javaweb学生管理系统源代码介绍

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学⽣信息管理系统源代码本⽂实例为⼤家分享了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学籍管理系统源代码

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();}}。
(完整版)JAVA学生管理系统源代码

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 程序设计 课程设计陈述宇文皓月课 题: 学生信息管理系统 姓 名: 学 号: 同组姓名: 专业班级: 指导教师: 设计时间:目 录1、需要实现的功能32、设计目的3 1、功能模块划分32、数据库结构描述43、系统详细设计文档64、各个模块的实现方法描述95、测试数据及期望结果11一、系统描述1、需求实现的功能1.1、录入学生基本信息的功能学生基本信息主要包含:学号、姓名、年龄、出生地、专业、班级总学分,在拔出时,如果数据库已经存在该学号,则不克不及再拔出该学号。
1.2、修改学生基本信息的功能在管理员模式下,只要在表格中选中某个学生,就可以对该学生信息进行修改。
评阅意见:评定成绩:指导老师签名:年 月 日1.3、查询学生基本信息的功能可使用“姓名”对已存有的学生资料进行查询。
1.4、删除学生基本信息的功能在管理员模式下,只要选择表格中的某个学生,就可以删除该学生。
1.5、用户登陆用分歧的登录权限可以进入分歧的后台界面,从而实现权限操纵。
1.6、用户登陆信息设置可以修改用户登陆密码2、设计目的学生信息管理系统是一个教育单位不成缺少的部分。
一个功能齐全、简单易用的信息管理系统不单能有效地减轻学校相关工作人员的工作负担,它的内容对于学校的决策者和管理者来说都至关重要。
所以学生信息管理系统应该能够为用户提供充足的信息和快捷的查询手段。
但一直以来人们使用传统人工的方式管理文件档案、统计和查询数据,这种管理方式存在着许多缺点,如:效率低、保密性差、人工的大量浪费;另外时间一长,将发生大量的文件和数据,这对于查找、更新和维护都带来了很多困难。
随着科学技术的不竭提高,计算机科学日渐成熟,其强大的功能已为人们深刻认识,它已进入人类社会的各个领域并发挥着越来越重要的作用。
作为计算机应用的一部分,使用计算机对学校的各类信息进行管理,具有手工管理无法比较的优点。
例如:检索迅速、查询方便、效率高、可靠性好、存储量大、保密性好、寿命长、成本低等。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
学生学籍管理详细设计学号:____________姓名:____________班级:____________一、设计题目:学生学籍管理二:设计内容:设计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 = 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 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 xg 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 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);(label3);(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运行程序。