数据库课程设计学生管理系统附代码

上传人:痛*** 文档编号:136439266 上传时间:2022-08-16 格式:DOC 页数:31 大小:247.50KB
收藏 版权申诉 举报 下载
数据库课程设计学生管理系统附代码_第1页
第1页 / 共31页
数据库课程设计学生管理系统附代码_第2页
第2页 / 共31页
数据库课程设计学生管理系统附代码_第3页
第3页 / 共31页
资源描述:

《数据库课程设计学生管理系统附代码》由会员分享,可在线阅读,更多相关《数据库课程设计学生管理系统附代码(31页珍藏版)》请在装配图网上搜索。

1、 数据库课程设计报告题 目: 学生信息管理系统院系名称: 计算机学院 专业名称: 班 级: 学生姓名: 学号(8位): 指导教师: 设计起止时间:2011年12月19日2011年12月30日一. 设计目的 1、掌握DBMS的基本工作原理 2、培养数据库应用系统设计的基本思路和方法 3、培养分析、解决问题的能力 二. 设计内容利用数据库实现对学生信息的管理所用数据库:sqlserver 2008开发语言:java、开发工具:eclipse三概要设计 通过访问数据库实现以下功能:1、 不同用户权限登陆系统2、 用户密码修改3、 学生信息的添加、查询、修改、浏览1功能模块图 系统用户管理学生信息管理

2、系统学生信息管理2各个模块详细的功能描述。1、系统用户管理模块管理员和普通用户通过这个模块登陆系统,不同的用户用不同的用户名登陆,通过选择登陆模式(管理员或者普通用户)登陆系统,完成不同的操作。两种用户都可以对自己的登陆密码进行修改。新用户可进行注册操作,注册后登陆,并进行信息的完善。2、学生信息管理模块管理员和普通用户对学生信息由不同的操作。管理员可以对信息进行增加,删除,修改和列表查看,普通用户对自己的信息可进行查询,和修改。 四详细设计1功能函数的调用关系图 Query()Comfirm()add() 管理员界面Delete()Liulan()UpdateCode()Login()主界面

3、登陆Query()Comfirm()Updateinfo() 普通用户界面UpdateCode() 查询信息操作 添加信息操作 删除信息操作 总体浏览操作 修改密码操作 查询个人信息 修改个人信息 修改个人密码系统登录2各功能函数的数据流程图普通用户登录管理员登录判断判断成功成功查询信息修改个人密码添加信息查询个人信息修改个人信息删除信息浏览信息修改密码 退出3重点设计及编码、-学生信息表-create table studentinfo(Sid int primary key identity(1,1),Sname varchar(30) not null,Ssex varchar(10)

4、check(Ssex=男 or Ssex=女),Snumber varchar(8) check(Snumber like 04090-90-90-90-9) not null,Sprofession varchar(30),Sclass varchar(20),Sdate datetime default getDate();-普通用户登陆信息表-create table userinfo( id int primary key identity(1,1), name varchar(30) not null, mima varchar(20) not null);-管理员登陆信息表-cre

5、ate table userinfo( id int primary key identity(1,1), name varchar(30) not null, mima varchar(20) not null);-连接数据库try Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver); catch(ClassNotFoundException e) System.out.print(加载驱动程序失败); String conURL=jdbc:sqlserver:/localhost:1433; DatabaseName=SI

