Пример #1
0
    public void BindItemTreeView()
    {
        DataSet dsProgramList = null;

        dsProgramList = BLL_LMS_Training.GET_Program_Details(UDFLib.ConvertToInteger(hdfProgram_Id.Value));


        if (dsProgramList.Tables.Count == 3)
        {
            foreach (DataRow drParent in dsProgramList.Tables[0].Rows)
            {
                TreeNode parentNode = new TreeNode(drParent["PROGRAM_NAME"].ToString());
                parentNode.NavigateUrl = "#";
                parentNode.ImageUrl    = "../Images/LMS_Program.png";


                DataRow[] drChildList_Chapter = dsProgramList.Tables[1].Select("PROGRAM_ID=" + drParent["PROGRAM_ID"].ToString());

                foreach (DataRow drChild1 in drChildList_Chapter)
                {
                    TreeNode Child_Chapter = new TreeNode(drChild1["CHAPTER_DESCRIPTION"].ToString());
                    Child_Chapter.NavigateUrl = "LMS_Chapter_Details.aspx?Chapter_ID=" + drChild1["CHAPTER_ID"].ToString() + "&Program_ID=" + hdfProgram_Id.Value + "&ProgramCategory=" + UDFLib.ConvertIntegerToNull(ddlProgramCategory.SelectedValue);
                    Child_Chapter.ImageUrl    = "../Images/LMS_Chapter.png";

                    DataRow[] drChildList_Items = dsProgramList.Tables[2].Select("CHAPTER_ID=" + drChild1["CHAPTER_ID"].ToString());

                    foreach (DataRow drChild2 in drChildList_Items)
                    {
                        TreeNode Child_Item;
                        if (drChild2["ITEM_TYPE"].ToString() != "FBM")
                        {
                            string ImagePath = "../Images/noneimg.png";

                            if (File.Exists(Server.MapPath("~/Images/DocTree/" + Path.GetExtension(drChild2["ITEM_PATH"].ToString()).Replace(".", "") + ".png")))
                            {
                                ImagePath = "../Images/DocTree/" + Path.GetExtension(drChild2["ITEM_PATH"].ToString()).Replace(".", "") + ".png";
                            }
                            else
                            {
                                if (drChild2["ITEM_TYPE"].ToString() == "VIDEO MATERIALS")
                                {
                                    ImagePath = "../Images/DocTree/mp4.png";
                                }
                                else
                                {
                                    ImagePath = "../Images/DocTree/txt.png";
                                }
                            }
                            string filePath = "";
                            if (File.Exists(Server.MapPath("~/Uploads/TrainingItems/" + drChild2["ITEM_PATH"].ToString())))
                            {
                                filePath = "../Uploads/TrainingItems/" + drChild2["ITEM_PATH"].ToString();
                            }
                            else
                            {
                                filePath = "../FileNotFound.aspx";
                            }
                            Child_Item = new TreeNode(drChild2["ITEM_NAME"].ToString(), "", ImagePath, filePath, drChild2["ITEM_NAME"].ToString());
                            Child_Chapter.ChildNodes.Add(Child_Item);
                            Child_Item.ToolTip = drChild2["ITEM_Description"].ToString();
                        }

                        else
                        {
                            string filePath = "";
                            filePath = "../QMS/FBM/" + drChild2["ITEM_PATH"].ToString();
                            //if (File.Exists(Server.MapPath("~/QMS/FBM/" + drChild2["ITEM_PATH"].ToString())))
                            //{


                            //}
                            //else
                            //{
                            //    filePath = "http://" + HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.ApplicationPath + "/FileNotFound.aspx";
                            //}
                            Child_Item = new TreeNode(drChild2["ITEM_NAME"].ToString(), "", "", filePath, drChild2["ITEM_NAME"].ToString());

                            Child_Chapter.ChildNodes.Add(Child_Item);
                        }
                    }

                    parentNode.ChildNodes.Add(Child_Chapter);
                }

                tvItemList.Nodes.Add(parentNode);
                parentNode.ExpandAll();
            }
        }

        String msgretv = String.Format("OnLoad();");

        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "msgret6v", msgretv, true);
    }