/* ConnectClass */
SqlCommand Sqlcmd;
string lookuppwd = null;
public static string conn = ConfigurationManager.ConnectionStrings["connDatabase"].ConnectionString.ToString();
SqlConnection Sqlconn = new SqlConnection(conn);
public bool validateuser(string username,string pwd,ref string Role)
{
try
{
Sqlconn.Open();
string spName = "sp_getUserDetails";
Sqlcmd = new SqlCommand(spName, Sqlconn);
Sqlcmd.CommandType = CommandType.StoredProcedure;
Sqlcmd.Parameters.Add(new SqlParameter("@Value", username));
lookuppwd = (string)Sqlcmd.ExecuteScalar();
Sqlconn.Close();
}
if (null == lookuppwd)
{ return false;}
return (0 == string.Compare(lookuppwd, pwd, false));
}
ConnectClass cc = new ConnectClass();
string Role = "";
lookuppwd = (string)Sqlcmd.ExecuteScalar();
Sqlconn.Close();
}
if (null == lookuppwd)
{ return false;}
return (0 == string.Compare(lookuppwd, pwd, false));
}
ConnectClass cc = new ConnectClass();
string Role = "";
if (cc.validateuser(txtUserName.Value.ToString(), txtUserPass.Value.ToString(),ref Role))
{
string strRedirect;
strRedirect = Request["ReturnUrl"];
if (strRedirect == null)
{
strRedirect = "Default.aspx";
Session["Role"] = Role;
Session["User"] = txtUserName.Value.ToString();
}
Response.Redirect(strRedirect, true);
}
else
{
Response.Redirect("TestLogin.aspx", true);
}
string strRedirect;
strRedirect = Request["ReturnUrl"];
if (strRedirect == null)
{
strRedirect = "Default.aspx";
Session["Role"] = Role;
Session["User"] = txtUserName.Value.ToString();
}
Response.Redirect(strRedirect, true);
}
else
{
Response.Redirect("TestLogin.aspx", true);
}
No comments:
Post a Comment