数据库课程设计学生管理系统附代码Word文档格式.docx

上传人:b****5 文档编号:20371878 上传时间:2023-01-22 格式:DOCX 页数:54 大小:64.25KB
下载 相关 举报
数据库课程设计学生管理系统附代码Word文档格式.docx_第1页
第1页 / 共54页
数据库课程设计学生管理系统附代码Word文档格式.docx_第2页
第2页 / 共54页
数据库课程设计学生管理系统附代码Word文档格式.docx_第3页
第3页 / 共54页
数据库课程设计学生管理系统附代码Word文档格式.docx_第4页
第4页 / 共54页
数据库课程设计学生管理系统附代码Word文档格式.docx_第5页
第5页 / 共54页
点击查看更多>>
下载资源
资源描述

数据库课程设计学生管理系统附代码Word文档格式.docx

《数据库课程设计学生管理系统附代码Word文档格式.docx》由会员分享,可在线阅读,更多相关《数据库课程设计学生管理系统附代码Word文档格式.docx(54页珍藏版)》请在冰豆网上搜索。

数据库课程设计学生管理系统附代码Word文档格式.docx

两种用户都可以对自己的登陆密码进行修改。

新用户可进行注册操作,注册后登陆,并进行信息的完善。

2、学生信息管理模块

管理员和普通用户对学生信息由不同的操作。

管理员可以对信息进行增加,删除,修改和列表查看,普通用户对自己的信息可进行查询,和修改。

四.详细设计

1.功能函数的调用关系图

查询信息操作

添加信息操作

删除信息操作

总体浏览操作

修改密码操作

查询个人信息

修改个人信息

修改个人密码

2.各功能函数的数据流程图

成功

3.重点设计及编码、

--学生信息表--

createtablestudentinfo

Sidintprimarykeyidentity(1,1),

Snamevarchar(30)notnull,

Ssexvarchar(10)check(Ssex='

男'

orSsex='

女'

),

Snumbervarchar(8)check(Snumberlike'

0409[0-9][0-9][0-9][0-9]'

)notnull,

Sprofessionvarchar(30),

Sclassvarchar(20),

SdatedatetimedefaultgetDate()

);

--普通用户登陆信息表--

createtableuserinfo

idintprimarykeyidentity(1,1),

namevarchar(30)notnull,

mimavarchar(20)notnull

--管理员登陆信息表--

--连接数据库—

try{

Class.forName("

"

}catch(ClassNotFoundExceptione){

"

加载驱动程序失败"

}

StringconURL="

jdbc:

;

DatabaseName=SIMS"

try{

Connectioncon=DriverManager.getConnection(conURL,"

sa"

"

majie"

Statementst=con.createStatement();

}catch(SQLExceptiong)

{

"

错误代码:

+g.getErrorCode());

错误内容:

+g.getMessage());

}

五.测试数据及运行结果

1.正常测试数据和运行结果

登录

信息查询

修改信息

2.异常测试数据及运行结果

六.调试情况,设计技巧及体会

1.改进方案

本次课程设计实现了系统的基本功能,做的不是很复杂,跟预期想的结果有些差距,数据库表的设计有点简单,下来还要增加表的复杂度,以及触发器的使用。

2.体会

连接数据库还是比较顺利的,因为之前有简单的使用过数据库。

总体来说系统算是完成了,基本功能也都实现了,但是在难度上还是不符合要求,还得增加一些更富有实际价值的设计。

七.参考文献

《数据库系统原理与应用》——孟彩霞、乔平安、张荣编著

八.附录:

源代码

package;

import;

publicclassAddimplementsActionListener

