JAVA课程设计---学籍管理系统_第1页
JAVA课程设计---学籍管理系统_第2页
JAVA课程设计---学籍管理系统_第3页
JAVA课程设计---学籍管理系统_第4页
JAVA课程设计---学籍管理系统_第5页
已阅读5页,还剩28页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、精选优质文档-倾情为你奉上JAVA课程设计 题目: JAVA学籍管理系统 姓 名: 学 号: 班 级: 日 期: 目 录专心-专注-专业一、设计思路随着社会经济的发展,入学的同学越来越多,为方便对同学学籍信息的的管理,设计学籍管理软家来管理本班级同学的学籍信息。该软件应支持添加、删除、修改、查询功能。并且查询功能分为两种情况显示查询的结果:查询方式主要是支持学号查询,例如:输入“111”,则显示该学生的信息。 运用流式、卡片、整体布局方式对系统的主界面和各功能界面进行设计;通过连接数据库的方式来实现对数据的存储;各功能实现时访问数据库,并对数据信息进行读取,运用Java语句对其进行输出,学号查

2、询时显示在文本框中;管理员登录、管理员添加信息,系统提示功能用来提醒用户的错误操作和输入时的错误信息,提醒用户进行改正二、具体实现该系统中的信息存储在数据库中,并实现以下各功能: 管理员登录:管理员帐号admin,密码:12345,进行增删查改。添加功能:添加数据信息,当有新同学进入是可以添加该同学的信息。通过文本框读入添加信息,连接数据库后储存数据。精确查询:输入要查询同学的学号,显示出该同学的信息。通过文本框读入要查找的信息,用SQL语句在数据库中进行查找。删除功能:该功能和精确查询功能在同一功能模块中实现,有于删除同学信息并更新数据库信息。修改功能:当同学的信息改变时,用此功能更新同学信

3、息。通过对数据库信息的更新保存最新信息。每种功能通过一个类来实现:类分分为主类、精确查询类、修改类、添加类、增加类。主类(Info_manager)实现系统主界面以及和各功能界面的连接;精确查询类(SearchStudent)实现对数据库中数据的精确查询;修改类(MdifyStudent)实现对数据的修改更新;添加类(AddStudent)向数据库中添加新数据;删除类(DeleteStudent)实现对数据的删除。该系统需要用数据库来实现对信息的存储,每次对信息的操作都要访问数据库,并对数据库的信息作相应的读入和取出。该系统流程图如下:系统管理员增加信息删除信息查询信息修改信息关于系统退出图

4、1 系统流程图图 2 程序流程图三、运行调试与分析讨论系统的详细设计代码请查阅附带的代码。以下仅对各个界面进行截图展示:图3系统登录界面图 4 系统主要界面图 5 修改信息时的界面图 6 添加信息的界面图7删除界面图8查询界面运行JAVA程序中的Infor_Manager文件,显示系统的主界面,如图三所示,主界面有进入其他子功能的按钮,选择相应的按钮便可进入相应的功能。添加号码功能如图四所示,根据提示输入要添加的信息,点击确定,将弹出提示框,确认是否添加。修改号码功能如图五所示,首先输入要修改的人姓名,点击开始修改,在下面的文本框现实当前数据库内所存该人的信息,同时录入修改键变化为可点击,在文

5、本框内输入要修改的学号,点击录入修改,系统将新信息录如数据库。点击精确查询按钮,将弹出查询对话框,输入学号便可以精确查询到此人的所有学籍信息。查询如图七所示,将显示数据库中所存的所有号码信息。四、设计体会与小结一周的课设,自己通过查找资料、复习课本、编程调试,写实验报告等环节,进一步掌握了以前学到的知识,并且还对GUI组键的应用有了更深入的认识与掌握,另外还学到了一些新东西,比如JAVA 的SWING、AWT包,以前是没有接触过的,可是通过这次课程设计使得我们对这个包更了解。通过与数据库的连接掌握了Java与数据库的连接技术。 通过实践的学习,我认到学好计算机要重视实践操作,不仅仅是学习jav

