C SQL学生成绩管理完整.docx
《C SQL学生成绩管理完整.docx》由会员分享,可在线阅读,更多相关《C SQL学生成绩管理完整.docx(31页珍藏版)》请在冰豆网上搜索。
![C SQL学生成绩管理完整.docx](https://file1.bdocx.com/fileroot1/2023-2/9/51c023de-c8c3-47b5-a339-3731d00d3b49/51c023de-c8c3-47b5-a339-3731d00d3b491.gif)
CSQL学生成绩管理完整
学生成绩管理系统
摘要
随着信息技术在管理上越来越深入而广泛的应用,管理信息系统的实施在技术上已逐步成熟。
管理信息系统是一个不断发展的新型学科,任何一个单位要生存要发展,要高效率地把内部活动有机地组织起来,就必须建立与自身特点相适应的管理信息系统。
本系统是在管理信息系统的理论和方法指导下、数据库技术支持下完成的。
本文在结构上首先论述了程序设计目的和意义,然后叙述了开发环境、开发平台以及数据库技术,接着用图片、说明和代码的方式介绍了系统的整体规划,接下来是系统在具体实现中的详细内容,最终本系统能够完成信息的添加、修改、删除、查询等功能,本系统界面友好,操作简单,比较实用,思路缜密严谨,管理起来方便快捷,能有效的达到学生信息的管理的目的。
关键词:
MicrosoftVisualC#2008ExpressEdition,SQLserver2005,界面,权限
目录
第一章绪论1
第二章系统介绍2
第三章数据库的设计3
3.1系统功能流程图3
3.2数据库设计4
3.2.1各表的物理结构4
3.2.2数据库连接代码5
第四章主要内容6
4.1登陆界面6
4.2学生成绩管理界面9
4.3教师管理界面13
4.4管理员界面18
总结22
参考文献23
图表清单
图3.1系统功能流程…………………………………………………………3
图4.1登陆界面………………………………………………………………6
图4.2学生成绩管理界面………………………………………………………9
图4.3教师管理界面…………………………………………………………13
图4.4管理员界面…………………………………………………………18
表3.2.1学生成绩表……………………………………………………………4
表3.2.2用户登录表……………………………………………………………4
第一章绪论
人类有几千年的历史,计算机从产生到现在只不过50多年,而网络的迅速发展也不过10年的时间。
但是,计算机和网络对社会的影响已经迅速扩大,甚至在改变人们的生活。
特别是90年代以来,多媒体和网络技术的飞速发展正在以惊人的速度改变着人们的工作方式、交往方式和生活方式。
正像著名的未来学家尼葛洛庞帝(1997)所说的:
“数字不再只和计算有关,它决定我们的生存。
”科学技术是第一生产力,是最先进的生产力。
现在,已经没有人怀疑信息技术的发展将会引起人类社会全面和深刻的变革,使人类社会由工业社会迈向信息社会。
目前,在社会各个方面都呈现出了与工业社会显著不同的特点。
网上书店,网上医院,网上学校,网上购物,网上银行,政府上网等新事物如雨后春笋般涌现出来,对人们的传统生活方式、工作方式产生极大的冲击。
使人们感受到技术发展的脉搏和信息时代前进的步伐。
随着学校的规模不断扩大,学生数量急剧增加,有关学生的各种信息量也成倍增长。
面对庞大的信息量需要有学生管理系统来提高学生管理工作的效率。
通过这样的系统可以做到信息的规范管理、科学统计和快速查询、修改、增加、删除等,从而减少管理方面的工作量。
第二章系统介绍
本系统主要用于学校学生信息管理,总体任务是实现学生信息关系的系统化、规范化和自动化,其主要任务是用计算机对学生信息进行日常管理,如查询、修改、增加、删除,另外还考虑到用户登录的权限,针对学生信息和权限登录的学生成绩管理系统。
本系统主要包括注册管理、教师管理、学生信息查询、添加、修改、删除等部分。
其功能主要有:
(1)学生信息的添加,包括输入学生基本信息和成绩。
(2)学生信息的查询,包括查询学生基本信息和成绩。
(3)学生信息的修改,包括修改学生基本信息和成绩。
(4)学生信息的删除,包括修改学生基本信息和成绩。
(5)登录用户密码修改,用户登录到系统可进行相应的用户密码修改。
(6)管理员用户对用户名的管理,包括添加新用户、删除用户。
学生成绩管理系统是典型的信息管理系统,其开发主要包括后台数据库的建立和维护以及前端应用程序的开发两个方面。
对于前者要求建立起数据一致性和完整性强、数据安全性好的库。
而对于后者则要求应用程序功能完备,易使用等特点。
经过分析,我们使用Microsoft公司的VisualC#2008ExpressEdition开发工具,利用其提供的各种面向对象的开发工具,尤其是数据窗口这一能方便而简洁操纵数据库的智能化对象,首先在短时间内建立系统应用原型,然后,对初始原型系统进行需求迭代,不断修正和改进,直到形成用户满意的可行系统。
第三章数据库的设计
3.1系统功能流程图
退出
图3.1系统功能流程
3.2数据库设计
本系统的数据库是SQLserver数据库,在SQL环境下创建数据库学生成绩管理系统.mdf文件。
该数据库包括学生成绩表、用户登录表用于纪录学生的基本信息数据库表结构如下所示:
3.2.1各表的物理结构
表3.2.1学生成绩表
表3.2.2用户登录表
3.2.2数据库连接代码
privatevoidbutton1_Click(objectsender,EventArgse)
{
stringconnStr="Server=.。
DataBase=LOCAL。
IntegratedSecurity=True"。
//数据库连接字符串,.表示本机服务器DataBase为表名,IntegratedSecurity=True是采用windows身份验证方式登录
SqlConnectionconn=newSqlConnection(connStr)。
//根据连接字符串,新建数据库连接
stringsqlStr="select*from[student1]"。
//查询student1表的查询语句
SqlCommandcmd=newSqlCommand(sqlStr,conn)。
//根据查询语句和数据库连接,等到查询命令对象
SqlDataReaderreader=cmd.ExecuteReader()。
//从查询命令对象中获得一个读取数据库数据的对象
while(reader.Read())//循环读取下一行数据,如果下一行没有数据返回false
{
stringid=reader["id"].ToString()。
//根据列名获得数据
stringname=reader["name"].ToString()。
stringsex=reader["sex"].ToString()。
MessageBox.Show(string.Format("id={0},name={1},sex={2}",id,name,sex))。
}
}
第四章主要内容
4.1登陆界面
图4.1登录界面
设计过程:
用于输入用户名和密码登录,选择相应的用户类型进入系统,若是用户类型选择错误则不能进入系统。
输入用户名和密码后点击确定判断数据库中的用户是否为合法用户。
设计代码:
usingSystem。
usingSystem.Collections.Generic。
usingSystem.ComponentModel。
usingSystem.Data。
usingSystem.Drawing。
usingSystem.Text。
usingSystem.Windows.Forms。
usingSystem.Data.SqlClient。
namespace学生成绩管理系统
{
publicpartialclassLogin:
Form
{
staticpublicstringsn,sub。
publicLogin()
{
InitializeComponent()。
}
Form2fr2=newForm2()。
Form3fr3=newForm3()。
Form4fr4=newForm4()。
//——————————————————————————创建新窗体
privatevoidLogin_Load(objectsender,EventArgse)
{
timer1.Start()。
//——————————————————————————Timer控件
}
privatevoidbtnlogin_Click(objectsender,EventArgse)
{//Password=123456789。
PersistSecurityInfo=True。
UserID=sa。
InitialCatalog=学生成绩管理系统。
DataSource=FLQ-PC\\SQLEXPRESS
//stringstr="Password=123456789。
PersistSecurityInfo=True。
UserID=sa。
InitialCatalog=学生成绩管理系统。
DataSource=FLQ-PC\\SQLEXPRESS"。
stringstr="Password=123456789。
PersistSecurityInfo=True。
UserID=sa。
InitialCatalog=学生成绩管理系统。
DataSource=FLQ-PC\\SQLEXPRESS"。
SqlConnectionconn=newSqlConnection(str)。
//———————————————————————————————————连接数据库
conn.Open()。
if(txtname.Text==""||txtpassword.Text=="")
MessageBox.Show("请不要遗漏信息!
")。
if(rbtnmanager.Checked)
{
stringcstr="select*from用户登录where类别='管理员'and用户名='"+txtname.Text.Trim()+"'and密码='"+txtpassword.Text.Trim()+"'"。
SqlCommandcomm=newSqlCommand(cstr,conn)。
SqlDataReaderdr=comm.ExecuteReader()。
if(dr.Read())
{sn=txtname.Text.Trim()。
fr4.Show()。
this.Visible=false。
}
else
{
MessageBox.Show("输入有误,请重新输入!
")。
txtname.Text=""。
txtpassword.Text=""。
}
}
if(rbtnteacher.Checked)
{
stringcstr="select*from用户登录where类别='教师'and用户名='"+txtname.Text.Trim()+"'and密码='"+txtpassword.Text.Trim()+"'"。
SqlCommandcomm=newSqlCommand(cstr,conn)。
SqlDataReaderdr=comm.ExecuteReader()。
if(dr.Read())
{sn=txtname.Text.Trim()。
sub=dr.GetValue(3).ToString()。
fr3.Show()。
this.Visible=false。
}
else
{
MessageBox.Show("输入有误,请重新输入!
")。
txtname.Text=""。
txtpassword.Text=""。
}
}
if(rbtnstudent.Checked)
{
stringcstr="select*from用户登录where类别='学生'and用户名='"+txtname.Text.Trim()+"'and密码='"+txtpassword.Text.Trim()+"'"。
SqlCommandcomm=newSqlCommand(cstr,conn)。
SqlDataReaderdr=comm.ExecuteReader()。
if(dr.Read())
{sn=txtname.Text.Trim()。
fr2.Show()。
this.Visible=false。
}
else
{
MessageBox.Show("输入有误,请重新输入!
")。
txtname.Text=""。
txtpassword.Text=""。
}
}
conn.Close()。
conn.Dispose()。
}
privatevoidbutton2_Click(objectsender,EventArgse)
{
Application.Exit()。
}
privatevoidtimer1_Tick(objectsender,EventArgse)
{
label1.Text="当前时间为:
"+DateTime.Now.ToLongDateString()+""+DateTime.Now.ToLongTimeString()。
}
}
}
4.2学生成绩管理界面
图4.2学生成绩管理界面
设计过程:
此部分主要针对学生信息的管理,可以查询学生的所有成绩信息,实现成绩的添加、删除、修改、计算平均分等功能。
还可以修改当前用户下的密码。
设计代码:
usingSystem。
usingSystem.Collections.Generic。
usingSystem.ComponentModel。
usingSystem.Data。
usingSystem.Drawing。
usingSystem.Text。
usingSystem.Windows.Forms。
usingSystem.Data.SqlClient。
namespace学生成绩管理系统
{
publicpartialclassForm2:
Form
{
publicForm2()
{
InitializeComponent()。
}
privatevoidForm2_Load(objectsender,EventArgse)
{
label1.Text=Login.sn+"同学,欢迎您使用本成绩管理系统!
"。
//————————————————————用窗体掉用静态变量
timer1.Start()。
groupBox1.Visible=false。
groupBox2.Visible=false。
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
}
privatevoidbutton3_Click(objectsender,EventArgse)
{
//stringstr="Password=123456789。
PersistSecurityInfo=True。
UserID=sa。
InitialCatalog=学生成绩管理系统。
DataSource=FLQ-PC\\SQLEXPRESS"。
//SqlConnectionconn=newSqlConnection(str)。
//conn.Open()。
//SqlDataAdapterda=newSqlDataAdapter("Select*from学生成绩表where姓名="+textBox1.Text,conn)。
//DataSetds=newDataSet()。
//da.Fill(ds,"usertable")。
//dataGridView1.DataSource=。
}
privatevoidtoolStripButton1_Click(objectsender,EventArgse)
{
stringstr="Password=123456789。
PersistSecurityInfo=True。
UserID=sa。
InitialCatalog=学生成绩管理系统。
DataSource=FLQ-PC\\SQLEXPRESS"。
SqlConnectionconn=newSqlConnection(str)。
conn.Open()。
SqlDataAdapterda=newSqlDataAdapter("Select*from学生成绩表where姓名='"+Login.sn.Trim()+"'",conn)。
//————详细信息
DataSetds=newDataSet()。
da.Fill(ds,"usertable")。
dataGridView1.DataSource=ds.Tables["usertable"].DefaultView。
conn.Close()。
conn.Dispose()。
}
privatevoidtoolStripButton2_Click(objectsender,EventArgse)
{
}
privatevoidtoolStripButton4_Click(objectsender,EventArgse)
{
groupBox1.Visible=true。
}
privatevoidbutton1_Click_1(objectsender,EventArgse)
{
stringstr="Password=123456789。
PersistSecurityInfo=True。
UserID=sa。
InitialCatalog=学生成绩管理系统。
DataSource=FLQ-PC\\SQLEXPRESS"。
SqlConnectionconn=newSqlConnection(str)。
conn.Open()。
if(txtnpd.Text!
=txtnpassword.Text){MessageBox.Show("请确认信密码的正确性!
")。
}
if(txtnpd.Text==""&&txtnpassword.Text==""){MessageBox.Show("密码不允许为空!
")。
}
if(txtnpd.Text==txtnpassword.Text&&txtnpd.Text!
="")
{
SqlCommandcom=newSqlCommand("update用户登录set密码='"+txtnpassword.Text.Trim()+"'where用户名='"+Login.sn.Trim()+"'",conn)。
if(com.ExecuteNonQuery()==1)
{
MessageBox.Show("密码修改成功!
")。
groupBox1.Visible=false。
}
}
conn.Close()。
conn.Dispose()。
}
privatevoidtoolStripButton5_Click(objectsender,EventArgse)
{
this.Close()。
Loginl=newLogin()。
l.Visible=true。
//______________________?
?
?
?
、、、
}
privatevoidtoolStripButton6_Click(objectsender,EventArgse)
{
//stringstr="Password=123456789。
PersistSecurityInfo=True。
UserID=sa。
InitialCatalog=学生成绩管理系统。
DataSource=FLQ-PC\\SQLEXPRESS"。
//SqlConnectionconn=newSqlConnection(str)。
//conn.Open()。
//SqlDataAdapterda=newSqlDataAdapter("Select*from学生成绩表where姓名='"+Login.sn.Trim()+"'",conn)。
//DataSetds=newDataSet()。
//da.Fill(ds,"usertable")。
//strings。
//for(inti=2。
i<=6。
i++)
//{
//if(int.Parse(ds.Tables["usertable"].Rows[0][i].ToString())<60)
//s=int.Parse(ds.Tables["usertable"].Rows[0][i].ToString())。
//}
}
privatevoidgroupBox2_Enter(objectsender,EventArgse)
{
}
privatevoidtoolStripButton3_Click(objectsender,EventArgse)
{
groupBox2.Visible=true。
stringstr="Password=123456789。
PersistSecurityInfo=True。
UserID=sa。
InitialCatalog=学生成绩管理系统。
DataSource=FLQ-PC\\SQLEXPRESS"。
SqlConnectionconn=newSqlConnection(str)。
conn.Open()。
SqlDataAdapterda=newSqlDataAdapter("Select*from学生成绩表where姓名='"+Login.sn.Trim()+"'",conn)。
DataSetds=newDataSet()。
da.Fill(ds,"usertable")。
intmax=0,min=1001。
doubleave=0.0。
for(inti=2。
i<=6。
i++)
{
if(int.Parse(ds.Tables["usertable"].Rows[0][i].ToString())>max)
max=int.Parse(ds.Tables["usertable"].Rows[0][i].ToString())。
if(int.Parse(ds.Tables["usertable"].Rows[0][i