1、对于后者则要求应用程序功能完备,易使用。该管理系统我使用的是Microsoft Visual Studio 2012 及 Microsoft SQL Server 2008。系统功能流程图图 2.1 系统功能流程三数据库设计3.1本系统的数据库采用的是SQL Server2008 。该数据库包括学生成绩表、用户登录表用于纪录学生的基本信息数据库表结构如下:成绩表物理结构图3.1图3.2用户登录表物理结构:图3.3图3.43.2触发器删除DLB中的记录时同时删除CJB中姓名相同的记录USE studentscoreGO/* Object: Trigger dbo.dlb_delete Scrip
2、t Date: 01/07/2015 12:42:17 */SET ANSI_NULLS ONSET QUOTED_IDENTIFIER ONALTER trigger dbo.dlb_deleteon dbo.dlb after deleteasbegindeclare leib varchar(50) select leib=学生from deleteddelete from cjb where 姓名 in (select 用户名 from deleted)End3.3数据库连接 string constr = Password=617804;Persist Security Info=T
3、rue;User ID=ywj;Initial Catalog=studentscore;Data Source=YANJING; SqlConnection conn = new SqlConnection(constr); string sqlstr = select * from cjb SqlCommand cmd = new SqlCommand(sqlstr, conn); SqlDataReader reader = cmd.ExecuteReader(); DataSet ds = new DataSet(); while (reader.Read() string id =
4、reader学号.ToString(); string name = reader姓名 MessageBox.Show(string.Format(id=0,name=1,学号,姓名); 四系统实现 4.1.登录界面图4.1该界面是学生成绩管理系统的登录界面,可以选择作为学生,管理员或者教师身份登录。每一个进入系统的人都会看到当前的时间,在登录时只有用户名,密码,与身份相符合时才能进入系统,否则登录无法成功。using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;us
5、ing System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.Data.SqlClient;namespace WindowsFormsApplication1 public partial class Form1 : Form static public string sn, sub; public Form1() InitializeComponent(); Form2 fr2 = new Form2();
6、 Form3 fr3 = new Form3(); Form4 fr4 = new Form4(); 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) conn.Open(); if (textname.Text = | textpassword.Text = ) MessageBox.Show
7、(信息不全,请不要遗漏信息!); if (rbtnmanager.Checked) string cstr = select * from dlb where 类别=管理员 and 用户名= + textname.Text.Trim() + and 密码= + textpassword.Text.Trim() + SqlCommand comm = new SqlCommand(cstr, conn); SqlDataReader dr = comm.ExecuteReader(); if (dr.Read() sn = textname.Text.Trim(); fr4.Show(); th
8、is.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(); private void button2_Click(object sender, EventArgs e) Application.Exit(); private
9、void timer1_Tick(object sender, EventArgs e) label4.Text = 当前时间: + DateTime.Now.ToLongDateString() + + DateTime.Now.ToLongTimeString();4.2学生成绩管理图4.2设计过程:此部分主要针对学生信息的管理,可以查询学生的所有成绩信息,实现成绩的添加、删除、修改、计算平均分等功能。还可以修改当前用户下的密码。 private void Form2_Load(object sender, EventArgs e) label1.Text = Form1.sn + 同学,
10、欢迎你进入成绩管理系统! groupBox1.Visible = false; groupBox2.Visible = false; private void button3_Click(object sender, EventArgs e) / string constr = Password=null;User ID=BINIANDOUKOUadministrator;Data Source=BINIANDOUKOUSQLEXPRESS /SqlConnection conn = new SqlConnection(constr); /conn.Open(); /SqlDataAdapte
11、r da = new SqlDataAdapter(Select * from cjb where 姓名=+textBox1 .Text , conn); /DataSet ds = new DataSet(); /da.Fill(ds, usertable /dataGridView1.DataSource = ; private void toolStripButton1_Click(object sender, EventArgs e) dataGridView1.Visible = true; SqlDataAdapter da = new SqlDataAdapter(select
12、* from cjb where 姓名= + Form1.sn.Trim() + , conn);/-详细信息 da.Fill(ds, dataGridView1.DataSource = ds.Tables.DefaultView; private void toolStripButton2_Click(object sender, EventArgs e) private void toolStripButton4_Click(object sender, EventArgs e) groupBox1.Visible = true; private void button1_Click_1
13、(object sender, EventArgs e) if (textnpd.Text != textpassword.Text) MessageBox.Show(密码输入有误,请重新输入 if (textnpd.Text = & textpassword.Text = ) MessageBox.Show(密码不允许为空! if (textnpd.Text=textpassword.Text & textnpd.Text != SqlCommand com = new SqlCommand(update dlb set 密码=where 用户名= if (com.ExecuteNonQue
14、ry() = 1)密码更改成功 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) private void toolStripButton5_Click(object sender, EventArgs e) this.Close(); Form1 l = new Form1(); l.Visible = true; private void toolStripButton6_Click(object sender, EventArgs e) /string s; /f
15、or(int i=2;i =6;i+) / / if (int.Parse(ds.Tables.Rows0i.ToString() max) max=int.Parse(ds.Tables if (int.Parse(ds.Tables.Rows0i.ToString()min ) min=int.Parse(ds.Tables txthscore.Text=max.ToString(); txtlscore.Text=min.ToString(); txtall.Text=ds.Tables.Rows0总分 ave=int.Parse(ds.Tables.ToString()/(double
16、)5; txtave.Text=ave.ToString();conn.Dispose(); label2.Text=+DateTime.Now.ToLongDateString()+DateTime.Now.ToLongTimeString();4.3教师管理界面图4.3此部分主要针对教师信息管理,可以查询学生的所有成绩信息,实现成绩的添加、删除、修改、成绩升序排序等功能。private void button1_Click(object sender, EventArgs e) /查找 SqlConnection conn= new SqlConnection(constr); if (comboBox1.Text= SqlCommand cm=new SqlCommand(select 学号,+Form1 .sub + from cjb where 学号=+ textBox1.Text+,conn ); if (cm.ExecuteScalar ()=null)MessageBox.Show(用户名不存在 SqlDataAdapter da =new SqlDataAdapter(+Form1.sub+
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1