First Create BEL.CS (Business Entity Layer)
BEL.CS
private string _UserName;
private string _Password;
public string UserName
{
get
{return _UserName;
}
set
{
_UserName = value;
}
}
public string Password
{
get
{
return _Password;
}
set
{
_Password = value;
}
}
Second One For DAL.CS (Data Access Layer)
string ConnectionString = ConfigurationManager.AppSettings["LocalConnection"].ToString();
public string UserInformation(BEL objBELUserDetails)
{
SqlConnection con = new SqlConnection(ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("sp_userinformation", con);
cmd.CommandType = CommandType.StoredProcedure;
try
{
cmd.Parameters.AddWithValue("@UserName",objBELUserDetails.UserName);
cmd.Parameters.AddWithValue("@Password", objBELUserDetails.Password);
cmd.Parameters.Add("@ERROR", SqlDbType.Char, 500);
cmd.Parameters["@ERROR"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
string strMessage = (string) cmd.Parameters["@ERROR"].Value;
con.Close();
return strMessage;
}
catch (Exception ex)
{
throw ex;
}
finally
{
cmd.Dispose();
con.Close();
con.Dispose();
}
}
Third One For BLL.CSS (Business Access Layer)
BLL.CSS
public string UserDetails(BEL objUserDetails)
{
DAL objUserDAL = new DAL();
try
{
return objUserDAL.UserInformation(objUserDetails);
}
catch (Exception ex)
{
throw ex;
}
finally
{
objUserDAL = null;
}
}
Now In Presentation Layer
My Login.aspx.cs
protected void btnlogin_Click(object sender, EventArgs e)
{
try
{
string Output = string.Empty;
BEL objUserBEL = new BEL();
objUserBEL.UserName = txtuser.Text;
objUserBEL.Password = txtpwd.Text;
BLL objUserBLL = new BLL();
Output = objUserBLL.InsertUserDetails(objUserBEL);
Response.Redirect("Home.aspx");
}
catch(exception ex)
{
}
}