private void BindDataGrid()
 {
     DataGrid1.TableHeaderName = pagename + " 子菜单项管理";
     XmlDocumentExtender doc = new XmlDocumentExtender();
     doc.Load(configPath);
     string submenuid = SASRequest.GetString("submenuid");
     XmlNodeList submenusitem = doc.SelectNodes("/dataset/submain");
     DataTable dt = new DataTable();
     dt.Columns.Add(new DataColumn("id"));
     dt.Columns.Add(new DataColumn("menutitle"));
     dt.Columns.Add(new DataColumn("link"));
     int i = 0;
     foreach (XmlNode menuitem in submenusitem)
     {
         if (menuitem["menuparentid"].InnerText == submenuid)
         {
             DataRow dr = dt.NewRow();
             dr["id"] = i.ToString();
             dr["menutitle"] = menuitem["menutitle"].InnerText;
             dr["link"] = menuitem["link"].InnerText;
             dt.Rows.Add(dr);
         }
         i++;
     }
     DataGrid1.DataSource = dt;
     DataGrid1.DataBind();
 }
 private void BindDataGrid()
 {
     DataGrid1.TableHeaderName = "菜单管理";
     XmlDocumentExtender doc = new XmlDocumentExtender();
     doc.Load(configPath);
     XmlNodeList mainmenus = doc.SelectNodes("/dataset/toptabmenu");
     DataTable dt = new DataTable();
     dt.Columns.Add(new DataColumn("id"));
     dt.Columns.Add(new DataColumn("title"));
     dt.Columns.Add(new DataColumn("defaulturl"));
     dt.Columns.Add(new DataColumn("system"));
     dt.Columns.Add(new DataColumn("delitem"));
     foreach (XmlNode menuitem in mainmenus)
     {
         DataRow dr = dt.NewRow();
         dr["id"] = menuitem["id"].InnerText;
         dr["title"] = menuitem["title"].InnerText;
         dr["defaulturl"] = menuitem["defaulturl"].InnerText;
         dr["system"] = menuitem["system"].InnerText != "0" ? "是" : "否";
         if (menuitem["mainmenulist"].InnerText != "")
             dr["delitem"] = "删除";
         else
             dr["delitem"] = "<a href='managemainmenu.aspx?mode=del&menuid=" + menuitem["id"].InnerText + "' onclick='return confirm(\"您确认要删除此菜单项吗?\")'>删除</a>";
         dt.Rows.Add(dr);
     }
     DataGrid1.DataSource = dt;
     DataGrid1.DataBind();
 }
示例#3
0
 /// <summary>
 /// 删除一级菜单,其下子菜单必须为空
 /// </summary>
 /// <param name="menuid">要删除的一级菜单ID</param>
 /// <returns>操作成功否</returns>
 public static bool DeleteMainMenu(int menuid)
 {
     XmlDocumentExtender doc = new XmlDocumentExtender();
     doc.Load(configPath);
     XmlNodeList mainmenus = doc.SelectNodes("/dataset/toptabmenu");
     XmlNode delMenu = null;
     int newid = menuid;
     bool result = false;
     foreach (XmlNode menuitem in mainmenus)
     {
         if (menuitem["id"].InnerText == menuid.ToString())
         {
             if (menuitem["mainmenulist"].InnerText.Trim() != "")
                 return false;
             delMenu = menuitem;
             result = true;
             break;
         }
         else
         {
             if (delMenu != null)
             {
                 menuitem["id"].InnerText = newid.ToString();
                 newid++;
             }
         }
     }
     if (result)
     {
         delMenu.ParentNode.RemoveChild(delMenu);
         doc.Save(configPath);
     }
     return result;
 }
