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); }
protected void TreeNode_Populate(Object sender, TreeNodeEventArgs e) { int sectionId = Int32.Parse(e.Node.Value); PatientEducationDa da = new PatientEducationDa(); DataTable dt = da.GetTopicsBySection(sectionId); List <string> subTopicIds = new List <string>(); DataTable profilePartsDt = new DataTable(); DataTable subTopicTable = new DataTable(); string loadDocType = ""; // inside the loop we will want to check off boxes based on a profile or default doc if (ProfileId > 0) { profilePartsDt = da.GetProfileDocPartsByProfileId(ProfileId); loadDocType = "UserProfile"; } else if (PageUtil.IsInteger(_packetId.Value)) { // check off subtopics based on active packet subTopicTable = da.GetDiseaseVisitSubTopicByPacket(int.Parse(_packetId.Value)); loadDocType = "DefaultPacket"; PacketName.Text = _packetName.Value; } // get subtopics by topic foreach (DataRow row in dt.Rows) { string topicName = row[PatientEdTopic.TopicName].ToString(); TreeNode topicNode = new TreeNode("<span onclick='return false;' style='cursor:default;'>" + topicName + "</span>", row[PatientEdTopic.TopicId].ToString()); topicNode.Expanded = false; topicNode.ToolTip = topicName; topicNode.ImageToolTip = topicName; int topicId = Int32.Parse(row[PatientEdTopic.TopicId].ToString()); DataTable dtSubTopic = da.GetSubTopicsByTopic(topicId); foreach (DataRow dr in dtSubTopic.Rows) { string subTopicId = dr[PatientEdSubTopic.SubTopicId].ToString(); subTopicIds.Add(subTopicId); string subTopicName = dr[PatientEdSubTopic.SubTopicName].ToString(); TreeNode subTopicNode = new TreeNode("<span onclick='doNodeCheckboxClick(this);return false;' style='cursor:default;'>" + subTopicName + "</span>", dr[PatientEdSubTopic.SubTopicId].ToString()); subTopicNode.ToolTip = subTopicName; subTopicNode.ImageToolTip = subTopicName; subTopicNode.ShowCheckBox = true; //Loading an existing profile, so check off boxes if subtopic is part of the profile doc if (loadDocType.Equals("UserProfile")) { DataRow[] returnedRows = profilePartsDt.Select("SubTopicId = " + subTopicId + ""); if (returnedRows.Length > 0) { subTopicNode.Checked = true; topicNode.Expand(); } /* previous, less efficient way * foreach (DataRow pdr in profilePartsDt.Rows) * { * if (subTopicId == pdr[PatientEdProfileDocPart.SubTopicId].ToString()) * { * subTopicNode.Checked = true; * topicNode.Expand(); * } * } */ } else if (loadDocType.Equals("DefaultPacket")) //not for a particular patient { // if a the subtopic is part of the default packet, check it off DataRow[] foundRows = subTopicTable.Select("SubTopicId = " + subTopicId + ""); if (foundRows.Length > 0) { subTopicNode.Checked = true; topicNode.Expand(); } /*foreach (DataRow packetRow in subTopicTable.Rows) * { * if (subTopicId == packetRow[PatientEdDisease_VisitType_SubTopic.SubTopicId].ToString()) * { * subTopicNode.Checked = true; * topicNode.Expand(); * break; * } * }*/ /* Try to check off subtopics based on disease ddl and visit type * DataTable dST = da.GetDiseaseVisitSubTopicBySubTopic(Int32.Parse(subTopicId)); * foreach (DataRow r in dST.Rows) * { * string sVisitTypeId = ""; * //if (this._visitTypeId != 0) * if (VisitTypeId != 0) * { * sVisitTypeId = this._visitTypeId.ToString(); //this._visitTypeStage.Value * } * * if (r[PatientEdDisease_VisitType_SubTopic.DiseaseId].ToString() == this.ddlDiseaseProfile.SelectedValue * && r[PatientEdDisease_VisitType_SubTopic.VisitTypeId].ToString() == sVisitTypeId) * { * subTopicNode.Checked = true; * topicNode.Expand(); * break; * } * } */ } topicNode.ChildNodes.Add(subTopicNode); } topicNode.ShowCheckBox = false; e.Node.ChildNodes.Add(topicNode); } PatientEdUtil.RegisterStartupSubTopicIds(Page, sectionId, subTopicIds); }