6、MS; try Connection con=DriverManager.getConnection(conURL,sa,majie); Statement st=con.createStatement();、catch(SQLException g) System.out.println(错误代码:+g.getErrorCode();System.out.println(错误内容:+g.getMessage(); 五测试数据及运行结果1 正常测试数据和运行结果登录信息查询修改信息2异常测试数据及运行结果 六调试情况,设计技巧及体会1 改进方案本次课程设计实现了系统的基本功能,做的不是很复杂,

7、跟预期想的结果有些差距,数据库表的设计有点简单,下来还要增加表的复杂度,以及触发器的使用。2体会连接数据库还是比较顺利的,因为之前有简单的使用过数据库。总体来说系统算是完成了,基本功能也都实现了,但是在难度上还是不符合要求,还得增加一些更富有实际价值的设计。七参考文献数据库系统原理与应用 孟彩霞、乔平安、张荣 编著八附录:源代码package com.student.MS;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.GridLayout;import java

8、.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.FocusEvent;import java.awt.event.FocusListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import ja

9、vax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.SwingConstants;public class Add implements ActionListenerJFrame f1;Container ct;JPanel jp,jp1,jp2,jp3;JButton btn1,btn2;JLab

10、el label;JTextField tf1,tf2,tf3,tf4,tf5,tf6;Add()f1=new JFrame();ct=f1.getContentPane();/初始化面板jp=new JPanel();jp1=new JPanel(new GridLayout(6,1);jp2=new JPanel(new GridLayout(6,1);jp3=new JPanel();btn1=new JButton(确定);btn2=new JButton(取消);label=new JLabel(添加学生信息,SwingConstants.CENTER);label.setForeg

11、round(Color.gray);tf1=new JTextField(20);tf2=new JTextField(20);tf3=new JTextField(20);tf4=new JTextField(20);tf5=new JTextField(20);tf6=new JTextField(20);tf6.setText(例:2000-02-02);/文本框加入提示语tf6.addFocusListener(new FocusListener() public void focusGained(FocusEvent e) tf6.setText(); public void foc

12、usLost(FocusEvent e) );jp.add(label);ct.add(jp,North);jp1.add(new JLabel(姓名,SwingConstants.CENTER);jp2.add(tf1);jp1.add(new JLabel(性别,SwingConstants.CENTER);jp2.add(tf2);jp1.add(new JLabel(学号,SwingConstants.CENTER);jp2.add(tf3);jp1.add(new JLabel(专业,SwingConstants.CENTER);jp2.add(tf4);jp1.add(new JL

13、abel(班级,SwingConstants.CENTER);jp2.add(tf5);jp1.add(new JLabel(入学时间,SwingConstants.CENTER);jp2.add(tf6);jp3.add(btn1);jp3.add(btn2);ct.add(jp1,West);ct.add(jp2,East);ct.add(jp3,South);Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width;int y=screen.height;

14、f1.setSize(350,330);int xcenter=(x-350)/2;int ycenter=(y-330)/2;f1.setLocation(xcenter, ycenter);f1.setVisible(true); /f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);btn1.addActionListener(this);btn2.addActionListener(this);public void insert()if(tf1.getText().equals()|tf2.getText().equals()|tf3.

15、getText().equals()|tf4.getText().equals()|tf5.getText().equals()|tf6.getText().equals()JOptionPane.showMessageDialog(f1,请填写完整信息);return;try Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver); catch(ClassNotFoundException e) System.out.print(加载驱动程序失败); String conURL=jdbc:sqlserver:/localhost

16、:1433; DatabaseName=SIMS; try Connection con=DriverManager.getConnection(conURL,sa,majie); Statement st=con.createStatement(); String s=insert into studentinfo values(+tf1.getText()+,+tf2.getText()+,+tf3.getText()+,+tf4.getText()+,+tf5.getText()+,+tf6.getText()+);String query=select * from studentin

17、fo where Snumber=+tf3.getText().trim()+;ResultSet res=st.executeQuery(query);if(res.next()JOptionPane.showMessageDialog(f1,学号信息已经存在!);con.close(); tf3.setText(); else if(tf6.getText().length()!=10)JOptionPane.showMessageDialog(f1,入学时间格式有误!);con.close();tf6.setText();int insert=st.executeUpdate(s);if

18、(insert=1)JOptionPane.showMessageDialog(f1,录入信息成功!);tf1.setText();tf2.setText();tf3.setText();tf4.setText();tf5.setText();tf6.setText(); catch(SQLException e) System.out.println(错误代码:+e.getErrorCode(); System.out.println(错误信息:+e.getMessage(); SuppressWarnings(deprecation)public void actionPerformed(

19、ActionEvent e)String cmd=e.getActionCommand();if(cmd.equals(确定)JOptionPane.showMessageDialog(null,与用户表冲突);insert();else if(cmd.equals(取消)f1.hide(); public Container getCt()return ct;public void setCt(Container ct)this.ct = ct;package com.student.MS;import java.awt.BorderLayout;import java.awt.Color;

20、import java.awt.Container;import java.awt.Dimension;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.sw

21、ing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.JTextField;import javax.swing.SwingConstants;public class Delete implements ActionListenerJFrame f2;Con

22、tainer ct;JPanel jp1,jp2,jp3,jp4;JLabel label; JTextField text;JTable table;/接收数据库中返回的信息JButton btn1,btn2,btn3;Object columnName=姓名,性别,学号,专业,班级,入学时间;Object ar=new Object806;Delete()f2=new JFrame();ct=f2.getContentPane();jp1=new JPanel();jp2=new JPanel();jp3=new JPanel();jp4=new JPanel();label=new JL

23、abel();text=new JTextField();btn1=new JButton(查询);btn2=new JButton(删除);btn3=new JButton(取消);label=new JLabel(请输入要删除的学生姓名:,SwingConstants.CENTER);label.setBackground(Color.blue);table=new JTable(ar,columnName);JScrollPane scroll=new JScrollPane(table);text=new JTextField(20);jp2.add(btn1);jp2.add(btn

24、2);jp2.add(btn3);jp1.add(label);jp1.add(text);ct.add(jp1,North);jp3.setLayout(new BorderLayout();jp3.add(new JLabel(学生信息如下);jp3.add(scroll);ct.add(jp2,South);ct.add(jp3,Center);Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width;int y=screen.height;f2.setS

25、ize(450, 400);int xcenter=(x-450)/2;int ycenter=(y-400)/2;f2.setLocation(xcenter, ycenter);f2.setVisible(true);/f2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);btn1.addActionListener(this);btn2.addActionListener(this);btn3.addActionListener(this);int i=0;public void show(String s) while(i=0)ari0=;

26、ari1=;ari2=;ari3=;ari4=;ari5=;i-;i=0; try Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver); catch(ClassNotFoundException e) System.out.print(加载驱动程序失败); String conURL=jdbc:sqlserver:/localhost:1433; DatabaseName=SIMS; try Connection con=DriverManager.getConnection(conURL,sa,majie); Stateme

27、nt st=con.createStatement(); String sql=select * from studentinfo where Sname=+s+; ResultSet res=st.executeQuery(sql); /*if(!(res.next() JOptionPane.showMessageDialog(f,所要查询的信息不存在); */ while(res.next() String sName=res.getString(1); String sSex=res.getString(2); String sNumber=res.getString(3); Stri

28、ng sProfession=res.getString(4); String sClass=res.getString(5); String sDate=res.getString(6); ari0=sName;ari1=sSex;ari2=sNumber;ari3=sProfession;ari4=sClass;ari5=sDate; i+; f2.repaint(); con.close(); catch(SQLException e)System.out.println(错误代码:+e.getErrorCode();System.out.println(错误信息:+e.getMessa

29、ge();public void delete(int line)try Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver); catch(ClassNotFoundException e) System.out.print(加载驱动程序失败); String conURL=jdbc:sqlserver:/localhost:1433; DatabaseName=SIMS; try Connection con=DriverManager.getConnection(conURL,sa,majie); Statement st

30、=con.createStatement(); String name=(String)(arline2); String sql=delete from studentinfo where Snumber =+name+; int del=st.executeUpdate(sql); if(del=1) arline0=;arline1=;arline2=;arline3=;arline4=;arline5=; JOptionPane.showMessageDialog(null,删除成功!, 信息, JOptionPane.YES_NO_OPTION); con.close(); f2.r

31、epaint(); catch(SQLException e) System.out.println(错误代码:+e.getErrorCode();System.out.println(错误信息:+e.getMessage(); SuppressWarnings(deprecation)public void actionPerformed(ActionEvent e)String cmd=e.getActionCommand();if(cmd.equals(查询)String qu=text.getText().trim();show(qu);if(cmd.equals(删除)int de=

32、table.getSelectedRow();if(de=-1)JOptionPane.showMessageDialog(null,请选定要删除的行, 错误信息, JOptionPane.YES_NO_OPTION);elsedelete(de);if(cmd.equals(取消)f2.hide(); package com.student.MS;import java.awt.Color;import java.awt.Container;import java.awt.Dimension;import java.awt.Toolkit;import java.awt.event.Acti

33、onEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax

34、.swing.JScrollPane;import javax.swing.JTable;import javax.swing.SwingConstants; public class Liulan implements ActionListenerJFrame f4;Container ct;JPanel jp1,jp2,jp3,jp4;JLabel label;JButton btn1,btn2;JTable table;Object ar=new Object806;Object columnName=姓名,性别,学号,专业,班级,入学时间;Liulan()f4=new JFrame()

35、;ct=f4.getContentPane();jp1=new JPanel();jp2=new JPanel();jp3=new JPanel();jp4=new JPanel();btn1=new JButton(点击浏览);btn2=new JButton( 取消 );label=new JLabel(学生信息浏览,SwingConstants.CENTER);label.setBackground(Color.blue);table=new JTable(ar, columnName);JScrollPane scroll=new JScrollPane(table);jp1.add(

36、label);jp2.add(btn1);jp2.add(btn2);jp3.add(scroll);ct.add(jp1,North);ct.add(jp3,Center);ct.add(jp2,South);Toolkit kit=Toolkit.getDefaultToolkit();Dimension screen=kit.getScreenSize();int x=screen.width;int y=screen.height;f4.setSize(500,530);int xcen=(x-500)/2;int ycen=(y-530)/2;f4.setLocation(xcen,

37、ycen);f4.setVisible(true);btn1.addActionListener(this);btn2.addActionListener(this);int i=0;public void select()while(i=0)ari0=; ari1=;ari2=;ari3=;ari4=;ari5=;i-;i=0;try Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver); catch(ClassNotFoundException e) System.out.print(加载驱动程序失败); String co

38、nURL=jdbc:sqlserver:/localhost:1433; DatabaseName=SIMS; try Connection con=DriverManager.getConnection(conURL,sa,majie); Statement st=con.createStatement(); String s=select * from studentinfo; ResultSet res=st.executeQuery(s); while(res.next() String sName=res.getString(1); String sSex=res.getString

39、(2); String sNumber=res.getString(3); String sProfession=res.getString(4); String sClass=res.getString(5); String sDate=res.getString(6); ari0=sName; ari1=sSex;ari2=sNumber;ari3=sProfession;ari4=sClass;ari5=sDate; i+; f4.repaint(); con.close(); catch(SQLException e)System.out.println(错误代码:+e.getErro

40、rCode();System.out.println(错误信息:+e.getMessage();SuppressWarnings(deprecation)Overridepublic void actionPerformed(ActionEvent e)String cmd=e.getActionCommand();if(cmd.equals(点击浏览)select();else if(cmd.equals( 取消 )f4.hide(); package com.student.MS;import java.awt.Color;import java.awt.Container;import

41、java.awt.Dimension;import java.awt.Toolkit;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.sql.ResultSet;import java.sql.SQLExce

42、ption;import java.sql.Statement;import java.sql.Connection;import java.sql.DriverManager;import javax.swing.ButtonGroup;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import jav

43、ax.swing.JRadioButton;import javax.swing.JTextField;import javax.swing.SwingConstants; SuppressWarnings(serial)class Login extends JFrame implements ActionListener Container cp=null; JFrame f=null; JButton button1,button2,button3; JTextField t1; JPasswordField t2; JLabel jlable1,jlable2; JRadioButto

44、n rabtn1,rabtn2; Color c; JPanel jp1,jp2,jp3; String table=null; Login() f=new JFrame(学生信息管理系统); button1=new JButton(确定); button2=new JButton(取消); button3=new JButton(注册); /button3.setOpaque(false); button3.setBorder(null); button3.setBackground(Color.getColor(#292421); rabtn1=new JRadioButton(普通用户)

45、; rabtn1.setBackground(Color.getColor(#292421); rabtn2=new JRadioButton(管理员); rabtn2.setBackground(Color.getColor(#292421); ButtonGroup group=new ButtonGroup(); group.add(rabtn1); group.add(rabtn2); cp=f.getContentPane(); jlable1=new JLabel(输入用户名); jlable2=new JLabel(输入密码); jp1=new JPanel(); jp2=new

46、 JPanel(); jp3=new JPanel(); t1=new JTextField(20); t2=new JPasswordField(20); /jp3.add(group); jp1.add(jlable1); jp1.add(t1); jp1.add(jlable2); jp1.add(t2); jp1.add(rabtn1); jp1.add(rabtn2); jp1.add(button3); JLabel JL=new JLabel(欢迎登陆 + ,SwingConstants.CENTER); cp.add(JL,North); jp2.add(button1); j

47、p2.add(button2); cp.add(jp1,Center); cp.add(South,jp2); cp.setBackground(new Color(127, 255, 212 ); jp2.setBackground(new Color(127, 255, 212 ); jp1.setBackground(new Color(127, 255, 212 ); Toolkit kit=Toolkit.getDefaultToolkit(); Dimension screen=kit.getScreenSize(); int x=screen.width; int y=scree

48、n.height; f.setSize(300,300); int xcenter=(x-300)/2; int ycenter=(y-300)/2; f.setLocation(xcenter,ycenter);/*显示在窗口中央*/ f.setVisible(true); /f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);/-/ /*监听事件*/ button1.addActionListener(this); button2.addActionListener(this); button3.addActionListener(this);

49、 rabtn1.addItemListener(new ItemListener()Overridepublic void itemStateChanged(ItemEvent e) JRadioButton jop=(JRadioButton) e.getSource(); if (jop.isSelected() table=userinfo;); rabtn2.addItemListener(new ItemListener()Overridepublic void itemStateChanged(ItemEvent e) JRadioButton jop=(JRadioButton)

50、 e.getSource(); if (jop.isSelected() table=manager;); f.addWindowListener(new WindowAdapter() public void windowClosing(WindowEvent e) System.exit(0); ); SuppressWarnings(deprecation)public void confirm(String tableName) try Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver); catch(ClassNotFoundException e) System.out.print(加载驱动程序失败); String conURL=jdbc:sqlserver:/localhost:1433; DatabaseName=SIMS; try Connection con=DriverManager.getConnection(conURL,sa,majie); State

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

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!