private void LoadEmployeeList() { int BranchId = 1; int DesignationId = 1; string FName = txtFName.Text; BusinessLayer.EmployeeMaster objEmployeeMaster = new BusinessLayer.EmployeeMaster(); DataTable DT = objEmployeeMaster.GetAll(BranchId, DesignationId, FName); dgvEmployeeMaster.DataSource = DT; dgvEmployeeMaster.DataBind(); //if (!HttpContext.Current.User.IsInRole(Entity.Utility.USER_ROLE_MODIFICATION)) // dgvEmployeeMaster.Columns[8].Visible = false; //if (!HttpContext.Current.User.IsInRole(Entity.Utility.USER_MODIFICATION)) // dgvEmployeeMaster.Columns[9].Visible = false; }
protected void UserLogin() { string u = txtUserName.Text.Trim(); string p = txtPassword.Text.Trim(); BusinessLayer.EmployeeMaster ObjEmployee = new BusinessLayer.EmployeeMaster(); Entity.EmployeeMaster Employee = new Entity.EmployeeMaster(); Employee = ObjEmployee.AuthenticateUser(u); if (Employee != null) { if (BusinessLayer.Cryptography.Decrypt(Employee.Password) == p) { string UserId = Employee.EmployeeId.ToString(); FormsAuthenticationTicket Authticket = new FormsAuthenticationTicket( 1, UserId, DateTime.Now, DateTime.Now.AddMinutes(240), false, UserId, FormsAuthentication.FormsCookiePath); string hash = FormsAuthentication.Encrypt(Authticket); HttpCookie Authcookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash); if (Authticket.IsPersistent) { Authcookie.Expires = Authticket.Expiration; } Response.Cookies.Add(Authcookie); System.Web.Caching.Cache cacheObject = System.Web.HttpContext.Current.Cache; cacheObject.Insert(UserId, Employee.Roles); Session["UserId"] = Employee.EmployeeId; Session["Role"] = Employee.DesignationId; Session.Timeout = 240; Response.Redirect("AddEditBlock.aspx"); } } txtUserName.Text = ""; txtPassword.Focus(); }