Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //菜单栏目
            Johnny.CMS.BLL.SystemInfo.MenuCategory category = new Johnny.CMS.BLL.SystemInfo.MenuCategory();
            IList<Johnny.CMS.OM.SystemInfo.MenuCategory> categoryModel = category.GetList();

            //菜单
            Johnny.CMS.BLL.SystemInfo.Menu menu = new Johnny.CMS.BLL.SystemInfo.Menu();
            IList<Johnny.CMS.OM.SystemInfo.Menu> menuModel = menu.GetList(true);
                        
            //用户权限
            Johnny.CMS.BLL.Access.Accounts accounts = new Johnny.CMS.BLL.Access.Accounts();
            ArrayList arrPermission = new ArrayList();
            arrPermission = accounts.GetUserPermission(DataConvert.GetString(Session["UserName"]));

            //顶部菜单与菜单类别
            int iTopMenuId = DataConvert.GetInt32(Request.QueryString["TopMenuId"]);
            if (iTopMenuId <= 0)
                iTopMenuId = 1;
            Johnny.CMS.BLL.SystemInfo.TopMenuBinding topMainMenu = new Johnny.CMS.BLL.SystemInfo.TopMenuBinding();
            IList<Johnny.CMS.OM.SystemInfo.TopMenuBinding> topMainMenuModel = topMainMenu.GetList(iTopMenuId);

            //生成左侧菜单导航栏
            foreach (Johnny.CMS.OM.SystemInfo.MenuCategory item in categoryModel)
            {
                if (CategoryContains(item.MenuCategoryId, topMainMenuModel))
                {
                    MainMenuItem mainmenu = new MainMenuItem();
                    mainmenu.Text = item.MenuCategoryName;

                    foreach (Johnny.CMS.OM.SystemInfo.Menu subitem in menuModel)
                    {
                        //判断是否属于该主菜单,并且具有访问权限
                        if (subitem.MenuCategoryId == item.MenuCategoryId && arrPermission.Contains(subitem.PermissionId))
                        {
                            SubMenuItem submenu = new SubMenuItem();
                            submenu.Text = subitem.MenuName;
                            submenu.Url = subitem.PageLink;
                            submenu.ToolTip = subitem.ToolTip;
                            submenu.Image = subitem.Image;
                            mainmenu.SubItems.Add(submenu);
                        }
                    }

                    if (mainmenu.SubItems.Count > 0)
                        LeftMenu1.items.Add(mainmenu);
                }
            }
        }
Пример #2
0
        private void BuildMainItems(TableRow tr, MainMenuItem item, int index)
        {
            //<tr height="29" style="background-image: url(images/menu_bg_01.gif);">
            //    <td width="26" align="center"><img src="images/menu_dot1.gif" width="8" height="11" alt="展开/隐藏" id="arrow_3" /></td>
            //    <td width="89">系统设定</td>
            //    <td width="50" align="center"><img src="images/menu_+.gif" width="8" height="11" alt="展开/隐藏" onclick="show_hide('profile_3', 'arrow_3')"  style="cursor:pointer;" /></td>
            //</tr>
            tr.Height = 29;
            tr.Attributes.Add("onclick", "show_hide('divSubMenu" + index.ToString() + "', 'arrow" + index.ToString() + "')");
            tr.Style.Add("cursor", "hand");
            tr.Style.Add("background-image", "url(images/leftmenu/menu_category_bg.gif)");

            //left image
            TableCell tcleft = new TableCell();
            tcleft.Width = 26;
            tcleft.HorizontalAlign = HorizontalAlign.Center;
            HtmlImage leftimg = new HtmlImage();
            leftimg.Src = "images/leftmenu/menu_expand.gif";
            //leftimg.Width = 11;
            //leftimg.Height = 8;
            leftimg.Alt = "隐藏/展开";
            leftimg.ID = "arrow" + index.ToString();
            tcleft.Controls.Add(leftimg);
            tr.Controls.Add(tcleft);

            //text
            TableCell tctext = new TableCell();
            tctext.Text = item.Text;
            tctext.Width = new Unit("89");
            tr.Controls.Add(tctext);

            //right image
            TableCell tcright = new TableCell();
            tcright.Width = 50;
            //tcright.HorizontalAlign = HorizontalAlign.Center;
            //HtmlImage rightimg = new HtmlImage();
            //rightimg.Src = "images/menu_+.gif";
            //rightimg.Width = 8;
            //rightimg.Height = 11;
            //rightimg.Alt = "隐藏/展开";
            //tcright.Controls.Add(rightimg);
            tr.Controls.Add(tcright);

        }
