protected void Page_Load(object sender, EventArgs e) { Int64 forWorkOutcomeId = 0; if (MercuryApplication == null) { return; } if ((!MercuryApplication.HasEnvironmentPermission(Mercury.Server.EnvironmentPermissions.WorkOutcomeReview)) && (!MercuryApplication.HasEnvironmentPermission(Mercury.Server.EnvironmentPermissions.WorkOutcomeManage))) { Response.Redirect("/PermissionDenied.aspx", true); return; } if (!Page.IsPostBack) { #region Initial Page Load if (Request.QueryString["WorkOutcomeId"] != null) { forWorkOutcomeId = Int64.Parse(Request.QueryString["WorkOutcomeId"]); } if (forWorkOutcomeId != 0) { workOutcome = MercuryApplication.WorkOutcomeGet(forWorkOutcomeId, false); if (workOutcome == null) { workOutcome = new Mercury.Client.Core.Work.WorkOutcome(MercuryApplication); } } else { workOutcome = new Mercury.Client.Core.Work.WorkOutcome(MercuryApplication); } InitializeAll(); Session[SessionCachePrefix + "WorkOutcome"] = workOutcome; Session[SessionCachePrefix + "WorkOutcomeUnmodified"] = workOutcome.Copy(); #endregion } // Initial Page Load else // Postback { workOutcome = (Mercury.Client.Core.Work.WorkOutcome)Session[SessionCachePrefix + "WorkOutcome"]; } ApplySecurity(); if (!String.IsNullOrEmpty(workOutcome.Name)) { Page.Title = "Work Outcome - " + workOutcome.Name; } else { Page.Title = "Work Outcome"; } return; }
protected Boolean ApplyChanges() { Boolean isModified = false; Boolean success = false; Mercury.Client.Core.Work.WorkOutcome workOutcomeUnmodified = (Mercury.Client.Core.Work.WorkOutcome)Session[SessionCachePrefix + "WorkOutcomeUnmodified"]; if (workOutcomeUnmodified.Id == 0) { isModified = true; } workOutcome.Name = WorkOutcomeName.Text.Trim(); workOutcome.Description = WorkOutcomeDescription.Text.Trim(); workOutcome.Enabled = WorkOutcomeEnabled.Checked; workOutcome.Visible = WorkOutcomeVisible.Checked; if (!isModified) { isModified = !workOutcome.IsEqual(workOutcomeUnmodified); } if (isModified) { success = MercuryApplication.WorkOutcomeSave(workOutcome); if (success) { workOutcome = MercuryApplication.WorkOutcomeGet(workOutcome.Id, false); Session[SessionCachePrefix + "WorkOutcome"] = workOutcome; Session[SessionCachePrefix + "WorkOutcomeUnmodified"] = workOutcome.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 { SaveResponseLabel.Text = "No Changes Detected."; success = true; } return(success); }