Presentation Layer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using DAL;
namespace _3_tiersample
{
public partial class RegistrationForm : System.Web.UI.Page
{
classBLL Objbal = new classBLL();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
string Output = string.Empty;
classBLL Objbalregistration = new classBLL();
Objbalregistration.Name = TextBox1.Text;
Objbalregistration.Roll_Number = Convert.ToInt32(TextBox2.Text);
Objbalregistration.Email_Id = TextBox3.Text;
Objbalregistration.Mobile_Number = TextBox4.Text;
Objbalregistration.InsertUserDetails(Objbal);
Console.WriteLine("Data Inserted");
}
catch(Exception Ex)
{
Console.WriteLine(Ex);
}
}
}
}
Business Logic Layer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
namespace BLL
{
public class classBLL
{
private string _Name;
private int _Roll_Number;
private string _Email_Id;
public string _Mobile_Number;
public string Name
{
set { _Name = value; }
get { return _Name; }
}
public int Roll_Number
{
set { _Roll_Number = value; }
get { return _Roll_Number; }
}
public string Email_Id
{
set { _Email_Id = value; }
get { return _Email_Id; }
}
public string Mobile_Number
{
set { _Mobile_Number = value; }
get { return _Mobile_Number; }
}
}
}
Data Access Layer
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using BLL;
namespace DAL
{
public class classDAL
{
string connection = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
public void InsertUserDetails(classBLL Objbal)
{
SqlConnection con = new SqlConnection(connection);
SqlCommand cmd = new SqlCommand("sp_InsertEmpdetails", con);
cmd.CommandType = CommandType.StoredProcedure;
con.Open();
try
{
cmd.Parameters.AddWithValue("@Name", Objbal.Name);
cmd.Parameters.AddWithValue("@Roll_Number", Objbal.Roll_Number);
cmd.Parameters.AddWithValue("@Email_Id", Objbal.Email_Id);
cmd.Parameters.AddWithValue("@Mobile_Number", Objbal.Mobile_Number);
Console.WriteLine( "data saved");
}
catch (Exception Ex)
{
Console.WriteLine(Ex);
}
finally
{
con.Dispose();
}
}
}
}
In the above code i have written the business Logic Layer code in Dataaccesslayer i mean my business rule is to insert the data into database but i have written the logic in data access layer but i want it to write in business logic layer.what is the code to write within the business logic layer.(in real time everyone used to write the business logic code with in the Business logic layer right)
Help me Out i'am getting Confused
Thanks in advance