コード例 #1
0
ファイル: ASQSE.aspx.cs プロジェクト: CHSR/PyramidModelWebApp
 /// <summary>
 /// This method populates the page controls from the passed ASQSE object
 /// </summary>
 /// <param name="ASQSEToPopulate">The ASQSE object with values to populate the page controls</param>
 private void PopulatePage(Models.ASQSE ASQSEToPopulate)
 {
     //Set the page controls to the values from the object
     deFormDate.Value                = ASQSEToPopulate.FormDate;
     ddChild.SelectedItem            = ddChild.Items.FindByValue(ASQSEToPopulate.ChildFK);
     ddVersion.SelectedItem          = ddVersion.Items.FindByValue(ASQSEToPopulate.Version);
     ddInterval.SelectedItem         = ddInterval.Items.FindByValue(ASQSEToPopulate.IntervalCodeFK);
     ddDemographicSheet.SelectedItem = ddDemographicSheet.Items.FindByValue(ASQSEToPopulate.HasDemographicInfoSheet);
     ddPhysicianLetter.SelectedItem  = ddPhysicianLetter.Items.FindByValue(ASQSEToPopulate.HasPhysicianInfoLetter);
     txtTotalScore.Value             = ASQSEToPopulate.TotalScore;
 }
コード例 #2
0
ファイル: ASQSE.aspx.cs プロジェクト: CHSR/PyramidModelWebApp
        protected void Page_Load(object sender, EventArgs e)
        {
            //Get the user's current program role
            currentProgramRole = Utilities.GetProgramRoleFromSession(Session);

            //Get the ASQSE PK from the query string
            if (!string.IsNullOrWhiteSpace(Request.QueryString["ASQSEPK"]))
            {
                int.TryParse(Request.QueryString["ASQSEPK"], out currentASQSEPK);
            }

            //Don't allow aggregate viewers into this page
            if (currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.AGGREGATE_DATA_VIEWER)
            {
                Response.Redirect("/Pages/ASQSEDashboard.aspx?messageType=NotAuthorized");
            }

            using (PyramidContext context = new PyramidContext())
            {
                //Get the ASQSE from the database
                currentASQSE = context.ASQSE
                               .AsNoTracking()
                               .Include(a => a.Program)
                               .Where(a => a.ASQSEPK == currentASQSEPK).FirstOrDefault();

                //Check to see if the ASQSE from the database exists
                if (currentASQSE == null)
                {
                    //The ASQSE from the database doesn't exist, set the current ASQSE to a default value
                    currentASQSE = new Models.ASQSE();

                    //Set the program label to the current user's program
                    lblProgram.Text = currentProgramRole.ProgramName;
                }
                else
                {
                    //Set the program label to the ASQSE's program
                    lblProgram.Text = currentASQSE.Program.ProgramName;
                }

                //Get the current interval and version
                int intervalFK = (ddInterval.Value == null ? currentASQSE.IntervalCodeFK : Convert.ToInt32(ddInterval.Value));
                int versionNum = (ddVersion.Value == null ? currentASQSE.Version : Convert.ToInt32(ddVersion.Value));

                //Get the ScoreASQSE object
                currentScoreASQSE = context.ScoreASQSE.AsNoTracking()
                                    .Where(sa => sa.IntervalCodeFK == intervalFK &&
                                           sa.Version == versionNum)
                                    .FirstOrDefault();
            }

            //Prevent users from viewing ASQSEs from other programs
            if (currentASQSE.ASQSEPK > 0 && !currentProgramRole.ProgramFKs.Contains(currentASQSE.ProgramFK))
            {
                Response.Redirect(string.Format("/Pages/ASQSEDashboard.aspx?messageType={0}", "NOASQSE"));
            }

            //Get the proper program fk
            currentProgramFK = (currentASQSE.ASQSEPK > 0 ? currentASQSE.ProgramFK : currentProgramRole.CurrentProgramFK.Value);

            //Set the max value for the form date
            deFormDate.MaxDate = DateTime.Now;

            if (!IsPostBack)
            {
                //Hide the master page title
                ((Dashboard)this.Master).HideTitle();

                //Bind the dropdowns
                BindDropDowns();

                //Check to see if this is an edit
                if (currentASQSEPK > 0)
                {
                    //This is an edit
                    //Populate the page
                    PopulatePage(currentASQSE);

                    //Update the child age label, the score type label, and the cutoff score label
                    UpdateChildAge(currentASQSE.ChildFK, currentASQSE.FormDate);
                    UpdateScoreType(currentASQSE.TotalScore, currentScoreASQSE);
                    UpdateCutoffAndMonitoringLabels(currentScoreASQSE);
                }
                else
                {
                    //This is an add, make the interval and total score read-only for now
                    ddInterval.ReadOnly    = true;
                    txtTotalScore.ReadOnly = true;
                }

                //Get the action from the query string
                string action;
                if (Request.QueryString["action"] != null)
                {
                    action = Request.QueryString["action"];
                }
                else
                {
                    action = "View";
                }

                //Allow adding/editing depending on the user's role and the action
                if (currentASQSE.ASQSEPK == 0 && currentProgramRole.AllowedToEdit.Value)
                {
                    //Show the submit button
                    submitASQSE.ShowSubmitButton = true;

                    //Show certain controls
                    hfViewOnly.Value = "False";

                    //Enable page controls
                    EnableControls(true);

                    //Set the page title
                    lblPageTitle.Text = "Add New ASQ:SE Screening";
                }
                else if (currentASQSE.ASQSEPK > 0 && action.ToLower() == "edit" && currentProgramRole.AllowedToEdit.Value)
                {
                    //Show the submit button
                    submitASQSE.ShowSubmitButton = true;

                    //Show certain controls
                    hfViewOnly.Value = "False";

                    //Enable page controls
                    EnableControls(true);

                    //Set the page title
                    lblPageTitle.Text = "Edit ASQ:SE Screening";
                }
                else
                {
                    //Hide the submit button
                    submitASQSE.ShowSubmitButton = false;

                    //Hide certain controls
                    hfViewOnly.Value = "True";

                    //Disable page controls
                    EnableControls(false);

                    //Set the page title
                    lblPageTitle.Text = "View ASQ:SE Screening";
                }

                //Set focus to the form date field
                deFormDate.Focus();
            }
        }