示例#4
0
 public void BindData()
 {
     string menuId = SASRequest.GetString("menuid");
     string menuTitle = "";
     string menuSubMenuList = "";
     XmlDocumentExtender doc = new XmlDocumentExtender();
     doc.Load(configPath);
     XmlNodeList mainMenus = doc.SelectNodes("/dataset/toptabmenu");
     foreach (XmlNode menuItem in mainMenus) //查找主菜单信息
     {
         if (menuItem["id"].InnerText == menuId)
         {
             menuTitle = menuItem["title"].InnerText;
             menuSubMenuList = menuItem["mainmenulist"].InnerText;
             break;
         }
     }
     DataGrid1.TableHeaderName = menuTitle + "  菜单项管理";
     XmlNodeList subMenus = doc.SelectNodes("/dataset/mainmenu");
     DataTable dt = new DataTable();
     if (menuSubMenuList == "")  //该菜单没有子菜单
     {
         DataGrid1.DataSource = dt;
         DataGrid1.DataBind();
         return;
     }
     dt.Columns.Add("id");
     dt.Columns.Add("menuid");
     dt.Columns.Add("submenuid");
     dt.Columns.Add("menutitle");
     dt.Columns.Add("delitem");
     foreach (XmlNode subMenuItem in subMenus)
     {
         if (("," + menuSubMenuList + ",").IndexOf("," + subMenuItem["id"].InnerText + ",") != -1)
         {
             DataRow dr = dt.NewRow();
             dr["id"] = subMenuItem["id"].InnerText;
             dr["menuid"] = menuId;
             dr["submenuid"] = subMenuItem["menuid"].InnerText;
             dr["menutitle"] = subMenuItem["menutitle"].InnerText;
             if (FindSubMenuItem(subMenuItem["menuid"].InnerText, doc))
             {
                 dr["delitem"] = "删除";
             }
             else
             {
                 dr["delitem"] = "<a href='managesubmenu.aspx?mode=del&menuid=" + menuId + "&submenuid=" + subMenuItem["id"].InnerText + "' onclick='return confirm(\"您确认要删除此菜单项吗?\");'>删除</a>";
             }
             dt.Rows.Add(dr);
         }
     }
     DataGrid1.DataSource = dt;
     DataGrid1.DataBind();
 }
示例#5
0
 public static void ImportPluginMenu(string menuConfigFile)
 {
     //备份菜单
     BackupMenuFile();
     XmlDocumentExtender doc = new XmlDocumentExtender();
     doc.Load(menuConfigFile);
     XmlNodeList menuitems = doc.SelectNodes("/pluginmenu/menuitem");
     int pluginMainId = FindPluginMainMenu();
     foreach (XmlNode menuitem in menuitems)
     {
         int newsubmenuid = NewSubMenu(pluginMainId, menuitem.Attributes["title"].InnerText);
         XmlNodeList items = menuitem.ChildNodes;
         foreach (XmlNode item in items)
         {
             NewMenuItem(newsubmenuid, item["title"].InnerText, item["link"].InnerText);
         }
     }
     CreateMenuJson();
 }
示例#6
0
 private static int FindMenuMenuid(string mainMenuTitle, string subMenuTitle)
 {
     XmlDocumentExtender doc = new XmlDocumentExtender();
     doc.Load(configPath);
     XmlNodeList mainmenus = doc.SelectNodes("/dataset/toptabmenu");
     bool find = false;
     string mainmenulist = "";
     foreach (XmlNode menuitem in mainmenus)
     {
         if (menuitem["title"].InnerText == mainMenuTitle)
         {
             mainmenulist = menuitem["mainmenulist"].InnerText;
             find = true;
         }
     }
     if (!find)
         return -1;
     XmlNodeList submains = doc.SelectNodes("/dataset/mainmenu");
     foreach (XmlNode menuItem in submains)
     {
         if (("," + mainmenulist + ",").IndexOf("," + menuItem["id"].InnerText + ",") != -1 && menuItem["menutitle"].InnerText == subMenuTitle)
         {
             return int.Parse(menuItem["menuid"].InnerText);
         }
     }
     return -1;
 }
示例#7
0
 private static int FindMenuID(string mainMenuTitle, string subMenuTitle, string menuItemTitle)
 {
     XmlDocumentExtender doc = new XmlDocumentExtender();
     doc.Load(configPath);
     XmlNodeList mainmenus = doc.SelectNodes("/dataset/toptabmenu");
     bool find = false;
     string mainmenulist = "";
     foreach (XmlNode menuitem in mainmenus)
     {
         if (menuitem["title"].InnerText == mainMenuTitle)
         {
             mainmenulist = menuitem["mainmenulist"].InnerText;
             find = true;
         }
     }
     if (!find)
         return -1;
     XmlNodeList submains = doc.SelectNodes("/dataset/mainmenu");
     find = false;
     string menuid = "";
     foreach (XmlNode menuItem1 in submains)
     {
         if (("," + mainmenulist + ",").IndexOf("," + menuItem1["id"].InnerText + ",") != -1 && menuItem1["menutitle"].InnerText == subMenuTitle)
         {
             menuid = menuItem1["menuid"].InnerText;
             find = true;
         }
     }
     if (!find)
     {
         return -1;
     }
     XmlNodeList submains1 = doc.SelectNodes("/dataset/submain");
     int rowcount = 0;
     foreach (XmlNode sub in submains1)
     {
         if (sub["menuparentid"].InnerText == menuid && sub["menutitle"].InnerText == menuItemTitle)
         {
             return rowcount;
         }
         rowcount++;
     }
     return -1;
 }
