public DataSet IsEmployeeIDValid(Model.clsLogin objLogin) { SqlParameter[] objParam = new SqlParameter[1]; objParam[0] = new SqlParameter("@EmployeeID", SqlDbType.Int); objParam[0].Value = objLogin.EmployeeID; //objParam[1] = new SqlParameter("@Password",SqlDbType.VarChar, 15); //objParam[1].Value = objLogin.Password; DataSet dsEmployeeExists = new DataSet(); try { dsEmployeeExists = SqlHelper.ExecuteDataset(sqlConn, CommandType.StoredProcedure, "sp_IsEmployeeIDValid", objParam); return(dsEmployeeExists); } catch (V2Exceptions ex) { throw; } catch (System.Exception ex) { FileLog objFileLog = FileLog.GetLogger(); objFileLog.WriteLine(LogType.Error, ex.Message, "clsDLLogin.cs", "IsEmployeeIDValid", ex.StackTrace); throw new V2Exceptions(ex.ToString(), ex); } }
public int isEmployeeSuperAdmin(Model.clsLogin objLogin) { int recordcount; SqlParameter[] objParam = new SqlParameter[1]; objParam[0] = new SqlParameter("@EmployeeID", SqlDbType.Int); objParam[0].Value = objLogin.EmployeeID; try { recordcount = Convert.ToInt32(SqlHelper.ExecuteScalar(sqlConn, CommandType.StoredProcedure, "IsEmployeeSuperAdmin", objParam)); return(recordcount); } catch (V2Exceptions ex) { throw; } catch (System.Exception ex) { FileLog objFileLog = FileLog.GetLogger(); objFileLog.WriteLine(LogType.Error, ex.Message, "clsDLLogin.cs", "isEmployeeSuperAdmin", ex.StackTrace); throw new V2Exceptions(ex.ToString(), ex); } }
public int isEmployeeSuperAdmin(Model.clsLogin objLogin) { try { return(objDLLogin.isEmployeeSuperAdmin(objLogin)); } catch (V2Exceptions ex) { throw; } catch (System.Exception ex) { FileLog objFileLog = FileLog.GetLogger(); objFileLog.WriteLine(LogType.Error, ex.Message, "clsBLLogin.cs", "isEmployeeSuperAdmin", ex.StackTrace); throw new V2Exceptions(ex.ToString(), ex); } }
//To verify loginid and password //protected void btnSubmit_Click(object sender, System.EventArgs e) public void loginAccess() { if ((Session["SAEmployeeID"].ToString() == "0")) { DataSet dsEmployeeExists = new DataSet(); // DataSet isEmployeeSuperAdmin = new DataSet(); int isEmployeeSuperAdmin = 0; objLogin = new Model.clsLogin(); objBLLogin = new BusinessLayer.clsBLLogin(); // int user = try { objLogin.EmployeeID = Convert.ToInt32(Session["EmployeeID"]); //objLogin.Password = txtPassword.Text; //if (Membership.ValidateUser(txtUserID.Text, txtPassword.Text)) { recordcount = objBLLogin.DoesEmployeeIDExist(objLogin); if (recordcount > 0) { dsEmployeeExists = objBLLogin.IsEmployeeIDValid(objLogin); if (dsEmployeeExists.Tables[0].Rows.Count > 0) { if (dsEmployeeExists.Tables[0].Rows[0]["isAdmin"].ToString() == "1" || dsEmployeeExists.Tables[0].Rows[0]["isAdmin"].ToString() == "True") { Session["SAEmployeeID"] = Convert.ToInt32(Session["EmployeeID"]); if (Roles.IsUserInRole(Convert.ToString(Session["EmployeeID"]), "Super Admin")) { Session["SuperAdmin"] = Convert.ToInt32(Session["EmployeeID"]); } //Response.Redirect("ViewSuperAdminIssues.aspx"); Response.Redirect("IssueHealth.aspx", false); } else if (dsEmployeeExists.Tables[0].Rows[0]["isAdmin"].ToString() == "0" || dsEmployeeExists.Tables[0].Rows[0]["isAdmin"].ToString() == "False") { //check if he has super admin role //then give him roles for masters and other roles. isEmployeeSuperAdmin = objBLLogin.isEmployeeSuperAdmin(objLogin); if (isEmployeeSuperAdmin > 0) { Session["SuperAdmin"] = Convert.ToInt32(Session["EmployeeID"]); } Session["IsExecutive"] = 1; Session["EmployeeID"] = Convert.ToInt32(Session["EmployeeID"]); Session["SAEmployeeID"] = Convert.ToInt32(Session["EmployeeID"]); Response.Redirect("IssueHealth.aspx", false); } else { lblMsg.Text = "UserID does not exist"; } } else if (Roles.IsUserInRole(Convert.ToString(Session["EmployeeID"]), "Super Admin")) { Session["SuperAdmin"] = Convert.ToInt32(Session["EmployeeID"]); Session["OnlySuperAdmin"] = Convert.ToInt32(Session["EmployeeID"]); Response.Redirect("ViewEmployeeDetails.aspx", false); } else { lblMsg.Text = "Sorry, you are not authorize to access the system"; } } else if (Roles.IsUserInRole(Convert.ToString(Session["EmployeeID"]), "Super Admin")) { Session["SuperAdmin"] = Convert.ToInt32(Session["EmployeeID"]); Session["OnlySuperAdmin"] = Convert.ToInt32(Session["EmployeeID"]); Response.Redirect("ViewEmployeeDetails.aspx"); } else { lblMsg.Text = "Sorry, you are not authorize to access the system"; } } //else //{ // lblMsg.Text = "Not a Valid User, Please check the credentials"; //} } catch (System.Threading.ThreadAbortException ex) { } catch (V2Exceptions ex) { throw; } catch (System.Exception ex) { FileLog objFileLog = FileLog.GetLogger(); objFileLog.WriteLine(LogType.Error, ex.Message, "Login.aspx", "btnSubmit_Click", ex.StackTrace); throw new V2Exceptions(ex.ToString(), ex); } } else { Session.Abandon(); Response.Redirect(ConfigurationManager.AppSettings["Log-OffURL"].ToString()); } }