private void AppendRow(Module module, int level, Hashtable htParent, Hashtable htSelected) { object[] objRow = new object[this.gridWebGrid.Columns.Count]; objRow[0] = string.Empty; objRow[1] = "1"; objRow[1 + level] = module.ModuleDescription; objRow[this.gridWebGrid.Columns.Count - 7] = module.ModuleCode; objRow[this.gridWebGrid.Columns.Count - 6] = module.ParentModuleCode; objRow[this.gridWebGrid.Columns.Count - 5] = module.FormUrl; string strRight = ""; if (htSelected.ContainsKey(module.ModuleCode) == true) { ModuleWithViewValue moduleSelected = (ModuleWithViewValue)htSelected[module.ModuleCode]; strRight = moduleSelected.ViewValue; } if (this.GetModuleRight(module.ModuleCode) != null) { strRight = this.GetModuleRight(module.ModuleCode); } if (strRight != "") { objRow[this.gridWebGrid.Columns.Count - 4] = securityFacade.HasRight(strRight, RightType.Export, false).ToString(); objRow[this.gridWebGrid.Columns.Count - 3] = securityFacade.HasRight(strRight, RightType.Read, false).ToString(); objRow[this.gridWebGrid.Columns.Count - 2] = securityFacade.HasRight(strRight, RightType.Write, false).ToString(); objRow[this.gridWebGrid.Columns.Count - 1] = securityFacade.HasRight(strRight, RightType.Delete, false).ToString(); } UltraGridRow gridRow = new UltraGridRow(objRow); // 设置是否突出显示 if ((this.drpModuleTypeEdit.SelectedValue != "" && module.ModuleType == this.drpModuleTypeEdit.SelectedValue) || (this.txtModuleCodeQuery.Text.Trim() != "" && module.ModuleCode.StartsWith(this.txtModuleCodeQuery.Text.Trim().ToUpper()) == true) || (this.txtModuleDescEdit.Text.Trim() != "" && module.ModuleDescription.StartsWith(this.txtModuleDescEdit.Text.Trim().ToUpper()) == true) || (this.txtModuleFormURLQuery.Text.Trim() != "" && module.FormUrl.ToUpper().IndexOf(this.txtModuleFormURLQuery.Text.Trim().ToUpper()) >= 0)) { gridRow.Style.BackColor = Color.PaleGoldenrod; } this.gridWebGrid.Rows.Add(gridRow); }
protected override object[] LoadDataSource(int inclusive, int exclusive) { if (facade == null) { facade = new SystemSettingFacadeFactory(base.DataProvider).Create(); } // 查询所有模块 object[] objs = facade.GetModuleWithViewValueVisibility(this.GetQueryParameterModuleParent()); ArrayList listMdl = new ArrayList(); if (objs != null) { // 查询用户组具有的权限 object[] objsSelected = facade.GetSelectedModuleWithViewValueByFunctionGroupCode( FormatHelper.PKCapitalFormat(FormatHelper.CleanString(this.txtFunctionGroupCodeQuery.Text)), string.Empty, string.Empty, string.Empty, this.GetQueryParameterModuleParent()); //this.GetRequestParam("expand") Hashtable htSelected = new Hashtable(); if (objsSelected != null) { for (int i = 0; i < objsSelected.Length; i++) { ModuleWithViewValue module = (ModuleWithViewValue)objsSelected[i]; htSelected.Add(module.ModuleCode, module); } } // 搜索每个模块的子模块 Hashtable htMdlChild = new Hashtable(); for (int i = 0; i < objs.Length; i++) { Module module = (Module)objs[i]; ArrayList listChild = new ArrayList(); if (htMdlChild.ContainsKey(module.ParentModuleCode) == true) { listChild = (ArrayList)htMdlChild[module.ParentModuleCode]; } else { htMdlChild.Add(module.ParentModuleCode, listChild); } listChild.Add(module); } // 查询具有子模块的模块代码 object[] objsParent = facade.GetModuleWithChild(); Hashtable htParent = new Hashtable(); for (int i = 0; i < objsParent.Length; i++) { htParent.Add(((Module)objsParent[i]).ModuleCode, ((Module)objsParent[i]).ModuleCode); } // 添加树型结构 listMdl.AddRange(GetChildrenModule(objs, string.Empty, 1, htMdlChild)); // 根据模块层级增加Grid列 AdjustGridColumnByLevel(moduleMaxLevel); if (securityFacade == null) { securityFacade = new SystemSettingFacadeFactory(base.DataProvider).CreateSecurityFacade(); } // 增加行 for (int i = 0; i < listMdl.Count; i++) { object[] objMdl = (object[])listMdl[i]; this.AppendRow((Module)objMdl[1], Convert.ToInt32(objMdl[0]), htParent, htSelected); } // 保存选中项 SaveModuleRightWhenPost(); // 调整展开/收缩图标 AdjustExpandCollact(listMdl, htParent); } return(null); }