Exemplo n.º 1
0
        /// <summary>
        /// Load danh mục chức năng trên menu (cấp cha)
        /// </summary>
        protected void BindMenu()
        {
            if (Request.QueryString["page"] != null)
            {
                pages = Request.QueryString["page"].ToString();
            }
            else
            {
                pages = "home";
            }
            string result                  = "";
            string temp_li_active          = @"<li class='selected'><a class='selected' href='{0}'>{1}</a></li>";
            string temp_li                 = @"<li><a href='{0}'>{1}</a></li>";
            string temp_li_parent_selected = @"<li class='selected'><a class='selected' href='{0}'>{1}</a>{2}</li>";
            string temp_li_parent          = @"<li><a href='{0}'>{1}</a>{2}</li>";
            string temp_ul                 = "<ul>{0}</ul>";

            if (Request.QueryString["page"] == null || Request.QueryString["page"].ToString() == "home" || pages == "home")
            {
                result += string.Format(temp_li_active, "/", "Bàn làm việc");
            }
            else
            {
                result += string.Format(temp_li, "/", "Bàn làm việc");
            }


            List <Sys_Function> listParentFunction = new List <Sys_Function>();

            listParentFunction = functionRepository.GetFunctionByTenPhanHe(PHANHE, 0, POSITION);
            string buildListLi = "";
            string buildUl     = "";

            foreach (Sys_Function function in listParentFunction)
            {
                List <Sys_Function> listChildFunction = new List <Sys_Function>();
                listChildFunction = functionRepository.GetFunctionByTenPhanHe(PHANHE, function.ID, POSITION);
                if (function != null)
                {
                    if (listChildFunction.Count > 0)
                    {
                        if (function.Icon != null && function.Icon.Contains(pages))
                        {
                            result += string.Format(temp_li_parent_selected, function.Href, function.TenChucNang, BindChildMenu(function));
                        }
                        else
                        {
                            result += string.Format(temp_li_parent, function.Href, function.TenChucNang, BindChildMenu(function));
                        }
                    }
                    else
                    {
                        if (function.Icon != null && function.Icon.Contains(pages))
                        {
                            result += string.Format(temp_li_active, function.Href, function.TenChucNang);
                        }
                        else
                        {
                            result += string.Format(temp_li, function.Href, function.TenChucNang);
                        }
                    }
                }
            }
            ltMenu.Text += result;
        }