5. 系统实现
本系统采用了三层架构来实现,即分为用户界面层(UI)、业务逻辑层(BLL)和数据访问层(DAL),用户界面层是展示给用户的界面,方便用户与系统进行交互;业务逻辑层是对系统业务实体的封装,完成系统业务功能;数据访问层直接与数据库打交道,为业务逻辑层提供底层的数据库操作。
5.1 Database类主要是与数据库连接,提供数据库操作功能,代码如下:
namespace MyElectCourse.DAL {
public class Database {
protected string connectionString;
protected SqlConnection connection = null;
public Database() {
connectionString =
ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString(); }
~Database() {
if (connection != null) {
connection = null; }
}
protected void Open() {
if (connection == null) {
connection = new SqlConnection(connectionString); }
if (connection.State.Equals(ConnectionState.Closed)) {
connection.Open(); } }
protected void Close() {
if (connection != null) {
connection.Close(); } }
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库软件工程课程设计报告模板(17)在线全文阅读。
相关推荐: