/// <summary> /// This method fires when the value in the ddInterval ComboBox's selected index /// changes and it updates the cutoff and score type /// </summary> /// <param name="sender">The ddInterval ComboBox</param> /// <param name="e">The SelectedIndexChanged event</param> protected void ddInterval_SelectedIndexChanged(object sender, EventArgs e) { //Get the total score, selected interval, and selected version number int totalScore = (txtTotalScore.Value == null ? 0 : Convert.ToInt32(txtTotalScore.Value)); int?selectedIntervalFK = (ddInterval.Value == null ? (int?)null : Convert.ToInt32(ddInterval.Value)); int?selectedVersionNum = (ddVersion.Value == null ? (int?)null : Convert.ToInt32(ddVersion.Value)); if (selectedIntervalFK.HasValue && selectedVersionNum.HasValue) { //Enable the total score text box txtTotalScore.ReadOnly = false; using (PyramidContext context = new PyramidContext()) { //Get the ScoreASQSE for the interval and version currentScoreASQSE = context.ScoreASQSE.AsNoTracking() .Where(sa => sa.IntervalCodeFK == selectedIntervalFK && sa.Version == selectedVersionNum) .FirstOrDefault(); } //Update the cutoff and score type UpdateCutoffAndMonitoringLabels(currentScoreASQSE); UpdateScoreType(totalScore, currentScoreASQSE); } else { txtTotalScore.ReadOnly = true; } }
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(); } }