コード例 #3
0
ファイル: ASQSE.aspx.cs プロジェクト: CHSR/PyramidModelWebApp
        /// <summary>
        /// This method fires when the user clicks the Save button in the
        /// submitASQSE user control
        /// </summary>
        /// <param name="sender">The submitASQSE control</param>
        /// <param name="e">The Click event</param>
        protected void submitASQSE_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value)
            {
                //To hold the success message type
                string successMessageType = null;

                //Fill the ASQSE fields from the form
                currentASQSE.FormDate = Convert.ToDateTime(deFormDate.Value);
                currentASQSE.HasDemographicInfoSheet = Convert.ToBoolean(ddDemographicSheet.Value);
                currentASQSE.HasPhysicianInfoLetter  = Convert.ToBoolean(ddPhysicianLetter.Value);
                currentASQSE.ChildFK        = Convert.ToInt32(ddChild.Value);
                currentASQSE.TotalScore     = Convert.ToInt32(txtTotalScore.Value);
                currentASQSE.IntervalCodeFK = Convert.ToInt32(ddInterval.Value);
                currentASQSE.Version        = Convert.ToInt32(ddVersion.Value);

                if (currentASQSEPK > 0)
                {
                    //This is an edit
                    using (PyramidContext context = new PyramidContext())
                    {
                        //Set the success message
                        successMessageType = "ASQSEEdited";

                        //Set the edit-only fields
                        currentASQSE.Editor   = User.Identity.Name;
                        currentASQSE.EditDate = DateTime.Now;

                        //Get the existing ASQSE record
                        Models.ASQSE existingASQ = context.ASQSE.Find(currentASQSE.ASQSEPK);

                        //Overwrite the existing ASQSE record with the values from the form
                        context.Entry(existingASQ).CurrentValues.SetValues(currentASQSE);
                        context.SaveChanges();
                    }

                    //Redirect the user to the ASQSE dashboard
                    Response.Redirect(string.Format("/Pages/ASQSEDashboard.aspx?messageType={0}", successMessageType));
                }
                else
                {
                    //This is an add
                    using (PyramidContext context = new PyramidContext())
                    {
                        //Set the success message
                        successMessageType = "ASQSEAdded";

                        //Set the create-only fields
                        currentASQSE.Creator    = User.Identity.Name;
                        currentASQSE.CreateDate = DateTime.Now;
                        currentASQSE.ProgramFK  = currentProgramRole.CurrentProgramFK.Value;

                        //Add the ASQSE to the database
                        context.ASQSE.Add(currentASQSE);
                        context.SaveChanges();
                    }

                    //Redirect the user to the ASQSE dashboard
                    Response.Redirect(string.Format("/Pages/ASQSEDashboard.aspx?messageType={0}", successMessageType));
                }
            }
        }