Пример #3
0
        private void BuildSubItems(TableRow tr, MainMenuItem item, int index)
        {
            //<tr>
            //    <td colspan=3>
            //    <div id="profile_3" style="display:block;">
            //    <table width="98%" border="0" cellspacing="2" cellpadding="2">
            //    <tr><td width='20'><img src='images/menu_dot_2.gif' alt='' border='0' align='right'></td><td align='left'><a class='menulist' href='Admin_Display.aspx' target='mainFrame'>探针</a></td></tr>
            //    <tr><td width='20'><img src='images/menu_dot_2.gif' alt='' border='0' align='right'></td><td align='left'><a class='menulist' href='Admin_ProvinceList.aspx' target='mainFrame'>省份</a></td></tr>
            //    <tr><td width='20'><img src='images/menu_dot_2.gif' alt='' border='0' align='right'></td><td align='left'><a class='menulist' href='Admin_CityList.aspx' target='mainFrame'>城市</a></td></tr>
            //    <tr><td width='20'><img src='images/menu_dot_2.gif' alt='' border='0' align='right'></td><td align='left'><a class='menulist' href='Admin_AdvertisementList.aspx' target='mainFrame'>广告</a></td></tr>
            //    <tr><td width='20'><img src='images/menu_dot_2.gif' alt='' border='0' align='right'></td><td align='left'><a class='menulist' href='Admin_MenuList.aspx' target='mainFrame'>菜单</a></td></tr>
            //    <tr><td width='20'><img src='images/menu_dot_2.gif' alt='' border='0' align='right'></td><td align='left'><a class='menulist' href='Admin_MenuCategoryList.aspx' target='mainFrame'>菜单类别</a></td></tr>
            //    </table>
            //    </div> 
            //    </td>
            //</tr>

            TableCell tc = new TableCell();
            tc.ColumnSpan = 3;

            Panel divPanel = new Panel();
            divPanel.Attributes.Add("id", "divSubMenu" + index.ToString());
            divPanel.Style.Add("display", "block");
            
            Table tb = new Table();
            tb.Width = new Unit("100%");
            tb.BorderWidth = new Unit("0");
            tb.BackColor = System.Drawing.ColorTranslator.FromHtml("#F8FDFF");
            tb.CellPadding = 2;
            tb.CellSpacing = 2;

            for (int ix = 0; ix < item.SubItems.Count; ix++)
            {
                TableRow subtr = new TableRow();

                //left image
                TableCell tcleft = new TableCell();
                tcleft.Width = new Unit("20");
                HtmlImage leftimg = new HtmlImage();
                leftimg.Src = "images/leftmenu/menu_item.gif";
                leftimg.Border = 0;
                leftimg.Align = "right";
                tcleft.Controls.Add(leftimg);
                subtr.Controls.Add(tcleft);
                //right anchor
                TableCell tcright = new TableCell();
                tcright.HorizontalAlign = HorizontalAlign.Left;
                HtmlAnchor anchor = new HtmlAnchor();
                anchor.HRef = item.SubItems[ix].Url;
                anchor.Target = "mainFrame";
                anchor.InnerText = item.SubItems[ix].Text;
                anchor.Title = item.SubItems[ix].ToolTip;
                anchor.Attributes.Add("class", "menulist");
                tcright.Controls.Add(anchor);
                subtr.Controls.Add(tcright);

                tb.Controls.Add(subtr);
            }

            divPanel.Controls.Add(tb);
            tc.Controls.Add(divPanel);
            tr.Controls.Add(tc);
        }
