C#期末测试大作业

上传人:仙*** 文档编号:30279184 上传时间:2021-10-10 格式:DOC 页数:21 大小:466KB
收藏 版权申诉 举报 下载
C#期末测试大作业_第1页
第1页 / 共21页
C#期末测试大作业_第2页
第2页 / 共21页
C#期末测试大作业_第3页
第3页 / 共21页
资源描述:

《C#期末测试大作业》由会员分享,可在线阅读,更多相关《C#期末测试大作业(21页珍藏版)》请在装配图网上搜索。

1、期末测试大作业:设计学生信息管理系统。一、功能要求:1 实现学生管理系统的登陆功能,按学生和管理员两种用户登录,要求有必要的输入验证和用户合法性验证;2 设计管理员主窗体,要求 实现新增学生功能, 实现查询学生信息功能, 实现修改学生用户功能 实现按年级筛选学生列表功能 实现批量修改学生信息功能 实现学生信息的筛选和排序 实现删除学生信息 实现学生成绩的添加与查看 以上功能大体分为学生信息管理功能和学生成绩管理功能,要求至少实现学生信息管理功能。大作业测试的主要技能点:会使用基本控件设计窗体,并合理布局,会实现MDI风格的窗体;使用ADO.NET 操作数据,能将数据库中的数据读取出来显示在窗体

2、上,能将窗体中的数据保存到数据库。二、书写设计报告报告封面见附录报告内容要求,写出系统的概要设计和详细设计,详细设计中,给出每一实现模块的功能描述、界面截图、主要代码和技术要点说明。最后给出心得体会。苏州科技学院课程结业期末测试大作业课 程 名 称: C#程序设计 专 业 班 级: 计算机科学与技术 所 在 院(系): 电子信息与工程学 姓 名: 孙尊路 指 导 教 师: 填写日期:2014年 6 月一 系统概要设计1 系统总体模块结构设计学生管理系统总体结构的设计分为两个部分的设计,分别是前台界面的设计,后台代码模块的设计。其中前台界面的设计,即对用户所属功能模块设计;而后台代码模块的设计,

3、即对功能代码的具体实现。系统总体模块结构图如下图4-3所示。 学生管理系统用户管理后台管理模块学生管理用户注册用户登录用户注销学生添加学生删除学生修改学生查询图1-1 系统总体模块结构图 其中,后台管理模块由用户管理和学生管理等模块组成。在后台管理模块中,各级管理员可以通过此模块对学生,用户,以及权限进行管理。1.1 系统总体处理流程学生管理系统总体流程图的设计,后台管理模块的设计。系统总体的流程图如图所示。学生管理信息系统用户登录身份验证失败后台管理模块用户注册用户登录学生添加学生删除学生修改学生查询系统总体的流程图1.2数据库设计1.2.1概念结构设计通过了解学生管理系统要实现的功能,可以

4、得学生管理数据库包含的实体有“管理员”、和“学生”。管理员的属性有:用户名、密码,权限读者的属性有:学生姓名、学号、性别、专业、入学时间、家庭住址、所在校区、班级在本系统中,涉及到用户、学生等实体。它们之间的关系如图:E-R图所示。学生学号入学时间班级姓名家庭住址专业性别用户姓名密码权限 实体间的E-R图1.2.2逻辑结构设计 数据库逻辑设计决定了数据库及其应用的整体性能,调优位置。在本系统中,主要设计了管理员表和学生信息表。表的具体设计如下:学生信息表用于存储读者的相关信息,如:姓名,学号,入学时间,性别,班级, 专业, 家庭住址,所在校区等。表的结构如下表41所示 学生信息表字 段 名类型

5、与宽度是否主键是否允许空值说 明学号varchar(50)姓名varchar(50)性别char(8)入学时间varchar(50)专业varchar(50)班级varchar(50)家庭住址varchar(50)所在校区varchar(50)管理员表用于存储借出图书的相关信息,如:用户名,权限。表的结构如下表2-2所示管理员表字 段 名类型与宽度是否主键是否允许空值说 明用户名varchar(50)密码varchar(50)权限char(10)二 系统详细设计与实现 2.1登录界面的详细设计与实现在进入系统进行各项具有相关操作功能的操作之前,首先会先进入登录界面,在此需要输入相关的登录名和密

