武汉工程大学计算机科学与工程学院课程设计报告设计名称:《数据库原理及应用》课程设计设计题目:学生信息管理系统学生学号: 1305120107 专业班级: 2013计算机工程01 学生姓名:何经纬学生成绩:指导教师(职称):刘黎志(副教授)完成时间: 2016-1-6 武汉工程大学计算机科学与工程学院制说明:1、报告中的第一、二、三项由指导教师在综合设计开始前填写并发给每个学生;四、五两项(中英文摘要)由学生在完成综合设计后填写。
2、学生成绩由指导教师根据学生的设计情况给出各项分值及总评成绩。
3、指导教师评语一栏由指导教师就学生在整个综合设计期间的表现、设计完成情况、报告的质量及答辩等方面,给出客观、全面的评价。
4、所有学生必须参加综合设计的答辩环节。
凡不参加答辩者,其成绩一律按不及格处理。
答辩小组成员应由2人及以上教师组成。
5、报告正文字数一般应不少于5000字,也可由指导教师根据本门综合设计的情况另行规定。
6、平时表现成绩低于6分的学生,其综合设计成绩按不及格处理。
7、此表格式为武汉工程大学计算机科学与工程学院提供的基本格式(适用于学院各类综合设计),各教研室可根据本门综合设计的特点及内容做适当的调整,并上报学院批准。
答辩记录表成绩评定表学生姓名:何经纬学号: 1305120107 班级: 2013计算机工程01目录摘要 (II)Abstract (III)第一章绪论 (1)1.1 需求分析 (1)1.2 语言 (1)1.3 数据库 (1)1.4 开发工具特点 (1)第二章设计简介 (2)2.1 系统流程图 (2)2.2 数据库设计 (3)第三章详细设计 (5)3.1 创建数据库 (5)3.2 连接数据库 (5)3.3 登录界面设计 (5)3.4 功能设计 (6)第四章设计结果及分析 (10)4.1 设计结果 (10)4.2 设计分析 (12)总结 (14)致谢 (15)参考文献 (16)摘要学生信息管理系统是典型的信息管理系统,其开发主要包括后台数据库的建立和维护以及前端应用程序的开发两个方面。
对于前者要求建立起数据一致性和完整性强、数据安全性好的库。
而对于后者则要求应用程序功能完备、易使用、界面美观等特点。
本次开发使用了 Microsoft 公司的visualstudio2010 开发工具,利用其提供的各种面向对象的开发工具,尤其是数据窗口这一能方便而简洁操纵数据库的智能化对象,首先在短时间内建立系统应用原型,然后,对初始原型系统进行需求迭代,不断修正和改进,直到形成用户满意的可行系统。
关键词:SQL2012;C#.NET;信息管理系统AbstractStudent information management system is a typical information management system, Its development mainly includes the backstage database's establishment and maintenance as well as the onstage application procedure development. The former needs to establish a data consistency and integrity, data security database. The latter requires the application program function is complete, easy to use, the interface is beautiful and so on. The system uses the Microsoft company's visualstudio2010 development tools, using the various object-oriented development tools, Data window, in particular, First in a short period of time we build a prototype system application, then, the initial prototype system needs iteration, and constantly revised and improved, until the user satisfaction.Keywords:SQL2012; C#.NET; MIS第一章绪论1.1 需求分析随着学校的规模不断扩大,学生数量急剧增加,有关学生的各种信息量也成倍增长。
面对庞大的信息量需要有学生管理系统来提高学生管理工作的效率。
通过这样的系统可以做到信息的规范管理、科学统计和快速查询、修改、增加、删除等,从而减少管理方面的工作量。
1.2 语言C#是微软公司发布的一种面向对象的、运行于.NET Framework之上的高级程序设计语言。
并定于在微软职业开发者论坛(PDC)上登台亮相。
C#是微软公司研究员Anders Hejlsberg的最新成果。
C#看起来与Java有着惊人的相似;它包括了诸如单一继承、接口、与Java几乎同样的语法和编译成中间代码再运行的过程。
但是C#与Java有着明显的不同,它借鉴了Delphi的一个特点,与COM(组件对象模型)是直接集成的,而且它是微软公司 .NET windows网络框架的主角。
C#是一种安全的、稳定的、简单的、优雅的,由C和C++衍生出来的面向对象的编程语言。
它在继承C和C++强大功能的同时去掉了一些它们的复杂特性(例如没有宏以及不允许多重继承)。
C#综合了VB简单的可视化操作和C++的高运行效率,以其强大的操作能力、优雅的语法风格、创新的语言特性和便捷的面向组件编程的支持成为.NET开发的首选语言。
C#是面向对象的编程语言。
它使得程序员可以快速地编写各种基于MICROSOFT .NET平台的应用程序,MICROSOFT .NET提供了一系列的工具和服务来最大程度地开发利用计算与通讯领域。
1.3 数据库SQL Server 是Microsoft 公司推出的关系型数据库管理系统。
具有使用方便可伸缩性好与相关软件集成程度高等优点,可跨越从运行Microsoft Windows 98 的膝上型电脑到运行Microsoft Windows 2012 的大型多处理器的服务器等多种平台使用。
Microsoft SQL Server 是一个全面的数据库平台,使用集成的商业智能 (BI)工具提供了企业级的数据管理。
Microsoft SQL Server 数据库引擎为关系型数据和结构化数据提供了更安全可靠的存储功能,使您可以构建和管理用于业务的高可用和高性能的数据应用程序。
1.4 开发工具特点本系统后台数据库采用Microsoft SQL Server 数据库,该数据库系统在安全性、准确性和运行速度方面有绝对的优势,并且处理数据量大,效率高。
本系统前台采用Microsoft 公司的Visual Studio 2010作为主要开发工具,可与SQL Server 2012数据库无缝链接。
第二章设计简介2.1 系统流程图该系统的流程图如图2.1所示。
图2.1 系统流程图2.2 数据库设计2.2.1 E-R图n1图2.2 学生信息实体联系图2.2.2设计数据表通过E-R 图分析,此学生成绩信息表中有2个表需要建立。
学生信息表(Student),包括学号(StudentId)、姓名(StudentName)、性别(Gender)、出生日期(Birthday)、身份证号(StudentIdNo )、年龄(Age)、手机号码(PhoneNumber )、家庭住址(StudentAddress )、卡号(CardNo )、班级号(ClassId )。
班级号手机号码学生专业班级就读班级号班级名称家庭住址图2.3 学生信息表专业班级表(StudentClass),包括班级号(ClassId),班级名称(ClassName)。
图2.4 专业班级表第三章详细设计3.1 创建数据库建立std数据库SQL代码:create database stdon (name = std,FILENAME ='d:\std.mdf')LOG ON (name = std_Log ,FILENAME ='d:\std.ldf');GOcreate table StudentClass(ClassId int primary key,ClassName varchar(20) not null )gocreate table Students(StudentId int identity(100000,1),StudentName varchar(20) not null,Gender char(2) not null,Birthday datetime not null,StudentIdNo numeric(18,0) not null,Age int not null,PhoneNumber varchar(50),StudentAddress varchar(500),CardNo varchar(20) not null,ClassId int not null)3.2 连接数据库连接数据库代码如下:string connString = "Server=.;DataBase=std;Uid=sa;Pwd=123456";SqlConnection conn = new SqlConnection(connString);3.3 登录界面设计登录界面代码如下:private void button1_Click(object sender, EventArgs e){textAdmin.Text = textAdmin.Text.Trim();textPassword.Text = textPassword.Text.Trim();if (textAdmin.Text == "123456" && textPassword.Text == "123456"){MessageBox.Show("登陆成功,按确认键进入系统。
");this.DialogResult = DialogResult.OK;this.Close();}else{MessageBox.Show("密码错误!");}}3.4 功能设计3.4.1 添加学生信息添加学生信息部分代码如下:private void label2_Click(object sender, EventArgs e){string connString = "Server=.;DataBase=std;Uid=sa;Pwd=123456";SqlConnection conn = new SqlConnection(connString); string sql = "insert into Students(StudentName,Gender,Birthday,StudentIdNo,Age,PhoneNumber,StudentAddress,CardNo,ClassId)";sql += " values('{0}','{1}','{2}',{3},{4},'{5}','{6}','{7}',{8})";Student objStudent = new Student(){StudentName = this.textStuName.Text.Trim(),Gender = this.rdbMale.Checked ? "男" : "女", Birthday = Convert.ToDateTime(this.dateBirthday.Text),StudentIdNo = this.textStuIdNo.Text.Trim(),Age = DateTime.Now.Year -Convert.ToDateTime(this.dateBirthday.Text).Year,PhoneNumber = this.textPhone.Text.Trim(),StudentAddress = this.textaddress.Text.Trim(), CardNo = this.textCardNo.Text.Trim(),ClassId = Convert.ToInt32(this.cboClassName.SelectedValue)};sql = String.Format(sql, objStudent.StudentName, objStudent.Gender, objStudent.Birthday,objStudent.StudentIdNo, objStudent.Age,objStudent.PhoneNumber, objStudent.StudentAddress,objStudent.CardNo, objStudent.ClassId);SqlCommand cmd = new SqlCommand(sql, conn);conn.Open();int result = cmd.ExecuteNonQuery();conn.Close();if (result == 1)MessageBox.Show("添加成功!");elseMessageBox.Show("添加失败!");}3.4.2 查询学生信息查询学生信息部分代码如下:private void button1_Click(object sender, EventArgs e) {string connString = "Server=.;DataBase=std;Uid=sa;Pwd=123456";SqlConnection conn = new SqlConnection(connString);string sql = "selectStudentId,StudentName,Age,StudentIdNo,ClassName,Birthday from Students";sql += " inner join StudentClass onStudents.ClassId=StudentClass.ClassId";sql += " where Students.ClassId=" +this.cboClassName.SelectedValue.ToString();SqlCommand cmd = new SqlCommand(sql, conn);conn.Open();SqlDataReader objReader = cmd.ExecuteReader();List<Student> list = new List<Student>();while (objReader.Read()){list.Add(new Student(){StudentId =Convert.ToInt32(objReader["StudentId"]),StudentName =objReader["StudentName"].ToString(),Age = Convert.ToInt32(objReader["Age"]),ClassName =objReader["ClassName"].ToString(), Birthday =Convert.ToDateTime(objReader["Birthday"])});}objReader.Close();conn.Close();this.dataGridView1.AutoGenerateColumns = false;}3.4.3 删除学生信息删除学生信息部分代码如下:1、按班级删除private void buttonDelete2_Click(object sender, EventArgs e) {string connString = "Server=.;DataBase=std;Uid=sa;Pwd=123456";SqlConnection conn = new SqlConnection(connString); string sql = "delete from Students where Students.ClassId="+this.cboClassName.SelectedValue.ToString();SqlCommand cmd = new SqlCommand(sql, conn);conn.Open();int result = cmd.ExecuteNonQuery();if (result >= 1)MessageBox.Show("删除成功!");elseMessageBox.Show("无此学生信息!");conn.Close();}2、按学号删除private void buttonDelete1_Click(object sender, EventArgs e) {string connString = "Server=.;DataBase=std;Uid=sa;Pwd=123456";SqlConnection conn = new SqlConnection(connString);string sql = "delete from Students where Students.StudentId=" +Convert.ToInt32(this.textStuNo.Text.Trim());SqlCommand cmd = new SqlCommand(sql, conn);conn.Open();int result = cmd.ExecuteNonQuery();if (result >= 1)MessageBox.Show("删除成功!");elseMessageBox.Show("无此学生信息!");conn.Close();}3.3.4 修改学生信息修改学生信息部分代码如下:private void Updatebutton_Click(object sender, EventArgs e){string connString = "Server=.;DataBase=std;Uid=sa;Pwd=123456";SqlConnection conn = new SqlConnection(connString);string sql = "update Students set StudentName='{0}',PhoneNumber={1},StudentAddress='{2}',Birthday='{3}',ClassId={4},StudentIdNo='{5}',Gender='{6}'";sql += " where StudentId=" +this.textStuNo.Text;sql = string.Format(sql, this.textStuName.Text.Trim(), this.textPhone.Text.Trim(),this.textaddress.Text.Trim(), this.dateBirthday.Value,this.cboClassName.SelectedValue,this.textStuIdNo.Text.Trim(),this.textGender.Text.Trim());SqlCommand cmd = new SqlCommand(sql, conn); conn.Open();int result = cmd.ExecuteNonQuery();conn.Close();if (result == 1)MessageBox.Show("修改成功");elseMessageBox.Show("修改失败");}第四章设计结果及分析4.1 设计结果4.1.1登录界面登录界面运行截图如图4.1所示。