C# .NET - 3 Tier Architecture - Asked By Sreelatha Devi on 14-Feb-12 01:17 AM

Hi,
I am new to .net 3 tier so i want some sample programs based on 3 tier .....

sreelatha
Web Star replied to Sreelatha Devi on 14-Feb-12 01:22 AM
3-Tier architecture generally contains UI or Presentation Layer, Business Access Layer (BAL) or Business Logic Layer and Data Access Layer (DAL). 
Presentation Layer (UI) 
Presentation layer cotains pages like .aspx or windows form where data is presented to the user or input is taken from the user. 
Business Access Layer (BAL) or Business Logic Layer 
BAL contains business logic, validations or calculations related with the data, if needed. I will call it Business Access Layer in my demo. 
Data Access Layer (DAL) 
DAL contains methods that helps business layer to connect the data and perform required action, might be returning data or manipulating data (insert, update, delete etc). For this demo application, I have taken a very simple example. I am assuming that I have to play with record of persons (FirstName, LastName, Age) and I will refer only these data through out this article.

here is some gud documentation: http://msdn.microsoft.com/en-us/asp.net/bb278076.aspx 
also see other thread describe it on eggheadcafe http://www.eggheadcafe.com/community/asp-net/17/10359079/3-tier-architecture-sample-project.aspx 
smr replied to Sreelatha Devi on 14-Feb-12 01:23 AM
hi

3-Tier architecture generally contains UI or Presentation Layer, Business Access Layer (BAL) or Business Logic Layer and Data Access Layer (DAL).

Presentation Layer (UI)
Presentation layer cotains pages like .aspx or windows form where data is presented to the user or input is taken from the user.

Business Access Layer (BAL) or Business Logic Layer
BAL contains business logic, validations or calculations related with the data, if needed. I will call it Business Access Layer in my demo.

Data Access Layer (DAL)
DAL contains methods that helps business layer to connect the data and perform required action, might be returning data or manipulating data (insert, update, delete etc). For this demo application, I have taken a very simple example. I am assuming that I have to play with record of persons (FirstName, LastName, Age) and I will refer only these data through out this article.


refer
http://www.codeproject.com/Articles/11128/3-tier-architecture-in-C
http://imar.spaanjaars.com/476/n-layered-web-applications-with-aspnet-35-part-1-general-introduction

Have a look at

http://msdn.microsoft.com/practices/

You should find most of your are looking for ..

Other interesting areas to look at are going to be generating data layer dynamically...

http://www.codesmithtools.com/

Sreelatha Devi replied to Sreelatha Devi on 14-Feb-12 01:23 AM
I need a program on 3 tier on c#. which are simple and easy to understand because i am in learning stage of .net
Reena Jain replied to Sreelatha Devi on 14-Feb-12 01:24 AM
HI,


3-Tier architecture generally contains UI or Presentation Layer, Business Access Layer (BAL) or Business Logic Layer and Data Access Layer (DAL).

Presentation Layer (UI)
Presentation layer cotains pages like .aspx or windows form where data is presented to the user or input is taken from the user.

Business Access Layer (BAL) or Business Logic Layer
BAL contains business logic, validations or calculations related with the data, if needed. I will call it Business Access Layer in my demo.

Data Access Layer (DAL)
DAL contains methods that helps business layer to connect the data and perform required action, might be returning data or manipulating data (insert, update, delete etc). For this demo application, I have taken a very simple example. I am assuming that I have to play with record of persons (FirstName, LastName, Age) and I will refer only these data through out this article.

here is the link to understand it more
http://www.codeproject.com/KB/architecture/three_tier_architecture.aspx
http://www.dotnetfunda.com/articles/article71.aspx
http://www.c-sharpcorner.com/uploadfile/paulabraham/building3tierapppa11282005053625am/building3tierapppa.aspx

hope this will help you
DL M replied to Sreelatha Devi on 14-Feb-12 01:30 AM
Hi..

get here sample code of 3 tier architecture


http://sourcecode-world.blogspot.in/p/three-tier-architecture-in-aspnet-with.html
Somesh Yadav replied to Sreelatha Devi on 14-Feb-12 01:38 AM
hi,

Three-Tier Architecture:

Three tier architecture having three layers. They are 
  1. Client layer
  2. Business layer
  3. Data layer
Client layer: Here we design the form using textbox, label etc.

Business layer: It is the intermediate layer which has the functions for client layer and it is used to make communication faster between client and data layer. It provides the business processes logic and the data access.

Data layer: it has the database.

2.gif

Advantages
  1. Easy to modify with out affecting other modules
  2. Fast communication
  3. Performance will be good in three tier architecture.
here is a simple programme on 3-tier.
Let's talk about simple 3-tier application = 1 window application + 2 class library (Library1 and Library2).

In Library 2 , I was declared one interface in_Application with some simple method LoadApplication().

    public interface in_Application
       {
        void LoadApplication();
       }


In libary1 I was add reference to Library2, and in a class (myClass) in library1 implement this interface

    public class myClass:Library2.in_Application
      {
       public void LoadApplication()
         {
          Console.WriteLine( "Load application . Please wait ...");
        }
    
       }



Finally , in windows application I was added reference to Library1 .

for more information refer to the below link.

http://www.codeproject.com/Articles/36847/Three-Layer-Architecture-in-C-NET

Hope it helps you.
dipa ahuja replied to Sreelatha Devi on 14-Feb-12 02:22 AM
Presentation Layer (UI)
Presentation layer cotains pages like .aspx or windows form where data is presented to the user or input is taken from the user.

Business Access Layer (BAL) or Business Logic Layer
BAL contains business logic, validations or calculations related with the data, if needed. I will call it Business Access Layer in my demo.

Data Access Layer (DAL)
DAL contains methods that helps business layer to connect the data and perform required action, might be returning data or manipulating data (insert, update, delete etc). For this demo application, I have taken a very simple example. I am assuming that I have to play with record of persons (FirstName, LastName, Age) and I will refer only these data throughout this article.
For this you have to add the  BAL , DAL code in the App_code folder
DAL :
public class DAL
{
  string connStr = ConfigurationManager.ConnectionStrings["connstring"].ToString();
 
    public DAL()
    {
      //
      // TODO: Add constructor logic here
      //
    }
  public static DataTable getdata(int empid)
  {
    SqlDataAdapter da = new SqlDataAdapter("select * from table1 where empid=" + empid, connStr);
    DataTable dt = new DataTable();
    da.Fill(dt);
    return dt;
  }
}
 
BAL
public class BAL
{
    public BAL()
    {
      //
      // TODO: Add constructor logic here
      //
    }
  public static DataTable getdata(int empid)
  {     
    try
    {
      return DAL.getdata(empid);
    }
    finally
    {
    }
  }
}
 
Use in PL
GridView1.DataSource = BAL.getdata(1);
 
 
 
 
 
 
Serena Yeoh replied to Sreelatha Devi on 26-May-12 10:06 AM
Hi!

You may want to check-out http://layersample.codeplex.com to have a better idea on Layered Architecture.