{

JFramef1;

Containerct;

JPaneljp,jp1,jp2,jp3;

JButtonbtn1,btn2;

JLabellabel;

JTextFieldtf1,tf2,tf3,tf4,tf5,tf6;

Add(){

f1=newJFrame();

ct=f1.getContentPane();

//初始化面板

jp=newJPanel();

jp1=newJPanel(newGridLayout(6,1));

jp2=newJPanel(newGridLayout(6,1));

jp3=newJPanel();

btn1=newJButton("

确定"

btn2=newJButton("

取消"

label=newJLabel("

<

html>

fontcolor=#CC00FFsize='

4'

>

添加学生信息<

/font>

SwingConstants.CENTER);

label.setForeground(Color.gray);

tf1=newJTextField(20);

tf2=newJTextField(20);

tf3=newJTextField(20);

tf4=newJTextField(20);

tf5=newJTextField(20);

tf6=newJTextField(20);

tf6.setText("

例:

2000-02-02"

//文本框加入提示语

tf6.addFocusListener(newFocusListener(){

publicvoidfocusGained(FocusEvente){

tf6.setText("

publicvoidfocusLost(FocusEvente){}

});

jp.add(label);

ct.add(jp,"

North"

jp1.add(newJLabel("

姓名"

SwingConstants.CENTER));

jp2.add(tf1);

性别"

jp2.add(tf2);

学号"

jp2.add(tf3);

专业"

jp2.add(tf4);

班级"

jp2.add(tf5);

入学时间"

jp2.add(tf6);

jp3.add(btn1);

jp3.add(btn2);

ct.add(jp1,"

West"

ct.add(jp2,"

East"

ct.add(jp3,"

South"

Toolkitkit=Toolkit.getDefaultToolkit();

Dimensionscreen=kit.getScreenSize();

intx=screen.width;

inty=screen.height;

f1.setSize(350,330);

intxcenter=(x-350)/2;

intycenter=(y-330)/2;

f1.setLocation(xcenter,ycenter);

f1.setVisible(true);

//f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

btn1.addActionListener(this);

btn2.addActionListener(this);

}

publicvoidinsert(){

if(tf1.getText().equals("

)||tf2.getText().equals("

)||tf3.getText().equals("

)||

tf4.getText().equals("

)||tf5.getText().equals("

)||tf6.getText().equals("

)){

JOptionPane.showMessageDialog(f1,"

请填写完整信息"

return;

try{

Class.forName("

}catch(ClassNotFoundExceptione){

"

StringconURL="

Connectioncon=DriverManager.getConnection(conURL,"

Statementst=con.createStatement();

Strings="

insertintostudentinfovalues('

+tf1.getText()+"

'

'

+tf2.getText()+"

+

tf3.getText()+"

+tf4.getText()+"

+tf5.getText()+"

+tf6.getText()+"

Stringquery="

select*fromstudentinfowhereSnumber='

+tf3.getText().trim()+"

ResultSetres=st.executeQuery(query);

if(res.next()){

JOptionPane.showMessageDialog(f1,"

学号信息已经存在!

con.close();

tf3.setText("

}elseif(tf6.getText().length()!

=10){

入学时间格式有误!

tf6.setText("

}

intinsert=st.executeUpdate(s);

if(insert==1){

录入信息成功!

tf1.setText("

tf2.setText("

tf4.setText("

tf5.setText("

}catch(SQLExceptione){

+e.getErrorCode());

错误信息:

+e.getMessage());

@SuppressWarnings("

deprecation"

publicvoidactionPerformed(ActionEvente){

Stringcmd=e.getActionCommand();

if(cmd.equals("

JOptionPane.showMessageDialog(null,"

与用户表冲突"

insert();

elseif(cmd.equals("

f1.hide();

publicContainergetCt()

{

returnct;

publicvoidsetCt(Containerct)

this.ct=ct;

}

publicclassDeleteimplementsActionListener

JFramef2;

JPaneljp1,jp2,jp3,jp4;

JTextFieldtext;

JTabletable;

//接收数据库中返回的信息

JButtonbtn1,btn2,btn3;

ObjectcolumnName[]={"

};

Objectar[][]=newObject[80][6];

Delete(){

f2=newJFrame();

ct=f2.getContentPane();

jp1=newJPanel();

jp2=newJPanel();

jp4=newJPanel();

label=newJLabel();

text=newJTextField();

查询"

删除"

btn3=newJButton("

请输入要删除的学生姓名:

label.setBackground(Color.blue);

table=newJTable(ar,columnName);

JScrollPanescroll=newJScrollPane(table);

text=newJTextField(20);

jp2.add(btn1);

jp2.add(btn2);

jp2.add(btn3);

jp1.add(label);

jp1.add(text);

jp3.setLayout(newBorderLayout());

jp3.add(newJLabel("

学生信息如下"

));

jp3.add(scroll);

Center"

f2.setSize(450,400);

intxcenter=(x-450)/2;

intycenter=(y-400)/2;

f2.setLocation(xcenter,ycenter);

f2.setVisible(true);

//f2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

btn3.addActionListener(this);

inti=0;

publicvoidshow(Strings){

while(i>

=0)

{

ar[i][0]="

ar[i][1]="

ar[i][2]="

ar[i][3]="

ar[i][4]="

ar[i][5]="

i--;

i=0;

Stringsql="

select*fromstudentinfowhereSname='

+s+"

ResultSetres=st.executeQuery(sql);

/*if(!

(res.next())){

JOptionPane.showMessageDialog(f,"

所要查询的信息不存在"

}*/

while(res.next()){

StringsName=res.getString

(1);

StringsSex=res.getString

(2);

StringsNumber=res.getString(3);

StringsProfession=res.getString(4);

StringsClass=res.getString(5);

StringsDate=res.getString(6);

ar[i][0]=sName;

ar[i][1]=sSex;

ar[i][2]=sNumber;

ar[i][3]=sProfession;

ar[i][4]=sClass;

ar[i][5]=sDate;

i++;

f2.repaint();

con.close();

}catch(SQLExceptione){

"

publicvoiddelete(intline){

Stringname=(String)(ar[line][2]);

deletefromstudentinfowhereSnumber='

+name+"

intdel=st.executeUpdate(sql);

if(del==1){

ar[line][0]="

ar[line][1]="

ar[line][2]="

ar[line][3]="

ar[line][4]="

ar[line][5]="

JOptionPane.showMessageDialog(null,"

删除成功!

"

信息"

JOptionPane.YES_NO_OPTION);

Stringqu=text.getText().trim();

show(qu);

intde=table.getSelectedRow();

if(de==-1){

JOption

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1