Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Int64 forServiceId = 0;


            if (MercuryApplication == null)
            {
                return;
            }

            if ((!MercuryApplication.HasEnvironmentPermission(ReviewPermission)) &&
                (!MercuryApplication.HasEnvironmentPermission(ManagePermission)))
            {
                Response.Redirect("/PermissionDenied.aspx", true); return;
            }

            if ((MercuryApplication != null) && (!Page.IsPostBack))
            {
                #region Initial Page Load

                if (Request.QueryString["ServiceId"] != null)
                {
                    forServiceId = Int64.Parse(Request.QueryString["ServiceId"]);
                }

                if (forServiceId != 0)
                {
                    serviceSet = MercuryApplication.MedicalServiceSetGet(forServiceId);

                    if (serviceSet == null)
                    {
                        serviceSet = new Mercury.Client.Core.MedicalServices.ServiceSet(MercuryApplication);
                    }

                    Page.Title = "Service Set - " + serviceSet.Name;
                }

                else
                {
                    serviceSet = new Mercury.Client.Core.MedicalServices.ServiceSet(MercuryApplication);
                }

                InitializeGeneralPage();

                InitializeDefinitionGrid();

                Session[SessionCachePrefix + "ServiceSet"] = serviceSet;

                Session[SessionCachePrefix + "ServiceSetUnmodified"] = serviceSet.Copy();

                #endregion
            } // Initial Page Load

            else   // Postback

            {
                serviceSet = (Mercury.Client.Core.MedicalServices.ServiceSet)Session[SessionCachePrefix + "ServiceSet"];
            }

            ApplySecurity();

            return;
        }
Example #2
0
        protected Boolean ApplyChanges()
        {
            Boolean success = false;

            Boolean isModified = false;

            Boolean isValid = false;

            Dictionary <String, String> validationResponse;


            ValidateSession();


            Mercury.Client.Core.MedicalServices.ServiceSet serviceSetUnmodified = (Mercury.Client.Core.MedicalServices.ServiceSet)Session[SessionCachePrefix + "ServiceSetUnmodified"];

            Mercury.Server.Application.ObjectSaveResponse saveResponse;


            serviceSet.Name = ServiceSetName.Text;

            serviceSet.Description = ServiceSetDescription.Text;

            serviceSet.ServiceClassification = (Mercury.Server.Application.ServiceClassification)Int32.Parse(ServiceSetClassification.SelectedValue);

            serviceSet.SetType = (Mercury.Server.Application.ServiceSetType)(Int32.Parse(ServiceSetType.SelectedItem.Value));

            if (serviceSet.SetType == Mercury.Server.Application.ServiceSetType.Intersection)
            {
                if (ServiceSetWithinDays.Value.HasValue)
                {
                    serviceSet.WithinDays = (Int32)ServiceSetWithinDays.Value;
                }

                else
                {
                    serviceSet.WithinDays = 0;
                }
            }

            serviceSet.Enabled = ServiceSetEnabled.Checked;

            serviceSet.Visible = ServiceSetVisible.Checked;


            if (serviceSetUnmodified.Id == 0)
            {
                isModified = true;
            }

            if (!isModified)
            {
                isModified = !serviceSet.IsEqual(serviceSetUnmodified);
            }


            validationResponse = serviceSet.Validate();

            isValid = (validationResponse.Count == 0);


            if ((isModified) && (isValid))
            {
                if (!MercuryApplication.HasEnvironmentPermission(ManagePermission))
                {
                    SaveResponseLabel.Text = "Permission Denied.";

                    return(false);
                }

                saveResponse = MercuryApplication.MedicalServiceSave(serviceSet);

                success = saveResponse.Success;

                if (success)
                {
                    serviceSet = MercuryApplication.MedicalServiceSetGet(saveResponse.Id);

                    Session[SessionCachePrefix + "ServiceServiceSet"] = serviceSet;

                    Session[SessionCachePrefix + "ServiceServiceSetUnmodified"] = serviceSet.Copy();

                    SaveResponseLabel.Text = "Save Successful.";

                    InitializeGeneralPage();

                    InitializeDefinitionGrid();
                }


                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);
        }