protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); CmdDB.FillToListBox(dropParent.Items); dropParent.Items.Insert(0, new ListItem("Root", "0")); if (txtID.Text != string.Empty) { CmdInfo info = CmdDB.GetInfo(ConvertUtility.ToInt32(txtID.Text)); if (info != null) { dropParent.SelectedIndex = -1; MiscUtility.SetSelected(dropParent.Items, info.Cmd_ParentID.ToString()); } } nodePath = "|"; TreeViewNode focusNode = tvwCmds.SelectedNode; if (focusNode != null) { while (true) { if (focusNode.ParentNode == null) { break; } else { focusNode = focusNode.ParentNode; nodePath += focusNode.ID + "|"; } } } tvwCmds.Nodes.Clear(); TreeViewNode topRoot = new TreeViewNode(); topRoot.Text = "Root"; topRoot.ID = "0"; tvwCmds.Nodes.Add(topRoot); DataTable dtRoot = CmdDB.GetByParentID(0); foreach (DataRow row in dtRoot.Rows) { TreeViewNode rootNode = new TreeViewNode(); rootNode.Text = row["Cmd_Name"].ToString(); rootNode.ID = row["Cmd_ID"].ToString(); if (nodePath.IndexOf("|" + rootNode.ID + "|") >= 0) { rootNode.Expanded = true; } tvwCmds.Nodes.Add(rootNode); LoadCmdItem(rootNode); } }
protected void Page_Load(object sender, EventArgs e) { lnkMail.NavigateUrl = AppEnv.ADMIN_CMD + "mailmanager"; lnkError.NavigateUrl = AppEnv.ADMIN_CMD + "errorreport"; lnkOrder.NavigateUrl = AppEnv.ADMIN_CMD + "classregisterlist"; cmd = ConvertUtility.ToString(Request.QueryString["cmd"]); GetPath(); if (!CurrentAdminInfo.User_SuperAdmin) { GetRoles(); } lblFullName.Text = CurrentAdminInfo.User_FullName; mnuCommands.Items.Clear(); DataTable dtRoot = CmdDB.GetByParentID(0); // test foreach (DataRow row in dtRoot.Rows) { if ((row["Cmd_Value"].ToString() == "maincmdmanager") && (CurrentAdminInfo.User_Email != AppEnv.ADMIN_EMAIL)) { continue; } MenuItem rootItem = new MenuItem(); rootItem.Text = row["Cmd_Name"].ToString(); rootItem.ID = row["Cmd_ID"].ToString(); rootItem.LookId = "TopItemLook"; if (row["Cmd_Url"].ToString() != string.Empty) { rootItem.NavigateUrl = row["Cmd_Url"].ToString(); } else if (row["Cmd_Value"].ToString() != string.Empty) { rootItem.NavigateUrl = AppEnv.ADMIN_CMD + row["Cmd_Value"] + row["Cmd_Params"]; } if (path.IndexOf("|" + rootItem.ID + "|") >= 0) { rootItem.Look.CssClass = "TopMenuItemHover"; } if ((row["Cmd_Visible"].ToString() == "False") || (row["Cmd_Enable"].ToString() == "False")) { continue; } else if (CurrentAdminInfo.User_SuperAdmin || (arrCmdRoles.IndexOf("|" + rootItem.ID + "|") >= 0)) { mnuCommands.Items.Add(rootItem); } LoadCmdItem(rootItem); } }
public static DataTable GetByParentID(int _parentID) { DataCaching dataCaching = new DataCaching(); string _cacheKey = "Main.Cmds_GetByParentID"; DataTable _retVal = (DataTable)dataCaching.GetHashCache(_cacheKey, _parentID); if (_retVal == null) { _retVal = CmdDB.GetByParentID(_parentID); dataCaching.SetHashCache(_cacheKey, _parentID, 0, _retVal); } return(_retVal); }
private void LoadCmdItem(MenuItem curItem) { int curID = Convert.ToInt32(curItem.ID); DataTable dtChild = CmdDB.GetByParentID(curID); foreach (DataRow row in dtChild.Rows) { if ((row["Cmd_Value"].ToString() == "maincmdmanager") && (CurrentAdminInfo.User_Email != AppEnv.ADMIN_EMAIL)) { continue; } MenuItem childItem = new MenuItem(); childItem.Text = row["Cmd_Name"].ToString(); childItem.ID = row["Cmd_ID"].ToString(); childItem.LookId = "DefaultItemLook"; childItem.CssClass = "MenuItem"; if (row["Cmd_Url"].ToString() != string.Empty) { childItem.NavigateUrl = row["Cmd_Url"].ToString(); } else if (row["Cmd_Value"].ToString() != string.Empty) { childItem.NavigateUrl = AppEnv.ADMIN_CMD + row["Cmd_Value"] + row["Cmd_Params"]; } if (path.IndexOf("|" + childItem.ID + "|") >= 0) { childItem.Look.CssClass = "MenuItemHover"; } if ((row["Cmd_Visible"].ToString() == "False") || (row["Cmd_Enable"].ToString() == "False")) { continue; } else if (CurrentAdminInfo.User_SuperAdmin || (arrCmdRoles.IndexOf("|" + childItem.ID + "|") >= 0)) { curItem.Items.Add(childItem); } LoadCmdItem(childItem); if ((curItem.Items.Count > 0) && (curItem.ParentItem != null)) { curItem.Look.RightIconUrl = "/Administrator/images/iDK/arrow_small.gif"; curItem.Look.RightIconWidth = 15; } } }
private void LoadCmdItem(TreeViewNode curNode) { int curID = Convert.ToInt32(curNode.ID); DataTable dtChild = CmdDB.GetByParentID(curID); TreeViewNode childNode; foreach (DataRow row in dtChild.Rows) { childNode = new TreeViewNode(); childNode.Text = row["Cmd_Name"].ToString(); childNode.ID = row["Cmd_ID"].ToString(); if (nodePath.IndexOf("|" + childNode.ID + "|") >= 0) { childNode.Expanded = true; } curNode.Nodes.Add(childNode); LoadCmdItem(childNode); } }