I hope that it will be beneficial for everyone.....
protected void Button1_Click(object sender, EventArgs e)
{
if (txtmajorhead.Text == "")
{
lbl_msg.Text = "User Name is required !";
}
else if (txtdescp.Text == "")
{
lbl_msg.Text = "Password is required !";
}
else
{
Parameter UserId = new Parameter(txtmajorhead.Text);
Parameter Password = new Parameter(txtdescp.Text);
SqlDataAdapter da = new SqlDataAdapter("select * from Login where UserID='" + UserId + "' and Password='" + Password + "'", con);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
Session["UserID"] = ds.Tables[0].Rows[0]["UserID"].ToString();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if ((ds.Tables[0].Rows[i]["UserID"].ToString() == txtmajorhead.Text) && (ds.Tables[0].Rows[i]["Password"].ToString() == txtdescp.Text))
{
f = 1;
Response.Redirect("AddCategory.aspx");
break;
}
}
}
if (f == 0)
{
lbl_msg.Text = "UserName And Password Are Incorrect";
}
txtmajorhead.Focus();
}
protected void Button1_Click(object sender, EventArgs e)
{
if (txtmajorhead.Text == "")
{
lbl_msg.Text = "User Name is required !";
}
else if (txtdescp.Text == "")
{
lbl_msg.Text = "Password is required !";
}
else
{
Parameter UserId = new Parameter(txtmajorhead.Text);
Parameter Password = new Parameter(txtdescp.Text);
SqlDataAdapter da = new SqlDataAdapter("select * from Login where UserID='" + UserId + "' and Password='" + Password + "'", con);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
Session["UserID"] = ds.Tables[0].Rows[0]["UserID"].ToString();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
if ((ds.Tables[0].Rows[i]["UserID"].ToString() == txtmajorhead.Text) && (ds.Tables[0].Rows[i]["Password"].ToString() == txtdescp.Text))
{
f = 1;
Response.Redirect("AddCategory.aspx");
break;
}
}
}
if (f == 0)
{
lbl_msg.Text = "UserName And Password Are Incorrect";
}
txtmajorhead.Focus();
}
No comments:
Post a Comment