Пример #4
0
 /// <summary>
 /// Removes a specified MenuItem from the collection.
 /// </summary>
 /// <param name="item">The MenuItem instance to remove.</param>
 public void Remove(MainMenuItem item)
 {
     menuItems.Remove(item);
 }
Пример #5
0
 /// <summary>
 /// Inserts a MenuItem instance at a particular location in the collection.
 /// </summary>
 /// <param name="index">The ordinal location to insert the item.</param>
 /// <param name="item">The MenuItem to insert.</param>
 public virtual void Insert(int index, MainMenuItem item)
 {
     menuItems.Insert(index, item);
 }
Пример #6
0
 /// <summary>
 /// Returns the ordinal index of a MenuItem, if it exists; if the item does not exist,
 /// -1 is returned.
 /// </summary>
 /// <param name="item">The MenuItem to search for.</param>
 /// <returns>The ordinal position of the item in the collection.</returns>
 public virtual int IndexOf(MainMenuItem item)
 {
     return menuItems.IndexOf(item);
 }
Пример #7
0
 /// <summary>
 /// Determines if a particular MenuItem exists within the collection.
 /// </summary>
 /// <param name="item">The MenuItem instance to check for.</param>
 /// <returns>A Boolean - true if the MenuItem is in the collection, false otherwise.</returns>
 public virtual bool Contains(MainMenuItem item)
 {
     return menuItems.Contains(item);
 }
Пример #8
0
        /// <summary>
        /// Adds a MenuItem to the collection.  If the ViewState is being tracked, the
        /// MenuItem's TrackViewState() method is called and the item is set to dirty, so
        /// that we don't lose any settings made prior to the Add() call.
        /// </summary>
        /// <param name="item">The MenuItem to add to the collection</param>
        /// <returns>The ordinal position of the added item.</returns>
        public virtual int Add(MainMenuItem item)
        {
            int result = menuItems.Add(item);

            return result;
        }
Пример #9
0
 /// <summary>
 /// Removes a specified MenuItem from the collection.
 /// </summary>
 /// <param name="item">The MenuItem instance to remove.</param>
 public void Remove(MainMenuItem item)
 {
     menuItems.Remove(item);
 }
Пример #10
0
 /// <summary>
 /// Inserts a MenuItem instance at a particular location in the collection.
 /// </summary>
 /// <param name="index">The ordinal location to insert the item.</param>
 /// <param name="item">The MenuItem to insert.</param>
 public virtual void Insert(int index, MainMenuItem item)
 {
     menuItems.Insert(index, item);
 }
Пример #11
0
 /// <summary>
 /// Returns the ordinal index of a MenuItem, if it exists; if the item does not exist,
 /// -1 is returned.
 /// </summary>
 /// <param name="item">The MenuItem to search for.</param>
 /// <returns>The ordinal position of the item in the collection.</returns>
 public virtual int IndexOf(MainMenuItem item)
 {
     return(menuItems.IndexOf(item));
 }
Пример #12
0
 /// <summary>
 /// Determines if a particular MenuItem exists within the collection.
 /// </summary>
 /// <param name="item">The MenuItem instance to check for.</param>
 /// <returns>A Boolean - true if the MenuItem is in the collection, false otherwise.</returns>
 public virtual bool Contains(MainMenuItem item)
 {
     return(menuItems.Contains(item));
 }
