public ActionResult Grid1_RowSelect(string selectedRowId, JArray Grid2_fields) { // 当前选中角色拥有的权限列表 _currentRolePowers.Clear(); Hashtable table = Sys_PowersDal.SearchRolePower(0, 0, "Name", "DESC", " and RoleID=" + selectedRowId); DataTable dt = (DataTable)table["data"]; for (int i = 0; i < dt.Rows.Count; i++) { string powerName = dt.Rows[i]["Name"].ToString();; if (!_currentRolePowers.ContainsKey(powerName)) { _currentRolePowers.Add(powerName, true); } } Hashtable tableGroup = Sys_PowersDal.SearchGroupName(0, 0, "GroupName", "ASC", ""); DataTable dtGroup = (DataTable)tableGroup["data"]; UIHelper.Grid("Grid2").DataSource(dtGroup, Grid2_fields); return(UIHelper.Result()); }
private List <GroupPowerViewModel> RolePower_GetData() { string sql1 = string.Empty; string sql2 = string.Empty; if (GetUserType().Equals("3")) //如果登录用户是客户 { sql1 = sql1 + " IsCustomerLook=1"; sql2 = sql2 + " and b.IsCustomerLook=1"; } Hashtable tableGroup = Sys_PowersDal.SearchGroupName(0, 0, "GroupName", "ASC", sql1); DataTable dtGroup = (DataTable)tableGroup["data"]; List <GroupPowerViewModel> groupPowers = new List <GroupPowerViewModel>(); for (int i = 0; i < dtGroup.Rows.Count; i++) { var groupPower = new GroupPowerViewModel(); groupPower.GroupName = dtGroup.Rows[i][0].ToString(); Hashtable table = Sys_PowersDal.SearchGroupList(0, 0, "Name", "DESC", " and a.GroupName='" + dtGroup.Rows[i][0].ToString() + "'" + sql2); DataTable dt = (DataTable)table["data"]; JArray ja = new JArray(); for (int j = 0; j < dt.Rows.Count; j++) { JObject jo = new JObject(); jo.Add("id", dt.Rows[j]["ID"].ToString()); jo.Add("name", dt.Rows[j]["Name"].ToString()); jo.Add("title", dt.Rows[j]["Title"].ToString()); ja.Add(jo); } groupPower.Powers = ja; groupPowers.Add(groupPower); } return(groupPowers); }