6、a语言,还是其它的语言,以及其它的计算机方面的知识都要重在实践,所以后在学习过程中,我会更加注视实践操作,使自己便好地学好计算机。五、参考文献1朱福喜,尹为民等编著.Java语言与面向对象程序设计.武汉:武汉大学出版社,2002.12 2冯军,程超等编著.JBuilder 9.0程序设计.北京:中国水利水电出版社,2004.53丁振凡,黎章等编著.Java语言实用教程.北京:北京邮电大学出版社,2005.84何桥,李肃义等编著.Java程序设计简明教程.北京:中国水利水电出版社,2004.9六、附录程序的主要代码:主界面模块主要代码登录界面Info_Manager.javapublic cla

7、ss Info_Manage extends Frame implements ActionListener JLabel JLUserName = new JLabel("用户名:");/ 创建一个标签对象,现实用户名JLabel JLPaw = new JLabel("密码:");/ 创建一个标签对象,现实密码JTextField JTUserName = new JTextField();/ 创建一个密码框对象JPasswordField JPsw = new JPasswordField();/ 创建一个对象框对象JButton JB1 = ne

8、w JButton("登录");/ 创建按钮对象JButton JB2 = new JButton("取消");public Info_Manage() this.setTitle("学籍管理系统");/ 设置窗口的显示标题this.setLayout(null);JLUserName.setBounds(100, 40, 100, 20);/ 设置姓名标签显示的大小和位置this.add(JLUserName);/ 将组件添加到容器中JTUserName.setBounds(200, 40, 80, 20);/ 设置姓名输入对话框标

9、签的大小和位置this.add(JTUserName);JLPaw.setBounds(100, 100, 60, 20);/ 设置密码标签显示的大小和位置this.add(JLPaw);/ 将组件添加到容器中JPsw.setBounds(200, 100, 80, 20);/ 设置密码框的大小和位置this.add(JPsw);/ 将组件添加到容器中JB1.setBounds(100, 200, 60, 20);/ 设置按钮显示的大小和位置this.add(JB1);/ 将组件添加到容器中JB1.addActionListener(this);JB2.setBounds(200, 200,

10、60, 20);/ 设置按钮显示的大小和位置this.add(JB2);/ 将组件添加到容器中JB2.addActionListener(this);this.setVisible(true);this.setBounds(10, 10, 400, 250);addWindowListener(new WindowAdapter()/ 设置关闭窗口的事件监听public void windowClosing(WindowEvent e)System.exit(0););public static void main(String args) / TODO Auto-generated meth

