C与SQL数据库学生成绩管理系统完整代码_第1页
C与SQL数据库学生成绩管理系统完整代码_第2页
C与SQL数据库学生成绩管理系统完整代码_第3页
C与SQL数据库学生成绩管理系统完整代码_第4页
C与SQL数据库学生成绩管理系统完整代码_第5页
免费预览已结束,剩余26页可下载查看

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、C#与SQL数据库学生成绩治理系统完整代码数据库技术及应用工程设计报告学生成绩治理系统姓名:Celia Yan2021-01-070 / 30C#W SQL数据库学生成绩治理系统完整代码一.设计目的及意义在如今的高校日常治理中,学生成绩治理系统是其中非常重要的一环,特别是当前学校规模不断扩大,学生人数日益增加, 课程门类多,校区分散等实际情况,学生成绩统计功能 越来越繁重,稍有疏忽就会出现过失.因此,学生成绩治理系统更具有非常大的实际应用意 义.在互联网快速崛起的今天,改革传统的手工录入方式,公正,准确,及时反映学生的信息和成绩的情况,以适应信息时代的要求,是学生成绩治理系统的一个新的理念.通

2、过成绩治理可以大大提升学校的工作效率. 学生成绩治理系统应该完成以下两个方面的内容: 学生 档案资料的治理、学生成绩的治理.通过学生成绩治理系统可以做到信息的标准治理, 科学统计和快速查询、修改、增加、删除等,减少治理方面的工作量.二.主要功能该系统主要用于学校学生信息治理,总体任务是实现学生信息关系的系统化、标准化和自动化,其主要任务是用计算机对学生信息进行日常治理,如查询、修改、增加、删除,另外还考虑到用户登录的权限,针对学生信息和权限登录的学生成绩治理系统.本系统主要包括注册治理、教师治理、学生信息查询、添加、修改、删除等局部.其主要功能有:(1)学生信息的添加,包括输入学生根本信息和成

3、绩.(2)学生信息的查询,包括查询学生的根本信息和成绩.(3)学生信息的修改,包括修改学生根本信息和成绩.(4)学生信息的删除,包括删除学生根本信息和成绩.(5)登录用户密码修改,用户登录到系统可进行相应的用户密码修改.(6)治理员用户对用户名的治理,包括添加新用户、删除用户.学生成绩治理系统是典型的信息治理系统,其开发主要包括后台数据库的建立和维护以及前端应用程序开发两个方面.对于前者要求建立起数据一致性和完整性强、数据平安性1 / 30C#与SQL数据库学生成绩治理系统完整代码好的数据库.对于后者那么要求应用程序功能完备,易使用.及 Microsoft SQL Server该治理系统我使用

4、的是Microsoft Visual Studio 20212021.系统功能流程图学生成绩治理系统学生网既言理系筑教师治理系统登录治理员系统图2.1 系统功能流程三.数据库设计2 / 30C#与SQL数据库学生成绩治理系统完整代码3.1本系统的数据库采用的是SQL Server2021 .该数据库包括学生成绩表、用户登录表用于纪录学生的根本信息数据库表结构如下:成绩表物理结构图3.1匚1菇果3消息学£姓军叶算机硝期相率实用物程面句好象程序谗计粉宴港总廿12挛二80位5S汴的023李二45修7S珊判031手一珞C376钙035刻的E3455905A7B阴63965A1IE75型现F0

5、77区七B2史6183333那么同般81£77B0图3.2用户登录表物理结构:3 / 30C#与SQL数据库学生成绩治理系统完整代码DELU-53034ASQLEk.ntscore - dbo.dlb列名数据类型允许N山值用户名varthar(50)|R密码varchar(50)类别vanchsr50)0科目varhsrtSO) j 7图3.3口见果口IS用尸鼻生码铝晔1江丘1224&67S初用计直4H1遍2侬虑以5£»9契用融访工用物更3营蛔打H英弟4枝酊123K7H勃布5手一123450学生GOTTOMOTf1r7李二9川口学生9S11S.06MIXX

