洛阳理工学院
课 程 设 计 报 告
课程名称 Web程序设计课程设计
设计题目 学生成绩管理系统
专 业 计算机科学与技术
班 级
学 号
姓 名
完成日期 2014.6.27
目 录
第1章 需求分析................................................................................................................. 1
1.1 系统概述............................................................................................................... 1
1.1.1 流程分析..................................................................................................... 1
1.1.3 系统设计分析.............................................................................................. 1
第2章 数据库设计............................................................................................................ 2
2.1 概念结构设计........................................................................................................ 2
2.1.1 引言............................................................................................................ 2
2.1.2 E-R图....................................................................................................... 2
2.2 逻辑结构设计........................................................................................................ 3
2.2.1 成绩表........................................................................................................ 3
2.2.2 教师表........................................................................................................ 3
2.2.3 课程表........................................................................................................ 3
2.2.4 学生表........................................................................................................ 3
2.2.5 用户表........................................................................................................ 4
第3章 概要设计............................................................................................................... 5
3.1 总体设计............................................................................................................... 5
3.2 界面设计............................................................................................................... 6
3.2.1 界面设计原则.............................................................................................. 6
3.2.2 界面分析与规范.......................................................................................... 6
第4章 详细设计与实现..................................................................................................... 7
4.1 管理员模块介绍..................................................................................................... 7
4.1.1 登录界面子模块登录界面如图4-1所示:................................................... 7
4.1.2 学生主操作界面如4-2所示........................................................................ 9
4.1.3 学生基本信息查询界面如图4-3所示........................................................ 11
4.1.4 学生成绩产讯界面如图4-4所示:........................................................... 13
4.1.5 学生成绩排名界面如图4-5所示............................................................... 16
4.1.6 学生修改基本信息界面如图4-6所示........................................................ 20
第5章 总结..................................................................................................................... 24
第1章 需求分析
1.1 系统概述
经过对部分学生成绩管理网站系统详细调查,并阅读大量相关资料后,加深了对现行管理网站管理业务的了解,在此基础上,对本系统做出简单介绍:本系统提供用户注册、登录功能,且在此基础上可进行成绩的查询、修改、删除、插入等功能,此网站提供友好的页面且是使管理员能够进行简单维护的网站。
1.1.1 流程分析
学校工作总体规划由教务人员在学生信息管理中完成对运行教务处所需的基本数据的维护,包括这些信息的增加、修改及对各项信息的变动都将在这进行操作。
新的学年,教务人员首先加入年级信息,然后编排班级,再对来校学生进行基本的信息录入,新生入学后由教务人员在学籍系统中完成新学生信息的维护。
每举行一次考试后由管理员对成绩进行录入,各位同学对以上录入的信息可以跟据自己的需要进行适当的查询和对自己信息的修改。
1.1.2 系统设计思路
采用现有的资源,先进的管理系统开发方案,充分利用学校现有的资源,减少开发中的时间和财力、物力、提高系统开发的水平和应用效果。
系统就满足学校的需求,例如学生信息的录入、查询、更新等。。
系统就具备数据库维护功能,及时根据用户需求进行数据添加、删除、修改等操作。
1.1.3 系统设计分析
系统功能分析是在系统开发的总体任务的基础上完成的。本套高校学生成绩管理系统需要完成的功能如下:
(1)数据的录入,包括学生基本情况信息以及学生学科成绩的录入等;
(2)对学生基本信息的查询,包括学生基本情况以及学生学科成绩的查询等;
(3)对学生基本信息的修改,包括学生基本情况以及学生学科成绩的修改等;
(4)对教师基本信息的查询,包括学生基本情况以及学生学科成绩的查询等;
(5)对教师基本信息的修改,包括学生基本情况以及学生学科成绩的修改等;
(6)系统用户的管理、权限管理等;
(7)系统用户的密码修改等;
(8)系统的相关设计等;
第2章 数据库设计
2.1 概念结构设计
2.1.1 引言
数据库设计是对于一个给定的应用环境,构造最优的数据库模式,建立数据库及其应用系统,使之能有效地存取数据,满足用户的信息要求和处理要求。数据库设计包括数据库的结构设计和数据库的行为设计,数据库的结构设计是根据给定的应用环境,进行数据库的模式或子模式的设计。本系统的数据库设计采用基于E-R 模型的数据库设计方法。首先,根据调研结果分析系统中存在哪些实体,并确定各实体的属性,再找出各实体间的联系,确定各联系的派生属性,最后按照数据库设计原则产生本系统的所有数据库结构并优化。本系统中存在的实体有:学生、课程、教师、班级、各实体都有自己相应的属性,其中“学生”实体和“课程”之间存在着多对多的联系,其派生属性为成绩。
2.1.2 E-R图
图2-1 E-R图
2.2 逻辑结构设计
2.2.1 成绩表
成绩为课程和学生之间联系派生的属性,如下图2-2所示:
图 2-2 成绩表
2.2.2 教师表
教师表如下图2-3所示:
图2-3 教师表
2.2.3 课程表
课程表如下图2-4所示:
图2-4 课程表
2.2.4 学生表
学生表如下图2-5所示:
图2-5 学生表
2.2.5 用户表
用户表如下图2-6所示:
图 2-6用户表
第3章 概要设计
3.1 总体设计
系统结构图:
图 3-1系统结构图
3.2 界面设计
3.2.1 界面设计原则
(1)用户原则。人机界面设计首先要确立用户类型。划分类型可以从不同的
角度,视实际情况而定。确定类型后要针对其特点预测他们对不同界面的反应。
这就要从多方面设计分析。
(2)信息最小量原则。人机界面设计要尽量减少用户记忆负担,采用有助于
记忆的设计方案。
(3)帮助和提示原则。要对用户的操作命令做出反应,帮助用户处理问题。
系统要有恢复出错现场的能力,在系统内部处理工作要有提示,尽量把主动权让
给用户。
(4)媒体最佳组合原则。多媒体界面的成功并不在于仅向用户提供丰富的媒
体,而应在相关理论指导下,注意处理好各种媒体间的关系,恰当选用。
3.2.2 界面分析与规范
在人机界面设计中,首先应进行界面设计分析,进行用户特性分析,用户任
务分析,记录用户有关系统的概念、术语。
第4章 详细设计与实现
4.1 管理员模块介绍
在本阶段设计中,由于采用小组,我分配到的是对管理员模块进行设计,管理员主要权限就是对本系统中其他用户的管理。由于代码量较大,采取其中两个典型为例:(1)账户信息管理(2)学生信息管理。
4.1.1 登录界面子模块登录界面如图4-1所示:
4-1 学生登录界面
源程序:
public partial class _Default : System.Web.UI.Page
{
int temp = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DropDownList1.Items.Add("管理员");
DropDownList1.Items.Add("教师");
DropDownList1.Items.Add("学生");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string strcnn = ConfigurationManager.ConnectionStrings["stuManConnectionString"].ConnectionString;
string strcmd="";
if(TextBox1.Text!=""&&TextBox2.Text!="")
{
if (DropDownList1.Text == "管理员")
{
strcmd = "select count(*) from 用户表 where 用户名='" + TextBox1.Text + "' and 密码='" + TextBox2.Text + "'";
temp = 1;
}
if (DropDownList1.Text == "教师")
{
strcmd = "select count(*) from 教师表 where 教师编号='" + TextBox1.Text + "' and 密码='" + TextBox2.Text + "'";
temp = 2;
}
if (DropDownList1.Text == "学生")
{
strcmd = "select count(*) from 学生表 where 学号='" + TextBox1.Text + "' and 密码='" + TextBox2.Text + "'";
temp = 3;
}
SqlConnection cnn = new SqlConnection(strcnn);
cnn.Open();
SqlCommand cmd = new SqlCommand(strcmd,cnn);
if ((int)cmd.ExecuteScalar() == 1)
{
this.Session.Add("name", Convert.ToString(TextBox1.Text));
if (temp == 1)
Response.Redirect("管理员//学生信息管理.aspx");
if (temp == 2)
Response.Redirect("教师//Default1.aspx");
if (temp == 3)
Response.Redirect("学生//Default.aspx");
}
else
Response.Write("<script LANGUAGE='javascript'>alert('账号或密码错误!');history.go(-1);</script>");
cnn.Close();
}
else
Response.Write("<script LANGUAGE='javascript'>alert('请输入账号或密码!');history.go(-1);</script>");
}
protected void 登陆_Click(object sender, EventArgs e)
{
DropDownList1.Text = "管理员";
TextBox1.Text = "";
TextBox2.Text = "";
}
}
4.1.2 学生主操作界面如4-2所示
4-2 学生操作主界面
源程序:
public partial class _Default : System.Web.UI.Page
{
string student;
protected void Page_Load(object sender, EventArgs e)
{
student = this.Session["name"].ToString();
string myConnstr = ConfigurationManager.ConnectionStrings["stuManConnectionString"].ConnectionString;
SqlConnection myConn = new SqlConnection(myConnstr);
string sql = "select 姓名 from 学生表 where 学号= '" + student + "'";
SqlCommand myComm = new SqlCommand(sql, myConn);
string name="";
myConn.Open();
SqlDataReader myDataReader = myComm.ExecuteReader();
if(myDataReader.Read())
{
name = myDataReader.GetValue(0).ToString();
}
myConn.Close();
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
this.Response.Redirect("登陆页面.aspx");
}
}
4.1.3 学生基本信息查询界面如图4-3所示
4-3学生基本信息查询
源程序:
public partial class Default2 : System.Web.UI.Page
{
string student;
protected void Page_Load(object sender, EventArgs e)
{
student = this.Session["name"].ToString();
string myConnstr = ConfigurationManager.ConnectionStrings["stuManConnectionString"].ConnectionString;
SqlConnection myConn = new SqlConnection(myConnstr);
string sql = "select 学号,姓名,性别,院系,出生日期,家庭住址,入学时间,政治面貌,备注 from 学生表 where 学号= '"+student+"'";
SqlCommand myComm = new SqlCommand(sql, myConn);
myConn.Open();
SqlDataReader myDataReader = myComm.ExecuteReader();
if(myDataReader.Read())
{
TextBox1.Text = myDataReader.GetValue(0).ToString();
DataBind();
TextBox2.Text = myDataReader.GetValue(1).ToString();
DataBind();
TextBox3.Text = myDataReader.GetValue(2).ToString();
DataBind();
TextBox4.Text = myDataReader.GetValue(3).ToString();
DataBind();
TextBox5.Text = myDataReader.GetValue(4).ToString();
DataBind();
TextBox6.Text = myDataReader.GetValue(5).ToString();
DataBind();
TextBox7.Text = myDataReader.GetValue(6).ToString();
DataBind();
TextBox8.Text = myDataReader.GetValue(7).ToString();
DataBind();
TextBox9.Text = myDataReader.GetValue(8).ToString();
DataBind();
}
myConn.Close();
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
this.Response.Redirect("登陆页面.aspx");
}
}
4.1.4 学生成绩产讯界面如图4-4所示:
4-4 学生成绩查询界面
源程序:
public partial class Default3 : System.Web.UI.Page
{
//static bool x = false;
string student;
protected void Page_Load(object sender, EventArgs e)
{
student = this.Session["name"].ToString();
if (DropDownList1.Text == "")
{
string str = "";
string myConnstr = ConfigurationManager.ConnectionStrings["stuManConnectionString"].ConnectionString;
SqlConnection myConn = new SqlConnection(myConnstr);
string sql = "select distinct 成绩表.日期 from 成绩表,学生表,课程表 where 成绩表.课程号=课程表.课程号 and 成绩表.学号='" + student + "' and 学生表.学号='" + student + "'";
myConn.Open();
//成绩表.学号,学生表.姓名,成绩表.成绩,课程表.课程名,
SqlCommand myComm = new SqlCommand(sql, myConn);
SqlDataReader myDataReader = myComm.ExecuteReader();
while (myDataReader.Read())
{
if (str != myDataReader.GetValue(0).ToString())
{
this.DropDownList1.Items.Add(myDataReader.GetValue(0).ToString());
}
str = myDataReader.GetValue(0).ToString();
}
myConn.Close();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
int x=0;
string myConnstr = ConfigurationManager.ConnectionStrings["stuManConnectionString"].ConnectionString;
SqlConnection myConn = new SqlConnection(myConnstr);
string sql = "select 成绩表.学号,学生表.姓名,成绩表.成绩,课程表.课程名,成绩表.日期,课程表.学分 from 成绩表,学生表,课程表 where 成绩表.课程号=课程表.课程号 and 成绩表.学号='" + student + "' and 学生表.学号='" + student + "' and 课程表.课程号=成绩表.课程号 and 成绩表.日期='" + DropDownList1.Text + "'";
myConn.Open();
SqlCommand myComm = new SqlCommand(sql, myConn);
SqlDataReader myDataReader = myComm.ExecuteReader();
while (myDataReader.Read())
{
if (int.Parse(myDataReader.GetValue(2).ToString()) >= 60)
{
x += int.Parse(myDataReader.GetValue(5).ToString());
}
}
TextBox1.Text = Convert.ToString(x);
myConn.Close();
myConn.Open();
myComm = new SqlCommand(sql, myConn);
myDataReader = myComm.ExecuteReader();
GridView1.DataSource = myDataReader;
GridView1.DataBind();
myConn.Close();
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
this.Response.Redirect("登陆页面.aspx");
}
}
4.1.5 学生成绩排名界面如图4-5所示
4-5 学生成绩排名界面
源程序:
public partial class Default4 : System.Web.UI.Page
{
string student;
protected void Page_Load(object sender, EventArgs e)
{
student = this.Session["name"].ToString();
if (DropDownList1.Text == "")
{
string myConnstr = ConfigurationManager.ConnectionStrings["stuManConnectionString"].ConnectionString;
SqlConnection myConn = new SqlConnection(myConnstr);
string sql = "select 课程名 from 课程表 ";
myConn.Open();
SqlCommand myComm = new SqlCommand(sql, myConn);
SqlDataReader myDataReader = myComm.ExecuteReader();
while (myDataReader.Read())
this.DropDownList1.Items.Add(myDataReader.GetValue(0).ToString());
myConn.Close();
}
if (DropDownList2.Text == "")
{
string myConnstr1 = ConfigurationManager.ConnectionStrings["stuManConnectionString"].ConnectionString;
SqlConnection myConn1 = new SqlConnection(myConnstr1);
string sql1 = "select distinct 成绩表.日期 from 成绩表,学生表,课程表 where 成绩表.课程号=课程表.课程号 and 成绩表.学号='" + student + "' and 学生表.学号='" + student + "'";
myConn1.Open();
SqlCommand myComm1 = new SqlCommand(sql1, myConn1);
SqlDataReader myDataReader1 = myComm1.ExecuteReader();
while (myDataReader1.Read())
this.DropDownList2.Items.Add(myDataReader1.GetValue(0).ToString());
myConn1.Close();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
int n = 1;
string stu2;
float stu1, stu3=0,stu4;
string myConnstr = "data source=localhost;database=学生成绩智能管理系统;user id=sa;password=sa;";
SqlConnection myConn = new SqlConnection(myConnstr);
string sql = "select 成绩表.成绩 from 课程表,成绩表 where 课程表.课程名='" + DropDownList1.Text + "'and 成绩表.学号='" + student + "' and 课程表.课程号 = 成绩表.课程号";
myConn.Open();
SqlCommand myComm = new SqlCommand(sql, myConn);
SqlDataReader myDataReader = myComm.ExecuteReader();
Label2.Text = DropDownList1.Text;
while (myDataReader.Read())
{
stu3 = float.Parse(myDataReader.GetValue(0).ToString());
}
myConn.Close();
sql = "select 成绩表.成绩,成绩表.学号 from 课程表,成绩表 where 课程表.课程名=" + "'"+DropDownList1.Text+"'"+"and 课程表.课程号 = 成绩表.课程号";
myConn.Open();
myComm = new SqlCommand(sql, myConn);
myDataReader = myComm.ExecuteReader();
Label2.Text = DropDownList1.Text;
while (myDataReader.Read())
{
stu1 = float.Parse(myDataReader.GetValue(0).ToString());
stu2 = myDataReader.GetValue(1).ToString();
stu2=stu2.Trim();
if (stu1 > stu3 && stu2 != student)
{
n++;
}
if (stu2 == student)
{
stu4 = stu3;
Label6.Text = Convert.ToString(stu4);
}
}
Label4.Text=Convert.ToString(n);
myConn.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
int x1 = 0,stux=0,stux1=0;
int c=0,v=1;
float[] stu = new float[100];
DateTime st;
st = DateTime.Parse(DropDownList2.Text);
string myConnstr = "data source=localhost;database=学生成绩智能管理系统;user id=sa;password=sa;";
SqlConnection myConn = new SqlConnection(myConnstr);
string sql = "select 成绩表.学号,成绩表.成绩,课程表.课程名,成绩表.日期,课程表.学分 from 成绩表,学生表,课程表 where 成绩表.课程号=课程表.课程号 and 成绩表.学号 = 学生表.学号 and 课程表.课程号=成绩表.课程号 and 成绩表.日期='" +st+ "'";
myConn.Open();
SqlCommand myComm = new SqlCommand(sql, myConn);
SqlDataReader myDataReader = myComm.ExecuteReader();
while (myDataReader.Read())
{
stux = int.Parse(myDataReader.GetValue(0).ToString());
stu[stux] += float.Parse(myDataReader.GetValue(1).ToString());
if (int.Parse(myDataReader.GetValue(1).ToString()) >= 60 && myDataReader.GetValue(0).ToString().Trim() == student)
{
x1 += int.Parse(myDataReader.GetValue(4).ToString());
}
}
stux1 = int.Parse(student);
Label13.Text = Convert.ToString(stu[stux1]);
Label14.Text = Convert.ToString(x1);
for (c = 0; c < 100; c++)
{
if (stu[c] > stu[stux1])
{
v++;
}
}
Label15.Text = Convert.ToString(v);
myConn.Close();
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
this.Response.Redirect("登陆页面.aspx");
}
}
4.1.6 学生修改基本信息界面如图4-6所示
4-6 学生修改基本信息界面
源程序:
public partial class Default7 : System.Web.UI.Page
{
public SqlCommandBuilder scb;
string student;
protected void Page_Load(object sender, EventArgs e)
{
student = this.Session["name"].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
DateTime date;
if (Button1.Text == "修改")
{
Button1.Text = "保存";
DropDownList1.Enabled = true;
TextBox2.Enabled = true;
TextBox3.Enabled = true;
TextBox4.Enabled = true;
}
else if (Button1.Text == "保存")
{
if (!(DropDownList1.Text == "" && TextBox2.Text == "" && TextBox3.Text == "" && TextBox4.Text == ""))
{
Button1.Text = "修改";
DropDownList1.Enabled = false;
TextBox2.Enabled = false;
TextBox3.Enabled = false;
TextBox4.Enabled = false;
string myConnstr = ConfigurationManager.ConnectionStrings["stuManConnectionString"].ConnectionString;
SqlConnection myConn = new SqlConnection(myConnstr);
string sql = "select 学号,政治面貌,出生日期,家庭住址,备注 from 学生表 where 学号='" + student + "'";
SqlCommand myComm = new SqlCommand(sql, myConn);
SqlDataAdapter myDataAdapter = new SqlDataAdapter();
myDataAdapter.SelectCommand = myComm;
DataSet myDataSet = new DataSet();
myConn.Open();
myDataAdapter.Fill(myDataSet, "学生表");
DataTable myDataTable = myDataSet.Tables["学生表"];
foreach (DataRow myDataRow in myDataTable.Rows)
{
myDataTable.PrimaryKey = new DataColumn[] { myDataTable.Columns["学号"] };
DataRow myEditDataRow = myDataTable.Rows.Find(student);
scb = new SqlCommandBuilder(myDataAdapter);
if (DropDownList1.Text != "")
myDataSet.Tables["学生表"].Rows[0]["政治面貌"] = DropDownList1.Text;
if (TextBox2.Text != "")
{
date = DateTime.Parse(TextBox2.Text);
myDataSet.Tables["学生表"].Rows[0]["出生日期"] = date;
}
if (TextBox3.Text != "")
myDataSet.Tables["学生表"].Rows[0]["家庭住址"] = TextBox3.Text;
if (TextBox4.Text != "")
myDataSet.Tables["学生表"].Rows[0]["备注"] = TextBox4.Text;
myDataAdapter.Update(myDataSet.Tables["学生表"]);
Response.Write("<script>alert('信息修改完成!');</script>");
}
}
else
Response.Write("<script>alert('输入不能为空!');</script>");
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
//if(Response.Write("<script>alert('确定注销!');</script>"))
this.Response.Redirect("登陆页面.aspx");
}
}
第5章 总结
在整个设计过程中,我们小组分工比较明确,但是由于个人看法及水品的不同,有些地方观点不一致,导致开始速度一直较慢,但是当总体设计出来后,每个人分到自己的任务后,由于分工明确所以速度也快了。查阅了课本以及网上的一些资料,结合VB和SQL进行具体的操作,没跟人将自己的模块完成后组装,最后还是完成了本次课程设计。
在这过程中也遇到很多难题,先是怎样把几个表连接起来,再怎样用GataGrid把一个学生的多天记录显示出来,再自己查阅资料以及同学的帮助下还是顺利完成了。在这次课程设计的过程中,我们也总结出许多问题,比如:在写代码的时候,一定要养成良好的语法习惯,对窗体和控件的name属性和caption属性,要尽量习惯用相应的英文单词的缩写或简写,因为这样便于自己的查找和修改,还有就是在写代码的时候不要图简单,一些语法结构总是写不全,老是用最简单的形式,还有就是在数据库的操作部分,一定要检验数据源的连接成功与否,还有就是在控件与数据库连接的时候,不要忘了每个控件的datasource属性和datafield属性,要确保其与数据库的成功连接。
经过本次的VB课程设计,让我对VB的软件开发流程,整体筹划方面有了一定的了解,我相信有了这次的经历,对我以后的VB的学习有很大的帮助。