Thursday, February 4, 2010

How to use 3 tier architecture ?

1) create App_code folder
2) In App_code folder create BLL folder and again In BLL folder create BLL.CS file
3) In App_code folder create DAL folder and again In DAL folder create DAL.CS file
4) IN every BLL and DLL class file create private,public regions for variables and methods.

FOR EXAMPLE BLL.cs

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;

///
/// Summary description for BLL
///

public class BLL
{
public BLL()
{
//
// TODO: Add constructor logic here
//
}
#region Private Variables

DateTime _date;

#endregion

#region Public Properties

public DateTime DATE
{
set { _date = value; }
get { return _date; }
}

#endregion


#region Public Methods

public DataSet GetUserInfo()
{
DataSet ds = new DataSet();
try
{
ds = DAL.GetUserInfo(this);
return ds;
}
catch(Exception ex)
{
ex=ex;
return ds;
}
}

FOR EXAMPLE DAL.cs

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 LCE.DAL;
using System.Data.SqlClient;
///
/// Summary description for DAL
///

public class DAL
{
public DAL()
{
//
// TODO: Add constructor logic here
//
}
#region Private Variables
#endregion
#region Public Properties
#endregion
#region Public Methods

public static DataSet GetUserInfo(BLL objUser)
{
DataSet ds = new DataSet();
try
{
ds = (SqlHelper.ExecuteDataset(LCE.Configuration.GetConnectionString(), CommandType.StoredProcedure,

"spGetUserInfo"));
return ds;
}
catch(Exception ex)
{
ex = ex;
return ds;
}
}

No comments:

Post a Comment