Пример #13
0
        /// <summary>
        /// Adds a MenuItem to the collection.  If the ViewState is being tracked, the
        /// MenuItem's TrackViewState() method is called and the item is set to dirty, so
        /// that we don't lose any settings made prior to the Add() call.
        /// </summary>
        /// <param name="item">The MenuItem to add to the collection</param>
        /// <returns>The ordinal position of the added item.</returns>
        public virtual int Add(MainMenuItem item)
        {
            int result = menuItems.Add(item);

            return(result);
        }
Пример #14
0
        private void BuildSubItems(TableRow tr, MainMenuItem item, int index)
        {
            //<tr>
            //    <td colspan=3>
            //    <div id="profile_3" style="display:block;">
            //    <table width="98%" border="0" cellspacing="2" cellpadding="2">
            //    <tr><td width='20'><img src='images/menu_dot_2.gif' alt='' border='0' align='right'></td><td align='left'><a class='menulist' href='Admin_Display.aspx' target='mainFrame'>探针</a></td></tr>
            //    <tr><td width='20'><img src='images/menu_dot_2.gif' alt='' border='0' align='right'></td><td align='left'><a class='menulist' href='Admin_ProvinceList.aspx' target='mainFrame'>省份</a></td></tr>
            //    <tr><td width='20'><img src='images/menu_dot_2.gif' alt='' border='0' align='right'></td><td align='left'><a class='menulist' href='Admin_CityList.aspx' target='mainFrame'>城市</a></td></tr>
            //    <tr><td width='20'><img src='images/menu_dot_2.gif' alt='' border='0' align='right'></td><td align='left'><a class='menulist' href='Admin_AdvertisementList.aspx' target='mainFrame'>广告</a></td></tr>
            //    <tr><td width='20'><img src='images/menu_dot_2.gif' alt='' border='0' align='right'></td><td align='left'><a class='menulist' href='Admin_MenuList.aspx' target='mainFrame'>菜单</a></td></tr>
            //    <tr><td width='20'><img src='images/menu_dot_2.gif' alt='' border='0' align='right'></td><td align='left'><a class='menulist' href='Admin_MenuCategoryList.aspx' target='mainFrame'>菜单类别</a></td></tr>
            //    </table>
            //    </div>
            //    </td>
            //</tr>

            TableCell tc = new TableCell();

            tc.ColumnSpan = 3;

            Panel divPanel = new Panel();

            divPanel.Attributes.Add("id", "divSubMenu" + index.ToString());
            divPanel.Style.Add("display", "block");

            Table tb = new Table();

            tb.Width       = new Unit("100%");
            tb.BorderWidth = new Unit("0");
            tb.BackColor   = System.Drawing.ColorTranslator.FromHtml("#F8FDFF");
            tb.CellPadding = 2;
            tb.CellSpacing = 2;

            for (int ix = 0; ix < item.SubItems.Count; ix++)
            {
                TableRow subtr = new TableRow();

                //left image
                TableCell tcleft = new TableCell();
                tcleft.Width = new Unit("20");
                HtmlImage leftimg = new HtmlImage();
                leftimg.Src    = "images/leftmenu/menu_item.gif";
                leftimg.Border = 0;
                leftimg.Align  = "right";
                tcleft.Controls.Add(leftimg);
                subtr.Controls.Add(tcleft);
                //right anchor
                TableCell tcright = new TableCell();
                tcright.HorizontalAlign = HorizontalAlign.Left;
                HtmlAnchor anchor = new HtmlAnchor();
                anchor.HRef      = item.SubItems[ix].Url;
                anchor.Target    = "mainFrame";
                anchor.InnerText = item.SubItems[ix].Text;
                anchor.Title     = item.SubItems[ix].ToolTip;
                anchor.Attributes.Add("class", "menulist");
                tcright.Controls.Add(anchor);
                subtr.Controls.Add(tcright);

                tb.Controls.Add(subtr);
            }

            divPanel.Controls.Add(tb);
            tc.Controls.Add(divPanel);
            tr.Controls.Add(tc);
        }