protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["UsersId"] != null) { BLL.Users users = new BLL.Users(); Model.Users user = users.GetModel((int)Session["UsersId"]); BLL.Roles roles = new BLL.Roles(); Model.Roles role = roles.GetModel(user.Fk_Roles_Id.Value); BLL.PermisssionsNodes permisssionsNodes = new BLL.PermisssionsNodes(); List <Model.PermisssionsNodes> permisssionsNodesList = permisssionsNodes.GetModelList("Fk_Permissions_Id='" + role.Fk_Permissions_Id + "'"); List <Model.Nodes> nodes = new List <Model.Nodes>(); foreach (Model.PermisssionsNodes pn in permisssionsNodesList) { BLL.Nodes nodesBLL = new BLL.Nodes(); Model.Nodes node = nodesBLL.GetModel(pn.Fk_Nodes_Id.Value); if (node != null) { if (node.ParentId == 0 && node.IsVisible == true) { nodes.Add(node); } } } Repeater1.DataSource = nodes.OrderBy(p => p.Orders).ToList(); Repeater1.DataBind(); } } }
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { Repeater Repeater2 = e.Item.FindControl("Repeater2") as Repeater; Label lblId = e.Item.FindControl("lblId") as Label; //BLL.Nodes nodes = new BLL.Nodes(); //List<Model.Nodes> list = nodes.GetModelList("ParentId='" + lblId.Text + "' and IsVisible='True'").OrderBy(p => p.Orders).ToList(); BLL.Users users = new BLL.Users(); Model.Users user = users.GetModel((int)Session["UsersId"]); BLL.Roles roles = new BLL.Roles(); Model.Roles role = roles.GetModel(user.Fk_Roles_Id.Value); BLL.PermisssionsNodes permisssionsNodes = new BLL.PermisssionsNodes(); List <Model.PermisssionsNodes> permisssionsNodesList = permisssionsNodes.GetModelList("Fk_Permissions_Id='" + role.Fk_Permissions_Id + "'"); List <Model.Nodes> nodes = new List <Model.Nodes>(); foreach (Model.PermisssionsNodes pn in permisssionsNodesList) { BLL.Nodes nodesBLL = new BLL.Nodes(); Model.Nodes node = nodesBLL.GetModel(pn.Fk_Nodes_Id.Value); if (node != null) { if (node.ParentId == int.Parse(lblId.Text) && node.IsVisible == true) { nodes.Add(node); } } } Repeater2.DataSource = nodes.OrderBy(p => p.Orders).ToList(); Repeater2.DataBind(); } }
private void Add(HttpContext context) { var roleModel = new Models.Roles(); roleModel.ID = Guid.NewGuid(); //roleModel.CreateId = Profile.CurrentUser.UserId; //roleModel.CreateName = Profile.CurrentUser.UserName; roleModel.CreateTime = System.DateTime.Now; SetModelValue(roleModel, context); var roleBll = new BLL.Roles(); var result = false; var msg = ""; try { result = roleBll.Add(roleModel); if (!result) { msg = "保存失败!"; } } catch (Exception ex) { LogHelper.WriteLogofExceptioin(ex); result = false; msg = ex.Message; } context.Response.Write(msg); }
/// <summary> /// 验证参数中每项功能是否权限 /// </summary> /// <param name="validateParms">需要验证的功能参数列表</param> /// <returns>返回与参数各项对应的true或false的验证结果(注:当参数是"WorkflowTempl","CustomTask","AlertRules"或"AlertRuleTempl"时, /// 将返回对应的增删改三项的权限。 例:WorkflowTempl将返回"Create","Edit","Delete"三项权限)</returns> private Dictionary <string, bool> ValidatePermission(string[] validateParms) { if (validateParms == null || validateParms.Length == 0) { throw new ArgumentNullException("validateParms", "Parameter is empty!"); } if (userInfo == null || userInfo.UserId == 0 || userInfo.RoleId <= 0) { throw new Exception("load user failed!"); } var permissionResult = new Dictionary <string, bool>(); //这四个字段都是smallint类型,分别用来标识该项的create,edit,delete权限的(在项目一期中不会验证这些权限) var specialField = new List <string> { "WorkflowTempl", "CustomTask", "AlertRules", "AlertRuleTempl" }; var roleMgr = new BLL.Roles(); var dsRole = roleMgr.GetList(string.Format(" RoleId={0}", _iRoleID)); if (dsRole == null || dsRole.Tables.Count == 0 || dsRole.Tables[0].Rows.Count == 0) { throw new Exception("load user role failed!"); } //根据查询结果检查参数中各项的权限,并加入返回结果集 foreach (var validateParm in validateParms) { if (!dsRole.Tables[0].Columns.Contains(validateParm)) //table中不包含要验证的字段 { continue; } if (!specialField.Contains(validateParm)) { permissionResult.Add(validateParm, dsRole.Tables[0].Rows[0].Field <bool>(validateParm)); } } return(permissionResult); }
private void ShowInfo(int Id) { Maticsoft.BLL.Users bll = new Maticsoft.BLL.Users(); Maticsoft.Model.Users model = bll.GetModel(Id); this.lblId.Text = model.Id.ToString(); this.lblName.Text = model.Name; this.lblTrueName.Text = model.TrueName; this.lblSex.Text = model.Sex; this.lblPhone.Text = model.Phone; this.iPhoto.ImageUrl = "~/" + model.Photo; this.lblEmail.Text = model.Email; this.lblBirthday.Text = model.Birthday.ToString(); BLL.Roles BLLRoles = new BLL.Roles(); Model.Roles ModelRoles = BLLRoles.GetModel((int)model.Fk_Roles_Id); this.lblFk_Roles_Id.Text = ModelRoles.Name; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BLL.Roles bllRoles = new BLL.Roles(); var dsRoles = bllRoles.GetList(" RoleId=" + CurrUser.iRoleID); if (dsRoles != null && dsRoles.Tables.Count != 0 && dsRoles.Tables[0].Rows.Count > 0) { if (dsRoles.Tables[0].Rows[0]["OtherLoanAccess"] == null || dsRoles.Tables[0].Rows[0]["OtherLoanAccess"].ToString().Trim().Length == 0) { Response.Redirect("../Unauthorize.aspx"); return; } } BindFilter(); fromHomeFilter = FilterFromHomePiplineSummary(); BindGrid(); } }
/// <summary> /// get login user info /// </summary> public LoginUser() { // do not check authorization for Unauthorize page if (System.IO.Path.GetFileName(HttpContext.Current.Request.PhysicalPath).ToLower() == "unauthorize.aspx") { return; } string sLoginUserId = HttpContext.Current.User.Identity.Name; if (sLoginUserId.IndexOf("\\") >= 0) { sLoginUserId = sLoginUserId.Substring(sLoginUserId.LastIndexOf("\\") + 1); } // 加载用户数据 var userManager = new Users(); //DataTable dtUserInfo = userManager.GetModel(" AND Username='******'"); //if (dtUserInfo == null || dtUserInfo.Rows.Count == 0) //{ // HttpContext.Current.Response.Redirect("~/_layouts/LPWeb/Unauthorize.aspx"); // return; //} string sqlCmd = string.Format("Select top 1 UserId from Users where username='******'", sLoginUserId); object obj = DAL.DbHelperSQL.GetSingle(sqlCmd); int userId = (obj == null || obj == DBNull.Value) ? 0 : (int)obj; if (userId <= 0) { HttpContext.Current.Response.Redirect("~/_layouts/LPWeb/Unauthorize.aspx"); return; } int userid = (int)obj; userInfo = userManager.GetModel_WithoutPicture(userid); _iUserID = userid; _bUserEnabled = userInfo.UserEnabled; _sUserName = userInfo.Username; _sFirstName = userInfo.FirstName; _sLastName = userInfo.LastName; _sEmail = userInfo.EmailAddress; _sFullName = _sFirstName + ' ' + _sLastName; _iRoleID = userInfo.RoleId; if (_iRoleID <= 0) { HttpContext.Current.Response.Redirect("~/_layouts/LPWeb/Unauthorize.aspx"); return; } var roleMgr = new BLL.Roles(); _userRole = roleMgr.GetModel(_iRoleID); _sRoleName = _userRole.Name; _bAccessOtherLoans = _userRole.OtherLoanAccess; GetUserOrganizationInfo(userManager); GetRecentItems(userid); #region CR48 LPWeb.BLL.UserHomePref UserHomePref1 = new LPWeb.BLL.UserHomePref(); LPWeb.Model.UserHomePref UserPrefInfo = UserHomePref1.GetModel(userid); if (UserPrefInfo != null) { this._QuickLeadForm = UserPrefInfo.QuickLeadForm; this._RemindTaskDue = userInfo.RemindTaskDue; this._TaskReminder = userInfo.TaskReminder; this._SortTaskPickList = userInfo.SortTaskPickList; } // init TaskListDueToday this.InitTaskListDueToday(); #endregion //CR38 this._ViewLockInfo = _userRole.ViewLockInfo; this._LockRate = _userRole.LockRate; //CR52 this._AccessProfitability = _userRole.AccessProfitability; this._ViewCompensation = _userRole.ViewCompensation; //CR65 this._UpdateCondition = _userRole.UpdateCondition; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (!CurrUser.userRole.CompanySetup) { Response.Redirect("../Unauthorize.aspx"); Response.End(); } this.imgUserPic.Attributes.Add("onload", string.Format("resizeImage('{0}')", this.imgUserPic.ClientID)); // get UserId from query string int nUserId = -1; if (!int.TryParse(Request.QueryString["uid"], out nUserId)) { nUserId = -1; } if (-1 == nUserId) { UserId = null; } else { UserId = nUserId; } BLL.Company_General comGeneral = new BLL.Company_General(); Model.Company_General company = comGeneral.GetModel(); if (null != company) { this.lbPrefix.Text = company.AD_OU_Filter; } // bind User Loan Rep gridview BindLoanRep(); // bind Group gridview BindGroup(); // bind Role dropdown list BLL.Roles RolesManager = new BLL.Roles(); DataSet dsRoles = RolesManager.GetList(string.Empty); this.ddlRole.DataSource = dsRoles; this.ddlRole.DataValueField = "RoleId"; this.ddlRole.DataTextField = "Name"; this.ddlRole.DataBind(); this.ddlRole.Items.Insert(0, new ListItem("Please Select", "")); Mode = Request.QueryString["mode"]; if ("0" == Mode) { this.btnDelete.Enabled = false; this.btnClone.Enabled = false; } if ("1" == Mode) { // Load user info if (!UserId.HasValue) { // if no UserId,thorw exception LPLog.LogMessage(LogType.Logerror, "Invalid UserId"); throw new Exception("Invalid UserId"); } else { Model.Users user = UsersManager.GetModel(UserId.Value); if (null == user) { LPLog.LogMessage(LogType.Logerror, string.Format("Cannot find the user with UserId = {0}", UserId.Value)); } else { this.ckbEnabled.Checked = user.UserEnabled; this.tbUserName.Text = user.Username; this.tbEmail.Text = user.EmailAddress; this.tbFirstName.Text = user.FirstName; this.tbLastName.Text = user.LastName; ListItem item = this.ddlRole.Items.FindByValue(user.RoleId.ToString()); if (null != item) { this.ddlRole.ClearSelection(); item.Selected = true; } this.hiUserLoanCount.Value = LoanTeamManager.GetUserLoanCount(UserId.Value).ToString(); this.hiUserContactCount.Value = ContactUsersManager.GetUserContactCount(UserId.Value).ToString(); //gdc 20110606 Add this.txbPhone.Text = user.Phone; this.txbFax.Text = user.Fax; this.txbCell.Text = user.Cell; this.txbBranchManagerCompensation.Text = user.BranchMgrComp.ToString("00.000"); this.txbDivisionManagerCompensation.Text = user.DivisionMgrComp.ToString("00.000"); this.txbLoanOfficerCompenstation.Text = user.LOComp.ToString("00.000"); this.txbRegionalManagerCompensation.Text = user.RegionMgrComp.ToString("00.000"); //ExchangePassword this.txbExchangePassword.Text = user.ExchangePassword; this.txbExchangePassword.Attributes.Add("value", user.ExchangePassword); } } } if (UserId.HasValue && Mode == "1") { this.tbUserName.Enabled = false; this.tbUserName.BackColor = System.Drawing.Color.LightGray; } else { this.tbUserName.Enabled = true; this.tbUserName.BackColor = System.Drawing.Color.Transparent; } } }
protected void Page_Init(object sender, EventArgs e) { this.context = new EntitiesContext(); this.roles = new BLL.Roles(context); }
private void Del(string id, HttpContext context) { if (!string.IsNullOrEmpty(id)) { var result = false; var msg = ""; var roleBll = new BLL.Roles(); try { var roleModel = roleBll.GetModel(new Guid(id)); //roleModel.LastModifyId = Profile.CurrentUser.UserId; //roleModel.LastModifyName = Profile.CurrentUser.UserName; roleModel.LastModifyTime = System.DateTime.Now; roleModel.Rstatus = 2; result = roleBll.Update(roleModel); if (!result) { msg = "保存失败!"; } } catch (Exception ex) { LogHelper.WriteLogofExceptioin(ex); result = false; msg = ex.Message; } context.Response.Write(msg); } }
private void Query(HttpContext context) { var name = string.IsNullOrEmpty(context.Request["Name"]) ? "" : context.Request["Name"].Trim(); var rstatus = string.IsNullOrEmpty(context.Request["Rstatus"]) ? "" : context.Request["Rstatus"].Trim(); var description = string.IsNullOrEmpty(context.Request["Description"]) ? "" : context.Request["Description"].Trim(); var createTime = string.IsNullOrEmpty(context.Request["CreateTime"]) ? "" : context.Request["CreateTime"].Trim(); var ds = new DataSet(); var roleBll = new BLL.Roles(); var strWhere = ""; if (!string.IsNullOrEmpty(name)) { strWhere = string.Format(" Name like '%" + name + "%' "); } if (!string.IsNullOrEmpty(rstatus)) { if (!string.IsNullOrEmpty(strWhere)) { strWhere += string.Format(" and Rstatus like '%" + rstatus + "%' "); } else { strWhere = string.Format(" Rstatus like '%" + rstatus + "%' "); } } if (!string.IsNullOrEmpty(description)) { if (!string.IsNullOrEmpty(strWhere)) { strWhere += string.Format(" and Description like '%" + description + "%' "); } else { strWhere = string.Format(" Description like '%" + description + "%' "); } } if (!string.IsNullOrEmpty(createTime)) { if (!string.IsNullOrEmpty(strWhere)) { strWhere += string.Format(" and CreateTime >= '" + description + "' "); } else { strWhere = string.Format(" CreateTime >= '" + description + "' "); } } var page = Convert.ToInt32(context.Request["page"]); var rows = Convert.ToInt32(context.Request["rows"]); var sort = string.IsNullOrEmpty(context.Request["sort"]) ? "Name" : context.Request["sort"]; var order = string.IsNullOrEmpty(context.Request["order"]) ? "asc" : context.Request["order"]; var startIndex = (page - 1) * rows + 1; var endIndex = startIndex + rows - 1; var num = roleBll.GetRecordCount(strWhere); ds = roleBll.GetListByPage(strWhere, sort, startIndex, endIndex, order); var str = JsonConvert.SerializeObject(new { total = num, rows = ds.Tables[0] }); context.Response.Write(str); }
private string GetData(HttpContext context) { var ds = new DataSet(); var rolesBll = new BLL.Roles(); var page = Convert.ToInt32(context.Request["page"]); var rows = Convert.ToInt32(context.Request["rows"]); var sort = string.IsNullOrEmpty(context.Request["sort"]) ? "Name" : context.Request["sort"]; var order = string.IsNullOrEmpty(context.Request["order"]) ? "asc" : context.Request["order"]; var startIndex = (page - 1) * rows + 1; var endIndex = startIndex + rows - 1; var num = rolesBll.GetRecordCount(" Rstatus !=0 "); ds = rolesBll.GetListByPage(" Rstatus !=0 ", sort, startIndex, endIndex, order); var str = JsonConvert.SerializeObject(new { total = num, rows = ds.Tables[0] }); return str; }