数据库原理及应用课程设计学生学籍管理系统设计与实现_第1页
数据库原理及应用课程设计学生学籍管理系统设计与实现_第2页
数据库原理及应用课程设计学生学籍管理系统设计与实现_第3页
数据库原理及应用课程设计学生学籍管理系统设计与实现_第4页
数据库原理及应用课程设计学生学籍管理系统设计与实现_第5页
已阅读5页,还剩22页未读 继续免费阅读

下载本文档

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

文档简介

摘 要学籍管理系统是管理信息系统在学籍管理方面的一个分支和具体的应用,本文介绍了用浏览器朋艮务器(B/S)模式和ASP技术访问Web数据库的优点,通过ASP和ADO技术实现学籍管理的方法,简单谈了基于B/S结构的学生学籍管理系统的设计与实现UDP协议的广播应用程序通信,达到同一局域网内一对多的通信。一、 问题的需求分析当今的校园体制是非常复杂的,为了提高效率,使用计算机系统是一条比较便捷的途径,如果仍使用手工操作或使用相当繁琐的软件,既浪费了人力,又浪费了物力,效率无法提高,为此开发学籍管理系统软件,能够适应现今社会并提高生产效率。开发此学籍管理系统软件,以供教学人员及操作者进行学籍管理,方便操作者随时添加、查询、修改等。该系统软件非常容易被接受,他具有简单易学性,便于管理等功能。他是对学校学籍管理的一种工具。能简单明确的对学生的学籍进行管理。 二、 可行性研究1.对现有产品的分析在windows环境的学籍管理系统是学籍管理的应用程序,最终的产品是帮助行政人员对学籍进行有计划、有步骤、方便的管理学籍。学籍管理系统文件的扩展名.DBC,它属于平面型数据库。库文件下面的表文件的扩展名.DBF。它里面包含着学生的全部信息,是由主界面及库里面的表经过编译和连接而完成的。学籍管理系统生成后,要建立在windows的目录下,可以直接使用。例如:在windows资源管理窗口中,双击这个学籍系统的图标,学籍管理系统就会自动打开这个文件。2.产品系统流程图(逻辑模块图).3.工作产品本工程的设计目标就为学校学籍管理提供快捷方法,使用户能够便捷查询学生档案,使学校管理自动化。软件系统的界面要美观,布局要合理,窗口的内容尽量简单明了的提供信息,语言要通俗易懂,有层次感,分类清晰明了。 根据现有条件和知识我们必须在技术方面,进行学习和提高。4.产品系统流程图关键词: UDP;Socket;数据报;通信;广播目 录1 课题描述12 设计过程22.1 基本设计思路22.2 程序设计32.4程序源代码53 测试223.1运行结果22总 结24参考文献251 课题描述在现实生活中,有些局域网内的用户需要将信息发送到本局域网内的所有站点,并且信息报文不需回复确认,此即局域网内的广播通信,基于UDP实现。用户数据报协议(UDP)是一个无连接协议,使用这种协议时,并不需要在两台计算机之间建立固定的连接,也就是说,通信双方没有服务器和客户机之分,它们之间进行的是对等通信。UDP协议则是无连接的,每个分组都携带完整的目的地址,各分组在系统中独立传送。它不能保证分组的先后顺序,不进行分组出错的恢复与重传,因此不保证传输的可靠性,但是,它提供高传输效率的数据报服务,适于实时的语音、图像传输、广播消息等网络传输。本课题利用Socket 套接字实现主机之间的数据通信,并设计一个局域网内的一个主机对其余主机进行单方不回复确认通信,实现基于UDP的广播通信。IP地址有三种:单播地址、广播地址和多播地址。单播应用于TCP,而广播和多播应用于UDP,它们对需将报文同时传往多个接收者的应用者来说十分重要。一个主机要向网上的所有其他主机发送帧,这就是广播。通过ARP和RARP可以看到这一过程。广播(broadcast)帧即发送给本局域网上所有站点的帧(全1地址)。通常某主机发送广播帧至各目的主机后,目的主机的适配器可以识别该帧属于哪种传播帧,并接受处理。开发工具:VC+ 6.02 设计过程本次设计的基于UDP(User Datagram Protocol)的局域网内的广播通信程序易于实现局域网内多台计算机之间实现通信,适合单用户对本局域网内所有站点通信的需要。UDP协议使用端口号为不同的应用保留其各自的数据传输通道。UDP协议正是采用这一机制实现对同一时刻内多项应用同时发送和接收数据的支持。数据发送一方(可以是客户端或服务器端)将UDP数据报通过源端口发送出去,而数据接收一方则通过目标端口接收数据。2.1 基本设计思路TCP/IP是一个协议族。TCP、UDP都是其中的组成部分,IP位于它们之下。只有UDP才支持广播,TCP是不支持广播的。主机之间一对所有的通讯模式,网络对其中每一台主机发出的信号都进行无条件复制并转发,所有主机都可以接收到所有信息(不管你是否需要),由于其不用路径选择,所以其网络成本可以很低廉。有线电视网就是典型的广播型网络,我们的电视机实际上是接受到所有频道的信号,但只将一个频道的信号还原成画面。在数据网络中也允许广播的存在,但其被限制在二层交换机的局域网范围内,禁止广播数据穿过路由器,防止广播数据影响大面积的主机。在发送方与接收方程序的设计中采用C+语言,并利用Socket 套接字实现主机之间的数据通信,发送主机程序中既有连接状态信息提示,又有发送至接收主机的信息报文,本例采用的状态信息为“ok! Hi”,用来表示已搜寻到本地局域网中的接收主机,已成功发送广播信息;发送的信息报文为“Hello!This is a test”,为各接收主机的接收信息。本设计的Socket 套接字工作流程为:启动SOCKET库,版本为2.0WSAStartu;然后赋值给两个地址,一个用来绑定套接字,一个用来从网络上的广播地址接收消息;无连接协议不用LISTEN也不用ACCEPT,他直接从广播地址上接收消息,但我们必须要设置该套接字为广播类型。发送端的程序需将发送地址改为广播地址,设置套接字为BROADCAST类型。2.2 程序设计接收方程序需将创建SOCK_DGRAM类型的Socket,并将其初始化为广播地址,本例设计接受信息显示时间间隔为2秒,并时时监测广播地址,有信息到达立即放进缓冲区并做处理。流程图如下:图2.1 接受方程序流程图 图2.2 发送方程序流程图2.4程序源代码 这是本人刚学习C+不久时写的一个学生信息管理系统,基本功能没问题。*/*下面分几个文件你可以先建立一个空工程,然后将这几个文件分别添加到工程中(应该会吧?),或者你把文件分别保存,最后打开“学生信息管理系统.cpp”直接编译、连接(会询问建立一个默认的工程)。此程序在VC6.0环境下测试通过。*/文件“学生信息管理系统.cpp”#include#include#includecommon.h#include信息录入.cpp#include信息查询.cpp#include信息排序.cpp#include信息修改.cpp#include信息删除.cppusing namespace std;int main() int a;h1: cout *学生信息管理系统*endlendl; cout1-学生基本信息录入 2-学生信息查询endl; cout3-学生信息排序 4-学生信息修改endl; cout5-学生信息删除 0-退出record_n; /读取record_n,获知文件student.dat中保存有几个学生的数据 infile.close();h2: cout已经记录有record_na; switch(a) case 0:return 0;break; case 1:info_input();break; case 2:info_inquire();break; case 3:info_sort();break; case 4:info_update();break; case 5:info_delete();break; default:coutError!endlendl;goto h2; coutendl; goto h1; return 0;/文件“信息修改.cpp”#include#include#include using namespace std;/*信息修改函数*/void info_update() int i,j,answer,num; student stud1n,stud2n; coutnum; if(num=0)goto h0; else ifstream infile(student.dat,ios:binary); if(!infile) cerrOpen file error!endl; exit(1); if(record_n=0)coutError!n没有记录endl; else for(i=0;irecord_n;i+) /读取所有数据到一个数组 infile.read(char *)&stud1i,sizeof(stud1i); /*进行对比,找到相应学号*/ infile.close(); for(i=0;irecord_n;i+) if(num=stud1i.num) /判断,如果符合查询条件则输出到屏幕 cout学号:setw(20)stud1i.num 姓名:setw(20)endl; cout性别:setw(20)stud1i.sex 出生年月:setw(10)stud1i.birthday.year年stud1i.birthday.month月 endl; cout电话号码:setw(16)stud1i.phone 来自省份:setw(16)stud1i.addressendlendl; j=i; /记录要修改学号的序号 for(i=0;i=record_n) coutError!n未找到该学号,; goto h0; for(i=0;ij;i+) stud2i=stud1i; for(i=j+1;irecord_n;i+) stud2i=stud1i; cout请按照姓名、性别、出生年、月、电话号码、省份的顺序输入学生新信息(若要修改学号请删除该记录后重新录入新信息):stud2j.sexstud2j.birthday.yearstud2j.birthday.monthstud2j.phonestud2j.address;ha: cout是否确定修改该记录?确定输入1,返回输入0answer; if(answer=0)goto h0; if(answer!=0&answer!=1) coutError!endl; goto ha; if(answer=1) fstream iofile(student.dat,ios:out|ios:binary); if(!iofile) cerrOpen file error!endl; exit(1); for(i=0;irecord_n;i+) iofile.write(char *)&stud2i,sizeof(stud2i); iofile.close(); cout该学生信息修改完毕!endl; h0: coutendl;/文件“信息删除.cpp”#include#include#include using namespace std;/*信息删除函数*/void info_delete() int i,j,answer,num; student stud1n,stud2n; cout返回请输入0,删除全部学生信息请输入-1endl; coutnum; if(num=-1) ofstream outfile(record_n.txt,ios:out); if(!outfile) cerrOpen file error!endl; abort(); outfile0; /数据个数恢复为0 outfile.close(); fstream iofile(student.dat,ios:out|ios:binary); if(!iofile) cerrOpen file error!endl; exit(1); iofile.close(); cout学生信息已经全部删除endl; else if(num=0)goto h0; else ifstream infile(student.dat,ios:binary); if(!infile) cerrOpen file error!endl; exit(1); if(record_n=0)coutError!n没有记录endl; else for(i=0;irecord_n;i+) /读取所有数据到一个数组 infile.read(char *)&stud1i,sizeof(stud1i); infile.close(); /*进行对比,找到相应学号*/ for(i=0;irecord_n;i+) if(num=stud1i.num) /判断,如果符合查询条件则输出到屏幕 cout学号:setw(20)stud1i.num 姓名:setw(20)endl; cout性别:setw(20)stud1i.sex 出生年月:setw(10)stud1i.birthday.year年stud1i.birthday.month月 endl; cout电话号码:setw(16)stud1i.phone 来自省份:setw(16)stud1i.addressendlendl; j=i; /记录要删除学号的序号 for(i=0;i=record_n) coutError!n未找到该学号,; goto h0; ha: cout是否确定删除该记录?确定输入1,返回输入0answer; if(answer=0)goto h0; if(answer!=0&answer!=1) coutError!endl; goto ha; if(answer=1) /*将对应学号去掉后,剩余学生信息用stud2记录,清空原文件,再写入文件*/ for(i=0;ij;i+) stud2i=stud1i; for(i=j;irecord_n-1;i+) stud2i=stud1i+1; ofstream outfile(record_n.txt,ios:out); if(!outfile) cerrOpen file error!endl; abort(); outfilerecord_n-1; /记录数据个数 outfile.close(); fstream iofile(student.dat,ios:out|ios:binary); if(!iofile) cerrOpen file error!endl; exit(1); for(i=0;irecord_n-1;i+) iofile.write(char *)&stud2i,sizeof(stud2i); iofile.close(); cout该学号已经删除endl; h0: coutendl;/文件“信息排序.cpp”#include#include#include using namespace std;/*信息排序函数*/void info_sort() int i; coutendl1按学号排序,2按出生年月排序,0返回endl;h3: couti; switch(i) case 0:goto h7; case 1:sort_num();break; case 2:sort_day();break; default:coutError!endlendl;goto h3; h7: coutendl; /*按照学号排序函数*/void sort_num() int i,j; student stud1n,t; ifstream infile(student.dat,ios:binary); if(!infile) cerrOpen file error!endl; exit(1); if(record_n=0)coutError!n没有记录endl; else for(i=0;irecord_n;i+) infile.read(char *)&stud1i,sizeof(stud1i); for(i=0;irecord_n-1;i+) /用起泡法对所有学号进行排序 for(j=0;jstud1j+1.num) t=stud1j; stud1j=stud1j+1; stud1j+1=t; infile.close(); /*将排序好的数据写入文件*/ ofstream outfile(student.dat,ios:out|ios:binary); if(!outfile) cerrOpen file error!endl; exit(1); for(i=0;irecord_n;i+) outfile.write(char *)&stud1i,sizeof(stud1i); outfile.close(); cout排序完成; coutendl; /*按照出生年月排序函数*/void sort_day() int i,j; student stud1n,t; ifstream infile(student.dat,ios:binary); if(!infile) cerrOpen file error!endl; exit(1); if(record_n=0)coutError!n没有记录endl; else for(i=0;irecord_n;i+) infile.read(char *)&stud1i,sizeof(stud1i); /*以下对学生的出生年月进行排序*/ for(i=0;irecord_n-1;i+) /用起泡法对学生出生年份进行排序 for(j=0;jstud1j+1.birthday.year) t=stud1j; stud1j=stud1j+1; stud1j+1=t; for(i=0;irecord_n-1;i+) /用起泡法对出生年份相同的学生的出生月份进行排序 for(j=0;jstud1j+1.birthday.month) t=stud1j; stud1j=stud1j+1; stud1j+1=t; infile.close(); /*将排序好的数据写入文件*/ ofstream outfile(student.dat,ios:out|ios:binary); if(!outfile) cerrOpen file error!endl; exit(1); for(i=0;irecord_n;i+) outfile.write(char *)&stud1i,sizeof(stud1i); outfile.close(); coutendl排序完成endl;/文件“信息录入.cpp”#include#include#include using namespace std; /*信息录入函数*/void info_input() int i=0,j; student stud1n; student *p,*p1; p=stud+i; p1=stud1+record_n; ifstream infile(student.dat,ios:binary); if(record_n=0)coutendl; else if(!infile) cerrOpen file error!endl; exit(1); for(i=0;irecord_n;i+) /for语句读取记录到一个数组,便于进行比较,使输入学号不重复 infile.read(char *)&stud1i,sizeof(stud1i); infile.close(); coutendl; cout请按以下顺序输入学生信息:学号、姓名、性别、出生年、月、电话号码、省份; coutendl如果要终止录入学生信息,请输入0,然后回车endlendl; for(i=0;in;i+,p+,p1+) cout请输入第record_n+i+1p-num; p1-num=p-num; if(p-num=0)break; for(j=0;jnum=stud1j.num) coutError!n输入的学号与已有记录重复!p-namep-sex; cinp-birthday.yearp-birthday.month; cinp-phonep-address; ofstream outfile(student.dat,ios:app|ios:binary); if(!outfile) cerrOpen file error!endl; abort(); outfile.write(char *)&studi,sizeof(studi); outfile.close(); fstream iofile(record_n.txt,ios:out); if(!iofile) cerrOpen file error!endl; abort(); iofilerecord_n+i+1; /记录数据个数 iofile.close(); hi: coutendl; /文件“信息查询.cpp”#include#include#include using namespace std;/*信息查询函数*/void info_inquire() int i;h6: coutendl1按学号查询, 2按姓名查询, 3按性别查询,endl; cout4输出全部学生信息, 0返回endl;h3: couti; switch(i) case 0:goto h7; case 1:acc_num();break; case 2:acc_name();break; case 3:acc_sex();break; case 4:output_all();break; default:coutError!endlendl;goto h3; goto h6;h7: coutendl; /*按照学号查询函数*/void acc_num() int i; int num; student stud1n; ifstream infile(student.dat,ios:binary); if(!infile) cerrOpen file error!endl; goto h5; h4: cout请输入要查询的学生的学号(返回请输入0):num; if(num=0) infile.close(); goto h5; for(i=0;irecord_n;i+) /for语句读取记录到一个数组 infile.read(char *)&stud1i,sizeof(stud1i); infile.close(); for(i=0;irecord_n;i+) if(num=stud1i.num) /判断,如果符合查询条件则输出到屏幕 cout学号:setw(20)stud1i.num 姓名:setw(20)endl; cout性别:setw(20)stud1i.sex 出生年月:setw(10)stud1i.birthday.year年stud1i.birthday.month月 endl; cout电话号码:setw(16)stud1i.phone 来自省份:setw(16)stud1i.addressendlendl; for(i=0;i=record_n)coutError!n未找到该学号,; goto h4;h5: coutendl; /*按照姓名查询函数*/void acc_name() int i; char name20; student stud1n; ifstream infile(student.dat,ios:binary); if(!infile) cerrOpen file error!endl; goto h5; h4: cout请输入要查询的学生的姓名(返回请输入0):name; if(strcmp(name,0)=0) infile.close(); goto h5; for(i=0;irecord_n;i+) infile.read(char *)&stud1i,sizeof(stud1i); infile.close(); for(i=0;irecord_n;i+) if(strcmp(name,)=0) cout学号:setw(20)stud1i.num 姓名:setw(20)endl; cout性别:setw(20)stud1i.sex 出生年月:setw(10)stud1i.birthday.year年stud1i.birthday.month月 endl; cout电话号码:setw(15)stud1i.phone 来自省份:setw(15)stud1i.addressendlendl; for(i=0;i=record_n)coutError!n未找到该姓名,; goto h4;h5: coutendl; /*按照性别查询函数*/void acc_sex() int i; char sex5; student stud1n; ifstream infile(student.dat,ios:binary); if(!infile) cerrOpen file error!endl; goto h5; h4: cout请输入要查询的学生的性别(返回请输入0):sex; if(strcmp(sex,0)=0) infile.close(); goto h5; for(i=0;irecord_n;i+) infile.read(char *)&stud1i,sizeof(stud1i); infile.close(); for(i=0;irecord_n;i+) if(strcmp(sex,stud1i.sex)=0) cout学号:setw(20)stud1i.num 姓名:setw(20)endl; cout性别:setw(20)stud1i.sex 出生年月:setw(10)stud1i.birthday.year年stud1i.birthday.month月 endl; cout电话号码:setw(15)stud1i.phone 来自省份:setw(15)stud1i.addressendlendl; for(i=0;i=record_n)coutError!n未找到该性别的学生记录,; goto h4;h5: coutendl; /*输出全部学生信息*/void output_all() int i; student stud1n; ifstream infile(student.dat,ios:binary); if(!infile) cerrOpen file error!endl; goto h0; if(record_n=0)coutError!n没有记录endl; else for(i=0;irecord_n;i+) infile.read(char *)&stud1i,sizeof(stud1i); cout第i+1个学生数据:endl; cout学号:setw(20)stud1i.num 姓名:setw(20)endl; cout性别:setw(20)stud1i.sex 出生年月:setw(10)stud1i.birthday.year年stud1i.birthday.month月 endl; cout电话号码:setw(15)stud1i.phone 来自省份:setw(15)stud1i.addressendlendl; infile.close();h0: coutendl;/文件“common.h”/*定义类定义类*/struct Day /定义结构体类型Day int year; int month;class student /定义类studentpublic: int num; char name20; char sex5; Day birthday; char phone15; char address15;/*全局变量、函数声明全局变量、函数声明*/const int n=200; /n=200,表示最多可记录20

温馨提示

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

评论

0/150

提交评论