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

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

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

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

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”
![]() |
作者:ylbtech 出處:http://ylbtech.cnblogs.com/ 本文版權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利。 |