示例#8
0
 private static int FindMenuID(string mainMenuTitle)
 {
     XmlDocumentExtender doc = new XmlDocumentExtender();
     doc.Load(configPath);
     XmlNodeList mainmenus = doc.SelectNodes("/dataset/toptabmenu");
     foreach (XmlNode menuitem in mainmenus)
     {
         if (menuitem["title"].InnerText == mainMenuTitle)
         {
             return int.Parse(menuitem["id"].InnerText);
         }
     }
     return -1;
 }
示例#9
0
        /// <summary>
        /// 增加子菜单
        /// </summary>
        /// <param name="mainmenuid">主菜单ID</param>
        /// <param name="menutitle">子菜单标题</param>
        /// <returns>新建子菜单ID</returns>
        public static int NewSubMenu(int mainmenuid, string menutitle)
        {
            int newid = 1;
            int newmenuid = 100;
            XmlDocumentExtender doc = new XmlDocumentExtender();
            doc.Load(configPath);
            XmlNodeList submains = doc.SelectNodes("/dataset/mainmenu");
            newid += int.Parse(submains.Item(submains.Count - 1)["id"].InnerText);
            newmenuid += int.Parse(submains.Item(submains.Count - 1)["menuid"].InnerText);
            XmlElement mainmenu = doc.CreateElement("mainmenu");
            XmlElement node = doc.CreateElement("id");
            node.InnerText = newid.ToString();
            mainmenu.AppendChild(node);

            node = doc.CreateElement("menuid");
            node.InnerText = newmenuid.ToString();
            mainmenu.AppendChild(node);

            node = doc.CreateElement("menutitle");
            node.InnerText = menutitle;
            mainmenu.AppendChild(node);

            doc.SelectSingleNode("/dataset").AppendChild(mainmenu);

            XmlNodeList mainMenus = doc.SelectNodes("/dataset/toptabmenu");
            foreach (XmlNode menuItem in mainMenus) //查找主菜单信息
            {
                if (menuItem["id"].InnerText == mainmenuid.ToString())
                {
                    menuItem["mainmenulist"].InnerText += "," + newid;
                    menuItem["mainmenuidlist"].InnerText += "," + newmenuid;
                    menuItem["mainmenulist"].InnerText = menuItem["mainmenulist"].InnerText.TrimStart(',');
                    menuItem["mainmenuidlist"].InnerText = menuItem["mainmenuidlist"].InnerText.TrimStart(',');
                    break;
                }
            }
            doc.Save(configPath);
            return newmenuid;
        }
示例#10
0
        /// <summary>
        /// 新建菜单项
        /// </summary>
        /// <param name="menuparentid">父菜单ID</param>
        /// <param name="title">菜单标题</param>
        /// <param name="link">菜单链接</param>
        /// <returns>操作成功否</returns>
        public static bool NewMenuItem(int menuparentid, string title, string link)
        {
            XmlDocumentExtender doc = new XmlDocumentExtender();
            doc.Load(configPath);
            XmlNodeList submains = doc.SelectNodes("/dataset/submain");
            foreach (XmlNode sub in submains)
            {
                if (sub["link"].InnerText == link)
                {
                    return false;
                }
            }
            XmlElement submain = doc.CreateElement("submain");
            XmlElement node = doc.CreateElement("menuparentid");
            node.InnerText = menuparentid.ToString();
            submain.AppendChild(node);

            node = doc.CreateElement("menutitle");
            node.InnerText = title;
            submain.AppendChild(node);

            node = doc.CreateElement("link");
            node.InnerText = link;
            submain.AppendChild(node);

            node = doc.CreateElement("frameid");
            node.InnerText = "main";
            submain.AppendChild(node);

            doc.SelectSingleNode("/dataset").AppendChild(submain);
            doc.Save(configPath);
            return true;
        }
