【SQL开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。
网学会员整理了SQL开源代码-java编写的简单的学生信息管理系统(源码、需求分析) - 编程语言的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
学生信息管理系统 一、需求分析 1、可行性分析 知识爆炸的时代里求学的人数越来越多但学校的数量及学校所能提供的资源很有限。
为优化管
理学生的人力资源
设计了这个系统。
2、任务概述 1目标 在
计算机网络数据库和先进的开发平台上利用现有 的
软件、硬件资源开发一个具有开放体系结构的 易扩充的易维护的具有良好人机交互界面的学 生信息管理系统。
2需求要求 这个简单的学生信息管理系统包括以下两个基本功能 · 管理员登陆 · 学生信息管理 二、层次图 三、界面预览 登录界面 学生信息
管理系统 管理员
登陆 学生信息管理 增加学生信息 查询学生信息 修改学生信息 删除学生信息 显示学生信息 该管理员不存在 学生信息管理界面 填写学生信息 录入学生信息 按学号进行查询 查询后可以进行信息的修改 学生信息的删除 显示全部学生信息 四、
系统说明 1该系统并未使用数据库只是把信息存放在了一个新建立的文本
文档中 2关于管理员信息必须现在C盘建立一个名为Login的文本
文档在Login中存入用户名和密码且必须分行写入 3若要修改学生信息必须先进行信息的查询查询后方可进行信息修改 五、源
代码 登录界面源
代码 import java.awt.event. import javax.swing. import java.awt. import java.awt.event.ActionEvent import java.awt.event.ActionListener import java.awt.event.WindowAdapter import java.awt.event.WindowEvent import java.io.BufferedReader import java.io.File import java.io.FileReader import java.io.IOException import java.util. import java.
sql. class Login extends JFrame implements ActionListener Container cpnull String namenull String pswnull JFrame fnull JButton j1j2 JTextField t1 JPasswordField t2 JLabel jlable1jlable2 Color c JPanel jp1jp2 Login fnew JFramequot学生管理系统quot j1new JButtonquot确定quot j2new JButtonquot取消quot cpf.getContentPane jlable1new JLabelquot 输入用户名quot jlable2new JLabelquot 用户密码quot jp1new JPanel jp2new JPanel t1new JTextField18 t2new JPass
wordField18 jp1.addjlable1 jp1.addt1 jp1.addjlable2 jp1.addt2 JLabel JLnew JLabelquotlthtmlgtltfont color000000 size6gtltigt欢迎进入学生管理系统lt/igtlt/fontgtquotSwingConstants.CENTER cp.addJLquotNorthquot jp2.addj1 jp2.addj2 cp.addjp1quotCenterquot cp.addquotSouthquotjp2 jp1.setBackgroundColor.lightGray Toolkit kitToolkit.getDefaultToolkit Dimension screenkit.getScreenSize int xscreen.width /取得显示器窗口的宽度/ int yscreen.height /取得显示器窗口的高度/ //setSizexy /让系统窗口平铺整个显示器窗口/ f.setSize300300 int xcenterx-300/2 int ycentery-300/2 f.setLocationxcenterycenter/显示在窗口中央/ f.setVisibletrue //----------------------------------------------------- j1.addActionListenerthis//
注册事件监听器 j2.addActionListenerthis f.addWindowListenernew WindowAdapter public void windowClosingWindowEvent e System.exit0 public void confirm throws IOException//验证用户和密码是否存在 File file new FilequotC://Login.txtquot try iffile.exists file.createNewFile catch IOException e e.printStackTrace BufferedReader br new BufferedReadernew FileReaderfile String tempbr.readLine String line whilelinebr.readLinenull tempquotquotline iftempnull System.out.println else ///分割字符串 String strtemp.splitquotquot namestr0 pswstr1 ift1.getText.trim.equalsnameampampt2.getText.trim.equalspsw new Test f.hide br.close else JOptionPane.showMessageDialognullquot该用户不存在quotquot提示quot JOptionPane.YES_NO_OPTION t1.setTextquotquot t2.setTextquotquot //forint i0igtstr.lengthi //System.out.printlnstri // public void actionPerformedActionEvent e String cmde.getActionCommand ifcmd.equalsquot确定quot try confirm catch IOException e1 // TODO Auto-generated catch block e1.printStackTrace else ifcmd.equalsquot取消quot f.dispose public static void mainString arg Login anew Login 学生信息管理界面源
代码 import java.awt. import java.awt.event. import javax.swing. import java.io. import java.util. class Student implements java.io.Serializable String numbernamespecialtygradeborthsex public Student public void setNumberString number this.numbernumber public String getNumber return number public void setNameString name this.namename public String getName return name public void setSexString sex this.sexsex public String getSex return sex public void setSpecialtyString specialty this.specialtyspecialty public String getSpecialty return specialty public void setGradeString grade this.gradegrade public String getGrade return grade public void setBorthString borth this.borthborth public String getBorth return borth public class Test extends JFrame JLabel lbnew JLabelquot录入请先输入记录查询、删除请先输入学号修改是对
查询quot quot内容改后的保存quot JTextField 学号姓名专业年级出生 JRadioButton 男女 ButtonGroup groupnull JButton 录入查询删除修改显示 JPanel p1p2p3p4p5p6pvph Student 学生null Hashtable 学生散列表null File filenull FileInputStream inOnenull ObjectInputStream inTwonull FileOutputStream outOnenull ObjectOutputStream outTwonull public Test superquot学生信息管理系统quot 学号new JTextField10 姓名new JTextField10 专业new JTextField10 年级new JTextField10 出生new JTextField10 groupnew ButtonGroup 男new JRadioButtonquot男quottrue 女new JRadioButtonquot女quotfalse group.add男 group.add女 录入new JButtonquot录入quot 查询new JButtonquot查询quot 删除new JButtonquot删除quot 修改new JButtonquot修改quot 显示new JButtonquot显示quot 录入.addActionListenernew InputAct 查询.addActionListenernew InquestAct 修改.addActionListenernew ModifyAct 删除.addActionListenernew DeleteAct 显示.addActionListenernew ShowAct 修改.setEnabledfalse p1new JPanel p1.addnew JLabelquotENTER p1.add学号 p2new JPanel p2.addnew JLabelquot姓名:quotJLabel.CENTER p2.add姓名 p3new JPanel p3.addnew JLabelquot性别:quotJLabel.CENTER p3.add男 p3.add女 p4new JPanel p4.addnew JLabelquot专业:quotJLabel.CENTER p4.add专业 p5new JPanel p5.addnew JLabelquot年级:quotJLabel.CENTER p5.add年级 p6new JPanel p6.addnew JLabelquot出生:quotJLabel.CENTER p6.add出生 pvnew JPanel pv.setLayoutnew GridLayout61 pv.addp1 pv.addp2 pv.addp3 pv.addp4 pv.addp5 pv.addp6 phnew JPanel ph.add录入 ph.add查询 ph.add修改 ph.add删除 ph.add显示 filenew Filequot学生信息.txtquot 学生散列表new Hashtable iffile.exists try FileOutputStream outnew FileOutputStreamfile ObjectOutputStream objectOutnew ObjectOutputStreamout objectOut.writeObject学生散列表 objectOut.close out.close catchIOException e Container congetContentPane con.setLayoutnew BorderLayout con.addlb BorderLayout.NORTH con.addpv BorderLayout.CENTER con.addph BorderLayout.SOUTH setDefaultCloseOperationEXIT_ON_CLOSE setBounds100100600300 setVisibletrue public static void mainString args new Test class InputAct implements ActionListener public void actionPerformedActionEvent e 修改.setEnabledfalse String numberquotquot number学号.getText ifnumber.lengthgt0 try inOnenew FileInputStreamfile inTwonew ObjectInputStreaminOne 学生散列表HashtableinTwo.readObject inOne.close inTwo.close catchException eeSystem.out.printlnquot创建散列表出现问题quot if学生散列表.containsKeynumber String warningquot该生信息已存在请到修改页面修改quot JOptionPane.showMessageDialognullwarningquot警告quot JOptionPane.WARNING_MESSAGE //end if1 else String mquot该生信息将被录入quot int okJOptionPane.showConfirmDialognullmquot确认quot JOptionPane.YES_NO_OPTIONJOptionPane.INFORMATION_MESSAGE ifokJOptionPane.YES_OPTION String name姓名.getText String specialty专业.getText String grade年级.getText String borth出生.getText String sexnull if男.isSelectedsex男.getText elsesex女.getText 学生new Student 学生.setNumbernumber 学生.setNamename 学生.setSpecialtyspecialty 学生.setGradegrade 学生.setBorthborth 学生.setSexsex try outOnenew FileOutputStreamfile outTwonew ObjectOutputStreamoutOne 学生散列表.putnumber学生 outTwo.writeObject学生散列表 outTwo.close outOne.close catchException eeSystem.out.printlnquot输出散列表出现
问题quot 学号.setTextnull 姓名.setTextnull 专业.setTextnull 年级.setTextnull 出生.setTextnull //end else1 //end if0 else String warningquot必须输入学号quot JOptionPane.showMessageDialognullwarning quot警告quotJOptionPane.WARNING_MESSAGE //end else0 //end actionPerformed //end class class InquestAct implements ActionListener public void actionPerformedActionEvent e String numberquotquot number学号.getText ifnumber.lengthgt0 try inOnenew FileInputStreamfile inTwonew ObjectInputStreaminOne 学生散列表HashtableinTwo.readObject inOne.close inTwo.close catchException eeSystem.out.printlnquot散
列表有问题quot if学生散列表.containsKeynumber 修改.setEnabledtrue Student stuStudent学生散列表.getnumber 姓名.setTextstu.getName 专业.setTextstu.getSpecialty 年级.setTextstu.getGrade 出生.setTextstu.getBorth ifstu.getSex.equalsquot男quot男.setSelectedtrue else女.setSelectedtrue else 修改.setEnabledfalse String warningquot该学号不存在quot JOptionPane.showMessageDialognullwarning quot警告quotJOptionPane.WARNING_MESSAGE else 修改.setEnabledfalse String warningquot必须输入学号quot JOptionPane.showMessageDialognullwarning quot警告quotJOptionPane.WARNING_MESSAGE class ModifyAct implements ActionListener public void actionPerformedActionEvent e String number学号.getText String name姓名.getText String specialty专业.getText String grade年级.getText String borth出生.getText String sexnull if男.isSelectedsex男.getText elsesex女.getText Student 学生new Student 学生.setNumbernumber 学生.setNamename 学生.setSpecialtyspecialty 学生.setGradegrade 学生.setBorthborth 学生.setSexsex try outOnenew FileOutputStreamfile outTwonew ObjectOutputStreamoutOne 学生散列表.putnumber 学生 outTwo.writeObject学生散列表 outTwo.close outOne.close 学号.setTextnull 姓名.setTextnull 专业.setTextnull 年级.setTextnull 出生.setTextnull catchException ee System.out.printlnquot录入修改出现异常quot 修改.setEnabledfalse class DeleteAct implements ActionListener public void actionPerformedActionEvent e 修改.setEnabledfalse String number学号.getText ifnumber.lengthgt0 try inOnenew FileInputStreamfile inTwonew ObjectInputStreaminOne 学生散列表HashtableinTwo.readObject inOne.close inTwo.close catchException ee if学生散列表.containsKeynumber Student stuStudent学生散列表.getnumber 姓名.setTextstu.getName 专业.setTextstu.getSpecialty 年级.setTextstu.getGrade 出生.setTextstu.getBorth ifstu.getSex.equalsquot男quot男.setSelectedtrue else女.setSelectedtrue String mquot确定要删除该学生的记录吗quot int okJOptionPane.showConfirmDialognullmquot确认quot JOptionPane.YES_NO_OPTIONJOptionPane.QUESTION_MESSAGE ifokJOptionPane.YES_OPTION 学生散列表.removenumber try outOnenew FileOutputStreamfile outTwonew ObjectOutputStreamoutOne outTwo.writeObject学生散列表 outTwo.close outOne.close 学号.setTextnull 姓名.setTextnull 专业.setTextnull 年级.setTextnull 出生.setTextnull catchException eeSystem.out.printlnee else ifokJOptionPane.NO_OPTION 学号.setTextnull 姓名.setTextnull 专业.setTextnull 年级.setTextnull 出生.setTextnull else String warningquot该学号不存在quot JOptionPane.showMessageDialognullwarning quot警告quotJOptionPane.WARNING_MESSAGE else String warningquot必须输入学号quot JOptionPane.showMessageDialognullwarning quot警告quotJOptionPane.WARNING_MESSAGE class ShowAct implements ActionListener public void actionPerformedActionEvent e new StudentShowfile class StudentShow extends JDialog Hashta.