l 3-tier architecture (TIER)

DAY - 28-06-2003

 

3-tier architecture (TIER)

1. 3tier architecture provides three specific layer

A. BussinessObject layer

B. BussinessLogic layer

C. DataAcess layer

 

A. BussinessObject layer :-

It only created data member as per database column.

 

B. BussinessLogic Layer :-

This layer only communicated with aspx page.

 

C. DataAcess layer :- In this layer we work on database .

 

How to create 3 tier architecture?

Step 1 :- create layer

GO TO SOLUTION EXPLOSER -> RIGHT CLICK ON SOLUTION-------->CLICK ON NEW PROJECT ->SELECT CLASS LIBRARY (.NET FRAMEWORK)C# -> NAME OF LIBRARY.


Step 2 :- create a class in each layer

1. BussinessLogic - classname=userBL.

2. BussinessObject - classname=userBO.

3. DataAccess-classname=userDA

 

How to create a class :-

Rightclick on the layer -> add class

Step 3 - change all class to public which we made.

All class is used for public specifier

 

Step4 is to add reference

A. DataAccess - BussinessObject ka ref add hoje

B. BussinessLogic - DataAcess & BussinessObject

C. Root - Bussinessobject & BussinessLogic

 

Ø Working of Bussiness Object:-

1. Only create a datamember using Get/Set Properties .

2. Inside the BussinessObject create public and private datamembers.

 

Private int _ROLL;

Public int ROll

{

Get

{return _ROll}

SET{_Roll=Values;}

}

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace BussinessObject

{

    public class userBO

    {

        private int _roll;

        private string _name;

 

        public int roll

        {

            get

            {

                return _roll;

            }

            set

            {

                _roll = value;

            }

        }

        public string name

        {

            get

            {

                return _name;

            }

            set

            {

                _name = value;

            }

        }

 

}

    }

}

 

 

Day - 04-07-2025

 

Ø WORKING OF DATA ACCESS LAYERS

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

//INCLUDE BUSSINESS OBJECT LIBRARIES

using BussinessObject;

using System.Data.SqlClient;

 

 

 

namespace DataAccess

{

    public class userDA

    {

        //CREATE CONNECTION OBJECT

 

        SqlConnection con = new SqlConnection(@"pth");

 

        public int adduserdetail(userBO objbo )// access all data member like roll ,name etc

        {

            // perform insert queries

 

            string inst = "INSERT INTO DEMO(ROLL,NAME) VALUES (@ROLL1,@NAME1)";

            SqlCommand com = new SqlCommand(inst, con);

 

            com.Parameters.AddWithValue("ROLL1",objbo.roll);

            com.Parameters.AddWithValue("NAME1", objbo.name);

 

            con.Open();

            // CHECKING QUERY

            int RESULT = com.ExecuteNonQuery();

 

            return RESULT;

 

        }

 

        //public int upduserdetail (userBO objup)//

        //{

 

       // }

 

    }

}

 

Ø Working of Business logic layers

This layers directly communicated with  .aspx page

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using DataAccess;

using BussinessObject;

 

namespace BussinessLogic

{

     public class userBL

    {

        public int saveuserdetail(userBO objbo1)// accessing datamember

        {

            //create dataacess object

 

            userDA da1 = new userDA();

 

            return da1.adduserdetail(objbo1);

 

        }

 

    }

}

 

Ø Working of aspx page (default.aspx)

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using BussinessLogic;

using BussinessObject;

 

namespace WebApplication1

{

    public partial class DEFAULT : System.Web.UI.Page

    {

        userBO bo = new userBO();

        userBL bl = new userBL();

        protected void Page_Load(object sender, EventArgs e)

        {

            if (!IsPostBack)

            {

 

            }

        }

 

        protected void Button1_Click(object sender, EventArgs e)

        {

            //access bussiness logic method

 

            int returnvalue = 0;

 

            bo.roll = int.Parse(TextBox1.Text);

            bo.name = TextBox2.Text;

 

            returnvalue = bl.saveuserdetail(bo);

 

 

        }

    }

}

Comments

Popular posts from this blog

ViewState for state management

Database joining

INTRODUCTION OF C#