示例#11
0
        /// <summary>
        /// 增加主菜单
        /// </summary>
        /// <param name="title">主菜单标题</param>
        /// <param name="defaulturl">主菜单默认展开的页面</param>
        /// <returns>新主菜单项ID</returns>
        public static int NewMainMenu(string title, string defaulturl)
        {
            XmlDocumentExtender doc = new XmlDocumentExtender();
            doc.Load(configPath);
            XmlNodeList mainmenus = doc.SelectNodes("/dataset/toptabmenu");
            int newMenuId = mainmenus.Count + 1;
            XmlElement newMainMenuItem = doc.CreateElement("toptabmenu");
            XmlElement node = doc.CreateElement("id");
            node.InnerText = newMenuId.ToString();
            newMainMenuItem.AppendChild(node);

            node = doc.CreateElement("title");
            node.InnerText = title;
            newMainMenuItem.AppendChild(node);

            node = doc.CreateElement("mainmenulist");
            node.InnerText = "";
            newMainMenuItem.AppendChild(node);

            node = doc.CreateElement("mainmenuidlist");
            node.InnerText = "";
            newMainMenuItem.AppendChild(node);

            node = doc.CreateElement("defaulturl");
            node.InnerText = defaulturl;
            newMainMenuItem.AppendChild(node);

            node = doc.CreateElement("system");
            node.InnerText = "0";
            newMainMenuItem.AppendChild(node);

            doc.SelectSingleNode("/dataset").AppendChild(newMainMenuItem);
            doc.Save(configPath);
            return newMenuId;
        }
示例#12
0
 private bool FindSubMenuItem(string menuid, XmlDocumentExtender doc)
 {
     XmlNodeList submenuitem = doc.SelectNodes("/dataset/submain");
     foreach (XmlNode item in submenuitem)
     {
         if (item["menuparentid"].InnerText == menuid)
             return true;
     }
     return false;
 }
示例#13
0
 /// <summary>
 /// 查找扩展菜单
 /// </summary>
 /// <returns>扩展菜单项ID</returns>
 public static int FindPluginMainMenu()
 {
     XmlDocumentExtender doc = new XmlDocumentExtender();
     doc.Load(configPath);
     XmlNodeList mainmenus = doc.SelectNodes("/dataset/toptabmenu");
     foreach (XmlNode menuitem in mainmenus)
     {
         if (menuitem["system"].InnerText == "2")
         {
             return int.Parse(menuitem["id"].InnerText);
         }
     }
     return -1;
 }
示例#14
0
 /// <summary>
 /// 编辑子菜单
 /// </summary>
 /// <param name="submenuid">子菜单ID</param>
 /// <param name="menutitle">子菜单标题</param>
 /// <returns>操作成功否</returns>
 public static bool EditSubMenu(int submenuid, string menutitle)
 {
     XmlDocumentExtender doc = new XmlDocumentExtender();
     doc.Load(configPath);
     XmlNodeList submains = doc.SelectNodes("/dataset/mainmenu");
     bool result = false;
     foreach (XmlNode menuItem in submains)
     {
         if (menuItem["id"].InnerText == submenuid.ToString())
         {
             menuItem["menutitle"].InnerText = menutitle;
             result = true;
             break;
         }
     }
     if (result)
     {
         doc.Save(configPath);
     }
     return result;
 }
示例#15
0
 /// <summary>
 /// 编辑菜单项
 /// </summary>
 /// <param name="id">菜单项的序号</param>
 /// <param name="title">菜单项的标题</param>
 /// <param name="link">菜单项的链接</param>
 /// <returns>操作成功否</returns>
 public static bool EditMenuItem(int id, string title, string link)
 {
     XmlDocumentExtender doc = new XmlDocumentExtender();
     doc.Load(configPath);
     XmlNodeList submains = doc.SelectNodes("/dataset/submain");
     int rowcount = 0;
     foreach (XmlNode sub in submains)
     {
         if (rowcount.ToString() != id.ToString() && sub["link"].InnerText == link)
         {
             return false;
         }
         rowcount++;
     }
     string tmpLink = submains.Item(id)["link"].InnerText;
     submains.Item(id)["menutitle"].InnerText = title;
     submains.Item(id)["link"].InnerText = link;
     XmlNodeList shortcuts = doc.SelectNodes("/dataset/shortcut");
     foreach (XmlNode shortmenuitem in shortcuts)
     {
         if (shortmenuitem["link"].InnerText == tmpLink)
         {
             shortmenuitem["link"].InnerText = link;
             shortmenuitem["menutitle"].InnerText = title;
             break;
         }
     }
     doc.Save(configPath);
     return true;
 }
