C#与SQL数据库学生成绩管理系统完整代码Word文档下载推荐.docx
- 文档编号:18490340
- 上传时间:2022-12-17
- 格式:DOCX
- 页数:23
- 大小:366.21KB
C#与SQL数据库学生成绩管理系统完整代码Word文档下载推荐.docx
《C#与SQL数据库学生成绩管理系统完整代码Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《C#与SQL数据库学生成绩管理系统完整代码Word文档下载推荐.docx(23页珍藏版)》请在冰豆网上搜索。
学生成绩管理系统是典型的信息管理系统,其开发主要包括后台数据库的建立和维护以及前端应用程序开发两个方面。
对于前者要求建立起数据一致性和完整性强、数据安全性好的数据库。
对于后者则要求应用程序功能完备,易使用。
该管理系统我使用的是MicrosoftVisualStudio2012及MicrosoftSQLServer2008。
系统功能流程图
图2.1系统功能流程
三.数据库设计
3.1本系统的数据库采用的是SQLServer2008。
该数据库包括学生成绩表、用户登录表用于纪录学生的基本信息数据库表结构如下:
成绩表物理结构
图3.1
图3.2
用户登录表物理结构:
图3.3
图3.4
3.2触发器
删除DLB中的记录时同时删除CJB中姓名相同的记录
USE[studentscore]
GO
/******Object:
Trigger[dbo].[dlb_delete]ScriptDate:
01/07/201512:
42:
17******/
SETANSI_NULLSON
SETQUOTED_IDENTIFIERON
ALTERtrigger[dbo].[dlb_delete]
on[dbo].[dlb]afterdelete
as
begin
declare@leibvarchar(50)
select@leib='
学生'
fromdeleted
deletefromcjb
where姓名in(select用户名fromdeleted)
End
3.3数据库连接
stringconstr="
Password=617804;
PersistSecurityInfo=True;
UserID=ywj;
InitialCatalog=studentscore;
DataSource=YANJING"
;
SqlConnectionconn=newSqlConnection(constr);
stringsqlstr="
select*fromcjb"
SqlCommandcmd=newSqlCommand(sqlstr,conn);
SqlDataReaderreader=cmd.ExecuteReader();
DataSetds=newDataSet();
while(reader.Read())
{
stringid=reader["
学号"
].ToString();
stringname=reader["
姓名"
MessageBox.Show(string.Format("
id={0},name={1},学号,姓名"
));
}
四.系统实现
4.1.登录界面
图4.1
该界面是学生成绩管理系统的登录界面,可以选择作为学生,管理员或者教师身份登录。
每一个进入系统的人都会看到当前的时间,在登录时只有用户名,密码,与身份相符合时才能进入系统,否则登录无法成功。
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Threading.Tasks;
usingSystem.Windows.Forms;
usingSystem.Data.SqlClient;
namespaceWindowsFormsApplication1
{
publicpartialclassForm1:
Form
staticpublicstringsn,sub;
publicForm1()
InitializeComponent();
Form2fr2=newForm2();
Form3fr3=newForm3();
Form4fr4=newForm4();
privatevoidForm1_Load(objectsender,EventArgse)
timer1.Start();
privatevoidlabel1_Click(objectsender,EventArgse)
privatevoidbutton1_Click(objectsender,EventArgse)
conn.Open();
if(textname.Text=="
"
||textpassword.Text=="
)
MessageBox.Show("
信息不全,请不要遗漏信息!
);
if(rbtnmanager.Checked)
stringcstr="
select*fromdlbwhere类别='
管理员'
and用户名='
+textname.Text.Trim()+"
'
and密码='
+textpassword.Text.Trim()+"
SqlCommandcomm=newSqlCommand(cstr,conn);
SqlDataReaderdr=comm.ExecuteReader();
if(dr.Read())
sn=textname.Text.Trim();
fr4.Show();
this.Visible=false;
;
else
密码或用户名出错,请重新输入!
textname.Text="
textpassword.Text="
if(rbtnteacher.Checked)
教师'
sub=dr.GetValue(3).ToString();
fr3.Show();
if(rbtnstudent.Checked)
fr2.Show();
conn.Close();
conn.Dispose();
privatevoidbutton2_Click(objectsender,EventArgse)
Application.Exit();
privatevoidtimer1_Tick(objectsender,EventArgse)
label4.Text="
当前时间:
+DateTime.Now.ToLongDateString()+"
+DateTime.Now.ToLongTimeString();
}
4.2学生成绩管理
图4.2
设计过程:
此部分主要针对学生信息的管理,可以查询学生的所有成绩信息,实现成绩的添加、删除、修改、计算平均分等功能。
还可以修改当前用户下的密码。
privatevoidForm2_Load(objectsender,EventArgse)
label1.Text=Form1.sn+"
同学,欢迎你进入成绩管理系统!
groupBox1.Visible=false;
groupBox2.Visible=false;
privatevoidbutton3_Click(objectsender,EventArgse)
//stringconstr="
Password=null;
UserID=BINIANDOUKOU\administrator;
DataSource=BINIANDOUKOU\\SQLEXPRESS"
//SqlConnectionconn=newSqlConnection(constr);
//conn.Open();
//SqlDataAdapterda=newSqlDataAdapter("
Select*fromcjbwhere姓名="
+textBox1.Text,conn);
//DataSetds=newDataSet();
//da.Fill(ds,"
usertable"
//dataGridView1.DataSource=;
privatevoidtoolStripButton1_Click(objectsender,EventArgse)
dataGridView1.Visible=true;
SqlDataAdapterda=newSqlDataAdapter("
select*fromcjbwhere姓名='
+Form1.sn.Trim()+"
conn);
//----详细信息
da.Fill(ds,"
dataGridView1.DataSource=ds.Tables["
].DefaultView;
privatevoidtoolStripButton2_Click(objectsender,EventArgse)
privatevoidtoolStripButton4_Click(objectsender,EventArgse)
groupBox1.Visible=true;
privatevoidbutton1_Click_1(objectsender,EventArgse)
if(textnpd.Text!
=textpassword.Text){MessageBox.Show("
密码输入有误,请重新输入"
if(textnpd.Text=="
&
&
textpassword.Text=="
){MessageBox.Show("
密码不允许为空!
if(textnpd.Text==textpassword.Text&
textnpd.Text!
="
SqlCommandcom=newSqlCommand("
updatedlbset密码='
where用户名='
if(com.ExecuteNonQuery()==1)
密码更改成功"
privatevoiddataGridView1_CellContentClick(objectsender,DataGridViewCellEventArgse)
privatevoidtoolStripButton5_Click(objectsender,EventArgse)
this.Close();
Form1l=newForm1();
l.Visible=true;
privatevoidtoolStripButton6_Click(objectsender,EventArgse)
//strings;
//for(inti=2;
i<
=6;
i++)
//{
//if(int.Parse(ds.Tables["
].Rows[0][i].ToString())<
60)
//s=int.Parse(ds.Tables["
].Rows[0][i].ToString());
//}
privatevoidgroupBox2_Enter(objectsender,EventArgse)
dataGridView1.Visible=false;
privatevoidtoolStripButton3_Click(objectsender,EventArgse)
groupBox2.Visible=true;
Select*fromcjbwhere姓名='
+Form1.sn.Trim()+"
conn);
intmax=0,min=1001;
doubleave=0.0;
for(inti=2;
if(int.Parse(ds.Tables["
].Rows[0][i].ToString())>
max)
max=int.Parse(ds.Tables["
if(int.Parse(ds.Tables["
].Rows[0][i].ToString())<
min)
min=int.Parse(ds.Tables["
txthscore.Text=max.ToString();
txtlscore.Text=min.ToString();
txtall.Text=ds.Tables["
].Rows[0]["
总分"
ave=int.Parse(ds.Tables["
].ToString())/(double)5;
txtave.Text=ave.ToString();
conn.Dispose();
label2.Text="
+DateTime.Now.ToLongDateString()+DateTime.Now.ToLongTimeString();
4.3教师管理界面
图4.3
此部分主要针对教师信息管理,可以查询学生的所有成绩信息,实现成绩的添加、删除、修改、成绩升序排序等功能。
privatevoidbutton1_Click(objectsender,EventArgse)//查找
SqlConnectionconn=newSqlConnection(constr);
if(comboBox1.Text=="
SqlCommandcm=newSqlCommand("
select学号,"
+Form1.sub+"
fromcjbwhere学号='
+textBox1.Text+"
conn);
if(cm.ExecuteScalar()==null){MessageBox.Show("
用户名不存在"
SqlDataAdapterda=newSqlDataAdapter("
+Form1.sub+"
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C# SQL 数据库 学生 成绩管理系统 完整 代码