11、od stubnew Info_Manage();public void actionPerformed(ActionEvent e)/ 单机登录时的事件处理if (e.getSource() = JB1) String name = JTUserName.getText();/ 获取用户名String password = new String(JPsw.getPassword();/ 获取密码if (name != null && (name.equals("admin")&& (password != null && p

12、assword.equals("12345")/ 判断用户名和密码是否匹配new Student_manage();/ 主页打开this.setVisible(false);/ 隐藏该登录窗口/ 取消按钮/ else if(e.getSource()=JB2)/ / System.exit(0);/ else JOptionPane.showMessageDialog(null, "对不起!亲,您输入的用户名或密码有误,请重新输入");管理功能模块主要代码Student_manage.javapublic class Student_manage ext

13、ends JFrame implements ActionListener / 设置选项信息JMenuBar jmb = new JMenuBar();JMenu Message = new JMenu("学生信息");JMenuItem Item1 = new JMenuItem("增加学籍信息");JMenuItem Item2 = new JMenuItem("删除学籍信息");JMenuItem Item3 = new JMenuItem("修改学籍信息");JMenuItem Item4 = new JM

14、enuItem("查询学籍信息");JMenu exit = new JMenu("系统");JMenuItem Item5 = new JMenuItem("系统信息");JMenuItem Item6 = new JMenuItem("退出");/ JPanel panel = new JPanel();/设置图像面板/ String url = "D:Systemstitle.jpg"/图像添加public Student_manage() super("管理界面");

15、/ JLabel img = new JLabel(new ImageIcon(url);/图像添加/ img.setBounds(0,0,500,100);/图像添加/ panel.add(img);/图像添加this.setSize(500, 400);this.setVisible(true);this.setResizable(false);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setJMenuBar(jmb);jmb.add(Message);jmb.add(exit);/ 添加到组件Message.add(

16、Item1);Message.add(Item2);Message.add(Item3);Message.add(Item4);Item1.addActionListener(this);Item2.addActionListener(this);Item3.addActionListener(this);Item4.addActionListener(this);/ 设置退出exit.add(Item5);exit.add(Item6);Item5.addActionListener(this);Item6.addActionListener(this);public void action

17、Performed(ActionEvent e) / TODO Auto-generated method stubif (e.getSource() = Item1) AddStudent ad = new AddStudent(); else if (e.getSource() = Item2) DeleteStudent ds = new DeleteStudent(); else if (e.getSource() = Item3) ModifyStudent ms = new ModifyStudent(); else if (e.getSource() = Item4) Searc

18、hStudent ss = new SearchStudent(); else if (e.getSource() = Item5) / System.out.println("我的学籍管理系统");JOptionPane.showMessageDialog(null, "亲,欢迎访问我的学籍管理系统"); else System.exit(0);public static void main(String args) / TODO Auto-generated method stubnew Student_manage();增加模块代码主要代码 Add

19、Student.javapublic class AddStudent extends JFrame implements ActionListener JLabel JL = new JLabel("添加学生基本信息", JLabel.CENTER);JLabel JLNumber = new JLabel("学号:");/ 创建标签对象,用于显示学号JTextField JTNumber = new JTextField();/ 创建文本框对象,用于接收学号信息JLabel JLName = new JLabel("姓名:");/

20、 创建标签对象,用于显示姓名JTextField JTName = new JTextField();JLabel JLClass = new JLabel("班级:");/ 创建标签对象,用于显示班级JTextField JTClass = new JTextField();JLabel JLSex = new JLabel("性别:");/ 创建标签对象,用于显示性别ButtonGroup BG = new ButtonGroup();JRadioButton JRB1 = new JRadioButton("男");JRadio

21、Button JRB2 = new JRadioButton("女");JLabel JL1 = new JLabel("学院:");/ 创建标签对象,用于显示JTextField JT1 = new JTextField();JLabel JL2 = new JLabel("生日:");/ 创建标签对象,用于显示生日JTextField JT2 = new JTextField();JButton JBAdd = new JButton("添加:");/ 创建标签对象JButton JBNext = new JB

22、utton("重置:");/ 创建标签对象JButton JBExit = new JButton("退出:");/ 创建标签对象String sql = ""public AddStudent() this.setTitle("添加学生学籍信息");this.setLayout(null);JL.setFont(new Font("TimesRoman", Font.BOLD, 24);/ 设置字体和颜色JL.setForeground(Color.red);JL.setFont(new Fo

23、nt("宋体", Font.PLAIN, 19);JL.setBounds(100, 30, 200, 40);this.add(JL);/ 以下为设置前面所创建的标签和文本框,以按照顺序显示JLNumber.setBounds(100, 80, 100, 20);this.add(JLNumber);JTNumber.setBounds(200, 80, 80, 20);this.add(JTNumber);JLName.setBounds(100, 120, 60, 20);this.add(JLName);JTName.setBounds(200, 120, 80,

24、20);this.add(JTName);JLSex.setBounds(100, 160, 100, 20);this.add(JLSex);JRB1.setBounds(200, 160, 40, 20);JRB2.setBounds(300, 160, 40, 20);this.add(JRB1);this.add(JRB2);BG.add(JRB1);BG.add(JRB2);JL2.setBounds(100, 200, 80, 20);this.add(JL2);JT2.setBounds(200, 200, 80, 20);this.add(JT2);JLClass.setBou

25、nds(100, 240, 60, 20);this.add(JLClass);JTClass.setBounds(200, 240, 80, 20);this.add(JTClass);JL1.setBounds(100, 280, 60, 20);this.add(JL1);JT1.setBounds(200, 280, 80, 20);this.add(JT1);JBAdd.setBounds(80, 320, 90, 20);this.add(JBAdd);JBAdd.addActionListener(this);JBNext.setBounds(190, 320, 90, 20);

26、this.add(JBNext);JBNext.addActionListener(this);JBExit.setBounds(300, 320, 90, 20);this.add(JBExit);JBExit.addActionListener(this);this.setBounds(10, 10, 500, 400);this.setVisible(true);public void actionPerformed(ActionEvent e) / TODO Auto-generated method stubif (e.getSource() = JBAdd) String snum

27、ber = JTNumber.getText();/ 获取文本框中所输入的信息String sname = JTName.getText();/ 获取文本框中所输入的信息String sclass = JTClass.getText();/ 获取文本框中所输入的信息String ssex = "女"/ 获取文本框中所输入的信息if (JRB1.isSelected()ssex = "男"elsessex = "女"String scollect = JT1.getText();String sbir = JT2.getText();s

28、ql = "select * from student where id='" + snumber + "'"/ 根据ID对数据库信息进行查询try Class.forName("com.mysql.jdbc.Driver");/ 使用数据源进行数据库连接Connection con = (DriverManager.getConnection("jdbc:mysql:/localhost/student_info?user=root&password=root");/ 数据源名称stude

29、nt_infoStatement stmt = con.createStatement();ResultSet rs = stmt.executeQuery(sql);/ 传入sql语句,执行查询if (rs.next()/ 如果有查询结果,则提示该号已经存在,否则执行数据库写入JOptionPane.showMessageDialog(null, "该号已经存在");else / 将文本框中所有的输入信息都写入到数据库中,sql = "insert into student values('" + snumber + "',&

30、#39;"+ sname + "','" + sclass + "','" + ssex + "','"+ scollect + "','" + sbir + "')"/ 执行SQL语句,并将返回值赋值给iint i = stmt.executeUpdate(sql);if (i > 0)/ 判断如果i小于0,则说明添加成功,返回相应的提示信息JOptionPane.showMessageDialog(nul

31、l, "添加成功");else/ 否则提示添加失败JOptionPane.showMessageDialog(null, "添加失败"); catch (Exception ee) if (e.getSource() = JBNext) JTNumber.setText(null);JTName.setText(null);JTClass.setText(null);JT1.setText(null);JT2.setText(null);if (e.getSource() = JBExit) setVisible(false);/* * param ar

32、gs */public static void main(String args) / TODO Auto-generated method stubnew AddStudent();删除模块主要代码DeleteStudnet.javapublic class DeleteStudent extends JFrame implements ActionListener JLabel JL = new JLabel("删除学生学籍信息", JLabel.CENTER);JLabel JLNumber = new JLabel("学号:");/ 创建标签对象

33、,用于显示学号JTextField JTNumber = new JTextField();/ 创建文本框对象,用于获取学号信息JLabel JLName = new JLabel("姓名:");/ 创建标签对象,用于显示姓名输入提示JTextField JTName = new JTextField();/ 创建文本框对象,用于获取姓名信息JButton JBDel = new JButton("删除:");/ 创建按钮对象,用于显示删除JButton JBNext = new JButton("重置:");/ 创建按钮对象,用于显

34、示重置JButton JBExit = new JButton("退出:");/ 创建按钮对象,用于显示退出String sql = ""public DeleteStudent() this.setTitle("删除学生学籍信息");this.setLayout(null);JL.setFont(new Font("TimesRoman", Font.BOLD, 24);JL.setForeground(Color.red);JL.setFont(new java.awt.Font("宋体",

35、 Font.PLAIN, 19);JL.setBounds(100, 30, 200, 40);this.add(JL);JLNumber.setBounds(100, 120, 100, 20);this.add(JLNumber);JTNumber.setBounds(200, 120, 80, 20);this.add(JTNumber);JLName.setBounds(100, 160, 60, 20);this.add(JLName);JTName.setBounds(200, 160, 80, 20);this.add(JTName);JBDel.setBounds(80, 32

36、0, 90, 20);this.add(JBDel);JBDel.addActionListener(this);JBNext.setBounds(190, 320, 90, 20);this.add(JBNext);JBNext.addActionListener(this);JBExit.setBounds(300, 320, 90, 20);this.add(JBExit);JBExit.addActionListener(this);this.setBounds(10, 10, 500, 400);this.setVisible(true);addWindowListener(new

37、WindowAdapter() public void windowClosing(WindowEvent e) System.exit(0););public void actionPerformed(ActionEvent e) / 执行操作if (e.getSource() = JBDel) String snumber = JTNumber.getText();/ 获取到文本框中填入的学号信息String sname = JTName.getText();/ 获取到文本框中填入的姓名信息sql = "select * from student where id='&q

38、uot; + snumber + "'"try Class.forName("com.mysql.jdbc.Driver");/ 使用数据源进行数据库连接Connection con = (DriverManager.getConnection("jdbc:mysql:/localhost/student_info?user=root&password=root");/ 数据源名称Statement stm = con.createStatement();ResultSet rs = stm.executeQuery(

39、sql);/ 传入sql语句if (rs.next() sql = "delete from student where id='" + snumber + "'"int n = stm.executeUpdate(sql);if (n > 0)/ 如果执行成功则返回删除成功JOptionPane.showMessageDialog(null, "删除成功");else/ 否则提示删除失败JOptionPane.showMessageDialog(null, "删除失败"); else / 如

40、果不存在这个学号的学生,则返回相应的信息JOptionPane.showMessageDialog(null, "不存在该学号学生"); catch (Exception er) if (e.getSource() = JBNext) JTNumber.setText(null);JTName.setText(null);if (e.getSource() = JBExit) setVisible(false);/* * param args */public static void main(String args) new DeleteStudent();查询模块完整代

41、码 SearchStudent.javapublic class SearchStudent extends JFrame implements ActionListener JLabel JL = new JLabel("查询学生基本信息", JLabel.CENTER);JLabel JLNumber = new JLabel("请输入学号:");/ 创建标签对象,用于提示输入查询学号JTextField JTNumber = new JTextField();/ 创建文本框对象,用于接收学号信息JLabel JLName = new JLabel(

42、"姓名:");/ 创建标签对象,用于提示输入查询姓名JTextField JTName = new JTextField();/ 创建文本框对象,用于接收姓名信息JLabel JLClass = new JLabel("班级:");/ 创建标签对象,用于提示输入查询班级JTextField JTClass = new JTextField();/ 创建文本框对象,用于接收班级信息JLabel JLSex = new JLabel("性别:");/ 创建标签对象,用于提示输入查询性别ButtonGroup BG = new Button

43、Group();/ 创建文本框对象,用于接收性别信息JRadioButton JRB1 = new JRadioButton("男");JRadioButton JRB2 = new JRadioButton("女");JLabel JL1 = new JLabel("学院:");/ 创建标签对象,用于提示输出查询JTextField JT1 = new JTextField();/ 创建文本框对象,用于接收学号信息JLabel JL2 = new JLabel("生日:");/ 创建标签对象,用于提示输出查询生日

44、JTextField JT2 = new JTextField();/ 创建文本框对象,用于接收学号信息JButton JBSet = new JButton("查询:");/ 创建按钮对象JButton JBNext = new JButton("重置:");/ 创建按钮对象JButton JBExit = new JButton("退出:");/ 创建按钮对象String sql = ""public SearchStudent() / 设置所有的窗口大小和位置this.setTitle("查询学生学

45、籍信息");this.setLayout(null);JL.setFont(new Font("TimesRoman", Font.BOLD, 24);/ 设置字体和颜色JL.setForeground(Color.red);JL.setFont(new Font("宋体", Font.PLAIN, 19);JL.setBounds(100, 30, 200, 40);this.add(JL);/ 以下为设置前面所创建的标签和文本框,以按照顺序显示JLNumber.setBounds(100, 80, 100, 20);this.add(JLN

46、umber);JTNumber.setBounds(200, 80, 80, 20);this.add(JTNumber);JLName.setBounds(100, 160, 60, 20);this.add(JLName);JTName.setBounds(200, 160, 80, 20);this.add(JTName);JLSex.setBounds(100, 200, 100, 20);this.add(JLSex);JRB1.setBounds(200, 200, 40, 20);JRB2.setBounds(300, 200, 40, 20);this.add(JRB1);th

47、is.add(JRB2);BG.add(JRB1);BG.add(JRB2);JL2.setBounds(100, 240, 80, 20);this.add(JL2);JT2.setBounds(200, 240, 80, 20);this.add(JT2);JLClass.setBounds(100, 280, 60, 20);this.add(JLClass);JTClass.setBounds(200, 280, 80, 20);this.add(JTClass);JL1.setBounds(100, 320, 60, 20);this.add(JL1);JT1.setBounds(2

48、00, 320, 60, 20);this.add(JT1);JBSet.setBounds(80, 120, 90, 20);this.add(JBSet);JBSet.addActionListener(this);JBNext.setBounds(190, 120, 90, 20);this.add(JBNext);JBNext.addActionListener(this);JBExit.setBounds(300, 120, 90, 20);this.add(JBExit);JBExit.addActionListener(this);this.setBounds(10, 10, 5

49、00, 400);this.setVisible(true);public void actionPerformed(ActionEvent e) / TODO Auto-generated method stub/ TODO Auto-generated method stubif (e.getSource() = JBSet) String snumber = JTNumber.getText();/ 获取文本框中所输入的信息String sname = JTName.getText();/ 获取文本框中所输入的信息String sclass = JTClass.getText();/ 获

50、取文本框中所输入的信息String ssex = "女"/ 获取文本框中所输入的信息if (JRB1.isSelected()ssex = "男"String scollect = JT1.getText();String sbir = JT2.getText();sql = "select * from student where id='" + snumber + "'"/ 根据ID对数据库信息进行查询try Class.forName("com.mysql.jdbc.Driver&q

51、uot;);/ 使用数据源进行数据库连接Connection con = (DriverManager.getConnection("jdbc:mysql:/localhost/student_info?user=root&password=root");/ 数据源名称Statement stm = con.createStatement();ResultSet rs = stm.executeQuery(sql);/ 传入sql语句,执行查询if (rs.next()/ 将查询到的数据返回给相应的变量String name = rs.getString(2);JT

52、Name.setText(name);String clas = rs.getString(3);JTClass.setText(clas);String sex = rs.getString(4);JRB1.setText(sex);String collect = rs.getString(5);JT1.setText(collect);String bir = rs.getString(6);JT2.setText(bir);int n = stm.executeUpdate(sql);if (n > 0)/ 判断是否查询成功则返回各自输出结果JOptionPane.showMes

53、sageDialog(null, "查询成功");else/ 否则提示添加失败JOptionPane.showMessageDialog(null, "查询失败"); else / 否则提示不存在该学号学生JOptionPane.showMessageDialog(null, "不存在该学号学生"); catch (Exception ee) / 重置按钮,清空if (e.getSource() = JBNext) JTNumber.setText(null);JTName.setText(null);JTClass.setText(

54、null);JT1.setText(null);JT2.setText(null);/ 退出按钮,单击退出if (e.getSource() = JBExit) setVisible(false);/* * param args */public static void main(String args) / TODO Auto-generated method stubnew SearchStudent();修改模块完整代码 ModifyStudent.javapublic class ModifyStudent extends JFrame implements ActionListener JLabel JL = new JLabel("修改学生基本信息", JLabel.CENTER);JLabel JLNumber = new JL

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论