6、码,并选择是登录,登录运行界面如图所示:图5-1 登录运行界面当管理员登录进入系统后,将会进行相关的操作。下面具体的介绍管理员各个功能模块的界面设计与实现。实现此功能的代码如下:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace学生管理系统 public pa

7、rtial class 登录 : Form public static string name; public static string password; public static string entry; public 登录() InitializeComponent(); private void label2_Click(object sender, EventArgs e) private void 登录_Load(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)

8、 if (this.textBox1.Text = | this.textBox2.Text = ) MessageBox.Show(请输入用户名和密码); else SqlConnection con = new SqlConnection(); /创建连接 con.ConnectionString = server=(local);database=StudentDBMS;uid=sa;pwd=123456; con.Open(); SqlCommand cmd = con.CreateCommand(); cmd.CommandText =select *from 登录; SqlData

9、Reader dr = cmd.ExecuteReader(); if (dr.Read() string power = dr0.ToString(); 主界面 main = new 主界面(); main.Tag = this.FindForm(); this.Visible = false; main.ShowDialog(); this.Close(); else MessageBox.Show(用户名或密码错误!); con.Close(); private void button2_Click(object sender, EventArgs e) this.Close(); pu

10、blic void textBox1_TextChanged(object sender, EventArgs e) name = this.textBox1.Text; SqlConnection con = new SqlConnection(); /创建连接 con.ConnectionString = server=(local);database=StudentDBMS;uid=sa;pwd=123456; con.Open(); SqlCommand cmd = con.CreateCommand(); cmd.CommandText = select 权限 from 登录 whe

11、re 姓名= + this.textBox1.Text + ; SqlDataReader sqlread = cmd.ExecuteReader(CommandBehavior.CloseConnection); if (sqlread.Read() label4.Text = sqlread权限.ToString(); entry =this.label4.Text.Trim(); con.Close(); public void textBox2_TextChanged(object sender, EventArgs e) password = this.textBox2.Text;

12、2.2后台管理模块的详细设计与实现2.2.1学生查询模块设计与实现学生查询模块的功能主要是根据“学号“,“姓名” ,“入学时间” ,“所在班级” ,“家庭住址” “专业”等查询学生信息。此页面主要是操作数据库StudenDBMS的“学生”表,使用模糊查询。学生查询运行界面如图所示:图:学生查询运行界面从界面中,实现此功能的代码如下: using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;u

13、sing System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace 学生管理系统 public partial class 查询学生 : Form public 查询学生() InitializeComponent(); private void label1_Click(object sender, EventArgs e) private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) private void bu

14、tton1_Click(object sender, EventArgs e) string tempValue = comboBox1.ItemscomboBox1.SelectedIndex.ToString(); SqlConnection con = new SqlConnection(); con.ConnectionString = server=(local);uid=sa;password=123456;database=StudentDBMS; if (tempValue = 姓名) string co = select * from 学生 where 姓名= + this.

15、textBox1.Text + ; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(co, con); da.Fill(ds); dataGridView1.DataSource = ds.Tables0; if (tempValue = 入学时间) string co = select * from 学生 where 入学时间= + this.textBox1.Text + ; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapte

16、r(co, con); da.Fill(ds); dataGridView1.DataSource = ds.Tables0; if (tempValue = 学号) string co = select * from 学生 where 学号= + this.textBox1.Text + ; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(co, con); da.Fill(ds); dataGridView1.DataSource = ds.Tables0; if (tempValue = 班级) str

17、ing co = select * from 学生 where 班级= + this.textBox1.Text + ; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(co, con); da.Fill(ds); dataGridView1.DataSource = ds.Tables0; if (tempValue = 专业) string co = select * from 学生 where 专业= + this.textBox1.Text + ; DataSet ds = new DataSet()

18、; SqlDataAdapter da = new SqlDataAdapter(co, con); da.Fill(ds); dataGridView1.DataSource = ds.Tables0; if (tempValue = 家庭住址) string co = select * from 学生 where 家庭住址= + this.textBox1.Text + ; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(co, con); da.Fill(ds); dataGridView1.DataS

19、ource = ds.Tables0; if (tempValue = 所在校区) string co = select * from 学生 where 所在校区= + this.textBox1.Text + ; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(co, con); da.Fill(ds); dataGridView1.DataSource = ds.Tables0; private void button2_Click(object sender, EventArgs e) this.Clo

20、se(); 2.2.2学生添加模块的设计与实现学生添加运行界面如图5-3所示:图:学生添加运行界面实现此功能的代码如下:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace 学生管理系统 public partial clas

21、s 添加学生 : Form public 添加学生() InitializeComponent(); private void 添加学生_Load(object sender, EventArgs e) private void groupBox1_Enter(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e) if (this.textBox1.Text != ) string a = this.textBox1.Text; string c = this.textBox2.Te

22、xt; string b = this.dateTimePicker1.Value.ToShortDateString(); string d = this.textBox4.Text; string er = this.textBox5.Text; string f =this.textBox6.Text; string g = this.textBox7.Text; string h = this.textBox8.Text; SqlConnection con = new SqlConnection(); con.ConnectionString = server=(local);dat

23、abase=StudentDBMS;uid=sa;pwd=123456; SqlCommand cmd = con.CreateCommand(); cmd.CommandText = insert into 学生(姓名,入学时间,学号,班级,性别,专业,家庭住址,所在校区) + values( + a + , + b + , + c + , + d + , + er + , + f + , + g + , + h + ); con.Open(); int dd = cmd.ExecuteNonQuery(); if (dd = 1) MessageBox.Show(添加成功!); else

24、MessageBox.Show(请输入用户名!); private void button2_Click(object sender, EventArgs e) this.Close(); private void textBox6_TextChanged(object sender, EventArgs e) private void label7_Click(object sender, EventArgs e) private void textBox1_TextChanged(object sender, EventArgs e) 2.2.3 删除学生模块的设计与实现删除学生模块的功能

25、主要是根据学生姓名。删除学生运行界面如图5-4所示: 图:删除运行界面实现此功能的代码如下:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace学生管理系统 public partial class 删除学生 : Form p

26、ublic 删除学生() InitializeComponent(); private void button1_Click(object sender, EventArgs e) DialogResult result=new DialogResult (); result = MessageBox.Show(确定要删除该学生?,警告!,MessageBoxButtons .OKCancel ,MessageBoxIcon .Warning ); switch (result ) case DialogResult.OK: SqlConnection con = new SqlConnect

27、ion(); con.ConnectionString = server=(local);database=StudentDBMS;uid=sa;pwd=123456; SqlCommand cmd = con.CreateCommand(); cmd.CommandText = delete from 学生 where 姓名= + this.textBox1.Text + ; cmd.Connection = con; con.Open(); int d = cmd.ExecuteNonQuery(); if (d = 1) MessageBox.Show(删除成功); break; cas

28、e DialogResult.Cancel: break; private void button3_Click(object sender, EventArgs e) this.Close(); private void button2_Click(object sender, EventArgs e) textBox1.Clear(); private void button3_Click_1(object sender, EventArgs e) this.Close(); private void textBox1_TextChanged(object sender, EventArg

29、s e) 2.2.4浏览学生模块的设计与实现浏览学生运行界面如图5-5所示:图:浏览学生运行界面浏览按钮的主要代码:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace 学生管理系统 public partial class

30、浏览学生 : Form public 浏览学生() InitializeComponent(); SqlConnection con = new SqlConnection(); con.ConnectionString = server=(local);uid=sa;password=123456;database=StudentDBMS; string co = select * from 学生 ; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(co, con); da.Fill(ds); dataGr

31、idView1.DataSource = ds.Tables0; private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) 2.2.5添加用户模块的设计与实现添加用户运行界面如图:所示图:添加用户运行界面具体的用户添加的主要代码:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.

