private void GetRootNodes() { contentTV.Nodes.Clear(); PatientEducationDa da = new PatientEducationDa(); DataTable dt = da.GetAllSections(); //will eventually use GetAll() from BusinessObject foreach (DataRow row in dt.Rows) { TreeNode node = new TreeNode(); string sectionId = row[PatientEdSection.SectionId].ToString(); string sectionName = row[PatientEdSection.SectionName].ToString(); node.Value = sectionId; node.ToolTip = sectionName; node.ImageToolTip = sectionName; if (PageMode == PageModes.Single.ToString()) { node.Text = PatientEdUtil.GetFriendlyJavascriptTitle(sectionName, sectionId, sectionName, string.Empty, string.Empty, string.Empty, string.Empty, "Section"); } else { node.Text = "<span onclick='return false;' style='cursor:default;'>" + sectionName + "</span>"; } if (PageMode == PageModes.Single.ToString()) { if (!(topicBiz != null && topicBiz[PatientEdTopic.SectionId].ToString() == sectionId)) { if (sectionBiz != null && sectionBiz[PatientEdSection.SectionId].ToString() == sectionId) { SetContentDetailSrc("1", sectionId, sectionName); } } node.NavigateUrl = "ManageContentDetail.aspx?type=1&id=" + node.Value; } node.PopulateOnDemand = true; node.SelectAction = TreeNodeSelectAction.SelectExpand; node.ShowCheckBox = false; node.Expand(); if (!String.IsNullOrEmpty(PreloadedContentType)) { if (sectionBiz != null && topicBiz == null && subTopicBiz == null && sectionBiz[PatientEdSection.SectionId].ToString() == sectionId) { node.Selected = true; } } contentTV.Nodes.Add(node); } }
protected void TreeNode_Populate(Object sender, TreeNodeEventArgs e) { int sectionId = Int32.Parse(e.Node.Value); PatientEdSection sectionBiz = new PatientEdSection(); sectionBiz.Get(sectionId); string sectionTitle = sectionBiz[PatientEdSection.SectionName].ToString(); PatientEducationDa da = new PatientEducationDa(); // Wouldn't it be better to do use PatientEdTopic biz and GetByParent sectionId ??? DataTable dt = da.GetTopicsBySection(sectionId); List <string> subTopicIds = new List <string>(); //get topics foreach (DataRow row in dt.Rows) { int topicId = int.Parse(row[PatientEdTopic.TopicId].ToString()); string topicName = row[PatientEdTopic.TopicName].ToString(); string titleText = ""; if (PageMode == PageModes.Single.ToString()) { titleText = PatientEdUtil.GetFriendlyJavascriptTitle(topicName, sectionId.ToString(), sectionTitle, topicId.ToString(), topicName, String.Empty, String.Empty, "Topic"); } else { titleText = "<span onclick='return false;' style='cursor:default;'>" + topicName + "</span>"; } TreeNode topicNode = new TreeNode(titleText, topicId.ToString()); topicNode.ToolTip = topicName; topicNode.ImageToolTip = topicName; if (subTopicBiz != null && subTopicBiz[PatientEdSubTopic.TopicId].ToString() == topicId.ToString()) { topicNode.Expanded = true; } else { if (PageMode == PageModes.Single.ToString()) { if (topicBiz != null && topicBiz[PatientEdTopic.TopicId].ToString() == topicId.ToString()) { string title = sectionBiz[PatientEdSection.SectionName].ToString() + " > " + topicName; SetContentDetailSrc("2", topicId.ToString(), title); } } topicNode.Expanded = false; } if (PageMode == PageModes.Single.ToString()) { topicNode.NavigateUrl = "ManageContentDetail.aspx?type=2&id=" + topicNode.Value; } // get subtopics DataTable dtSubTopic = da.GetSubTopicsByTopic(topicId); foreach (DataRow dr in dtSubTopic.Rows) { string subTopicId = dr[PatientEdSubTopic.SubTopicId].ToString(); string subTopicName = dr[PatientEdSubTopic.SubTopicName].ToString(); string stText = ""; subTopicIds.Add(subTopicId); if (PageMode == PageModes.Single.ToString()) { stText = PatientEdUtil.GetFriendlyJavascriptTitle(subTopicName, sectionId.ToString(), sectionTitle, topicId.ToString(), topicName, subTopicId, subTopicName, "SubTopic"); } else { if (PageMode == PageModes.DefaultDoc.ToString()) { stText = "<span onclick='doNodeCheckboxClick(this);return false;' style='cursor:default;'>" + subTopicName + "</span>"; } else { stText = "<span onclick='return false;' style='cursor:default;'>" + subTopicName + "</span>"; } } TreeNode subTopicNode = new TreeNode(stText, subTopicId); if (PageMode == PageModes.Single.ToString()) { subTopicNode.NavigateUrl = "ManageContentDetail.aspx?type=3&id=" + subTopicNode.Value; } if (PageMode == PageModes.DefaultDoc.ToString()) { subTopicNode.ShowCheckBox = true; // NOTE: try to check off subtopics based on ddls DataTable dST = da.GetDiseaseVisitSubTopicBySubTopic(Int32.Parse(subTopicId)); foreach (DataRow r in dST.Rows) { if (r[PatientEdDisease_VisitType_SubTopic.DiseaseId].ToString() == ddlDiseaseType.SelectedValue && r[PatientEdDisease_VisitType_SubTopic.VisitTypeId].ToString() == ddlVisitType.SelectedValue && r[PatientEdPacket.PacketId].ToString() == ddlPacketName.SelectedValue) { subTopicNode.Checked = true; topicNode.Expand(); break; } } } subTopicNode.ToolTip = subTopicName; subTopicNode.ImageToolTip = subTopicName; if (!String.IsNullOrEmpty(PreloadedContentType)) { if (sectionBiz != null && topicBiz != null && subTopicBiz != null && subTopicBiz[PatientEdSubTopic.SubTopicId].ToString() == subTopicId) { subTopicNode.Selected = true; } } topicNode.ChildNodes.Add(subTopicNode); if (subTopicBiz != null && subTopicBiz[PatientEdSubTopic.SubTopicId].ToString() == subTopicId) { string title = sectionBiz[PatientEdSection.SectionName].ToString() + " > " + topicName + " > " + subTopicName; SetContentDetailSrc("3", subTopicId, title); } } if (!String.IsNullOrEmpty(PreloadedContentType)) { if (sectionBiz != null && topicBiz != null && subTopicBiz == null && topicBiz[PatientEdTopic.TopicId].ToString() == topicId.ToString()) { topicNode.Selected = true; } } topicNode.ShowCheckBox = false; e.Node.ChildNodes.Add(topicNode); } PatientEdUtil.RegisterStartupSubTopicIds(Page, sectionId, subTopicIds); }