资源描述
中南民族大学
软件课程设计汇报
电子信息工程学院 级
通信工程专业
题目 学生学籍管理系统
学生 。。 学号214
指导老师 老师
5 月 29 日
学生学籍管理系统
摘要:该软件可实现对学生学籍管理,并存放到数据库中,列表展示所采集数据。
关键字:学生 数据 存放 Java编程
1 引言
伴随现代社会快速发展,我们已进入信息化时代,管理系统在大家生活中应用越来越广泛,它已深入到我们工作,学习和生活各个方面。为了适应时代发展,此次课程设计关键任务是设计一个学生学籍管理系统并完成部分基础操作。
2 设计依据及框图
2.1 设计平台
本系统采取了eclipse开发工具,使用Java语言架设用户界面;使用eclipse建立和数据库连接设计。
2.2 设计思想
为了愈加好管理学生学籍信息,特地利用现在所学eclipse软件和相关数据库设计一个集管理员,老师和学生相关学籍查看,修改,删除和添加一系列功效学籍管理系统。在eclipse中利用JDBC连接到数据库SQL server,从而达成数据管理和存放,用eclipse写功效Java语言,从而跟简单在界面操作数据库。
2.3 设计框图、用户界面
数据库
2.3.1设计框图
Java程序
登录系统
添加信息
删除信息
查询信息
修改信息
2.3.2用户界面
图所表示,这是系统登录界面,登录分为管理员,老师,学生。
2.4 数据库表结构
本系统采取Java语言建立对数据库管理以下:
3 各模块功效及关键模块步骤图
3.1 各模块功效介绍
3.1.1添加信息模块
关键功效:当用户输入想要添加相关学生信息,只需要直接点击添加按钮进入添加信息界面,填上相关信息即可经过Java程序进行添加并存放到数据库。
3.1.2查询信息模块
关键功效:当用户需要查询学生相关信息时,只需要输入名字,Java程序即可运行并从数据库中提出相关信息显示在界面中。
3.1.3 修改信息模块
关键功效:当用户需要修改相关信息时,在信息界面点击修改时,Java程序即可就会调出相关信息,用户就能够修改,修改完成后,会直接把修改后信息存放到数据库中。
3.1.4 删除信息模块
关键功效:当用户需要删除信息是,直接点击删除按钮,Java程序会直接把相关信息从数据库中删除掉。
开始
3.2 关键步骤图
用户输入用户名和密码,点击按钮。
选择登录人员
管理员 学生
老师
显示相关功效提醒
显示个人相关信息
显示相关功效提醒
修改信息
删除信息
查询信息
修改信息
添加信息
添加信息
修改信息
删除信息
查询信息
结束
4 软件调试分析
经过数次调试,在开发时关键碰到以下问题:
Eclipse和数据库连接和相关配置环境
编写java代码和数据库连接时,总是显示会有加载驱动成功,不过连接不到数据库,编码中发觉,这是因为数据库相关配置环境没有设置好。
在编写Java程序时,应该和SQLserver中表名称相同,这么才能够直接在eclipse中利用Java语句结合SQL语言完成对数据相关操作。
5 结语
5.1 结论和讨论
经过这段时间学习,而且在老师帮助下,最终完成了这个课程设计,即使还有很多不足之处。在这段时间里,我们碰到过不少问题,使得总是原地踏步,但经过看书和问老师,我们最终处理碰到问题,而且也是学习到了很多相关知识。经过这次课程设计,使我们处理问题能力得到了提升,知识得到丰富,技能得到提升。
参考文件
[1].张桂珠 刘丽 陈爱国 Java面向对象程序设计(第2版)北京邮电大学出版社[2]毕广吉.Java程序设计实例教程[M]. 北京:冶金工业出版社,
[1] 何玉洁.数据库原理和应用(第3版)[M].北京:机械工业出版社,.8
附录
程序代码:
入口程序:
Student.Java
package pkg;
import javax.swing.UIManager;
import java.awt.*;
import java.sql.*;
//import screen
public class student
{
boolean packFrame=false;
//JFrame frame=new JFrame();
public student()
{
Mainframe frame=new Mainframe();
if(packFrame)
{
frame.pack();
}
else
{
frame.validate();
}
Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize=frame.getSize();
if(frameSize.height>screenSize.height)
{
frameSize.height=screenSize.height;
}
if(frameSize.width>screenSize.width)
{
frameSize.width=screenSize.width;
}
frame.setLocation((screenSize.width-frameSize.width)/2,(screenSize.height-frameSize.height)/2);
frame.setVisible(true);
}
public static void main(String[] args)
{
try{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e)
{
e.printStackTrace();
}
new student();
}
}
界面显示:
Mainframe.java
package pkg;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
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);//“管理员”初始状态被选中
static JRadioButton radioButton2=new JRadioButton("学生");
static JRadioButton radioButton3=new JRadioButton("老师");
ButtonGroup buttonGroup=new ButtonGroup();
public Mainframe()
{
JLabel label=new JLabel(new ImageIcon("E:\\pictures\\bg.jpg"));
label.setSize(400,400);
pan.add(label);
pan.setLayout(null);
pan.setSize(400,400);
this.setTitle("学籍管理系统");
this.setSize(400,400);
this.setLayout(null);
label1.setBounds(100,25,49,20);
textField1.setBounds(155,24,120,20);
label2.setBounds(100,62,49,20);
password.setBounds(155,61,120,20);
button1.setBounds(150,200,101,22);
radioButton1.setBounds(105,120,80,20);
radioButton2.setBounds(180,120,60,20);
radioButton3.setBounds(240,120,60,20);
button1.addActionListener(this);
buttonGroup.add(radioButton1);
buttonGroup.add(radioButton2);
buttonGroup.add(radioButton3);
this.add(radioButton1);
this.add(radioButton2);
this.add(radioButton3);
this.add(label1);
this.add(label2);
this.add(textField1);
this.add(password);
this.add(button1);
this.add(pan);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
// TODO Auto-generated constructor stub
}
public static void main(String[] args)
{
new Mainframe();// TODO Auto-generated method stub
}
public void actionPerformed(ActionEvent e)
{
if(radioButton1.isSelected())//管理员
{
if(textField1.getText().equals("asd") && password.getText().equals("123"))
{
interfac b=new interfac();
this.dispose();
JOptionPane.showMessageDialog(null,"登陆成功");
}else if("".equals(textField1.getText()) ||"".equals(password.getText()) )
{
JOptionPane.showMessageDialog(null,"用户名或密码不能为空");
}else{
JOptionPane.showMessageDialog(null,"用户名或密码输入有误");
}
}if(radioButton2.isSelected())//学生
{
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}
catch (ClassNotFoundException ce)
{
JOptionPane.showMessageDialog(s,ce.getMessage());
}
try{
Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=Student","sa","123");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from password where 用户 ='"+textField1.getText()+"' and 密码 ='"+password.getText()+"'");
if(textField1.getText().equals("用户")||password.getText().equals("密码"))
{
JOptionPane.showMessageDialog(this,"用户名或密码不可为空!");
}
else if(rs.next())
{
new interfac();
}
else
{JOptionPane.showMessageDialog(this,"您输入有误");}
stmt.close();
}
catch (SQLException se)
{
JOptionPane.showMessageDialog(s,se.getMessage());
}
}
}
}
主窗体设计:
Interface.Java:
package pkg;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class interfac extends JFrame implements ActionListener
{
static JMenuBar jMenuBar = new JMenuBar();//菜单条
static JMenu jMenuFile = new JMenu("文件");//菜单项
static JMenu jMenuExit = new JMenu("退出");
static JMenuItem jMenuItem1 = new JMenuItem("添加信息");//菜单子项
static JMenuItem jMenuItem2 = new JMenuItem("修改信息");
static JMenuItem jMenuItem3 = new JMenuItem("信息查询");
static JMenuItem jMenuItem4 = new JMenuItem("删除信息");
static JLabel label3 = new JLabel("请选择操作项");
static JLabel label4 = new JLabel("学籍管理系统");
static JButton button2 = new JButton("添加信息");
static JButton button3 = new JButton("修改信息");
static JButton button4 = new JButton("信息查询");
static JButton button5 = new JButton("删除信息");
public interfac()
{
this.setTitle("学籍管理系统");
this.setLayout(null);
this.setSize(400,400);
label3.setBounds(158,92,98,33);
label3.setFont(new Font("Dialog",Font.PLAIN,15));
label4.setFont(new Font("Dialog",Font.BOLD,20));
label4.setBounds(157,37,280,40);
button2.setBounds(74,136,97,33);
button3.setBounds(226,136,97,33);
button4.setBounds(74,185,97,33);
button5.setBounds(226,185,97,33);
this.add(button2);
this.add(button3);
this.add(button4);
this.add(button5);
this.add(label3);
this.add(label4);
setJMenuBar(jMenuBar);
jMenuFile.add(jMenuItem1);//”文件“菜单项中加入子菜单
jMenuFile.add(jMenuItem2);
jMenuFile.add(jMenuItem3);
jMenuFile.add(jMenuItem4);
jMenuBar.add(jMenuFile);//将菜单项加入菜单条
jMenuBar.add(jMenuExit);
button2.addActionListener(this);//本窗口向按钮事件源注册
button3.addActionListener(this);
button4.addActionListener(this);
button5.addActionListener(this);
jMenuItem1.addActionListener(this);//本窗口菜单子项注册
jMenuItem2.addActionListener(this);
jMenuItem3.addActionListener(this);
jMenuItem4.addActionListener(this);
jMenuExit.addActionListener(this);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
// TODO Auto-generated constructor stub
}
public static void main(String[] args)
{
interfac a=new interfac();// TODO Auto-generated method stub
}
public void actionPerformed(ActionEvent e) //按钮事件处理
{
if(e.getSource()==jMenuExit)
{
System.exit(0);
}
else if(e.getSource()==jMenuItem1||e.getSource()==button2)
{
try{
tj a=new tj();
}
catch(Exception ee){}
}
else if(e.getSource()==jMenuItem2||e.getSource()==button3)
{
try{
xg a=new xg();
}
catch(Exception ed) {}
}
else
if(e.getSource()==jMenuItem3||e.getSource()==button4)
{
try{
cx a=new cx();
}
catch(Exception ec){}
}
else
if(e.getSource()==jMenuItem4||e.getSource()==button5)
{
try{
sc a=new sc();
}catch(Exception es){}
}
}
}
添加信息:
tj.java:
package pkg;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
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()
{
this.setTitle("增加学生信息");
this.setLayout(null);
this.setSize(400,400);
label1.setBounds(30, 11, 51, 33);
textField1.setBounds(86, 16, 74, 22);
label2.setBounds(162, 11, 51, 33);
textField2.setBounds(192, 16, 44, 22);
label3.setBounds(241, 11, 70, 33);
textField7.setBounds(275, 15, 50, 25);
label4.setBounds(31, 53, 55, 33);
textField3.setBounds(86, 58, 74, 22);
label5.setBounds(241, 53, 70, 33);
textField8.setBounds(296, 57, 72, 25);
label6.setBounds(163, 53, 26, 33);
textField4.setBounds(191, 58, 44, 22);
label7.setBounds(30, 94, 50, 33);
textField9.setBounds(86,94,74,22);
label8.setBounds(163, 94, 51, 33);
textField5.setBounds(190, 99, 178, 22);
button1.setBounds(25,241,80,33);
button1.addActionListener(this);
this.add(label1);
this.add(label2);
this.add(label3);
this.add(label4);
this.add(label5);
this.add(label6);
this.add(label7);
this.add(label8);
this.add(textField1);
this.add(textField2);
this.add(textField3);
this.add(textField4);
this.add(textField5);
this.add(textField7);
this.add(textField8);
this.add(textField9);
this.add(button1);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args) throws Exception
{
tj a= new tj();
a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)//事件处理程序
{
if (e.getSource() == button1)
{
try{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
}
catch (ClassNotFoundException ce)
{
JOptionPane.showMessageDialog(s,ce.getMessage());
}
try {
Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=Student","sa","123");
Statement stmt = con.createStatement();
ResultSet rs=stmt.executeQuery("select * from xinxi where 学号='"+textField1.getText ()+"'");
if(rs.next())
{
JOptionPane.showMessageDialog(null,"此学号已经被注册");
}
else
{
stmt.execute("insert into xinxi (学号,姓名,性别,出生日期,政治面貌,"
+ " 籍贯,系别,专业) values ('"+
textField1.getText()+"','"+textField2.getText() +"','"+textField7.getText()+"','"+
textField3.getText()+"','"+textField8.getText() +"','"+textField4.getText()+"','"+
textField9.getText()+"','"+textField5.getText()+"')");
JOptionPane.showMessageDialog(null,"添加信息成功");
}
}
catch (SQLException se)
{
JOptionPane.showMessageDialog(s,se.getMessage());
}
}
}
}
修改信息:
Xg.java
package pkg;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
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() {
this.setTitle("修改学生信息");
this.setLayout(null);
this.setSize(400,400);
label1.setBounds(30, 11, 51, 33);
textField1.setBounds(86, 16, 74, 22);
label2.setBounds(162, 11, 51, 33);
textField2.setBounds(192, 16, 44, 22);
label3.setBounds(241, 11, 70, 33);
textField7.setBounds(275, 15, 50, 25);
label4.setBounds(31, 53, 55, 33);
textField3.setBounds(86, 58, 74, 22);
label5.setBounds(241, 53, 70, 33);
textField8.setBounds(296, 57, 72, 25);
label6.setBounds(163, 53, 26, 33);
textField4.setBounds(191, 58, 44, 22);
label7.setBounds(30, 94, 50, 33);
textField9.setBounds(86,94,74,22);
label8.setBounds(163, 94, 51, 33);
textField5.setBounds(190, 99, 178, 22);
button2.setBounds(115,241,80,33);
button2.addActionListener((ActionListener
展开阅读全文