32、Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace 学生管理系统 public partial class 添加用户 : Form public 添加用户() InitializeComponent(); private void label4_Click(object sender, EventArgs e) private void textBox1_TextChanged(object sender, EventArgs e) private void button

33、1_Click(object sender, EventArgs e) int m = 0; if (this.textBox1.Text = | this.textBox2.Text = | this.textBox3.Text = | boBox1.Text = ) MessageBox.Show(请输入完整信息!); else if (this.textBox2.Text != this.textBox3.Text) MessageBox.Show(两次密码输入不一致!, 警告); else SqlConnection con = new SqlConnection(); con.Con

34、nectionString = server=(local);database=StudentDBMS;uid=sa;pwd=123456; SqlCommand cmd = con.CreateCommand(); /cmd.CommandText = select * from 登录 where 姓名= + this.textBox1.Text + ; /con.Open(); / SqlDataReader dr = cmd.ExecuteReader(); / if (dr.Read() / / MessageBox.Show(用户名 + this.textBox1.Text + 已经

35、存在!); / con.Close(); / /else / cmd.CommandText = insert into 登录 (姓名,密码,权限) + values ( + this.textBox1.Text + , + this.textBox3.Text + , + boBox1.Items comboBox1.SelectedIndex.ToString () + ); con.Open(); m=cmd.ExecuteNonQuery(); / if (m = 1) MessageBox.Show(添加用户成功!); con.Close(); private void comboB

36、ox1_SelectedIndexChanged(object sender, EventArgs e) private void button2_Click(object sender, EventArgs e) this .Close (); private void 添加用户_Load(object sender, EventArgs e) 2.2.6删除用户模块的设计与实现用户删除运行界面如图:所示图:用户删除运行界面用户删除运行的代码如下:using System;using System.Collections.Generic;using System.ComponentModel

37、;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;namespace学生管理系统 public partial class 删除用户 : Form public 删除用户() InitializeComponent(); private void textBox1_TextChanged(object sender, EventArgs e) private void button2_Click(object sende

38、r, EventArgs e) this.Close(); private void button1_Click(object sender, EventArgs e) SqlConnection con = new SqlConnection(); con.ConnectionString = server=(local);database=StudentDBMS;uid=sa;pwd=123456; SqlCommand cmd = con.CreateCommand(); cmd.CommandText = delete from 登录 where 姓名= + this.textBox1

39、.Text + ; cmd.Connection = con; con.Open(); int d = cmd.ExecuteNonQuery(); if (d = 1) MessageBox.Show(删除成功); private void 删除用户_Load(object sender, EventArgs e) 总结 通过这次的课程设计让我对于C#的部分知识有了一定的认识和提高,例如关于和数据库的连接,关于sql语句和对于一些事件的处理。而且通过此次课程设计提高了自己的动手能力和独立完成作业的能力,在此课程设计中, 我知道了该如何用C#来开发一个系统,及其相关的事件处理,和相应的页面布局

40、。对于本系统,巧妙地运用窗体应用程序与SQL SERVER数据库的完美结合是开发成功的必要条件。我认为这个在学生管理系统中的采用用户控件的设计,比较具有新意,为其他网页的设计做了铺垫。简单明了,是本站的最大特点,但程序仍有不完整之处,那就是安全性的问题。在整个的设计中我还有更深的体会,那就是想要开发一个好的程序,并不能太注重编码的设计,而使在于系统总体设计和如何分析系统并建立系统模型。严格按照软件工程一个软件设计步骤进行设计。当然也不是说编码的设计不重要,想要编好程序也应该具有良好的编码风格,这样在设计中才会得心应手。设计中还要博众家之长,在遇到困难时要多向老师和同学请教,毕竟一个人的知识有限,还要充分利用网上资源,从多渠道获取知识,多看看别人对程序的设计思想,会对自己有很大的帮助。

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