基于ASP.NET学生成绩管理系统的设计与实现

2013-12-29 00:00:00俞露
电脑知识与技术 2013年4期

摘要:该文将学生成绩管理系统划分为三个功能模块:管理员管理模块,教师成绩录入模块,学生成绩查询模块。并采用三层架构来设计系统。在SQL server Management 2005中通过新建查询的方式建立数据库,在Visual studio 2010环境下,编写C#语言加以实现。

关键词:ASP.NET;成绩管理;C#;三层架构;SQL数据库

中图分类号:TP311 文献标识码:A 文章编号:1009-3044(2013)04-0679-04

Design on a Student Score Management System Based on ASP.NET

YU Lu

(Department of Computer Science and Technology, Nanjing Normal University, Nanjing 210000, China)

Abstract: This paper divides student score management system into three independent functional modules:administrator management module, teacher input score module, and student query score module,and uses three-tier architecture to design system. In SQL server Management 2005,this paper creates database by newing query , in the Visual Studio 2010 environment, this paper uses C# language to achieve system functions .

Key words: ASP.NET; score management; C#; three-tier architecture

学生成绩管理工作是教育管理工作中非常重要的一项,然而传统的手工管理方式下教师的工作量往往非常大,学生查询成绩时也会受到各种因素的限制,此外手工管理不便于学生信息规范化和系统化。随着计算机技术的迅猛发展,利用计算机在线管理系统,方便教师管理成绩、学生查询成绩、师生了解教务新闻,从而大大提高学生成绩管理的效率。

1 系统需求

本文的系统用户可以分为:管理员,教师,学生。

系统所需实现的功能:

①管理员管理系统用户的信息,具体包括对教师,学生信息的增加,删除和修改。

②管理员管理行政信息,具体包括对学院,班级信息的增加,删除和修改。

③管理员管理教务信息,具体包括对课程、教务新闻信息的增加,删除和修改。

④教师管理学生成绩的录入,修改和查询。

⑤学生查询成绩,课程信息。

2 数据库的设计

数据库:SQL数据库

设计语言:SQL

设计平台:SQL server Management 2005

2.1表的建立

在SQL Server Management 2005中用create 语句建立如下表格:

2.2表之间的联系(外键约束)

在SQL server Management2005中为各表中相关联,且为NOT NULL的字段建立外键约束,如下所示:

alter table score add constraint fk_no foreign key (no) references student(no) ;

alter table score add constraint fk_course foreign key (courseno)references course(no) ;

alter table student add constraint fk_class foreign key (class)references class(no) ;

alter table student add constraint fk_dep foreign key (dep)references dep(name) ;

2.3存储过程

在SQL Server Management 2005中用create procedure语句建立存储过程,示例如下:

1)查询某学期某一同学的所有成绩

create proc sp_display

@no char(8),@xueqi char(20)

as

begin

select b.no as '课程代码',b.name as '课程名',c.grade as '成绩'

from student a,course b,score c

where a.no=c.no and c.courseno=b.no and a.no=@no and b.xueqi=@xueqi

end

调用存储过程:

exec sp_display '19100201','5'

2)查询某班某学期开设的所有课程(课程代码、课程名)

创建存储过程

create proc sp_display2

@class char(3),@xueqi char(20)

as

begin

select distinct b.no as'课程代码',b.name as'课程名'

from student a,course b,score c

where a.no=c.no and c.courseno=b.no and a.class=@class and b.xueqi=@xueqi

end

调用存储过程

exec sp_display2 '191002','5'

3 系统的设计结构

采用经典的三层设计架构,分别为:表示层设计、业务逻辑层设计、数据访问层设计,提高了应用程序内部的聚合度,降低了应用程序的耦合度。

3.1三层构架的表现

3.1.1表示层设计(UI)

1)采用DIV+CSS布局技术,展现结构和表现的分离,方便日后网站的维修和升级。

2)采用模板页和内容页相结合技术,对页面进行集中处理,使得前台页面格调统一协调。

3.1.2业务逻辑层设计(BLL)

业务逻辑层连接表示层和数据访问层。

3.1.3数据访问层设计(DAL)

建立一个DBHelper类,用来定义访问数据库的方法,在.aspx文件中创建该类的对象,并调用其方法。

3.2核心代码

DBHelper类的定义:

public class DBHelper : System.Web.UI.Page

{String strConn;//定义变连接字符串

public DBHelper()

{strConn =

ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

}

//类的方法的定义:

public int Method(String procedureName,String parameter)

{DataSet ds = new DataSet();

SqlConnection Conn = new SqlConnection(strConn);

if (Conn.State!=ConnectionState.Open)

{Conn.Open();

}

SqlDataAdapter Cmd = new SqlDataAdapter(strSql, Conn);

Cmd.CommandType=CommandType.StoredProcedure;(下转第685页)

(上接第682页)

Cmd.Parameters.Add(“@parameter”);

Cmd.Parameters["@parameter"].Value=parameter;

Cmd.ExecuteNonQuery();

Conn.Close();

return 0;

}

.aspx文件通过构造DBHelper类来访问数据库:

private void Page_Load(object sender, System.EventArgs e)

{DBHeper helper=new DBHeper();

String parameter=TextBox_no.Text.ToString();

DataSet MyDataSet=new DataSet();

helper.method(“sp_display”,parameter);

}

4 总结

本文实现了在线学生成绩管理系统的基本功能,提高了学生成绩管理工作的效率。然而,基于三层架构的设计使得本能够直接访问数据库的业务必须通过中间层,不可避免的导致了系统性能的降低。

参考文献:

[1] 郑阿奇.ASP.NET3.5实用教程[M].北京:电子工业出版社,2011.

[2] 顾兵.数据库技术与应用[M].北京:清华大学出版社,2010.

[3] 周姝,张慧茹.基于VB的学生成绩档案管理系统的设计与实现[J],计算机光盘软件应用系统的设计与实现,2012(21):229-230.