protected void btDelete_Click(object sender, EventArgs e) { ArrayList pkArray = null; RoleManageBLL bll = null; try { bll = BLLFactory.CreateBLL <RoleManageBLL>(); pkArray = GvHelper.GetPKValueByChk(this.GvList, 0, "cbxSelect", 0); foreach (object key in pkArray) { bll.Delete(new RoleInfo { RoleID = key.ToString() }); } this.BindData(); } catch (Exception ex) { throw ex; } }
private void BindData() { RoleManageBLL bll = null; DataPage dp = new DataPage(); Entity.Sys.RoleInfo condition = new Entity.Sys.RoleInfo(); try { bll = BLLFactory.CreateBLL <RoleManageBLL>(); condition.RoleDESC = this.RoleName.Text; PagerHelper.InitPageControl(this.AspNetPager1, dp, true); dp = bll.GetList(condition, dp); List <Entity.Sys.RoleInfo> list = dp.Result as List <Entity.Sys.RoleInfo>; this.GvList.DataSource = list; this.GvList.DataBind(); for (int i = 0; i < this.GvList.Rows.Count; i++) { string click = string.Format("return edit('{0}');", this.GvList.DataKeys[i]["RoleID"].ToString()); (this.GvList.Rows[i].Cells[3].Controls[0] as WebControl).Attributes.Add("onclick", click); } PagerHelper.SetPageControl(AspNetPager1, dp, true); } catch (Exception ex) { throw ex; } }
private void BindData() { string id = Request.QueryString["id"]; RoleManageBLL bll = null; Entity.Sys.RoleInfo info = new Entity.Sys.RoleInfo(); try { bll = BLLFactory.CreateBLL <RoleManageBLL>(); if (string.IsNullOrEmpty(id) == false) { info.RoleID = id; info = bll.Get(info); UIBindHelper.BindForm(this.Page, info); this.hiID.Value = info.RoleID; this.HiCREATEUSER.Value = info.CreateUser; this.HiCREATETIME.Value = info.CreateTime.ToString(); } else { info = new RoleInfo(); info.Powers = new List <RoleAuthority>(); } this.HiPowerList.Value = this.GetTreePowers(info); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取权限树数据源 /// </summary> /// <returns></returns> public string GetTreeRoles(Entity.Sys.User user) { List <TreeNodeResult> list = new List <TreeNodeResult>(); List <Entity.Sys.RoleInfo> roles = null; try { roles = new RoleManageBLL().GetAll(); foreach (Entity.Sys.RoleInfo r in roles) { TreeNodeResult node = new TreeNodeResult(); node.Tid = r.RoleID; node.Ttext = r.RoleDESC; node.TChecked = user.Roles.Exists(p => p.RoleID == r.RoleID); list.Add(node); } return(TreeNodeResult.GetResultJosnS(list.ToArray())); } catch (Exception ex) { throw ex; } }
protected void btSave_Click(object sender, EventArgs e) { RoleInfo info = new RoleInfo(); RoleManageBLL bll = null; try { UIBindHelper.BindModelByControls(this.Page, info); bll = BLLFactory.CreateBLL <RoleManageBLL>(); //绑定权限 if (this.HiSelectedPowerList.Value != "") { string[] powers = this.HiSelectedPowerList.Value.Split(",".ToCharArray()); info.Powers = new List <RoleAuthority>(); foreach (string powerID in powers) { RoleAuthority p = new RoleAuthority(); p.AuthorityID = powerID; info.Powers.Add(p); } } if (this.hiID.Value == "") { bll.Insert(info); } else { info.CreateUser = this.HiCREATEUSER.Value; info.CreateTime = DateTime.Parse(this.HiCREATETIME.Value); info.RoleID = this.hiID.Value; bll.Update(info); } ClientScript.RegisterStartupScript(this.GetType(), "myjs", "parent.refreshData();parent.closeAppWindow1();", true); } catch (Exception ex) { throw ex; } }