public Int32 GetRoleId(string RoleName) { Int32 RoleId; RoleManagementBLL objRoleManagementBLL = null; try { objRoleManagementBLL = new RoleManagementBLL(); RoleId = objRoleManagementBLL.GetRoleId(RoleName); return RoleId; } catch (Exception e) { throw; } finally { objRoleManagementBLL = null; } }
protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { Int32 RoleId; string UserName = string.Empty; if (Session["RoleId"] == null) { Common objCommon = new Common(); UserName = objCommon.GetCurrentUserName(); using (RoleManagementBLL objRoleManagementBLL = new RoleManagementBLL()) { RoleId = objRoleManagementBLL.GetRoleId(UserName); Session["RoleId"] = RoleId; } } else { RoleId = Convert.ToInt32(Session["RoleId"]); } switch (RoleId) { case 1: break; case 2: break; case 3: break; default: Response.Redirect("~/Error.aspx"); break; } } } catch(Exception ex) { // Log the error to a text file in the Error folder Common.WriteError(ex); } }