Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Presentation layer;
C#
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
    {
        classDAL Objdal = new classDAL();
        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;
                Objdal.InsertUserDetails(Objbalregistration); 
                Console.WriteLine("Data Inserted");
            }
            catch(Exception Ex)
            {
                Console.WriteLine(Ex);
            }
        }

    }
}

Data access layer
C#
using System;
using System.Collections.Generic;
using System.Linq;
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();
          }

      }
       
    }  
}

Business Logic Layer
C#
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; }
        }

    }
}

when i running my application i'am getting only presentation layer executed.but nothing is working what i need to do to make it work?
thanks in advance
Posted
Updated 6-Mar-14 18:23pm
v3

put breakpoints in each layer and debug it with pressing F11..
 
Share this answer
 
you can use F11 key to navigate to different layer in the application or you can also add break point in your business layer or datalayer methods to take debug option to particular method.
 
Share this answer
 
At
Objdal.InsertUserDetails(Objbalregistration);



press fll while debugging
 
Share this answer
 

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