protected void Page_Load(object sender, EventArgs e) { int userID = getCurrentUserID(); if (!IsPostBack) { try { using (ERP_CMSEntities cntx = new ERP_CMSEntities()) { bool isAdmin = (bool)cntx.Users.Where(f => f.UserID == userID).Select(f => f.IsAdmin).FirstOrDefault(); if (!isAdmin) { bool haveRights = PortalUtilities.fnHaveRights(userID, Convert.ToInt32(PortalUtilities.MenuLinks.ManageShipper)); if (!haveRights) { Response.Redirect("~/Admin/"); } } } } catch (Exception) { throw; } } }
protected void Page_Load(object sender, EventArgs e) { int userID = getCurrentUserID(); if (!IsPostBack) { try { using (ERP_CMSEntities cntx = new ERP_CMSEntities()) { bool isAdmin = (bool)cntx.Users.Where(f => f.UserID == userID).Select(f => f.IsAdmin).FirstOrDefault(); if (!isAdmin) { bool haveRights = PortalUtilities.fnHaveRights(userID, Convert.ToInt32(PortalUtilities.MenuLinks.ManageAgentType)); if (!haveRights) { Response.Redirect("~/Admin/"); } } } } catch (Exception) { throw; } //HttpContext.Current("") = userID; //Server.Transfer("TreeLoader.ashx"); // Server.Transfer("AgentType_Handler.ashx?currentUser="******"AgentType_Handler.ashx?currentUser="******"AgentType_Handler.ashx?currentUser=" + userID); } }
protected void Page_Load(object sender, EventArgs e) { int userID = getCurrentUserID(); if (!IsPostBack) { using (ERP_CMSEntities cntx = new ERP_CMSEntities()) { bool isAdmin = (bool)cntx.Users.Where(f => f.UserID == userID).Select(f => f.IsAdmin).FirstOrDefault(); if (!isAdmin) { bool haveRights = PortalUtilities.fnHaveRights(userID, Convert.ToInt32(PortalUtilities.MenuLinks.ChangePassword)); if (!haveRights) { Response.Redirect("~/Admin/"); } } var user = cntx.Users.Where(f => f.UserID == userID).Select(f => f.UserName).FirstOrDefault(); if (user == null && user.Equals(null)) { lblUserName.Text = "-- Invalid User --"; btnChangePassword.Enabled = false; txtPassword.Enabled = false; txtConfirmPassword.Enabled = false; } else { lblUserName.Text = user; //txtEmailAddress.Text = user.Email //lblUserRole.Text = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(Roles.GetRolesForUser(strUserName)(0)) //strRole = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(Roles.GetRolesForUser(strUserName)(0)) //Dim objEmployee = cntx.Employees.Where(Function(f) f.EmployeeID = intEmpID).ToList().FirstOrDefault() //txtEmailAddress.Text = objEmployee.Email } } } }
protected void Page_Load(object sender, EventArgs e) { int userID = getCurrentUserID(); try { if (!IsPostBack) { using (ERP_CMSEntities cntx = new ERP_CMSEntities()) { bool isAdmin = (bool)cntx.Users.Where(f => f.UserID == userID).Select(f => f.IsAdmin).FirstOrDefault(); if (!isAdmin) { bool haveManageUserRights = PortalUtilities.fnHaveRights(userID, Convert.ToInt32(PortalUtilities.MenuLinks.ManageUsers)); bool haveManageRights = PortalUtilities.fnHaveRights(userID, Convert.ToInt32(PortalUtilities.MenuLinks.ManageRights)); bool haveChangePasswordRights = PortalUtilities.fnHaveRights(userID, Convert.ToInt32(PortalUtilities.MenuLinks.ChangePassword)); if (!haveManageUserRights) { divManageUsersDashboard.Visible = false; } if (!haveManageRights) { divManageRightsDashboard.Visible = false; } if (!haveChangePasswordRights) { divChangePasswordDashboard.Visible = false; } } } } } catch (Exception ex) { //lblStatus.Text = ex.Message; } }
protected void Page_Load(object sender, EventArgs e) { //if (!string.IsNullOrEmpty(Session["isAdmin"] as string)) //{ // string isAdmin = Session["isAdmin"].ToString(); // if (!isAdmin.Equals("True")) // { // Response.Redirect("~/Account/Login.aspx"); // } //} //else //{ // Response.Redirect("~/Account/Login.aspx"); //} if (!IsPostBack) { Page.Header.DataBind(); int userID = getCurrentUserID(); using (ERP_CMSEntities cntx = new ERP_CMSEntities()) { bool isAdmin = PortalUtilities.isUserAdmin(cntx, userID); if (isAdmin) { var objPanels = (from p in cntx.MenuPanels orderby p.DisplayOrder select new { p.PanelID, p.PanelTitle }).ToList(); rptrMenuPanels.DataSource = objPanels; rptrMenuPanels.DataBind(); } else { var objPanels = (from el in cntx.UserLinks join usr in cntx.Users on el.UserID equals usr.UserID join ml in cntx.MenuLinks on el.MenuLinkID equals ml.MenuLinkID join m in cntx.Menus on ml.MenuID equals m.MenuID join mp in cntx.MenuPanels on m.PanelID equals mp.PanelID where usr.UserID == userID select new { mp.PanelID, mp.PanelTitle, mp.DisplayOrder }).Distinct().OrderBy(f => f.DisplayOrder).ToList(); rptrMenuPanels.DataSource = objPanels; rptrMenuPanels.DataBind(); } bool haveChangePassword = PortalUtilities.fnHaveRights(userID, Convert.ToInt32(PortalUtilities.MenuLinks.ChangePassword)); if (haveChangePassword) { sideMenuLinkPassword.Visible = true; sideMenuDivider.Visible = true; } var objUserRights = cntx.sp_GetPageRightsByUserAndMenuLinkID(userID, Convert.ToInt32(PortalUtilities.MenuLinks.Profile)).Where(f => f.UserRightID > 0).ToList(); IList lstRights = objUserRights.Select(f => f.Title).ToList(); bool haveProfile = PortalUtilities.fnHaveRights(userID, Convert.ToInt32(PortalUtilities.MenuLinks.Profile)); if (objUserRights.Count > 0 && haveProfile == true && (lstRights.Contains("View Self") || lstRights.Contains("Edit Self"))) { sideMenuLinkProfile.Visible = true; sideMenuDivider.Visible = true; } try { var objUser = cntx.Users.Where(f => f.UserID == userID).ToList().FirstOrDefault(); lblLnkSideProfile.Text = objUser.UserName; } catch (Exception) { throw; } } } }