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);