protected void Page_Load(object sender, EventArgs e) { //Get the user's selected role currentProgramRole = Utilities.GetProgramRoleFromSession(Session); //Hide the states if the user is not a super admin if (currentProgramRole.RoleFK.Value != (int)Utilities.ProgramRoleFKs.SUPER_ADMIN) { divStates.Visible = false; } if (!IsPostBack) { //Bind the cohort, hub, and state data-bound controls BindCohorts(); BindHubs(); BindPrograms(); BindStates(); using (PyramidContext context = new PyramidContext()) { //Get the program types var programTypes = context.CodeProgramType.AsNoTracking().OrderBy(cpt => cpt.OrderBy).ToList(); lstBxProgramType.DataSource = programTypes; lstBxProgramType.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { //Get the user's program role currentProgramRole = Utilities.GetProgramRoleFromSession(Session); //Only allow super admins if (currentProgramRole.RoleFK.Value != (int)Utilities.ProgramRoleFKs.SUPER_ADMIN) { Response.Redirect("/Default.aspx"); } if (!IsPostBack) { //Set the view only value if (currentProgramRole.AllowedToEdit.Value) { hfViewOnly.Value = "False"; } else { hfViewOnly.Value = "True"; } //Check for messages in the query string string messageType = Request.QueryString["messageType"]; //Show the message if it exists if (!string.IsNullOrWhiteSpace(messageType)) { switch (messageType) { case "ReportCatalogItemAdded": msgSys.ShowMessageToUser("success", "Success", "Report Catalog Item successfully added!", 10000); break; case "ReportCatalogItemEdited": msgSys.ShowMessageToUser("success", "Success", "Report Catalog Item successfully edited!", 10000); break; case "ReportCatalogItemCanceled": msgSys.ShowMessageToUser("info", "Canceled", "The action was canceled, no changes were saved.", 10000); break; case "NOReportCatalogItem": msgSys.ShowMessageToUser("warning", "Warning", "The specified Report Catalog Item could not be found, please try again.", 15000); break; case "NotAuthorized": msgSys.ShowMessageToUser("danger", "Not Authorized", "You are not authorized to view that information!", 10000); break; default: break; } } } }
protected void Page_Load(object sender, EventArgs e) { //Get the current program role currentProgramRole = Utilities.GetProgramRoleFromSession(Session); if (!IsPostBack) { ApplicationDbContext appContext = new ApplicationDbContext(); using (PyramidContext context = new PyramidContext()) { //Get the program list var programs = context.Program.AsNoTracking().Include(p => p.Hub).OrderBy(p => p.ProgramName).Select(p => new { p.ProgramPK, ProgramName = p.ProgramName + " (" + p.Hub.Name + ")" }) .ToList(); ddProgram.DataSource = programs; ddProgram.DataBind(); //Get the program role list, limited to the roles the user is allowed to add var programRoles = context.CodeProgramRole.AsNoTracking() .Where(cpr => cpr.RolesAuthorizedToModify.Contains((currentProgramRole.RoleFK.Value.ToString() + ","))) .OrderBy(cpr => cpr.RoleName) .ToList(); ddProgramRole.DataSource = programRoles; ddProgramRole.DataBind(); } //Get the identity roles var identityRoles = appContext.Roles.OrderBy(r => r.Name).ToList(); //Remove the guest role because it is not implemented in any way IdentityRole guestRole = identityRoles.Where(ir => ir.Name == "Guest").FirstOrDefault(); if (guestRole != null) { identityRoles.Remove(guestRole); } //Only allow super admins to add admin identity roles if (currentProgramRole.RoleFK.Value != (int)Utilities.ProgramRoleFKs.SUPER_ADMIN) { //Remove the Admin identity role from the list IdentityRole adminRole = identityRoles.Where(ir => ir.Name == "Admin").FirstOrDefault(); identityRoles.Remove(adminRole); } //Bind the identity role dropdown ddIdentityRole.DataSource = identityRoles; ddIdentityRole.DataBind(); //Set focus to the username field txtUsername.Focus(); } }
protected void Page_Load(object sender, EventArgs e) { //Get the current program role currentProgramRole = Utilities.GetProgramRoleFromSession(Session); if (!IsPostBack) { //Load the user table bsGRUsers.DataBind(); //Check to see if there are any messages if (Request.QueryString["message"] != null) { //Get the message type string messageCode = Request.QueryString["message"].ToString(); string message = null; string messageType = null; // Strip the query string from action Form.Action = ResolveUrl("~/Admin/UserManagement"); //Get the message to display switch (messageCode) { case "CreateUserSuccess": message = "User successfully created!"; messageType = "success"; break; case "EditUserSuccess": message = "User successfully edited!"; messageType = "success"; break; case "UserNotFound": message = "User could not be found or an error occurred while retrieving the user!"; messageType = "danger"; break; default: message = null; messageType = null; break; } if (!string.IsNullOrWhiteSpace(message)) { //Show the message msgSys.ShowMessageToUser(messageType, "Success", message, 15000); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Get the current program role ProgramAndRoleFromSession currentProgramRole = Utilities.GetProgramRoleFromSession(Session); //Show/hide the BOQFCC link if (currentProgramRole.ShowBOQFCC.HasValue && currentProgramRole.ShowBOQFCC.Value) { divBOQFCCDashboardLink.Visible = true; } else { divBOQFCCDashboardLink.Visible = false; } //Show/hide the BOQ link if (currentProgramRole.ShowBOQ.HasValue && currentProgramRole.ShowBOQ.Value) { divBOQDashboardLink.Visible = true; } else { divBOQDashboardLink.Visible = false; } //Hide the master page title ((LoggedIn)this.Master).HideTitle(); using (PyramidContext context = new PyramidContext()) { //Get all the counts for the dashboard navigation var allCounts = context.spGetCountsForDashboardMaster(DateTime.Now, string.Join(",", currentProgramRole.ProgramFKs), currentProgramRole.HubFK, currentProgramRole.StateFK).FirstOrDefault(); //Display the counts spanASQSECount.InnerText = allCounts.ASQSECount.ToString(); spanBehaviorIncidentCount.InnerText = allCounts.BehaviorIncidentCount.ToString(); spanBOQCount.InnerText = allCounts.BOQCount.ToString(); spanBOQFCCCount.InnerText = allCounts.BOQFCCCount.ToString(); spanChildCount.InnerText = allCounts.ChildrenCount.ToString(); spanClassroomCount.InnerText = allCounts.ClassroomCount.ToString(); spanCoachingLogCount.InnerText = allCounts.CoachingLogCount.ToString(); spanEmployeeCount.InnerText = allCounts.EmployeeCount.ToString(); spanOtherSEScreenCount.InnerText = allCounts.OtherSEScreenCount.ToString(); spanTPITOSCount.InnerText = allCounts.TPITOSCount.ToString(); spanTPOTCount.InnerText = allCounts.TPOTCount.ToString(); spanFileUploadCount.InnerText = allCounts.FileUploadCount.ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { //Get the current program role currentProgramRole = Utilities.GetProgramRoleFromSession(Session); //Don't allow non-admins to use the page if (currentProgramRole.RoleFK.Value != (int)Utilities.ProgramRoleFKs.SUPER_ADMIN && currentProgramRole.RoleFK.Value != (int)Utilities.ProgramRoleFKs.APPLICATION_ADMIN) { //Kick out any non-admins Response.Redirect("/Default.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { try { //Get the current program role ProgramAndRoleFromSession currentProgramRole = Utilities.GetProgramRoleFromSession(Session); //Get the file name string fileName = Request.QueryString["FileName"].ToString(); //Check to see what file the user wants to download if (fileName == "NCPMIBIRExcelReport") { //This is the BIR excel file report //Get the parameters from the query string string programFKsString = Request.QueryString["ProgramFKs"].ToString(); List <int> programFKs = programFKsString.Split(',').Select(int.Parse).ToList(); string schoolYearString = Request.QueryString["SchoolYear"].ToString(); DateTime schoolYear; //Only continue if the school year is a valid year and the user is allowed //to run the report for the programs if (DateTime.TryParse(schoolYearString, out schoolYear) && programFKs.Except(currentProgramRole.ProgramFKs).ToList().Count < 1) { //Generate the Excel file to a byte array byte[] excel = Utilities.GenerateNCPMIExcelFile(programFKs, schoolYear); //Only continue if the byte array is not null if (excel != null) { //Download the file to the user Response.Clear(); Response.ContentType = "application/vnd.ms-excel.sheet.macroEnabled.12"; Response.AddHeader("content-disposition", string.Format("attachment;filename={0};", "BehaviorIncidentReport.xlsm")); Response.BinaryWrite(excel); Response.Flush(); Response.SuppressContent = true; HttpContext.Current.ApplicationInstance.CompleteRequest(); } } } } catch (Exception ex) { //Log any exceptions Utilities.LogException(ex); } }
protected void Page_Load(object sender, EventArgs e) { //Get the current program role currentProgramRole = Utilities.GetProgramRoleFromSession(Session); //-------- This page uses a SqlDataSource configured in both the .aspx file and this file to populate the gridview --------- //Set the values for the sql data source sqlUserFileUploadDataSource.ConnectionString = ConfigurationManager.ConnectionStrings["Pyramid"].ConnectionString; sqlUserFileUploadDataSource.SelectParameters["ProgramFKs"].DefaultValue = string.Join(",", currentProgramRole.ProgramFKs); sqlUserFileUploadDataSource.SelectParameters["HubFK"].DefaultValue = currentProgramRole.HubFK.Value.ToString(); sqlUserFileUploadDataSource.SelectParameters["StateFK"].DefaultValue = currentProgramRole.StateFK.Value.ToString(); sqlUserFileUploadDataSource.SelectParameters["CohortFKs"].DefaultValue = string.Join(",", currentProgramRole.CohortFKs); if (!IsPostBack) { //Set the view only value if (currentProgramRole.AllowedToEdit.Value || currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.HUB_DATA_VIEWER) { hfViewOnly.Value = "False"; } else { hfViewOnly.Value = "True"; } //Bind the dropdowns BindDropDowns(); //Check for messages in the query string string messageType = Request.QueryString["messageType"]; //Show the message if it exists if (!String.IsNullOrWhiteSpace(messageType)) { switch (messageType) { case "UploadSuccess": msgSys.ShowMessageToUser("success", "Success", "File successfully uploaded!", 10000); break; default: break; } } } }
protected void Page_Load(object sender, EventArgs e) { //Attempt to get the role from session programRole = Utilities.GetProgramRoleFromSession(Session); if (!IsPostBack) { //Show/hide the test site message divTestSiteMessage.Visible = Utilities.IsTestSite(); //Set the labels' text to the user's role values lblUserProgram.Text = programRole.ProgramName; lblUserRole.Text = programRole.RoleName; //Set the disclaimer ltlStateDisclaimer.Text = programRole.StateDisclaimer; //Set the logo bsImgLogo.ImageUrl = "/Content/images/" + programRole.StateLogoFileName; //Set the application title label lblApplicationTitle.Text = Utilities.GetApplicationTitle(programRole); } //Prevent non-admins from accessing the admin menu and error log if (programRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.SUPER_ADMIN) { //Show the admin menu and error log link liAdminMenu.Visible = true; lnkErrorLog.Visible = true; lnkReportCatalogMaintenance.Visible = true; lnkReportDesigner.Visible = true; } else if (programRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.APPLICATION_ADMIN) { //Show the admin menu and hide the error log link liAdminMenu.Visible = true; } else { liAdminMenu.Visible = false; lnkErrorLog.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { //Hide the master page title ((Dashboard)this.Master).HideTitle(); //Check to see if there are any messages if (Request.QueryString["messageType"] != null) { //Get the message type string messageType = Request.QueryString["messageType"].ToString(); //Get the message to display switch (messageType) { case "TwoFactorVerified": msgSys.ShowMessageToUser("success", "Two-Factor Code Verified", "Your Two-Factor code was successfully verified!", 5000); break; } } //Show or hide the fireworks ShowHideFireworks(); } //Get the user's current program role currentProgramRole = Utilities.GetProgramRoleFromSession(Session); DateTime lastMonth = DateTime.Now.AddDays(-30); BindNews(lastMonth); //Set the logo bsImgLargeLogo.ImageUrl = "/Content/images/" + (currentProgramRole.StateLogoFileName == null ? "GenericLogo.png" : currentProgramRole.StateLogoFileName); }
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(); } }
/// <summary> /// This method fires when the user selects a role /// </summary> /// <param name="sender">The lbSelectRole LinkButton</param> /// <param name="e">The Click event</param> protected void lbSelectRole_Click(object sender, EventArgs e) { //Get the calling button LinkButton deleteButton = (LinkButton)sender; //Get the specific repeater item that holds the button RepeaterItem item = (RepeaterItem)deleteButton.Parent; //Get the hidden fields for this role HiddenField hfProgramRoleFK = (HiddenField)item.FindControl("hfProgramRoleFK"); HiddenField hfProgramRoleName = (HiddenField)item.FindControl("hfProgramRoleName"); HiddenField hfProgramRoleAllowedToEdit = (HiddenField)item.FindControl("hfProgramRoleAllowedToEdit"); HiddenField hfProgramFK = (HiddenField)item.FindControl("hfProgramFK"); HiddenField hfProgramName = (HiddenField)item.FindControl("hfProgramName"); //To hold the role information ProgramAndRoleFromSession roleInfo = new ProgramAndRoleFromSession(); //Set the session variables for the program roles roleInfo.RoleFK = Convert.ToInt32(hfProgramRoleFK.Value); roleInfo.RoleName = hfProgramRoleName.Value; roleInfo.AllowedToEdit = Convert.ToBoolean(hfProgramRoleAllowedToEdit.Value); roleInfo.CurrentProgramFK = Convert.ToInt32(hfProgramFK.Value); roleInfo.ProgramName = hfProgramName.Value; //Get the hub and state information using (PyramidContext context = new PyramidContext()) { Program currentProgram = context.Program .Include(p => p.Hub) .Include(p => p.State) .Where(p => p.ProgramPK == roleInfo.CurrentProgramFK.Value).FirstOrDefault(); roleInfo.HubFK = currentProgram.HubFK; roleInfo.HubName = currentProgram.Hub.Name; roleInfo.StateFK = currentProgram.StateFK; roleInfo.StateName = currentProgram.State.Name; roleInfo.StateLogoFileName = currentProgram.State.LogoFilename; roleInfo.StateCatchphrase = currentProgram.State.Catchphrase; roleInfo.StateDisclaimer = currentProgram.State.Disclaimer; //Set the allowed program fks if (roleInfo.RoleFK == (int)Utilities.ProgramRoleFKs.HUB_DATA_VIEWER) { //Hub viewer, allow them to see the programs in that hub var hubPrograms = context.Program.AsNoTracking() .Where(p => p.HubFK == roleInfo.HubFK.Value) .ToList(); roleInfo.ProgramFKs = hubPrograms .Select(hp => hp.ProgramPK) .ToList(); //Allow them to see all cohorts in their hub roleInfo.CohortFKs = hubPrograms .Select(hp => hp.CohortFK) .Distinct() .ToList(); //Don't restrict their view of the BOQs roleInfo.ShowBOQ = true; roleInfo.ShowBOQFCC = true; } else if (roleInfo.RoleFK == (int)Utilities.ProgramRoleFKs.APPLICATION_ADMIN) { //App admin, allow them to see all programs in a state roleInfo.ProgramFKs = context.Program.AsNoTracking() .Where(p => p.StateFK == roleInfo.StateFK.Value) .Select(p => p.ProgramPK).ToList(); //Allow them to see all cohorts in a state roleInfo.CohortFKs = context.Cohort.AsNoTracking() .Where(c => c.StateFK == roleInfo.StateFK.Value) .Select(c => c.CohortPK).ToList(); //Don't restrict their view of the BOQs roleInfo.ShowBOQ = true; roleInfo.ShowBOQFCC = true; } else if (roleInfo.RoleFK == (int)Utilities.ProgramRoleFKs.SUPER_ADMIN) { //Super admin, all programs in all states roleInfo.ProgramFKs = context.Program.AsNoTracking() .Select(p => p.ProgramPK).ToList(); //All cohorts roleInfo.CohortFKs = context.Cohort.AsNoTracking() .Select(c => c.CohortPK).ToList(); //Don't restrict their view of the BOQs roleInfo.ShowBOQ = true; roleInfo.ShowBOQFCC = true; } else { //Something else, limit to the current program fk List <int> programFKs = new List <int>(); programFKs.Add(roleInfo.CurrentProgramFK.Value); roleInfo.ProgramFKs = programFKs; //Limit to current cohort fk List <int> cohortFKs = new List <int>(); cohortFKs.Add(currentProgram.CohortFK); roleInfo.CohortFKs = cohortFKs; //Determine if this program is a FCC program var fccProgramTypes = currentProgram.ProgramType .Where(pt => pt.TypeCodeFK == (int)Utilities.ProgramTypeFKs.FAMILY_CHILD_CARE || pt.TypeCodeFK == (int)Utilities.ProgramTypeFKs.GROUP_FAMILY_CHILD_CARE) .ToList(); //Limit their view to the right BOQ type if (fccProgramTypes.Count > 0) { roleInfo.ShowBOQ = false; roleInfo.ShowBOQFCC = true; } else { roleInfo.ShowBOQ = true; roleInfo.ShowBOQFCC = false; } } } //Add the role information to the session Utilities.SetProgramRoleInSession(Session, roleInfo); //Record the role and program in the login history if a record for the login exists if (Session["LoginHistoryPK"] != null && !String.IsNullOrWhiteSpace(Session["LoginHistoryPK"].ToString())) { //Get the login history pk from session int historyPK = Convert.ToInt32(Session["LoginHistoryPK"].ToString()); //Add the record to the database with the logout time using (PyramidContext context = new PyramidContext()) { LoginHistory history = context.LoginHistory.Find(historyPK); history.ProgramFK = Convert.ToInt32(hfProgramFK.Value); history.Role = hfProgramRoleName.Value; context.SaveChanges(); } } //Redirect the user after the role selection if (String.IsNullOrWhiteSpace(Request.QueryString["ReturnUrl"])) { Response.Redirect("/Default.aspx"); } else { IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response); } }
/// <summary> /// This method fires when the user clicks the Login button and it attempts to log /// the user in /// </summary> /// <param name="sender">The btnLogin DevExpress button</param> /// <param name="e">The Click event</param> protected void btnLogin_Click(object sender, EventArgs e) { if (ASPxEdit.AreEditorsValid(this, btnLogin.ValidationGroup)) { // Validate the user password var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>(); var signinManager = Context.GetOwinContext().GetUserManager <ApplicationSignInManager>(); //Try to get the user PyramidUser user = manager.FindByName(txtUsername.Text); //Make sure that the user is confirmed if (user != null && manager.IsEmailConfirmed(user.Id)) { //Try to sign the user in var result = signinManager.PasswordSignIn(txtUsername.Text, txtPassword.Text, false, user.LockoutEnabled); switch (result) { case SignInStatus.Success: //The user successfully logged in List <UserProgramRole> userProgramRoles; List <spGetUserCustomizationOptions_Result> userCustomizationOptions; using (PyramidContext context = new PyramidContext()) { //Get the user's program roles userProgramRoles = context.UserProgramRole.AsNoTracking() .Include(upr => upr.CodeProgramRole) .Include(upr => upr.Program) .Where(upr => upr.Username == txtUsername.Text).ToList(); //Get the user's customization options userCustomizationOptions = context.spGetUserCustomizationOptions(txtUsername.Text).ToList(); //Keep a record of successful logins LoginHistory history = new LoginHistory(); history.Username = txtUsername.Text; history.LoginTime = DateTime.Now; //If the user only has one program role, record it in the login history if (userProgramRoles.Count == 1) { history.ProgramFK = userProgramRoles.First().ProgramFK; history.Role = userProgramRoles.First().CodeProgramRole.RoleName; } //Save the login history context.LoginHistory.Add(history); context.SaveChanges(); //Save the LoginHistory primary key to the session for later access Session["LoginHistoryPK"] = history.LoginHistoryPK; } //Set the user customization options cookie Utilities.SetCustomizationOptionCookie(userCustomizationOptions); //Redirect the user based on the number of roles they have if (userProgramRoles.Count > 1) { Response.Redirect(String.Format("/Account/SelectRole.aspx?ReturnUrl={0}", (Request.QueryString["ReturnUrl"] != null ? Request.QueryString["ReturnUrl"].ToString() : "/Default.aspx"))); } else { //To hold the role information ProgramAndRoleFromSession roleInfo = new ProgramAndRoleFromSession(); //Get the UserProgramRole UserProgramRole userRole = userProgramRoles.FirstOrDefault(); //Set the session variables for the program roles roleInfo.RoleFK = userRole.CodeProgramRole.CodeProgramRolePK; roleInfo.RoleName = userRole.CodeProgramRole.RoleName; roleInfo.AllowedToEdit = userRole.CodeProgramRole.AllowedToEdit; roleInfo.CurrentProgramFK = userRole.ProgramFK; roleInfo.ProgramName = userRole.Program.ProgramName; //Get the hub and state information using (PyramidContext context = new PyramidContext()) { Program currentProgram = context.Program.AsNoTracking() .Include(p => p.Hub) .Include(p => p.State) .Include(p => p.ProgramType) .Where(p => p.ProgramPK == userRole.ProgramFK).FirstOrDefault(); roleInfo.HubFK = currentProgram.HubFK; roleInfo.HubName = currentProgram.Hub.Name; roleInfo.StateFK = currentProgram.StateFK; roleInfo.StateName = currentProgram.State.Name; roleInfo.StateLogoFileName = currentProgram.State.LogoFilename; roleInfo.StateCatchphrase = currentProgram.State.Catchphrase; roleInfo.StateDisclaimer = currentProgram.State.Disclaimer; //Set the allowed program fks if (roleInfo.RoleFK == (int)Utilities.ProgramRoleFKs.HUB_DATA_VIEWER) { //Hub viewer, allow them to see the programs in that hub var hubPrograms = context.Program.AsNoTracking() .Where(p => p.HubFK == roleInfo.HubFK.Value) .ToList(); roleInfo.ProgramFKs = hubPrograms .Select(hp => hp.ProgramPK) .ToList(); //Allow them to see all cohorts in their hub roleInfo.CohortFKs = hubPrograms .Select(hp => hp.CohortFK) .Distinct() .ToList(); //Don't restrict their view of the BOQs roleInfo.ShowBOQ = true; roleInfo.ShowBOQFCC = true; } else if (roleInfo.RoleFK == (int)Utilities.ProgramRoleFKs.APPLICATION_ADMIN) { //App admin, allow them to see all programs in a state roleInfo.ProgramFKs = context.Program.AsNoTracking() .Where(p => p.StateFK == roleInfo.StateFK.Value) .Select(p => p.ProgramPK).ToList(); //Allow them to see all cohorts in a state roleInfo.CohortFKs = context.Cohort.AsNoTracking() .Where(c => c.StateFK == roleInfo.StateFK.Value) .Select(c => c.CohortPK).ToList(); //Don't restrict their view of the BOQs roleInfo.ShowBOQ = true; roleInfo.ShowBOQFCC = true; } else if (roleInfo.RoleFK == (int)Utilities.ProgramRoleFKs.SUPER_ADMIN) { //Super admin, all programs in all states roleInfo.ProgramFKs = context.Program.AsNoTracking() .Select(p => p.ProgramPK).ToList(); //All cohorts roleInfo.CohortFKs = context.Cohort.AsNoTracking() .Select(c => c.CohortPK).ToList(); //Don't restrict their view of the BOQs roleInfo.ShowBOQ = true; roleInfo.ShowBOQFCC = true; } else { //Something else, limit to the current program fk List <int> programFKs = new List <int>(); programFKs.Add(roleInfo.CurrentProgramFK.Value); roleInfo.ProgramFKs = programFKs; //Limit to current cohort fk List <int> cohortFKs = new List <int>(); cohortFKs.Add(currentProgram.CohortFK); roleInfo.CohortFKs = cohortFKs; //Determine if this program is a FCC program var fccProgramTypes = currentProgram.ProgramType .Where(pt => pt.TypeCodeFK == (int)Utilities.ProgramTypeFKs.FAMILY_CHILD_CARE || pt.TypeCodeFK == (int)Utilities.ProgramTypeFKs.GROUP_FAMILY_CHILD_CARE) .ToList(); //Limit their view to the right BOQ type if (fccProgramTypes.Count > 0) { roleInfo.ShowBOQ = false; roleInfo.ShowBOQFCC = true; } else { roleInfo.ShowBOQ = true; roleInfo.ShowBOQFCC = false; } } } //Add the role information to the session Utilities.SetProgramRoleInSession(Session, roleInfo); //Redirect the user Response.Redirect(Request.QueryString["ReturnUrl"] != null ? Request.QueryString["ReturnUrl"].ToString() : "/Default.aspx"); } break; case SignInStatus.LockedOut: Response.Redirect("/Account/Lockout"); break; case SignInStatus.RequiresVerification: Response.Redirect(String.Format("/Account/TwoFactorAuthenticationSignIn?ReturnUrl={0}", Request.QueryString["ReturnUrl"]), true); break; case SignInStatus.Failure: default: //Show the user an error message msgSys.ShowMessageToUser("danger", "Error", "Invalid login attempt", 120000); //Focus the password text box txtPassword.Focus(); break; } } else { msgSys.ShowMessageToUser("danger", "Error", "Invalid login attempt", 120000); } } }
protected void Page_Load(object sender, EventArgs e) { //Get the user's current program role currentProgramRole = Utilities.GetProgramRoleFromSession(Session); //Get the OtherSEScreen PK from the query string if (!string.IsNullOrWhiteSpace(Request.QueryString["OtherSEScreenPK"])) { int.TryParse(Request.QueryString["OtherSEScreenPK"], out currentOtherSEScreenPK); } //Don't allow aggregate viewers into this page if (currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.AGGREGATE_DATA_VIEWER) { Response.Redirect("/Pages/OtherSEScreenDashboard.aspx?messageType=NotAuthorized"); } using (PyramidContext context = new PyramidContext()) { //Get the OtherSEScreen from the database currentOtherSEScreen = context.OtherSEScreen.AsNoTracking() .Include(ose => ose.Program) .Where(ose => ose.OtherSEScreenPK == currentOtherSEScreenPK).FirstOrDefault(); //Check to see if the OtherSEScreen from the database exists if (currentOtherSEScreen == null) { //The OtherSEScreen from the database doesn't exist, set the current OtherSEScreen to a default value currentOtherSEScreen = new Models.OtherSEScreen(); //Set the program label to the current user's program lblProgram.Text = currentProgramRole.ProgramName; } else { //Set the program label to the form's program lblProgram.Text = currentOtherSEScreen.Program.ProgramName; } } //Prevent users from viewing OtherSEScreens from other programs if (currentOtherSEScreen.OtherSEScreenPK > 0 && !currentProgramRole.ProgramFKs.Contains(currentOtherSEScreen.ProgramFK)) { Response.Redirect(string.Format("/Pages/OtherSEScreenDashboard.aspx?messageType={0}", "NOOtherSEScreen")); } //Get the proper program fk currentProgramFK = (currentOtherSEScreen.OtherSEScreenPK > 0 ? currentOtherSEScreen.ProgramFK : currentProgramRole.CurrentProgramFK.Value); //Set the max value for the form date deScreenDate.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 (currentOtherSEScreenPK > 0) { //This is an edit //Populate the page PopulatePage(currentOtherSEScreen); } //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 (currentOtherSEScreen.OtherSEScreenPK == 0 && currentProgramRole.AllowedToEdit.Value) { //Show the submit button submitOtherSEScreen.ShowSubmitButton = true; //Show certain controls hfViewOnly.Value = "False"; //Enable page controls EnableControls(true); //Set the page title lblPageTitle.Text = "Add New Other Social Emotional Screening"; } else if (currentOtherSEScreen.OtherSEScreenPK > 0 && action.ToLower() == "edit" && currentProgramRole.AllowedToEdit.Value) { //Show the submit button submitOtherSEScreen.ShowSubmitButton = true; //Show certain controls hfViewOnly.Value = "False"; //Enable page controls EnableControls(true); //Set the page title lblPageTitle.Text = "Edit Other Social Emotional Screening"; } else { //Hide the submit button submitOtherSEScreen.ShowSubmitButton = false; //Hide certain controls hfViewOnly.Value = "True"; //Disable page controls EnableControls(false); //Set the page title lblPageTitle.Text = "View Other Social Emotional Screening"; } //Set focus on the screen date field deScreenDate.Focus(); } }
protected void Page_Load(object sender, EventArgs e) { //Get the user's current program role currentProgramRole = Utilities.GetProgramRoleFromSession(Session); //Get the BOQ PK from the query string if (!string.IsNullOrWhiteSpace(Request.QueryString["BOQFCCPK"])) { int.TryParse(Request.QueryString["BOQFCCPK"], out BOQFCCPK); } //Don't allow aggregate viewers into this page if (currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.AGGREGATE_DATA_VIEWER) { Response.Redirect("/Pages/BOQFCCDashboard.aspx?messageType=NotAuthorized"); } //Get the BOQ from the database using (PyramidContext context = new PyramidContext()) { //To hold the program information Program program; //Get the BOQ currentBOQFCC = context.BenchmarkOfQualityFCC.AsNoTracking().Where(boqfcc => boqfcc.BenchmarkOfQualityFCCPK == BOQFCCPK).FirstOrDefault(); //If the BOQ is null (this is an add) if (currentBOQFCC == null) { //Set the current BOQ to a blank BOQ currentBOQFCC = new BenchmarkOfQualityFCC(); //Get the program program = context.Program.AsNoTracking().Where(p => p.ProgramPK == currentProgramRole.CurrentProgramFK.Value).FirstOrDefault(); } else { program = context.Program.AsNoTracking().Where(p => p.ProgramPK == currentBOQFCC.ProgramFK).FirstOrDefault(); } //Set the labels lblProgramName.Text = program.ProgramName; lblProgramLocation.Text = program.Location; } //Don't allow users to view BOQs from other programs if (currentBOQFCC.BenchmarkOfQualityFCCPK > 0 && !currentProgramRole.ProgramFKs.Contains(currentBOQFCC.ProgramFK)) { //Redirect the user to the dashboard with an error message Response.Redirect(string.Format("/Pages/BOQFCCDashboard.aspx?messageType={0}", "NoBOQFCC")); } if (!IsPostBack) { //Hide the master page title ((Dashboard)this.Master).HideTitle(); //If this is an edit or view, populate the page with values if (BOQFCCPK != 0) { PopulatePage(currentBOQFCC); } //Get the action 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 (currentBOQFCC.BenchmarkOfQualityFCCPK == 0 && currentProgramRole.AllowedToEdit.Value) { //Show the submit button submitBOQFCC.ShowSubmitButton = true; //Show other controls hfViewOnly.Value = "False"; //Lock the controls EnableControls(true); //Set the page title lblPageTitle.Text = "Add New Benchmarks of Quality FCC Form"; } else if (currentBOQFCC.BenchmarkOfQualityFCCPK > 0 && action.ToLower() == "edit" && currentProgramRole.AllowedToEdit.Value) { //Show the submit button submitBOQFCC.ShowSubmitButton = true; //Show other controls hfViewOnly.Value = "False"; //Lock the controls EnableControls(true); //Set the page title lblPageTitle.Text = "Edit Benchmarks of Quality FCC Form"; } else { //Hide the submit button submitBOQFCC.ShowSubmitButton = false; //Hide other controls hfViewOnly.Value = "True"; //Lock the controls EnableControls(false); //Set the page title lblPageTitle.Text = "View Benchmarks of Quality FCC Form"; } //Set focus to the form date field deFormDate.Focus(); } }
protected void Page_Load(object sender, EventArgs e) { //Get the user's current program role currentProgramRole = Utilities.GetProgramRoleFromSession(Session); //Get the file PK from the query string if (!string.IsNullOrWhiteSpace(Request.QueryString["UserFileUploadPK"])) { int.TryParse(Request.QueryString["UserFileUploadPK"], out filePK); } else if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportCatalogPK"])) { int.TryParse(Request.QueryString["ReportCatalogPK"], out reportCatalogPK); } //Get the file information from the database if (filePK > 0) { using (PyramidContext context = new PyramidContext()) { //Get the file record currentFile = context.UserFileUpload.AsNoTracking() .Where(ufu => ufu.UserFileUploadPK == filePK) .FirstOrDefault(); //Check to see if the file record exists if (currentFile == null) { //The file record doesn't exist, set to a default currentFile = new UserFileUpload(); } } } else { currentFile = new UserFileUpload(); } if (reportCatalogPK > 0) { using (PyramidContext context = new PyramidContext()) { //Get the report catalog record currentReportCatalog = context.ReportCatalog.AsNoTracking() .Where(rc => rc.ReportCatalogPK == reportCatalogPK) .FirstOrDefault(); //Check to see if the report catalog record exists if (currentReportCatalog == null) { //The report catalog record doesn't exist, set to a default currentReportCatalog = new ReportCatalog(); } } } else { currentReportCatalog = new ReportCatalog(); } //Don't allow users to view files from other programs if (currentFile.UserFileUploadPK > 0) { if (currentFile.TypeCodeFK == (int)Utilities.FileTypeFKs.STATE_WIDE && currentProgramRole.StateFK.Value != currentFile.StateFK.Value) { //This is a state-wide file and the user is not logged in under that state lblMessage.Text = "No file found..."; } else if (currentFile.TypeCodeFK == (int)Utilities.FileTypeFKs.HUB_WIDE && currentProgramRole.HubFK.Value != currentFile.HubFK.Value) { //This is a hub-wide file and the user is not logged in under that hub lblMessage.Text = "No file found..."; } else if (currentFile.TypeCodeFK == (int)Utilities.FileTypeFKs.PROGRAM_WIDE && !currentProgramRole.ProgramFKs.Contains(currentFile.ProgramFK.Value)) { //This is a program-wide file and the user is not allowed to see that cohort lblMessage.Text = "No file found..."; } else if (currentFile.TypeCodeFK == (int)Utilities.FileTypeFKs.COHORT_WIDE && !currentProgramRole.CohortFKs.Contains(currentFile.CohortFK.Value)) { //This is a cohort-wide file and the user is not allowed to see that cohort lblMessage.Text = "No file found..."; } else { //Get the file URL from Azure storage string fileLink = Utilities.GetFileLinkFromAzureStorage(currentFile.FileName, currentFile.FileName.Contains(".pdf"), Utilities.ConstantAzureStorageContainerName.UPLOADED_FILES.ToString()); //Redirect the user to the file link Response.Redirect(fileLink); } } else if (!string.IsNullOrWhiteSpace(currentReportCatalog.DocumentationLink)) { //Get the file path string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/'); string filePath = currentReportCatalog.DocumentationLink.Replace("~", baseUrl); //Redirect the user to the file link Response.Redirect(filePath); } else { lblMessage.Text = "No file found..."; } }
protected void Page_Load(object sender, EventArgs e) { //Get the user's current program role currentProgramRole = Utilities.GetProgramRoleFromSession(Session); //Get the News Entry PK from the query string if (!string.IsNullOrWhiteSpace(Request.QueryString["NewsEntryPK"])) { int.TryParse(Request.QueryString["NewsEntryPK"], out currentNewsEntryPK); } using (PyramidContext context = new PyramidContext()) { //Get the News Entry from the database currentNewsEntry = context.NewsEntry.AsNoTracking() .Include(ne => ne.CodeNewsEntryType) .Where(ne => ne.NewsEntryPK == currentNewsEntryPK).FirstOrDefault(); //Check to see if the News Entry from the database exists if (currentNewsEntry == null) { //The NewsEntry from the database doesn't exist, set the current News Entry to a default value currentNewsEntry = new Models.NewsEntry(); } } //Prevent users from viewing entries from other programs if (currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.DATA_COLLECTOR || (currentNewsEntry.NewsEntryPK > 0 && ((currentNewsEntry.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.PROGRAM_WIDE && !currentProgramRole.ProgramFKs.Contains(currentNewsEntry.ProgramFK.Value)) || (currentNewsEntry.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.STATE_WIDE && currentProgramRole.StateFK.Value != currentNewsEntry.StateFK.Value) || (currentNewsEntry.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.HUB_WIDE && currentProgramRole.HubFK.Value != currentNewsEntry.HubFK.Value) || (currentNewsEntry.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.COHORT_WIDE && !currentProgramRole.CohortFKs.Contains(currentNewsEntry.CohortFK.Value)) || !currentNewsEntry.CodeNewsEntryType.RolesAuthorizedToModify.Contains(currentProgramRole.RoleFK.Value.ToString() + ",")))) { Response.Redirect(string.Format("/Pages/News.aspx?messageType={0}", "NotAuthorized")); } //Show certain divs based on whether this is an add or edit if (currentNewsEntryPK > 0) { divAddOnlyMessage.Visible = false; divEditOnly.Visible = true; } else { divAddOnlyMessage.Visible = true; divEditOnly.Visible = false; } //Show the edit only div if this is an edit divEditOnly.Visible = (currentNewsEntryPK > 0 ? true : false); if (!IsPostBack) { //Hide the master page title ((LoggedIn)this.Master).HideTitle(); //Bind the data bound controls BindDataBoundControls(); //Check to see if this is an edit if (currentNewsEntryPK > 0) { //This is an edit //Populate the page PopulatePage(currentNewsEntry); } //Get the action from the query string string action; if (Request.QueryString["action"] != null) { action = Request.QueryString["action"]; } else { action = "View"; } //Check for messages in the query string string messageType = Request.QueryString["messageType"]; //Show the message if it exists if (!string.IsNullOrWhiteSpace(messageType)) { switch (messageType) { case "NewsEntryAdded": msgSys.ShowMessageToUser("success", "Success", "News entry successfully added!<br/><br/>Specific items can now be added.", 10000); break; case "NotAuthorized": msgSys.ShowMessageToUser("danger", "Not Authorized", "You are not authorized to view that information!", 10000); break; default: break; } } //Allow adding/editing depending on the user's role and the action if (currentNewsEntry.NewsEntryPK == 0 && (currentProgramRole.AllowedToEdit.Value || currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.HUB_DATA_VIEWER)) { //Show the submit button submitNewsEntry.ShowSubmitButton = true; //Show certain controls hfViewOnly.Value = "False"; //Enable page controls EnableControls(true); //Set the page title lblPageTitle.Text = "Add New News Entry"; } else if (currentNewsEntry.NewsEntryPK > 0 && action.ToLower() == "edit" && (currentProgramRole.AllowedToEdit.Value || currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.HUB_DATA_VIEWER)) { //Show the submit button submitNewsEntry.ShowSubmitButton = true; //Show certain controls hfViewOnly.Value = "False"; //Enable page controls EnableControls(true); //Set the page title lblPageTitle.Text = "Edit News Entry"; } else { //Hide the submit button submitNewsEntry.ShowSubmitButton = false; //Hide certain controls hfViewOnly.Value = "True"; //Disable page controls EnableControls(false); //Set the page title lblPageTitle.Text = "View News Entry"; } //Set the focus to the news entry date field deEntryDate.Focus(); } }
protected void Page_Load(object sender, EventArgs e) { //Get the current program role currentProgramRole = Utilities.GetProgramRoleFromSession(Session); //Get the user manager manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>(); //Get the user id from the query string string id = Request.QueryString["Id"]; //Get the user object currentUser = manager.FindById(id); //Make sure the user exists if (currentUser == null) { Response.Redirect("/Admin/UserManagement.aspx?message=UserNotFound"); } if (!IsPostBack) { using (PyramidContext context = new PyramidContext()) { //Show the user's program roles BindUserProgramRoles(context, currentUser); //Get the program list var programs = context.Program.AsNoTracking().Include(p => p.Hub).OrderBy(p => p.ProgramName).Select(p => new { p.ProgramPK, ProgramName = p.ProgramName + " (" + p.Hub.Name + ")" }).ToList(); ddProgram.DataSource = programs; ddProgram.DataBind(); //Get the program role list, limited to the roles the user is allowed to add var programRoles = context.CodeProgramRole.AsNoTracking() .Where(cpr => cpr.RolesAuthorizedToModify.Contains((currentProgramRole.RoleFK.Value.ToString() + ","))) .OrderBy(cpr => cpr.RoleName) .ToList(); ddProgramRole.DataSource = programRoles; ddProgramRole.DataBind(); } //Get the identity roles var identityRoles = appContext.Roles.OrderBy(r => r.Name).ToList(); //Remove the guest role because it is not implemented in any way IdentityRole guestRole = identityRoles.Where(ir => ir.Name == "Guest").FirstOrDefault(); if (guestRole != null) { identityRoles.Remove(guestRole); } //Only allow super admins and application admins who are editing themselves to see the Admin identity role if (currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.SUPER_ADMIN || (currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.APPLICATION_ADMIN && User.Identity.Name == currentUser.UserName)) { //Do not remove the Admin identity role } else { //Remove the Admin identity role IdentityRole adminRole = identityRoles.Where(ir => ir.Name == "Admin").FirstOrDefault(); identityRoles.Remove(adminRole); } //Bind the identity role dropdown ddIdentityRole.DataSource = identityRoles; ddIdentityRole.DataBind(); //If the user exists, fill the form txtFirstName.Value = currentUser.FirstName; txtLastName.Value = currentUser.LastName; txtEmail.Value = currentUser.Email; txtPhoneNumber.Value = currentUser.PhoneNumber; deLockoutEndDate.Value = (currentUser.LockoutEndDateUtc.HasValue ? currentUser.LockoutEndDateUtc.Value.ToString("MM/dd/yyyy") : ""); ddIdentityRole.SelectedItem = ddIdentityRole.Items.FindByValue(currentUser.Roles.FirstOrDefault().RoleId); //Set focus to the first name field txtFirstName.Focus(); } }
protected void Page_Load(object sender, EventArgs e) { //Get the current program role currentProgramRole = Utilities.GetProgramRoleFromSession(Session); //Don't allow aggregate viewers to see the action column if (currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.AGGREGATE_DATA_VIEWER) { //Get the action column index (the farthest right column) int actionColumnIndex = (bsGRTPITOS.Columns.Count - 1); //Hide the action column bsGRTPITOS.Columns[actionColumnIndex].Visible = false; } if (!IsPostBack) { //Set the view only value if (currentProgramRole.AllowedToEdit.Value) { hfViewOnly.Value = "False"; } else { hfViewOnly.Value = "True"; } //Check for messages in the query string string messageType = Request.QueryString["messageType"]; //Show the message if it exists if (!string.IsNullOrWhiteSpace(messageType)) { switch (messageType) { case "TPITOSAdded": msgSys.ShowMessageToUser("success", "Success", "TPITOS observation successfully added!", 10000); break; case "TPITOSEdited": msgSys.ShowMessageToUser("success", "Success", "TPITOS observation successfully edited!", 10000); break; case "TPITOSCanceled": msgSys.ShowMessageToUser("info", "Canceled", "The action was canceled, no changes were saved.", 10000); break; case "NOTPITOS": msgSys.ShowMessageToUser("warning", "Warning", "The specified TPITOS observation could not be found, please try again.", 15000); break; case "NotAuthorized": msgSys.ShowMessageToUser("danger", "Not Authorized", "You are not authorized to view that information!", 10000); break; default: break; } } } }
protected void Page_Load(object sender, EventArgs e) { //Get the current program role currentProgramRole = Utilities.GetProgramRoleFromSession(Session); if (!IsPostBack) { //Set the view only value if ((currentProgramRole.AllowedToEdit.Value && currentProgramRole.RoleFK.Value != (int)Utilities.ProgramRoleFKs.DATA_COLLECTOR) || currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.HUB_DATA_VIEWER) { hfViewOnly.Value = "False"; } else { hfViewOnly.Value = "True"; } //Check for messages in the query string string messageType = Request.QueryString["messageType"]; //Show the message if it exists if (!string.IsNullOrWhiteSpace(messageType)) { switch (messageType) { case "NewsEntryAdded": msgSys.ShowMessageToUser("success", "Success", "News entry successfully added!", 10000); break; case "NewsEntryEdited": msgSys.ShowMessageToUser("success", "Success", "News entry successfully edited!", 10000); break; case "NewsEntryCanceled": msgSys.ShowMessageToUser("info", "Canceled", "The action was canceled, no changes were saved.", 10000); break; case "NoNewsEntry": msgSys.ShowMessageToUser("warning", "Warning", "The specified news entry could not be found, please try again.", 15000); break; case "NotAuthorized": msgSys.ShowMessageToUser("danger", "Not Authorized", "You are not authorized to view that information!", 10000); break; default: break; } } //Bind the databound controls BindDataBoundControls(); //Pre-fill the limit date deLimitDate.Value = DateTime.Now.AddDays(-30); //Bind the news BindNews(); } }
protected void Page_Load(object sender, EventArgs e) { //Get the user's current program role currentProgramRole = Utilities.GetProgramRoleFromSession(Session); //Only allow super admins if (currentProgramRole.RoleFK.Value != (int)Utilities.ProgramRoleFKs.SUPER_ADMIN) { Response.Redirect("/Default.aspx"); } //Get the CoachingLog PK from the query string if (!string.IsNullOrWhiteSpace(Request.QueryString["ReportCatalogPK"])) { int.TryParse(Request.QueryString["ReportCatalogPK"], out currentReportCatalogPK); } using (PyramidContext context = new PyramidContext()) { //Get the Report Catalog item from the database currentReportCatalog = context.ReportCatalog.AsNoTracking().Where(rc => rc.ReportCatalogPK == currentReportCatalogPK).FirstOrDefault(); //Check to see if the Report Catalog item from the database exists if (currentReportCatalog == null) { //The Report Catalog item from the database doesn't exist, set the current Report Catalog item to a default value currentReportCatalog = new Models.ReportCatalog(); } } if (!IsPostBack) { //Hide the master page title ((LoggedIn)this.Master).HideTitle(); //Bind the databound controls BindDataBoundControls(); //Check to see if this is an edit or view if (currentReportCatalogPK > 0) { //This is an edit or view //Populate the page PopulatePage(currentReportCatalog); } //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 (currentReportCatalog.ReportCatalogPK == 0 && currentProgramRole.AllowedToEdit.Value) { //Show the submit button submitReportCatalogItem.ShowSubmitButton = true; //Show certain controls hfViewOnly.Value = "False"; //Enable page controls EnableControls(true); //Set the page title lblPageTitle.Text = "Add New Report Catalog Item"; } else if (currentReportCatalog.ReportCatalogPK > 0 && action.ToLower() == "edit" && currentProgramRole.AllowedToEdit.Value) { //Show the submit button submitReportCatalogItem.ShowSubmitButton = true; //Show certain controls hfViewOnly.Value = "False"; //Enable page controls EnableControls(true); //Set the page title lblPageTitle.Text = "Edit Report Catalog Item"; } else { //Hide the submit button submitReportCatalogItem.ShowSubmitButton = false; //Hide certain controls hfViewOnly.Value = "True"; //Disable page controls EnableControls(false); //Set the page title lblPageTitle.Text = "View Report Catalog Item"; } //Set the focus to the report name field txtReportName.Focus(); } }
protected void Page_Load(object sender, EventArgs e) { //Get the user's current program role currentProgramRole = Utilities.GetProgramRoleFromSession(Session); //Don't allow aggregate viewers into this page if (currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.AGGREGATE_DATA_VIEWER) { Response.Redirect("/Pages/BehaviorIncidentDashboard.aspx?messageType=NotAuthorized"); } //Get the BehaviorIncident PK from the query string if (!string.IsNullOrWhiteSpace(Request.QueryString["BehaviorIncidentPK"])) { int.TryParse(Request.QueryString["BehaviorIncidentPK"], out behaviorIncidentPK); } //Get the Behavior Incident from the database using (PyramidContext context = new PyramidContext()) { //Get the Behavior Incident currentBehaviorIncident = context.BehaviorIncident .AsNoTracking() .Include(bi => bi.Classroom) .Include(bi => bi.Classroom.Program) .Where(bi => bi.BehaviorIncidentPK == behaviorIncidentPK) .FirstOrDefault(); //If the Behavior Incident is null (this is an add) if (currentBehaviorIncident == null) { //Set the current Behavior Incident to a blank Behavior Incident currentBehaviorIncident = new Models.BehaviorIncident(); //Set the program label to the current user's program lblProgram.Text = currentProgramRole.ProgramName; } else { //Set the program label to the form's program lblProgram.Text = currentBehaviorIncident.Classroom.Program.ProgramName; } } //Don't allow users to view Behavior Incidents from other programs if (currentBehaviorIncident.BehaviorIncidentPK > 0 && !currentProgramRole.ProgramFKs.Contains(currentBehaviorIncident.Classroom.ProgramFK)) { //Redirect the user to the dashboard with an error message Response.Redirect(string.Format("/Pages/BehaviorIncidentDashboard.aspx?messageType={0}", "NoBehaviorIncident")); } //Get the proper program fk programFK = (currentBehaviorIncident.BehaviorIncidentPK > 0 ? currentBehaviorIncident.Classroom.ProgramFK : currentProgramRole.CurrentProgramFK.Value); //Set the max value for the incident datetime date edit deIncidentDatetime.MaxDate = DateTime.Now; if (!IsPostBack) { //Hide the master page title ((Dashboard)this.Master).HideTitle(); //Bind the dropdowns BindDropDowns(); //If this is an edit or view, populate the page with values if (behaviorIncidentPK != 0) { PopulatePage(currentBehaviorIncident); } else { ddChild.ReadOnly = true; } //Get the action 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 (currentBehaviorIncident.BehaviorIncidentPK == 0 && currentProgramRole.AllowedToEdit.Value) { //Show the submit button submitBehaviorIncident.ShowSubmitButton = true; //Show other controls hfViewOnly.Value = "False"; //Lock the controls EnableControls(true); //Set the page title lblPageTitle.Text = "Add New Behavior Incident Report"; } else if (currentBehaviorIncident.BehaviorIncidentPK > 0 && action.ToLower() == "edit" && currentProgramRole.AllowedToEdit.Value) { //Show the submit button submitBehaviorIncident.ShowSubmitButton = true; //Show other controls hfViewOnly.Value = "False"; //Lock the controls EnableControls(true); //Set the page title lblPageTitle.Text = "Edit Behavior Incident Report"; } else { //Hide the submit button submitBehaviorIncident.ShowSubmitButton = false; //Hide other controls hfViewOnly.Value = "True"; //Lock the controls EnableControls(false); //Set the page title lblPageTitle.Text = "View Behavior Incident Report"; } //Set focus on the incident datetime field deIncidentDatetime.Focus(); } }