示例#16
0
 /// <summary>
 /// 编辑一级主菜单
 /// </summary>
 /// <param name="menuid">一级主菜单的ID</param>
 /// <param name="title">一级主菜单标题</param>
 /// <param name="defaulturl">一级主菜单默认展开的页面</param>
 /// <returns>操作成功否</returns>
 public static bool EditMainMenu(int menuid, string title, string defaulturl)
 {
     XmlDocumentExtender doc = new XmlDocumentExtender();
     doc.Load(configPath);
     XmlNodeList mainmenus = doc.SelectNodes("/dataset/toptabmenu");
     bool result = false;
     foreach (XmlNode menuitem in mainmenus)
     {
         if (menuitem["id"].InnerText == menuid.ToString())
         {
             menuitem["title"].InnerText = title;
             menuitem["defaulturl"].InnerText = defaulturl;
             result = true;
             break;
         }
     }
     if (result)
     {
         doc.Save(configPath);
     }
     return result;
 }
示例#17
0
 /// <summary>
 /// 删除子菜单
 /// </summary>
 /// <param name="submenuid">子菜单ID</param>
 /// <param name="mainmenuid">主菜单ID</param>
 /// <returns>操作成功否</returns>
 public static bool DeleteSubMenu(int submenuid, int mainmenuid)
 {
     XmlDocumentExtender doc = new XmlDocumentExtender();
     doc.Load(configPath);
     XmlNodeList submains = doc.SelectNodes("/dataset/mainmenu");
     bool result = false;
     string menuid = "";
     foreach (XmlNode menuItem in submains)
     {
         if (menuItem["id"].InnerText == submenuid.ToString())
         {
             menuid = menuItem["menuid"].InnerText;
             XmlNodeList items = doc.SelectNodes("/dataset/submain");
             foreach (XmlNode item in items)
             {
                 if (item["menuparentid"].InnerText == menuid)
                     return false;
             }
             menuItem.ParentNode.RemoveChild(menuItem);
             result = true;
             break;
         }
     }
     XmlNodeList mainMenus = doc.SelectNodes("/dataset/toptabmenu");
     foreach (XmlNode menuItem in mainMenus) //查找主菜单信息
     {
         if (menuItem["id"].InnerText == mainmenuid.ToString())
         {
             menuItem["mainmenulist"].InnerText = ("," + menuItem["mainmenulist"].InnerText + ",").Replace("," + submenuid + ",", ",");
             menuItem["mainmenuidlist"].InnerText = ("," + menuItem["mainmenuidlist"].InnerText + ",").Replace("," + menuid + ",", ",");
             menuItem["mainmenulist"].InnerText = menuItem["mainmenulist"].InnerText.TrimStart(',').TrimEnd(',');
             menuItem["mainmenuidlist"].InnerText = menuItem["mainmenuidlist"].InnerText.TrimStart(',').TrimEnd(',');
             break;
         }
     }
     if (result)
     {
         doc.Save(configPath);
     }
     return result;
 }
示例#18
0
 /// <summary>
 /// 删除菜单项
 /// </summary>
 /// <param name="id">菜单项的序号</param>
 public static void DeleteMenuItem(int id)
 {
     XmlDocumentExtender doc = new XmlDocumentExtender();
     doc.Load(configPath);
     XmlNodeList submains = doc.SelectNodes("/dataset/submain");
     string link = submains.Item(id)["link"].InnerText;
     submains.Item(id).ParentNode.RemoveChild(submains.Item(id));
     XmlNodeList shortcuts = doc.SelectNodes("/dataset/shortcut");
     foreach (XmlNode shortmenuitem in shortcuts)
     {
         if (shortmenuitem["link"].InnerText == link)
         {
             shortmenuitem.ParentNode.RemoveChild(shortmenuitem);
             break;
         }
     }
     doc.Save(configPath);
 }