WebForm三层架构

ylbtech-Architecture:WebForm-三层架构
 
1.A,概念

三层架构(3-tier architecture) 通常意义上的三层架构就是将整个业务应用划分为:表现层(UI)、业务逻辑层(BLL)、数据访问层(DAL)。区分层次的目的即为了“高内聚,低耦合”的思想。

1、表现层(UI):通俗讲就是展现给用户的界面,即用户在使用一个系统的时候他的所见所得。
2、业务逻辑层(BLL):针对具体问题的操作,也可以说是对数据层的操作,对数据业务逻辑处理。
3、数据访问层(DAL):该层所做事务直接操作数据库,针对数据的增添、删除、修改、查找等。
1.B,解决方案资源管理器截图

 

1.C,类库(网站)-创建流程及引用类
一,
三层架构
DBUtility (工具类)


Model(属性类)

DAL(数据库操作类) <--Model

BLL(业务逻辑类) <--Model,DAL
  
Web  <---Model,BLL
1.D,功能实现代码(要点代码)

1.D.1,Model/PersonInfo.cs

View Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Model
{
    public class PersonInfo
    {
        //字段
        string id;
        string name;

        //构造
        public PersonInfo(string id, string name)
        {
            this.id = id;
            this.name = name;
        }
        //封装字段

        public string Id
        {
            get { return id; }
            set { id = value; }
        }

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
    }
}

1.D.2,DAL/PersonOper.cs

View Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using Model;
namespace DAL
{
    public class PersonOper
    {
        //输出
        public static string Write(PersonInfo dal)
        {
            string str = "";
            str = string.Format("编号{0},姓名{1}",dal.Id,dal.Name);
            return str;
        }
    }
}

1.D.3,BLL/Person.cs

View Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using Model;
using DAL;
namespace BLL
{
    public class Person
    {
         //输出
        public static string Write(PersonInfo dal)
        {
            return DAL.PersonOper.Write(dal);
        }
    }
}

1.D.4,Web/

1.D.4.1,Web/Default.aspx.cs

View Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Model;
using DAL;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Model.PersonInfo dal = new PersonInfo("11111", "ylb");
        Response.Write(BLL.Person.Write(dal));
        
    }
}

1.D.4.1,Web/web.config

1.E,注意事项

 相关引用:

1.F,代码下载
请单击“SolutiouSanCeng”
 
warn 作者:ylbtech
出处:http://ylbtech.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/ylbtech/p/2920652.html