private void ShowInfo(int _id) { var bll = new ManagerRoleService(); var model = bll.GetModel(_id); txtRoleName.Text = model.RoleName; //ddlRoleType.SelectedValue = model.role_type.ToString(); //管理权限 if (model.ManagerRoleValues != null) { for (int i = 0; i < rptList.Items.Count; i++) { string navName = ((HiddenField)rptList.Items[i].FindControl("hidName")).Value; CheckBoxList cblActionType = (CheckBoxList)rptList.Items[i].FindControl("cblActionType"); for (int n = 0; n < cblActionType.Items.Count; n++) { var modelt = model.ManagerRoleValues.Where(p => p.NavName == navName && p.ActionType == cblActionType.Items[n].Value); if (modelt != null) { cblActionType.Items[n].Selected = true; } } } } }
private bool DoEdit(int _id) { bool result = false; var bll = new ManagerRoleService(); var model = bll.GetModel(_id); model.RoleName = txtRoleName.Text.Trim(); // model.role_type = int.Parse(ddlRoleType.SelectedValue); //管理权限 var ls = new List<ManagerRoleValueInfo>(); for (int i = 0; i < rptList.Items.Count; i++) { string navName = ((HiddenField)rptList.Items[i].FindControl("hidName")).Value; CheckBoxList cblActionType = (CheckBoxList)rptList.Items[i].FindControl("cblActionType"); for (int n = 0; n < cblActionType.Items.Count; n++) { if (cblActionType.Items[n].Selected == true) { ls.Add(new ManagerRoleValueInfo { RoleId = _id, NavName = navName, ActionType = cblActionType.Items[n].Value }); } } } model.ManagerRoleValues = ls; if (bll.Update(model)) { AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "修改角色:" + model.RoleName); //记录日志 result = true; } return result; }