HTML ajax控件 目录树

  /// <summary>
        /// 目录树
        /// </summary>
        /// <param name="categoryid">目录ID,传0时,删除目录</param>
        /// <param name="questionid">问题ID,传0时,删除问题</param>
        /// <param name="gameID">游戏ID</param>
        /// <param name="ishavequestion">是不有问题存在</param>
        /// <param name="issuance">是否发布</param>
        /// <returns></returns>
        [AjaxPro.AjaxMethod]
        public static string MenuAndQuestionTree(int categoryid,int questionid,int gameID,int ishavequestion,int issuance)
        {
            //当category==0时,不删除
            if (categoryid != 0)
            {
                BllAccess.GetKbsCategory.DeleteCategory(categoryid);
            }

            //当questionid==0时,不删除
            if (questionid != 0)
            {
                BllAccess.GetKbsQuestion.DeleteQuestion(questionid);
            }
            DataTable dtTable = null;
            DataTable dtTable1 = null;
            DataTable dtTable2 = null;
            DataTable dtQuestion = null;
            if (-1 == issuance)//知识库,所有的
            {
                 dtTable = BllAccess.GetKbsCategory.GetCategorys(gameID, ENUM_KBS_CategoryIssuance.All);//目录中所有项,
                 dtTable1 = BllAccess.GetKbsCategory.GetCategorys(gameID, 1, ENUM_KBS_CategoryIssuance.All);//一级目录
                 dtTable2 = BllAccess.GetKbsCategory.GetCategorys(gameID, 2, ENUM_KBS_CategoryIssuance.All);//二级目录
                 dtQuestion = BllAccess.GetKbsQuestion.GetQuestions(0, ENUM_KBS_CategoryIssuance.All);//所有问题
            }
            else //系统自助后台,所有没有发布的
            {
                 dtTable = BllAccess.GetKbsCategory.GetCategorys(gameID, ENUM_KBS_CategoryIssuance.Yes);
                 dtTable1 = BllAccess.GetKbsCategory.GetCategorys(gameID, 1, ENUM_KBS_CategoryIssuance.Yes);
                 dtTable2 = BllAccess.GetKbsCategory.GetCategorys(gameID, 2, ENUM_KBS_CategoryIssuance.Yes);
                 dtQuestion = BllAccess.GetKbsQuestion.GetQuestions(0, ENUM_KBS_CategoryIssuance.All);
            }


            if (dtTable != null)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<div style=\"border:solid 1px red;width:300px;float:left;\">");
                sb.Append("<div style=\"text-align:left;margin-left:0px;\"><img src=\"/Images/folder1.gif\" alt=\"menubutton\"><a href=\"#\" οnclick=\"$('#bigdiv').toggle();\">" + BllAccess.ConfigService.GetGame(gameID).Game_Name + "</a></div>");
                sb.Append("<div id=\"bigdiv\">");
               
                if (dtTable != null)
                {
                    for (int intIndex = 0; intIndex < dtTable1.Rows.Count; intIndex++)
                    {
                        string strText = dtTable1.Rows[intIndex][KBS_Category.n_.CategoryName].ToString();
                        string strValue = dtTable1.Rows[intIndex][KBS_Category.n_.CategoryID].ToString();
                        sb.Append("<div style=\"text-align:left;margin-left:10px;\"><img src=\"/Images/folder1.gif\" alt=\"menubutton\"><a href=\"#\" οnclick=\"GetMenuTreeID(1" + strValue + ",menu1div" + intIndex + ");\">" + strText + "</a></div>");
                        int tree1CategoryID = int.Parse(dtTable1.Rows[intIndex]["CategoryID"].ToString());

                       
                        if (dtTable2 != null)
                        {
                            sb.Append("<div id=\"menu1div"+intIndex+"\">");
                            for (int intIndex2 = 0; intIndex2 < dtTable2.Rows.Count; intIndex2++)
                            {
                                if (tree1CategoryID == int.Parse(dtTable2.Rows[intIndex2]["ParentCategoryID"].ToString()))
                                {
                                    string strText2 = dtTable2.Rows[intIndex2][KBS_Category.n_.CategoryName].ToString();
                                    string strValue2 = dtTable2.Rows[intIndex2][KBS_Category.n_.CategoryID].ToString();

                                    //在下面替换
                                    string strSecondMenuTemp = string.Empty;
                                    string strQuestion = string.Empty;
                                    strSecondMenuTemp = "<div style=\"text-align:left;margin-left:20px;\"><img src=\"/Images/folder1.gif\" alt=\"menubutton\"><a href=\"#\" οnclick=\"GetMenuTreeID(2" + strValue2 + ",0);\">" + strText2 + "</a></div>";

                                    if (1 == ishavequestion && dtQuestion!=null)//有问题,且dtQuestion不为null时
                                    {
                                        for (int intQuestion = 0; intQuestion < dtQuestion.Rows.Count; intQuestion++)
                                        {
                                            int intLeve2CategoryID = int.Parse(dtTable2.Rows[intIndex2][KBS_Category .n_ .CategoryID].ToString());

                                           
                                            if (intLeve2CategoryID == int.Parse(dtQuestion.Rows[intQuestion][KBS_Question.n_.CategoryID].ToString()))
                                            {
                                                //有问题,且dtQuestion不为null时,
                                                strSecondMenuTemp = "<div style=\"text-align:left;margin-left:20px;\"><img src=\"/Images/folder1.gif\" alt=\"menubutton\"><a href=\"#\" οnclick=\"GetMenuTreeID(2" + strValue2 + ",divQuestion" + intQuestion + ");\">" + strText2 + "</a></div>";

                                                strQuestion+="<div id=\"divQuestion" + intQuestion + "\" >";
                                                string strTextQuestion = dtQuestion.Rows[intQuestion][KBS_Question.n_.Question].ToString();
                                                string strValueQuestion = dtQuestion.Rows[intQuestion][KBS_Question.n_.QuestionID].ToString();
                                                strQuestion += "<div style=\"text-align:left;margin-left:30px;\"><img src=\"/Images/folder2.gif\" alt=\"menubutton\"><a href=\"#\" οnclick=\"GetMenuTreeID(3" + strValueQuestion + ",0);\">" + strTextQuestion + "</a></div>";
                                                strQuestion+="</div>";
                                            }
                                        }
                                    }
                                  
                                    sb.Append(strSecondMenuTemp);
                                    sb.Append(strQuestion);
                                }
                            }
                            sb.Append("</div>");
                        }

                    }
                }
                sb.Append("</div>");
                sb.Append("</div>");
                return sb.ToString();
            }


            return "";

        }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值