Professional Documents
Culture Documents
Firstly we need to clarify the difference between two terms in N-Tier architecture: tier
and layer. Tier usually means the physical deployment computer. Usually an individual
running server is one tier. Several servers may also be counted as one tier, such as
server failover clustering. By contrast, layer usually means logic software component
group mainly by functionality; layer is used for software development purpose. Layer
software implementation has many advantages and is a good way to achieve N-Tier
architecture. Layer and tier may or may not exactly match each other. Each layer may
run in an individual tier. However, multiple layers may also be able to run in one tier.
System;
System.Collections.Generic;
System.Linq;
System.Web;
System.Web.UI;
System.Web.UI.WebControls;
BusinessObjects;
namespace _3TierSumdemoApplication
{
public partial class Sumdemoapplication : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (txtavalue.Text=="")
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Please entera
value')", true);
}
else if (txtbvalue.Text == "")
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Please enter b
value')", true);
}
else
{
BusinessObjects.UserBo objUBo = new UserBo();
//pass the values from Controls through properties
objUBo.A = int.Parse(txtavalue.Text);
objUBo.B = int.Parse(txtbvalue.Text);
BusinessLogic.UserBl objUbl = new BusinessLogic.UserBl();
int r= objUbl.Addmethod(objUBo);
if (r>0)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "alert",
"alert('Record is inserted')", true);
}
}
}
}
}
System;
System.Collections.Generic;
System.Linq;
System.Text;
namespace BusinessObjects
{
public class UserBo
{
//variables
private int a;
private int b;
private int sum;
//Properties
public int A
{
set { a = value; }
get { return a; }
}
public int B
{
get { return b; }
set { b = value; }
}
public int Sum
{
get { return sum; }
set { sum = value; }
}
}
}
}
cmd.Parameters.AddWithValue("@b", objBo.B);
cmd.Parameters.AddWithValue("@sum", objBo.Sum);
int result= cmd.ExecuteNonQuery();
con.Close();
return result;
EXAMPLE-2:-