6、X1学生10地asm,.牲11区七0414bma学生取?MW学生n的frKaCM钿mMJiWi20000怪颗出阚苣幽图3.43.2 触发器删除DLB中的记录时同时删除CJB中姓名相同的记录USEstudentscoreGO/* Object:Trigger dbo.dlb_delete Script Date: 01/0力2021 12:42:17 */SETANSI_NULLSONGOSETQUOTED_IDENTIFIEFON4 / 30C#与SQL数据库学生成绩治理系统完整代码GOALTEFtrigger dbo .dlb_deleteon dbo .dlb after delete a

7、sbegindeclare leib varchar(50)select leib='学生'from deleteddelete from cjbwhere 姓名 in (select 用户名 from deleted)End3.3 数据库连接string constr = "Password=617804;Persist Security Info=True;User ID=ywj;Initial Catalog=studentscore;Data Source=YANJING"SqlConnection conn = new SqlConnection

8、(constr);string sqlstr = "select * from cjb" ;|SqlCommanotmd = new SqlCommandsqlstr, conn);SqlDataReader reader = cmd.ExecuteReader();DataSet ds = new DataSet ();while (reader.Read() (string id = reader"学号".ToString();string name = reader"姓名".ToString();MessageBoxShow(

9、string .Format( "id=0,name=1, 学号,姓名"); )5 / 30C#与SQL数据库学生成绩治理系统完整代码四.系统实现4.1.登录界面图4.1该界面是学生成绩治理系统的登录界面,可以选择作为学生,治理员或者教师身份登录.每一个进入系统的人都会看到当前的时间,在登录时只有用户名,密码,与身份相符合时才能进入系统,否那么登录无法成功.using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawi

10、ng;using System.Linq;using System.Text;6 / 30C#W SQL数据库学生成绩治理系统完整代码using System.Threading.Tasks;using System.Windows.Forms;using System.Data.SqlClient;namespace WindowsFormsApplication1public partial class Form1 : Formstatic public string sn, sub;public Form1()InitializeComponent();new Form4();Form2

11、 fr2 = new Form2(); Form3 fr3 = new Form3(); Form4 fr4 =private void Form1_Load( object sender, EventArgs e)timer1.Start();private void label1_Click( object sender, EventArgs e)private void button1_Click( object sender, EventArgs e)7 / 30C#与SQL数据库学生成绩治理系统完整代码string constr = "Password=617804;Per

12、sist Security Info=True;User ID=ywj;Initial Catalog=studentscore;Data Source=YANJING"SqlConnection conn = new SqlConnection (constr);conn.Open();if (textname.Text ="" | textpassword.Text ="")MessageBoxShow("信息不全,请不要遗漏信息!");if (rbtnmanager.Checked) 用户名;falsestring c

13、str = "select * from dlb where 类别='治理员'and='"+ textname.Text.Trim() + "'and 密码="'+ textpassword.Text.Trim() +SqlCommanccomm = new SqlCommandcstr, conn);SqlDataReader dr = comm.ExecuteReader();if (dr.Read()sn = textname.Text.Trim(); fr4.Show();this .Visible =;)

14、 elseMessageBoxShow("密码或用户名出错,请重新输入! ");textname.Text ="" ; textpassword.Text ="")if (rbtnteacher.Checked)8 / 30C#与SQL数据库学生成绩治理系统完整代码string cstr = "select * from dlb where 类别='教师and用户名="'+ textname.Text.Trim() + "'and 密码=" + textpassword.

15、Text.Trim() +""SqlCommancComm = new SqlCommandcstr, conn);SqlDataReader dr = comm.ExecuteReader();if (dr.Read()(sn = textname.Text.Trim(); sub = dr.GetValue(3).ToString();fr3.Show(); this .Visible = false ;)else(MessageBoxShow("密码或用户名出错,请重新输入!");textname.Text =""textpas

16、sword.Text =)if (rbtnstudent.Checked)(string cstr = "select * from dlb where 类别= 学生 and 用户名=" + textname.Text.Trim() + "and 密码=" + textpassword.Text.Trim() +""SqlCommanccomm = new SqlCommandcstr, conn);SqlDataReader dr = comm.ExecuteReader();if (dr.Read()(sn = textname.

17、Text.Trim(); fr2.Show();this .Visible = false9 / 30C#与SQL数据库学生成绩治理系统完整代码) else (MessageBoxShow("密码或用户名出错,请重新输入!");textname.Text ="" ; textpassword.Text ="")conn.Close(); conn.Dispose();)private void button2_Click( object sender, EventArgs e)(Application .Exit();)private

18、 void timer1_Tick( object sender, EventArgs e)(label4.Text ="当前时间:"+ DateTime .Now.ToLongDateString() +"" +DateTime .Now.ToLongTimeString();)4.2学生成绩治理10 / 30C#与SQL数据库学生成绩治理系统完整代码图4.2设计过程:此局部主要针对学生信息的治理,可以查询学生的所有成绩信息,实现成绩的添加、删除、修改、计算平均分等功能.还可以修改当前用户下的密码.private void Form2_Load( ob

19、ject sender, EventArgs e)(label1.Text =Form1.sn + "同学,欢送你进入成绩治理系统!"timer1.Start();groupBox1.Visible =false ;groupBox2.Visible =false ;11 / 30C#W SQL数据库学生成绩治理系统完整代码private void button1_Click( object sender, EventArgs e)(private void button3_Click( object sender, EventArgs e)(/ string constr

20、 = "Password=null;Persist Security Info=True;User ID=BINIANDOUKOUadministrator;Initial Catalog=studentscore;Data Source=BINIANDOUKOUSQLEXPRESS"/SqlConnection conn = new SqlConnection(constr);conn.Open();/SqlDataAdapter da = new SqlDataAdapter("Select * from cjb where姓g="+textBox1

21、 .Text , conn);/DataSet ds = new DataSet();/da.Fill(ds, "usertable");/dataGridView1.DataSource =;private void toolStripButton1_Click( object sender, EventArgs e)(dataGridView1.Visible =true ; groupBox1.Visible = false ;groupBox2.Visible = false ;string constr = "Password=617804;Persis

22、t Security Info=True;User ID=ywj;Initial Catalog=studentscore;Data Source=YANJING"SqlConnection conn = new SqlConnection (constr);姓名conn.Open();SqlDataAdapter da = new SqlDataAdapter ("select * from cjb where12 / 30C#与SQL数据库学生成绩治理系统完整代码='"+ Form1.sn.Trim() +""' , con

23、n); /-详细信息DataSet ds = new DataSet ();da.Fill(ds,"usertable");dataGridView1.DataSource = ds.Tables"usertable" .DefaultView;conn.Close(); conn.Dispose();private void toolStripButton2_Click( object sender, EventArgs e)object sender, EventArgs e)private void toolStripButton4_Click(

24、private void button1_Click_1( object sender, EventArgs e)groupBox1.Visible =true ;string constr = "Password=617804;Persist Security Info=True;User ID=ywj;Initial Catalog=studentscore;Data Source=YANJING"SqlConnection conn = new SqlConnection (constr);conn.Open();if (textnpd.Text != textpas

25、sword.Text) MessageBoxShow("密码输入有误,请重新输入");if (textnpd.Text = "" && textpassword.Text= "") MessageBoxShow(密码不允许为空!"); if (textnpd.Text=textpassword.Text && textnpd.Text !="")13 / 30C#与SQL数据库学生成绩治理系统完整代码SqlCommancbom = new SqlCommand "

26、update dlb set 密码="'+ textpassword.Text.Trim() + "'where 用户名="'+ Form1.sn.Trim() +""' , conn);if (com.ExecuteNonQuery() = 1)(MessageBoxShow("密码更改成功");groupBoxl.Visible = false)conn.Close(); conn.Dispose();)private void dataGridView1_CellContentClick

27、( object sender, DataGridViewCellEventArgs e)private void toolStripButton5_Click( object sender, EventArgs e)(this .Close(); Forml l = new Form1(); l.Visible = true ;)private void toolStripButton6_Click( object sender, EventArgs e)(/ string constr = "Password=null;Persist Security Info=True;Use

28、r ID=BINIANDOUKOUadministrator;Initial Catalog=studentscore;Data Source=BINIANDOUKOUSQLEXPRESS"14 / 30C#W SQL数据库学生成绩治理系统完整代码/SqlConnection conn = new SqlConnection(constr);/conn.Open();/SqlDataAdapter da = new SqlDataAdapter("Select * from cjb where姓g="+textBox1 .Text , conn);/DataSet

29、 ds = new DataSet();/da.Fill(ds, "usertable");/string s;/for(int i=2;i <=6;i+)/ if (int.Parse(ds.Tables"usertable".Rows0i.ToString() <60)/ s=int.Parse(ds.Tables"usertable".Rows0i.ToString();/private void groupBox2_Enter( object sender, EventArgs e)dataGridView1.Vi

30、sible =false ; groupBox1.Visible = false ;private void toolStripButton3_Click( object sender, EventArgs e)groupBox2 .Visible=true ;string constr = "Password=617804;Persist Security Info=True;User ID=ywj;Initial Catalog=studentscore;Data Source=YANJING"SqlConnection conn = new SqlConnection

31、 (constr);conn.Open();15 / 30C#W SQL数据库学生成绩治理系统完整代码姓名SqlDataAdapter da = new SqlDataAdapter ("Select * from cjb where ='"+Form1 .sn .Trim ()+""' , conn);DataSet ds = new DataSet ();da.Fill(ds,"usertable");int max=0,min=1001;double ave = 0.0; |for (int i=2;i <

32、=6;i+)if (int .Parse(ds.Tables "usertable" .Rows0i.ToString()>max)max=nt .Parse(ds.Tables "usertable" .Rows0i.ToString();if(int .Parse(ds.Tables "usertable" .Rows0i.ToString()<min)min=int .Parse(ds.Tables "usertable" .Rows0i.ToString(); Itxthscore.Text=m

33、ax.ToString();txtlscore.Text=min.ToString();txtall.Text=ds.Tables"usertable" .Rows0"总分".ToString();ave=int .Parse(ds.Tables"usertable" .Rows0"总分".ToString()/(double )5;txtave.Text=ave.ToString();conn.Close();conn.Dispose();private void timer1_Tick( object send

34、er, EventArgs e)16 / 30C#与SQL数据库学生成绩治理系统完整代码label2.Text= "当前时间:+DateTime .Now.ToLongDateString()+ DateTime .Now.ToLongTimeString();4.3 教师治理界面图4.3设计过程:此局部主要针对教师信息治理,可以查询学生的所有成绩信息,实现成绩的添加、删除、修改、成绩升序排序等功能.还可以修改当前用户下的密码.private void button1_Click( object sender, EventArgs e) /查找17 / 30C#W SQL数据库学生成

35、绩治理系统完整代码string constr = "Password=617804;Persist Security Info=True;User ID=ywj;Initial Catalog=studentscore;Data Source=YANJING"SqlConnection conn= new SqlConnection (constr);conn.Open();if (comboBox1.Text="学号")SqlCommandcm=newSqlCommand "select学号,"+Form1 .sub + "

36、;from cjbwhere 学号="'+ textBox1.Text+""' ,conn );if (cm.ExecuteScalar ()= null ) MessageBoxShow("用户名不存在"); elseSqlDataAdapter da = new SqlDataAdapter ("select 学 号,"+Form1.sub+" from cjb where学号="'+textBox1.Text+ ""' ,conn);DataSet

37、 ds = new DataSet ();da.Fill (ds ,"chaxun");dataGridView1.DataSource=ds.Tables"chaxun" .DefaultView;if (comboBox1.Text="姓名")SqlComman(tm=new SqlCommand "select姓名,"+ Form1.sub + "fromcjb where 姓名="'+ textBox1.Text+ ""' ,conn );if (cm

38、.ExecuteScalar()= null ) MessageBoxShow("该用户不存在"); elseSqlDataAdapter da = new SqlDataAdapter ("select 姓 名,"+Form1.sub + " from cjb where姓名="'+ textBox1.Text +""' ,conn );18 / 30C#W SQL数据库学生成绩治理系统完整代码DataSet ds = new DataSet ();da.Fill (ds,"table&

39、quot;);dataGridView1.DataSource=ds.Tables"table" .DefaultView; conn.Close();conn.Dispose(); private void textBox1_TextChanged( object sender, EventArgs e) private void toolStripButton2_Click( object sender, EventArgs e) / 查找 groupBox3 .Visible =false ; groupBox1.Enabled = true ; groupBox2.

40、Enabled =false ;private void toolStripButton1_Click( object sender, EventArgs e) /所有成绩groupBox3.Visible =true ;string constr = "Password=617804;Persist Security Info=True;User ID=ywj;Initial Catalog=studentscore;Data Source=YANJING"SqlConnection conn = new SqlConnection (constr);conn.Open(

41、);SqlDataAdapter da = new SqlDataAdapter ("select学号,姓名,"+ Form1.sub19 / 30C#与SQL数据库学生成绩治理系统完整代码+ " from cjb " ,conn);DataSet ds = new DataSet ();da.Fill(ds,"table");dataGridView1 .DataSource =ds.Tables "table" .DefaultView;conn.Close ();conn .Dispose();private

42、 void button2_Click( object sender, EventArgs e) / 修改成绩string constr = "Password=617804;Persist Security Info=True;User ID=ywj;Initial Catalog=studentscore;Data Source=YANJING"SqlConnection conn = new SqlConnection (constr);conn.Open();SqlCommandcom = new SqlCommand "update cjb set &q

43、uot;+ Form1.sub + "='"+ textBox3.Text + "'where 姓名='"+ textBox4.Text +"'" , conn);if (com.ExecuteNonQuery() = 1)MessageBoxShow("修改成功");elseMessageBoxShow("信息有误,请重新输入");conn.Close(); conn.Dispose();private void toolStripButton3_Click(

44、object sender, EventArgs e) 修改 学生成绩groupBox3 .Visible =false ; groupBox2.Enabled = true ;groupBox1.Enabled = false ; groupBox3.Visible = false ;20 / 30C#与SQL数据库学生成绩治理系统完整代码)private void textBox3_TextChanged( object sender, EventArgs e) ()private void groupBox2_Enter( object sender, EventArgs e)()pri

45、vate void button3_Click( object sender, EventArgs e) / 确认修改密码 (string constr = "Password=617804;Persist Security Info=True;User ID=ywj;Initial Catalog=studentscore;Data Source=YANJING"SqlConnection conn = new SqlConnection (constr);conn.Open();if (txtnpd.Text != txtnpassword.Text) MessageB

46、oxShow("两次输入密码不一致,请重新输入");if (txtnpd.Text ="" && txtnpassword.Text ="" ) MessageBoxShow(密码不允许为空,请输入密码);if (txtnpd.Text = txtnpassword.Text && txtnpd.Text !="")SqlCommanctom = new SqlCommand "update dlb set密码="'+txtnpassword.Text.T

47、rim() + "'where 用户名="'+ Form1.sn.Trim() +""' , conn);if (com.ExecuteNonQuery() = 1)21 / 30C#W SQL数据库学生成绩治理系统完整代码 (MessageBoxShow("密码更改成功");groupBoxl.Visible = true ;)conn.Close(); conn.Dispose();)private void toolStripButton5_Click( object sender, EventArgs

48、e)(groupBox4.Visible =true ; groupBox3.Visible = true ;dataGridView1.Visible = false ;)private void toolStripButton4_Click( object sender, EventArgs e) /升序排序(groupBox3.Visible =true ;string constr = "Password=617804;Persist Security Info=True;User ID=ywj;Initial Catalog=studentscore;Data Source

49、=YANJING"SqlConnection conn = new SqlConnection (constr);conn.Open();SqlDataAdapter da = new SqlDataAdapter ("select 学号,姓名,"+ Form1.sub + " from cjb order by "+ Form1.sub + " desc " , conn);DataSet ds = new DataSet ();da.Fill(ds,"table");dataGridView1.Dat

50、aSource = ds.Tables"table" .DefaultView;conn.Close(); conn.Dispose();22 / 30C#与SQL数据库学生成绩治理系统完整代码private void toolStripButton6_Click( object sender, EventArgs e)(this .Close(); Form1 l = new Form1(); l.Visible = true ;private void timer1_Tick( object sender, EventArgs e)(label8.Text ="

51、;当前时间:"+ DateTime .Now.ToLongDateString() +DateTime .Now.ToLongTimeString();4.4 治理员治理界面图4.4设计过程:此局部主要针对治理员的,可以添加和删除所有用户的账号和密码.private void Form4_Load( object sender, EventArgs e)23 / 30C#W SQL数据库学生成绩治理系统完整代码(timer1.Start();labell.Text =Forml.sn + "治理员,欢送进入成绩治理系统!groupBox2.Enabled =false ;p

52、rivate void label1_Click( object sender, EventArgs e)(EventArgs e)txtkm.Enabled =private void radioButton1_CheckedChanged( object sender,(if (radioButton1.Checked) groupBox2.Enabled = true ; true ; private void radioButton2_CheckedChanged( object sender, if (radioButton2.Checked) groupBox2.Enabled =

53、 true ; false ; private void txtyhm_TextChanged( object sender, EventArgsEventArgs e)txtkm.Enabled =e)24 / 30C#W SQL数据库学生成绩治理系统完整代码private void button2_Click( object sender, EventArgs e)(txtkm.Text = txtmm.Text = txtyhm.Text =""private void button3_Click( object sender, EventArgs e)(this .

54、Close(); Form1 l = new Form1(); l.Visible = true ;private void label5_Click( object sender, EventArgs e)(private void timer1_Tick( object sender, EventArgs e)(label5.Text ="当前时间:"+ DateTime .Now.ToLongDateString() +DateTime .Now.ToShortTimeString();private void button1_Click( object sender

55、, EventArgs e)(string constr = "Password=617804;Persist Security Info=True;User ID=ywj;Initial Catalog=studentscore;Data Source=YANJING"25 / 30C#与SQL数据库学生成绩治理系统完整代码SqlConnection conn = new SqlConnection (constr);conn.Open();if (radioButtonl .Checked ) (System.Console .Out.WriteLine("&

56、quot;);if (txtyhm .Text !="" &&txtmm .Text != "" && txtkm .Text !="")(SqlCommanctom = new SqlCommand( "select * from dlb where 用户名 ='"+ txtyhm .Text .Trim ()+'" ,conn);if (com.ExecuteScalar () != null ) MessageBox .Show ("用户已存在 ");elseSqlCommandcm = new SqlCommand( "insert into dlb ( 用户 名,密码,类别,科目)values ('"+ txtyhm .Text + "','" + txtmm .Text + "',' 教师?" +txtkm .Text +"')" ,conn );if (cm.ExecuteNonQuery ()=1)MessageBoxShow("添力口成功");elseMes

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论