protected void Page_Load(object sender, EventArgs e) { if (Session["EmpID"] != null) { String id = HttpContext.Current.User.Identity.GetUserId(); StationeryStoreEntities context = new StationeryStoreEntities(); Employee emp = context.Employee.Where(x => x.Id == id).ToList().FirstOrDefault(); if (emp != null) { int empId = emp.EmployeeID; int deptID = (int)emp.DepartmentID; String email = emp.Email; Session["EmpID"] = empId; Session["DeptID"] = deptID; Session["Email"] = email; } } }
protected void Page_Load(object sender, EventArgs e) { if (HttpContext.Current.User.Identity.IsAuthenticated) { if (HttpContext.Current.Session["EmpID"] == null) { // Response.Redirect("/Account/Login.aspx"); } else { String id = HttpContext.Current.User.Identity.GetUserId(); StationeryStoreEntities context = new StationeryStoreEntities(); Employee emp = context.Employee.Where(x => x.Id == id).ToList().FirstOrDefault(); int empId = emp.EmployeeID; int deptID = (int)emp.DepartmentID; if (HttpContext.Current.User.IsInRole("Dept Head")) { if (deptID == 2007) { PurchasingDHTreeView.Visible = true; } else { DHTreeView.Visible = true; } } else if (HttpContext.Current.User.IsInRole("Dept Staff")) { DateTime today = DateTime.Now.Date; Delegation d = context.Delegation.Where(x => x.EmployeeID == empId && (x.StartDate <= today && x.EndDate >= today)).FirstOrDefault <Delegation>(); if (d != null) { DelStaffTreeView.Visible = true; } else { if (emp.isUserRep == 1) { URDeptStaffTreeView.Visible = true; } else { DeptStaffTreeView.Visible = true; } } } else if (HttpContext.Current.User.IsInRole("Store Manager")) { ManagerTreeView.Visible = true; } else if (HttpContext.Current.User.IsInRole("Store Supervisor")) { SupervisorTreeView.Visible = true; } else if (HttpContext.Current.User.IsInRole("Store Clerk")) { ClerkTreeView.Visible = true; } else if (HttpContext.Current.User.IsInRole("Admin")) { AdminTreeView.Visible = true; } } } else { //Label1.Text = "Not logged in"; } }