protected Boolean ApplyChanges() { Boolean isModified = false; Boolean success = false; List <Int64> problemStatementIds = new List <Int64> (); // PROBLEM STATEMENTS TO ADD Int64 problemStatementId = 0; Mercury.Server.Application.MemberCaseModificationResponse response; // IDENTIFY ALL REQUESTED PROBLEM STATEMENTS TO ADD foreach (Telerik.Web.UI.RadTreeNode currentNode in ProblemStatementTreeView.GetAllNodes()) { // VALIDATE THAT THE NODE IS CHECKED AND REQUESTED TO BE ADDED TO CASE if (currentNode.Checked) { // VALIDATE THAT THE NODE IS A PROBLEM STATEMENT NODE if (Int64.TryParse(currentNode.Value, out problemStatementId)) { problemStatementIds.Add(problemStatementId); } } } isModified = (problemStatementIds.Count > 0); if (isModified) { success = true; foreach (Int64 currentProblemStatementId in problemStatementIds) { // TODO: ADD SINGLE INSTANCE SUPPORT HERE response = MercuryApplication.MemberCase_AddProblemStatement(Case, currentProblemStatementId, false); Case = new Client.Core.Individual.Case.MemberCase(MercuryApplication, response.MemberCase); if (response.HasException) { ExceptionMessage = response.Exception.Message; success = false; // REBUILD TREE AND SET ERROR NODE ACTIVE ProblemStatementTreeView.Nodes.Clear(); InitializeProblemStatementTreeView(); Telerik.Web.UI.RadTreeNode problemStatementNode = ProblemStatementTreeView.FindNodeByValue(currentProblemStatementId.ToString()); if (problemStatementNode != null) { problemStatementNode.Expanded = true; problemStatementNode.ParentNode.Expanded = true; problemStatementNode.ParentNode.ParentNode.Expanded = true; problemStatementNode.Selected = true; } break; } } if (success) // IF ALL PROBLEMS WERE ADDED WITHOUT PROBLEMS, REFRESH TREE { ProblemStatementTreeView.Nodes.Clear(); InitializeProblemStatementTreeView(); } } else { ExceptionMessage = "No Changes Detected"; success = true; } return(success); }
private void InitializeProblemStatementTreeView() { List <Client.Core.Individual.ProblemStatement> problemStatementsAvailable = MercuryApplication.ProblemStatementsAvailable(true); List <Client.Core.Individual.MemberProblemStatementIdentified> memberProblemStatementidentifiedAvailable = MercuryApplication.MemberProblemStatementIdentifiedAvailable(Case.MemberId, false, false); problemStatementsAvailable = (from currentProblemStatement in problemStatementsAvailable orderby currentProblemStatement.Classification, currentProblemStatement.Name select currentProblemStatement).ToList(); Dictionary <Int64, Client.Core.Individual.ProblemStatement> problemStatementsActive = Case.ProblemStatementsActive; foreach (Client.Core.Individual.ProblemStatement currentProblemStatement in problemStatementsAvailable) { Telerik.Web.UI.RadTreeNode domainNode = ProblemStatementTreeView.FindNodeByValue("ProblemDomain_" + currentProblemStatement.ProblemDomainId); Telerik.Web.UI.RadTreeNode classNode = ProblemStatementTreeView.FindNodeByValue("ProblemClass_" + currentProblemStatement.ProblemDomainId + "_" + currentProblemStatement.ProblemClassId); Telerik.Web.UI.RadTreeNode problemStatementNode = new Telerik.Web.UI.RadTreeNode(currentProblemStatement.Name, currentProblemStatement.Id.ToString()); if (domainNode == null) { domainNode = new Telerik.Web.UI.RadTreeNode(currentProblemStatement.ProblemDomainName, "ProblemDomain_" + currentProblemStatement.ProblemDomainId); domainNode.Checkable = false; ProblemStatementTreeView.Nodes.Add(domainNode); } if (classNode == null) { classNode = new Telerik.Web.UI.RadTreeNode(currentProblemStatement.ProblemClassName, "ProblemClass_" + currentProblemStatement.ProblemDomainId + "_" + currentProblemStatement.ProblemClassId); classNode.Checkable = false; domainNode.Nodes.Add(classNode); } // EXISTING PROBLEMS STATEMENTS WILL HAVE "Checked" TRUE AND "ForeColor" System.Drawing.Color.Black // IF THE PROBLEM STATEMENT EXISTS AND IS ACTIVE IN THE CASE ALREADY, DO NOT ALLOW IT TO BE ADDED AGAIN // IF THE PROBLEM STATEMENT IS AN IDENTIFIED PROBLEM STATEMENT, BOLD IT AND RECOMMEND IT if (problemStatementsActive.ContainsKey(currentProblemStatement.Id)) { problemStatementNode.Checkable = false; problemStatementNode.ImageUrl = "/Images/Common16/Check.png"; problemStatementNode.ForeColor = System.Drawing.Color.Black; } // ADD EARLY SO THAT EXPAND TO NODE WORKS (PARENT RELATIONSHIP REQUIRED) classNode.Nodes.Add(problemStatementNode); // DETERMINE IF IT IS AN IDENTIFIED PROBLEM STATEMENT Boolean identifiedProblemStatement = (from currentIdentifiedProblemStatement in memberProblemStatementidentifiedAvailable where currentIdentifiedProblemStatement.ProblemStatementId == currentProblemStatement.Id select currentIdentifiedProblemStatement).ToList().Count > 0; if (identifiedProblemStatement) { problemStatementNode.Text += " (recommended)"; problemStatementNode.Expanded = true; RadTreeView_ExpandToNode(problemStatementNode); problemStatementNode.Font.Bold = false; problemStatementNode.ForeColor = System.Drawing.Color.Red; } } return; }