protected Boolean ApplyChanges() { Boolean isModified = false; Boolean success = false; Boolean isValid = false; System.Collections.Generic.Dictionary <String, String> validationResponse; Mercury.Client.Core.Individual.CarePlan carePlanUnmodified = (Mercury.Client.Core.Individual.CarePlan)Session[SessionCachePrefix + "CarePlanUnmodified"]; if (carePlanUnmodified.Id == 0) { isModified = true; } carePlan.Name = CarePlanName.Text.Trim(); carePlan.Description = CarePlanDescription.Text.Trim(); carePlan.Enabled = CarePlanEnabled.Checked; carePlan.Visible = CarePlanVisible.Checked; if (!isModified) { isModified = !carePlan.IsEqual(carePlanUnmodified); } validationResponse = carePlan.Validate(); isValid = (validationResponse.Count == 0); if ((isModified) && (isValid)) { success = MercuryApplication.CarePlanSave(carePlan); if (success) { carePlan = MercuryApplication.CarePlanGet(carePlan.Id, false); Session[SessionCachePrefix + "CarePlan"] = carePlan; Session[SessionCachePrefix + "CarePlanUnmodified"] = carePlan.Copy(); SaveResponseLabel.Text = "Save Successful"; InitializeAll(); } else { SaveResponseLabel.Text = "Unable to Save."; if (MercuryApplication.LastException != null) { SaveResponseLabel.Text = SaveResponseLabel.Text + " [" + MercuryApplication.LastException.Message + "]"; } success = false; } } else if (!isModified) { SaveResponseLabel.Text = "No Changes Detected."; success = true; } else if (!isValid) { foreach (String validationKey in validationResponse.Keys) { SaveResponseLabel.Text = "Invalid [" + validationKey + "]: " + validationResponse[validationKey]; break; } success = false; } return(success); }