NEXT Student Login

Student

Login

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Data.SqlClient;

public partial class Student_Login : System.Web.UI.Page

{

DBMgt objDBMgt = new DBMgt();

protected void Page_Load(object sender, EventArgs e)

{

}

protected void btnLoginButton_Click(object sender, EventArgs e)

{

try

{

string sha1pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text.Trim(), "sha1");

SqlParameter[] parList = new SqlParameter[4];

parList[0] = new SqlParameter("@vLoginName ", txtUserName.Text.Trim());

parList[1] = new SqlParameter("@vPassword", txtPassword.Text.Trim());

parList[2] = new SqlParameter("@Yes_No", SqlDbType.Int, 4);

parList[3] = new SqlParameter("@iStuId", SqlDbType.Int, 4);

parList[2].Direction = ParameterDirection.Output;

parList[3].Direction = ParameterDirection.Output;

SqlCommand cmd = objDBMgt.ExecuteReaderStoreProc("checkStudentLogin", parList);

if (cmd != null)

{

if (Convert.ToInt16(cmd.Parameters["@Yes_No"].Value) == 1)

{

Session["iStuId"] = Convert.ToInt16(cmd.Parameters["@iStuId"].Value);

FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, true);

}

else

FailureText.Visible = true;

}

}

catch (SqlException SqlEx) // This Catch block is used to Catch the Sql or Backend related Problem

{

lblMsg.Text = "Sorry for inconvenience!!!!<br>Following BackEnd related Error Occured: +'" + SqlEx.Message + "'<br>Try Again!!!";

}

catch (Exception ex) // This Block is used to catch any exception occured if not related to upper exception

{

lblMsg.Text = "Sorry for inconvenience!!!!<br>Following Error Occured: +'" + ex.Message + "'<br>Try Again!!!";

}

}

}