DAL
public DataTable check_Sess_DTable(Prop_Sess pro)
{
con.Open();
cmd = new SqlCommand("sp_Reg", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@uname", pro.Cname);
cmd.Parameters.AddWithValue("@pwd", pro.Pwd);
da = new SqlDataAdapter(cmd);
dt = new DataTable();
da.Fill(dt);
con.Close();
return dt;
}
BLL
public DataTable check_Sess_DTable(Prop_Sess _Pro)
{
DataTable dt= d.check_Sess_DTable(_Pro);
return dt;
}
Application Layer
protected void Btn_Login_Click(object sender, EventArgs e)
{
Label1.Visible = false;
DataTable dt = null;
_Pro.Cname = txt_UName.Text;
_Pro.Pwd = txt_Pwd.Text;
dt = b.check_Sess_DTable(_Pro);
if (dt.Rows.Count > 0 && txt_UName.Text.ToString()== dt.Rows[0][3].ToString() && txt_Pwd.Text.ToString() == dt.Rows[0][5].ToString())
{
Session["Reg_ID"] = dt.Rows[0][0].ToString();
Session["FirstName"] = dt.Rows[0][1].ToString();
Session["LastName"] = dt.Rows[0][2].ToString();
Session["UserName"] = dt.Rows[0][3].ToString();
Session["Password"] = dt.Rows[0][5].ToString();
Response.Redirect("Redirect.aspx",true);
}
else
{
Label1.Visible = true;
Label1.ForeColor = System.Drawing.Color.Red;
Label1.Text = "Invalid Login Credentials";
}
}
Redirect Page
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Reg_ID"] != null)
{
txt_REgID.Text = Session["Reg_ID"].ToString();
}
if (Session["FirstName"] != null)
{
txt_FName.Text = Session["FirstName"].ToString();
}
if (Session["LastName"] != null)
{
txt_LName.Text = Session["LastName"].ToString();
}
if (Session["UserName"] != null)
{
txt_UName.Text = Session["UserName"].ToString();
}
if (Session["Password"] != null)
{
txt_Pwd.Text = Session["Password"].ToString();
}
}
public DataTable check_Sess_DTable(Prop_Sess pro)
{
con.Open();
cmd = new SqlCommand("sp_Reg", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@uname", pro.Cname);
cmd.Parameters.AddWithValue("@pwd", pro.Pwd);
da = new SqlDataAdapter(cmd);
dt = new DataTable();
da.Fill(dt);
con.Close();
return dt;
}
BLL
public DataTable check_Sess_DTable(Prop_Sess _Pro)
{
DataTable dt= d.check_Sess_DTable(_Pro);
return dt;
}
Application Layer
protected void Btn_Login_Click(object sender, EventArgs e)
{
Label1.Visible = false;
DataTable dt = null;
_Pro.Cname = txt_UName.Text;
_Pro.Pwd = txt_Pwd.Text;
dt = b.check_Sess_DTable(_Pro);
if (dt.Rows.Count > 0 && txt_UName.Text.ToString()== dt.Rows[0][3].ToString() && txt_Pwd.Text.ToString() == dt.Rows[0][5].ToString())
{
Session["Reg_ID"] = dt.Rows[0][0].ToString();
Session["FirstName"] = dt.Rows[0][1].ToString();
Session["LastName"] = dt.Rows[0][2].ToString();
Session["UserName"] = dt.Rows[0][3].ToString();
Session["Password"] = dt.Rows[0][5].ToString();
Response.Redirect("Redirect.aspx",true);
}
else
{
Label1.Visible = true;
Label1.ForeColor = System.Drawing.Color.Red;
Label1.Text = "Invalid Login Credentials";
}
}
Redirect Page
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Reg_ID"] != null)
{
txt_REgID.Text = Session["Reg_ID"].ToString();
}
if (Session["FirstName"] != null)
{
txt_FName.Text = Session["FirstName"].ToString();
}
if (Session["LastName"] != null)
{
txt_LName.Text = Session["LastName"].ToString();
}
if (Session["UserName"] != null)
{
txt_UName.Text = Session["UserName"].ToString();
}
if (Session["Password"] != null)
{
txt_Pwd.Text = Session["Password"].ToString();
}
}
No comments:
Post a Comment