Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have heard of three tiered architecture, but have no idea what it means ?
Posted
Updated 11-Feb-10 19:27pm
v2

I should add, you have a detailed answer from someone, it is broken on many levels, the code is of a poor quality, the overall answer is correct in showing that the database and business logic should be seperated from the presentation layer, but the way they have done it is pretty wrong, so don't take anything more than a broad hint from that post, long tho it is.
 
Share this answer
 
Just because you foind out some terminology reading a magazine on the toilet, does not mean you're ready for it. If you can't ask a question beyond one sentence, that indicates you don't really understand what you're asking.

Also, your caps lock key is stuck.
 
Share this answer
 
You could do googling or read some books for that. :)
 
Share this answer
 
Look at my rating, then look at his, and ask yourself which person is more likely to know what they are doing. Or look at the one question steeve_richard has asked. He asked for help with the code he gave you !!! So he gave it to you KNOWING it was broken. See also that I told him how to fix it, and instead of thanking me, he started to call me names. He's obviously unstable. I think it's great he tried to help, and his broad answer is correct, but his code is the equivelent of a bunch of disabled children throwing bananas at a keyboard and hoping that a working project will be the result.
 
Share this answer
 
 
Share this answer
 
Hi

You can read Here[^] too.
 
Share this answer
 
Three tier architecture means three layers for the application..


first layer is the presentation layer with which only user would interact..



second is the business logic layer where you would apply logics for the application...



third one is the Data access layer which will only deal with the database...


moreover, you should use stored procedure to make your application more flexible...


here is the demo code for the three tier architecture...


<big>Presentation layer</big> is the server page where you do html coding and use asp.net controls...






<big>Business Logic Layer</big>




using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class signin1 : System.Web.UI.Page
{
    #region objects
    signin.methodssignin mainobj = new signin.methodssignin();
    signin.prpsignin prpobj = new signin.prpsignin();
    #endregion
    #region userdefinedmethods
    public void checkuserstatus(DataTable dtbl)
    {
        if (dtbl.Rows[0]["user_status"].ToString() == "AC")
        {
            checkusertype(dtbl);
        }
        else
        {
            lblmsg.Text = "Your login has expired";
            Clear();
        }
    }
    public void checkusertype(DataTable dtbl)
    {
        Session["user_id"] = Convert.ToInt32(dtbl.Rows[0]["user_id"]);
        Session["user_name"] = dtbl.Rows[0]["first_name"].ToString() + " " + dtbl.Rows[0]["last_name"].ToString();
        Session["last_name"] = dtbl.Rows[0]["last_name"].ToString();
        Session["user_type"] = dtbl.Rows[0]["user_type"].ToString();
        prpobj.userid = Convert.ToInt32(dtbl.Rows[0]["user_id"]);
        mainobj.setuserstatusonline(prpobj);
        if (dtbl.Rows[0]["user_type"].ToString() == "Admin")
        {
            Response.Redirect("~/Admin/Home.aspx");
        }
        else
        {
            Response.Redirect("~/user/Home.aspx");
        }
    }
    public void Clear()
    {
        txtusername.Text = string.Empty;
        txtpwd.Text = string.Empty;
    }
    #endregion
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                Session.Clear();
                if (Request.QueryString["sts"] == "login")
                {
                    lblmsg.Text = "You should login to view that page";
                }
                if (Request.QueryString["sts"] == "logout")
                {
                    lblmsg.Text = "You do not have permission to view this page";
                }
                if (Request.QueryString["sts"] == "logoutbyuser")
                {
                    lblmsg.Text = "You have successfully logout";
                }
                if (Request.QueryString["sts"] == "problem")
                {
                    lblmsg.Text = "You do not have permission to view this page";
                }
            }
            catch (Exception ex)
            {
                Session.Clear();
            }
        }
    }
    protected void btnsignin_Click(object sender, EventArgs e)
    {
        prpobj.username = txtusername.Text.Trim();
        prpobj.userpwd = txtpwd.Text.Trim();
        if (txtusername.Text.Trim() != string.Empty && txtpwd.Text.Trim() != string.Empty)
        {
            checkuserpwd(prpobj);
        }
        else
        {
            lblmsg.Text = "Invalid username/password";
        }
    }
    public void checkuserpwd(signin.prpsignin prpobj)
    {
        DataTable dtbl = mainobj.getuserdetail(prpobj);
        if (dtbl.Rows.Count > 0)
        {
            if (dtbl.Rows[0]["user_pwd"].ToString() == txtpwd.Text.Trim())
            {
                checkuserstatus(dtbl);
            }
            else
            {
                lblmsg.Text = "Invalid username/password";
                Clear();
            }
        }
        else
        {
            lblmsg.Text = "Invalid username/password";
            Clear();
        }
    }
    protected void btncancel_Click(object sender, EventArgs e)
    {
        Clear();
        lblmsg.Text = string.Empty;
    }
}








<big>Data Access Layer</big>




using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

/// <summary>
/// Summary description for signin
/// </summary>
public class signin
{
    #region interface
    interface intersignin
    {
        int userid
        {
            get;
            set;
        }
        string username
        {
            get;
            set;
        }
        string userpwd
        {
            get;
            set;
        }
        string userline
        {
            get;
            set;
        }
    }
    #endregion
    #region properties
    public class prpsignin : intersignin
    {
        int intuserid;
        string strusername, struserpwd,struserline;
        public int userid
        {
            get
            {
                return intuserid;
            }
            set
            {
                intuserid = value;
            }
        }
        public string username
        {
            get
            {
                return strusername;
            }
            set
            {
                strusername = value;
            }
        }
        public string userpwd
        {
            get
            {
                return struserpwd;
            }
            set
            {
                struserpwd = value;
            }
        }
        public string userline
        {
            get
            {
                return struserline;
            }
            set
            {
                struserline = value;
            }
        }
    }
    #endregion
    #region databasemethods
    public class methodssignin : registeration.connection
    {
        public DataTable getuserdetail(prpsignin prpobj)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            cmd.CommandText = "sp_getuserdetail";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@user_name", SqlDbType.VarChar).Value = prpobj.username;
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlDataAdapter dad = new SqlDataAdapter(cmd);
            DataTable dtbl = new DataTable();
            dad.Fill(dtbl);
            return dtbl;
        }
        public void setuserstatusonline(prpsignin prpobj)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            cmd.CommandText = "sp_setuserstatusonline";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@user_id", SqlDbType.Int).Value = prpobj.userid;
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            cmd.ExecuteNonQuery();
        }
        public void setuserststatusoffline(prpsignin prpobj)
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            cmd.CommandText = "sp_setuserstatusoffline";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@user_id", SqlDbType.Int).Value = prpobj.userid;
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            cmd.ExecuteNonQuery();
        }
    }
    #endregion
}




hope this would help you..

regard richards.... :)
 
Share this answer
 
v2
Comments
[no name] 26-Oct-12 6:46am    
Worng answer rechard, you explained 3 layered arch ... 3 tier arch is different thing ... sorry answer downvoted.
because someone do not know the right answer so he is just making some foolish statements and he is not realising that no one is reading his message..


i think he is guiding you towards the wrong side...


just see what is helping you, use your mind instead of some foolish people around here like graus..


so just work hard to get work done...
 
Share this answer
 
http://www.atozkannada.in

free mp3 songs


Edit Comment : No Advertisments here pls.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900