Beispiel #1
0
    /// <summary>
    /// Bind danh sách các nút chức năng trên form
    /// </summary>
    /// <param name="child"></param>
    /// <param name="parentID">MenuID</param>
    private string BindFunctionOfMenu(int menuID)
    {
        FunctionController  controller       = new FunctionController();
        List <FunctionInfo> functionInfoList = controller.GetFunctionByMenuId(menuID);
        string rs = "";

        foreach (var item in functionInfoList)
        {
            //rs += string.Format("<li id='F{0}'>[{1}]</li>", item.ID, item.ControlText);
            if (item.ParentID == -1)    // la cha
            {
                List <FunctionInfo> childList = controller.GetByParentID(item.ID);
                string cap2 = "";
                foreach (FunctionInfo tmp in childList)
                {
                    List <FunctionInfo> chauList = controller.GetByParentID(tmp.ID);
                    string cap3 = "";
                    foreach (FunctionInfo t in chauList)
                    {
                        cap3 += string.Format("<li id='F{0}'>[{1}]</li>", t.ID, t.Description);
                    }
                    if (cap3 != "")
                    {
                        cap3 = "<ul>" + cap3 + "</ul>";
                    }

                    cap2 += string.Format("<li id='F{0}'>[{1}]{2}</li>", tmp.ID, tmp.Description, cap3);
                }
                if (cap2 != "")
                {
                    cap2 = "<ul>" + cap2 + "</ul>";
                }
                rs += string.Format("<li id='F{0}'>[{1}]{2}</li>", item.ID, item.Description, cap2);
            }
            //else
            //{
            //    rs += string.Format("<li id='F{0}'>[{1}]</li>", item.ID, item.ControlText);
            //}
        }
        if (!string.IsNullOrEmpty(rs))
        {
            rs = "<div class='functionTree' id='functionTree{0}' style='display:none;'><ul>" + rs + "</ul></div>";
        }

        Literal1.Text += string.Format(rs, menuID);
        return(rs);
    }