C#期末测试大作业.doc

上传人:laozhun 文档编号:2384349 上传时间:2023-02-17 格式:DOC 页数:21 大小:387.50KB
返回 下载 相关 举报
C#期末测试大作业.doc_第1页
第1页 / 共21页
C#期末测试大作业.doc_第2页
第2页 / 共21页
C#期末测试大作业.doc_第3页
第3页 / 共21页
C#期末测试大作业.doc_第4页
第4页 / 共21页
C#期末测试大作业.doc_第5页
第5页 / 共21页
点击查看更多>>
资源描述

《C#期末测试大作业.doc》由会员分享,可在线阅读,更多相关《C#期末测试大作业.doc(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 button1_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

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

当前位置:首页 > 建筑/施工/环境 > 项目建议


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号