3 Tier Architecture is composed by 3 Main Layers
User Interface Layer (UI):
Where all presentation and user interaction takes place. Displays and receives data to and from the user.
Business Logic Layer (BLL):
Application processing. Coordinates data between the UI and DAL.
Data Access Layer (DAL):
Where data management occurs. Typically using a database or web service.
=======================================================================
NOTE 1:
Each top layer only asks the below layer and never sees anything on top of it.
- Here "AddNumber " is Top layer (It is the User Interface)
- 2nd Layer :BLL
- 3rd Layer :DB
- UI > BLL> DB
- Donot Refer Back
- Common is a common project used to declare variable
- in Two-Tier,Database Layer and UI sections are directly connected by using add reference..
- In 3 tier there is a middle layer called BLL(Logic Layer) .
- So there is no direct contact between DB to UI
Why we need business logic layer?
Sure, there are plenty of reasons. The most important though is that if
anything about your business logic or your data logic changes (as always
happens), you can replace just one layer of code without having to disturb
the other.
The business layer is where your business rules are processed, the data
layer is where your data manipulation is done. Separating these also adds
another level of security to your applicaiton.
Lets Go.....
Reference
Each project must be rebuild before set reference
anything about your business logic or your data logic changes (as always
happens), you can replace just one layer of code without having to disturb
the other.
The business layer is where your business rules are processed, the data
layer is where your data manipulation is done. Separating these also adds
another level of security to your applicaiton.
Lets Go.....
- Create 4 projects
- 1st -- UI
- 2nd -- BLL
- 3rd -- DB
- 4Th -- Common(Variable)
Reference
Each project must be rebuild before set reference
UI = BLL,Common
BLL = DB ,Common
DB =Common
After Set Reference,We need to Add Codes......
1.Model.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Common
{
public class Model
{
public Int32 FstNumber
{
get;
set;
}
public Int32 ScndNumber
{
get;
set;
}
public Int32 Result
{
get;
set;
}
}
}
BLL = DB ,Common
DB =Common
- Reference from UI
- Reference From BLL
- Reference From DB
- After set Reference
After Set Reference,We need to Add Codes......
1.Model.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Common
{
public class Model
{
public Int32 FstNumber
{
get;
set;
}
public Int32 ScndNumber
{
get;
set;
}
public Int32 Result
{
get;
set;
}
}
}
=======================
2.BL_Manager.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using DB;
namespace BLL
{
public class Bl_Manager
{
DB_manager DbObj = new DB_manager();
public Model AddNumber(Model obj)
{
Model Newobj = new Model();
Newobj = DbObj.AddNumber(obj);
return Newobj;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using DB;
namespace BLL
{
public class Bl_Manager
{
DB_manager DbObj = new DB_manager();
public Model AddNumber(Model obj)
{
Model Newobj = new Model();
Newobj = DbObj.AddNumber(obj);
return Newobj;
}
}
}
=====================
3.Db_Manager.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
namespace DB
{
public class DB_manager
{
public Model AddNumber(Model obj)
{
obj.Result = obj.FstNumber + obj.ScndNumber;
return obj;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
namespace DB
{
public class DB_manager
{
public Model AddNumber(Model obj)
{
obj.Result = obj.FstNumber + obj.ScndNumber;
return obj;
}
}
}
==================
4.UI
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Common;
public partial class Add : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAdd_Click(object sender, EventArgs e)
{
Model obj = new Model();
Bl_Manager BLobj = new Bl_Manager();
obj.FstNumber = Convert.ToInt32(txtFirstNumber.Text);
obj.ScndNumber = Convert.ToInt32(txt2ndNumber.Text);
Model AddResult = BLobj.AddNumber(obj);
txtResult.Text = Convert.ToString(AddResult.Result);
}
}
IMAGES
Download free

using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Common;
public partial class Add : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAdd_Click(object sender, EventArgs e)
{
Model obj = new Model();
Bl_Manager BLobj = new Bl_Manager();
obj.FstNumber = Convert.ToInt32(txtFirstNumber.Text);
obj.ScndNumber = Convert.ToInt32(txt2ndNumber.Text);
Model AddResult = BLobj.AddNumber(obj);
txtResult.Text = Convert.ToString(AddResult.Result);
}
}
IMAGES
- UI
- BLL
- DB
- Common
Download free







No comments:
Post a Comment