Пример #1
0
        /// <summary>
        /// This method executes when the user clicks the save button for the cohorts
        /// and it saves the cohort information to the database
        /// </summary>
        /// <param name="sender">The submitCohort control</param>
        /// <param name="e">The Click event</param>
        protected void submitCohort_Click(object sender, EventArgs e)
        {
            if (ASPxEdit.AreEditorsValid(this, submitCohort.ValidationGroup))
            {
                //Get the cohort information
                int      cohortPK   = Convert.ToInt32(hfAddEditCohortPK.Value);
                string   cohortName = txtCohortName.Value.ToString();
                DateTime startDate  = Convert.ToDateTime(deCohortStartDate.Value);
                DateTime?endDate    = (String.IsNullOrWhiteSpace(deCohortEndDate.Value.ToString()) ? (DateTime?)null : Convert.ToDateTime(deCohortEndDate.Value));

                using (PyramidContext context = new PyramidContext())
                {
                    Cohort currentCohort;
                    //Check to see if this is an add or an edit
                    if (cohortPK == 0)
                    {
                        //Add
                        currentCohort            = new Cohort();
                        currentCohort.CohortName = cohortName;
                        currentCohort.StartDate  = startDate;
                        currentCohort.EndDate    = endDate;
                        currentCohort.StateFK    = Convert.ToInt32(ddCohortState.Value);
                        currentCohort.CreateDate = DateTime.Now;
                        currentCohort.Creator    = User.Identity.Name;

                        //Save to the database
                        context.Cohort.Add(currentCohort);
                        context.SaveChanges();

                        //Show a success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully added cohort!", 10000);
                    }
                    else
                    {
                        //Edit
                        currentCohort            = context.Cohort.Find(cohortPK);
                        currentCohort.CohortName = cohortName;
                        currentCohort.StartDate  = startDate;
                        currentCohort.EndDate    = endDate;
                        currentCohort.StateFK    = Convert.ToInt32(ddCohortState.Value);
                        currentCohort.EditDate   = DateTime.Now;
                        currentCohort.Editor     = User.Identity.Name;

                        //Save to the database
                        context.SaveChanges();

                        //Show a success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully edited cohort!", 10000);
                    }

                    //Reset the values in the hidden field and hide the div
                    hfAddEditCohortPK.Value  = "0";
                    divAddEditCohort.Visible = false;

                    //Re-bind the cohort controls
                    BindCohorts();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// This method executes when the user clicks the save button for the hubs
        /// and it saves the hub information to the database
        /// </summary>
        /// <param name="sender">The submitHub control</param>
        /// <param name="e">The Click event</param>
        protected void submitHub_Click(object sender, EventArgs e)
        {
            if (ASPxEdit.AreEditorsValid(this, submitHub.ValidationGroup))
            {
                //Get the hub PK and name
                int    hubPK   = Convert.ToInt32(hfAddEditHubPK.Value);
                string hubName = txtHubName.Value.ToString();

                using (PyramidContext context = new PyramidContext())
                {
                    Hub currentHub;
                    //Check to see if this is an add or an edit
                    if (hubPK == 0)
                    {
                        //Add
                        currentHub            = new Hub();
                        currentHub.Name       = hubName;
                        currentHub.StateFK    = Convert.ToInt32(ddHubState.Value);
                        currentHub.CreateDate = DateTime.Now;
                        currentHub.Creator    = User.Identity.Name;

                        //Save to the database
                        context.Hub.Add(currentHub);
                        context.SaveChanges();

                        //Show a success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully added hub!", 10000);
                    }
                    else
                    {
                        //Edit
                        currentHub          = context.Hub.Find(hubPK);
                        currentHub.Name     = hubName;
                        currentHub.StateFK  = Convert.ToInt32(ddHubState.Value);
                        currentHub.EditDate = DateTime.Now;
                        currentHub.Editor   = User.Identity.Name;

                        //Save to the database
                        context.SaveChanges();

                        //Show a success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully edited hub!", 10000);
                    }

                    //Reset the values
                    hfAddEditHubPK.Value  = "0";
                    divAddEditHub.Visible = false;

                    //Bind the hub controls
                    BindHubs();
                }
            }
        }
Пример #3
0
        /// <summary>
        /// This method fires when the user clicks the Save button in the
        /// submitOtherSEScreen user control
        /// </summary>
        /// <param name="sender">The submitOtherSEScreen control</param>
        /// <param name="e">The Click event</param>
        protected void submitOtherSEScreen_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value)
            {
                //To hold the success message type
                string successMessageType = null;

                //Fill the OtherSEScreen fields from the form
                currentOtherSEScreen.ScreenDate       = deScreenDate.Date;
                currentOtherSEScreen.ScreenTypeCodeFK = Convert.ToInt32(ddScreenType.Value);
                currentOtherSEScreen.ChildFK          = Convert.ToInt32(ddChild.Value);
                currentOtherSEScreen.Score            = Convert.ToInt32(txtScore.Value);
                currentOtherSEScreen.ScoreTypeCodeFK  = Convert.ToInt32(ddScoreType.Value);

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

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

                        //Get the existing OtherSEScreen record
                        Models.OtherSEScreen existingASQ = context.OtherSEScreen.Find(currentOtherSEScreen.OtherSEScreenPK);

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

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

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

                        //Add the OtherSEScreen to the database
                        context.OtherSEScreen.Add(currentOtherSEScreen);
                        context.SaveChanges();
                    }

                    //Redirect the user to the OtherSEScreen dashboard
                    Response.Redirect(string.Format("/Pages/OtherSEScreenDashboard.aspx?messageType={0}", successMessageType));
                }
            }
        }
Пример #4
0
        protected void Unnamed_LoggingOut(object sender, LoginCancelEventArgs e)
        {
            //Log the user out
            Context.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);

            //Record the logout if a record for the login existed
            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.LogoutTime = DateTime.Now;
                    history.LogoutType = "User logged out via the logout button on the navbar";
                    context.SaveChanges();
                }
            }

            //Ensure that the user's session is clear
            Session.Abandon();

            //Redirect the user to login page
            Response.Redirect("/Account/Login.aspx?messageType=LogOutSuccess");
        }
Пример #5
0
        /// <summary>
        /// This method executes when the user clicks the delete button for a cohort
        /// and it deletes the cohort information from the database
        /// </summary>
        /// <param name="sender">The lbDeleteCohort LinkButton</param>
        /// <param name="e">The Click event</param>
        protected void lbDeleteCohort_Click(object sender, EventArgs e)
        {
            //Get the PK from the hidden field
            int?rowToRemovePK = (String.IsNullOrWhiteSpace(hfDeleteCohortPK.Value) ? (int?)null : Convert.ToInt32(hfDeleteCohortPK.Value));

            //Remove the role if the PK is not null
            if (rowToRemovePK != null)
            {
                try
                {
                    using (PyramidContext context = new PyramidContext())
                    {
                        //Get the cohort to remove
                        Cohort cohortToRemove = context.Cohort.Where(h => h.CohortPK == rowToRemovePK).FirstOrDefault();
                        context.Cohort.Remove(cohortToRemove);
                        context.SaveChanges();

                        //Rebind the cohort controls
                        BindCohorts();

                        //Show a success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully deleted cohort!", 10000);
                    }
                }
                catch (DbUpdateException dbUpdateEx)
                {
                    //Check if it is a foreign key error
                    if (dbUpdateEx.InnerException?.InnerException is SqlException)
                    {
                        //If it is a foreign key error, display a custom message
                        SqlException sqlEx = (SqlException)dbUpdateEx.InnerException.InnerException;
                        if (sqlEx.Number == 547)
                        {
                            msgSys.ShowMessageToUser("danger", "Error", "Could not delete the cohort, there are related records in the system!<br/><br/>If you do not know what related records exist, please contact tech support via ticket.", 120000);
                        }
                        else
                        {
                            msgSys.ShowMessageToUser("danger", "Error", "An error occurred while deleting the cohort!", 120000);
                        }
                    }
                    else
                    {
                        msgSys.ShowMessageToUser("danger", "Error", "An error occurred while deleting the cohort!", 120000);
                    }

                    //Log the error
                    Elmah.ErrorSignal.FromCurrentContext().Raise(dbUpdateEx);
                }
            }
            else
            {
                msgSys.ShowMessageToUser("danger", "Error", "Could not find the cohort to delete!", 120000);
            }
        }
Пример #6
0
        /// <summary>
        /// This method fires when the user clicks the save button and
        /// it attempts to add a new user to the system with the information
        /// provided on the page
        /// </summary>
        /// <param name="sender">The submitUser control</param>
        /// <param name="e">The Click event</param>
        protected void submitUser_Click(object sender, EventArgs e)
        {
            //Get the user manager
            var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();

            //Create and fill the user object
            PyramidUser newUser = new PyramidUser();

            newUser.FirstName            = txtFirstName.Value.ToString();
            newUser.LastName             = txtLastName.Value.ToString();
            newUser.UserName             = txtUsername.Value.ToString();
            newUser.Email                = txtEmail.Value.ToString();
            newUser.EmailConfirmed       = false;
            newUser.TwoFactorEnabled     = false;
            newUser.PhoneNumber          = (txtPhoneNumber.Value == null ? null : txtPhoneNumber.Value.ToString());
            newUser.PhoneNumberConfirmed = false;

            //Attempt to create the user
            IdentityResult result = manager.Create(newUser, txtPassword.Value.ToString());

            if (result.Succeeded)
            {
                //If the user creation succeeded, send the user an email to confirm their account
                string emailcode   = manager.GenerateEmailConfirmationToken(newUser.Id);
                string callbackUrl = IdentityHelper.GetAccountConfirmationRedirectUrl(emailcode, newUser.Id, Request);
                manager.SendEmail(newUser.Id, "Confirm your account", Utilities.GetEmailHTML(callbackUrl, "Confirm Account", true, "Welcome " + newUser.FirstName + " " + newUser.LastName + "!", "Your user account for the Pyramid Model Implementation Data System was created by an administrator.<br/>Your username for this system is:<br/><br/>" + newUser.UserName + "<br/><br/>Once you confirm your account and create your password, you will be able to start using the system.<br/>To get started, please click the link below.", Request));

                //Add the user to their identity role
                manager.AddToRole(newUser.Id, ddIdentityRole.SelectedItem.Text.ToString());

                //Add the user to their program role
                using (PyramidContext context = new PyramidContext())
                {
                    //Create the UserProgramRole object and fill it
                    UserProgramRole userPrgRole = new UserProgramRole();
                    userPrgRole.CreateDate        = DateTime.Now;
                    userPrgRole.Creator           = User.Identity.Name;
                    userPrgRole.ProgramFK         = Convert.ToInt32(ddProgram.Value);
                    userPrgRole.ProgramRoleCodeFK = Convert.ToInt32(ddProgramRole.Value);
                    userPrgRole.Username          = newUser.UserName;

                    //Add the UserProgramRole to the database and save
                    context.UserProgramRole.Add(userPrgRole);
                    context.SaveChanges();
                }

                //Redirect the user
                Response.Redirect("/Admin/UserManagement?message=CreateUserSuccess");
            }
            else
            {
                msgSys.ShowMessageToUser("danger", "Error", result.Errors.FirstOrDefault(), 120000);
            }
        }
Пример #7
0
        /// <summary>
        /// This method executes when the user clicks the delete button for a news entry
        /// and it deletes the news entry from the database
        /// </summary>
        /// <param name="sender">The lbDeleteNews LinkButton</param>
        /// <param name="e">The Click event</param>
        protected void lbDeleteNews_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value || currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.HUB_DATA_VIEWER)
            {
                //Get the PK from the hidden field
                int?removeNewsPK = String.IsNullOrWhiteSpace(hfDeleteNewsPK.Value) ? (int?)null : Convert.ToInt32(hfDeleteNewsPK.Value);

                if (removeNewsPK.HasValue)
                {
                    using (PyramidContext context = new PyramidContext())
                    {
                        //Get the News to remove
                        var newsEntryToRemove = context.NewsEntry.Where(ne => ne.NewsEntryPK == removeNewsPK).FirstOrDefault();

                        //Ensure the user is allowed to delete this file
                        if (!newsEntryToRemove.CodeNewsEntryType.RolesAuthorizedToModify.Contains((currentProgramRole.RoleFK.Value.ToString() + ",")))
                        {
                            msgSys.ShowMessageToUser("danger", "Delete Failed", "You are not authorized to delete this news entry!", 10000);
                        }
                        else
                        {
                            //Get the item rows to remove
                            var newsItemsToRemove = context.NewsItem.Where(ni => ni.NewsEntryFK == removeNewsPK).ToList();
                            context.NewsItem.RemoveRange(newsItemsToRemove);

                            //Remove the News from the database
                            context.NewsEntry.Remove(newsEntryToRemove);
                            context.SaveChanges();

                            //Show a delete success message
                            msgSys.ShowMessageToUser("success", "Success", "Successfully deleted the news entry!", 1000);
                        }

                        //Bind the news
                        BindNews();
                    }
                }
                else
                {
                    msgSys.ShowMessageToUser("danger", "Error", "Could not find the news entry to delete!", 120000);
                }
            }
            else
            {
                //Not allowed to delete, show a message
                msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000);
            }
        }
Пример #8
0
        /// <summary>
        /// This method executes when the user clicks the delete button for an TPOT
        /// and it deletes the TPOT form from the database
        /// </summary>
        /// <param name="sender">The lbDeleteTPOT LinkButton</param>
        /// <param name="e">The Click event</param>
        protected void lbDeleteTPOT_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value)
            {
                //Get the PK from the hidden field
                int?removeTPOTPK = String.IsNullOrWhiteSpace(hfDeleteTPOTPK.Value) ? (int?)null : Convert.ToInt32(hfDeleteTPOTPK.Value);

                if (removeTPOTPK.HasValue)
                {
                    using (PyramidContext context = new PyramidContext())
                    {
                        //Get the TPOT to remove
                        var TPOTToRemove = context.TPOT.Where(x => x.TPOTPK == removeTPOTPK).FirstOrDefault();

                        //Get the participant rows to remove and remove them
                        var participantsToRemove = context.TPOTParticipant.Where(tp => tp.TPOTFK == removeTPOTPK).ToList();
                        context.TPOTParticipant.RemoveRange(participantsToRemove);

                        //Get the red flag rows to remove and remove them
                        var redFlagsToRemove = context.TPOTRedFlags.Where(trf => trf.TPOTFK == removeTPOTPK).ToList();
                        context.TPOTRedFlags.RemoveRange(redFlagsToRemove);

                        //Get the behavior responses to remove and remove them
                        var behaviorResponsesToRemove = context.TPOTBehaviorResponses.Where(tbr => tbr.TPOTFK == removeTPOTPK).ToList();
                        context.TPOTBehaviorResponses.RemoveRange(behaviorResponsesToRemove);

                        //Remove the TPOT from the database
                        context.TPOT.Remove(TPOTToRemove);
                        context.SaveChanges();

                        //Show a delete success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully deleted the TPOT observation!", 1000);

                        //Bind the gridview
                        bsGRTPOT.DataBind();
                    }
                }
                else
                {
                    msgSys.ShowMessageToUser("danger", "Error", "Could not find the TPOT observation to delete!", 120000);
                }
            }
            else
            {
                //Not allowed to delete, show a message
                msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000);
            }
        }
Пример #9
0
        /// <summary>
        /// This method fires when the user clicks the Remove Role button and
        /// it removes the Program Role from the user
        /// </summary>
        /// <param name="sender">The lbDeleteRole LinkButton</param>
        /// <param name="e">The Click event</param>
        protected void lbDeleteRole_Click(object sender, EventArgs e)
        {
            //Get the calling button
            LinkButton deleteButton = (LinkButton)sender;

            //Get the specific repeater item
            RepeaterItem item = (RepeaterItem)deleteButton.Parent;

            //Get the hidden field with the PK for deletion
            HiddenField hfUserProgramRolePK = (HiddenField)item.FindControl("hfUserProgramRolePK");

            //Get the PK from the hidden field
            int?rowToRemovePK = (String.IsNullOrWhiteSpace(hfUserProgramRolePK.Value) ? (int?)null : Convert.ToInt32(hfUserProgramRolePK.Value));

            //Remove the role if the PK is not null
            if (rowToRemovePK != null)
            {
                using (PyramidContext context = new PyramidContext())
                {
                    //Only remove the role if the user has another role
                    if (context.UserProgramRole.Where(upr => upr.Username == currentUser.UserName).ToList().Count > 1)
                    {
                        //Get the role to remove
                        UserProgramRole roleToRemove = context.UserProgramRole.Where(upr => upr.UserProgramRolePK == rowToRemovePK).FirstOrDefault();
                        context.UserProgramRole.Remove(roleToRemove);
                        context.SaveChanges();

                        //Show the changes
                        BindUserProgramRoles(context, currentUser);

                        //Show a success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully removed user's program role!", 10000);
                    }
                    else
                    {
                        //Show an error message
                        msgSys.ShowMessageToUser("danger", "Error", "You cannot remove a user's only program role!", 120000);
                    }
                }
            }
            else
            {
                msgSys.ShowMessageToUser("danger", "Error", "An error occurred while attempting to remove the role!", 120000);
            }
        }
Пример #10
0
        /// <summary>
        /// This method executes when the user clicks the delete button for an ASQSE
        /// and it deletes the ASQ:SE screening from the database
        /// </summary>
        /// <param name="sender">The lbDeleteASQSE LinkButton</param>
        /// <param name="e">The Click event</param>
        protected void lbDeleteASQSE_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value)
            {
                //Get the PK from the hidden field
                int?removeASQSEPK = String.IsNullOrWhiteSpace(hfDeleteASQSEPK.Value) ? (int?)null : Convert.ToInt32(hfDeleteASQSEPK.Value);

                if (removeASQSEPK.HasValue)
                {
                    using (PyramidContext context = new PyramidContext())
                    {
                        //Get the ASQSE to remove
                        var ASQSEToRemove = context.ASQSE.Where(x => x.ASQSEPK == removeASQSEPK).FirstOrDefault();

                        //Remove the ASQSE from the database
                        context.ASQSE.Remove(ASQSEToRemove);
                        context.SaveChanges();

                        //Show a delete success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully deleted the ASQ:SE screening!", 1000);

                        //Bind the gridview
                        bsGRASQSE.DataBind();

                        //Bind the chart
                        BindScoreTypeChart();
                    }
                }
                else
                {
                    msgSys.ShowMessageToUser("danger", "Error", "Could not find the ASQ:SE screening to delete!", 120000);
                }
            }
            else
            {
                //Not allowed to delete, show a message
                msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000);
            }
        }
Пример #11
0
        /// <summary>
        /// This method fires when the user clicks the Add Role button and
        /// it adds the selected Program Role to the user
        /// </summary>
        /// <param name="sender">The btnAddRole DevExpress Bootstrap button</param>
        /// <param name="e">The Click event</param>
        protected void btnAddRole_Click(object sender, EventArgs e)
        {
            //Only continue if the page is valid
            if (ASPxEdit.AreEditorsValid(this, btnAddRole.ValidationGroup))
            {
                int programRoleFK, programFK;

                //Get the program role fk and program fk
                programRoleFK = Convert.ToInt32(ddProgramRole.Value);
                programFK     = Convert.ToInt32(ddProgram.Value);

                //Create the object and fill it
                UserProgramRole newUpr = new UserProgramRole();
                newUpr.Creator           = User.Identity.Name;
                newUpr.CreateDate        = DateTime.Now;
                newUpr.ProgramFK         = programFK;
                newUpr.Username          = currentUser.UserName;
                newUpr.ProgramRoleCodeFK = programRoleFK;

                //Add the object to the database
                using (PyramidContext context = new PyramidContext())
                {
                    //Add the role
                    context.UserProgramRole.Add(newUpr);
                    context.SaveChanges();

                    //Show the changes
                    BindUserProgramRoles(context, currentUser);
                }

                //Clear the inputs
                ddProgramRole.Value = "";
                ddProgram.Value     = "";

                //Show a success message
                msgSys.ShowMessageToUser("success", "Success", "Successfully added program role to user!", 10000);
            }
        }
Пример #12
0
        /// <summary>
        /// This method fires when the user clicks the delete button for a news item
        /// and it removes the news item from the database
        /// </summary>
        /// <param name="sender">The lbDeleteNewsItem LinkButton</param>
        /// <param name="e">The Click event</param>
        protected void lbDeleteNewsItem_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value || currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.HUB_DATA_VIEWER)
            {
                //Get the PK from the hidden field
                int?rowToRemovePK = (String.IsNullOrWhiteSpace(hfDeleteNewsItemPK.Value) ? (int?)null : Convert.ToInt32(hfDeleteNewsItemPK.Value));

                //Remove the role if the PK is not null
                if (rowToRemovePK != null)
                {
                    using (PyramidContext context = new PyramidContext())
                    {
                        //Get the note to remove
                        NewsItem newsItemToRemove = context.NewsItem.Where(ni => ni.NewsItemPK == rowToRemovePK).FirstOrDefault();

                        //Remove the note
                        context.NewsItem.Remove(newsItemToRemove);
                        context.SaveChanges();

                        //Bind the news items
                        BindNewsItems();

                        //Show a success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully deleted the News Item!", 10000);
                    }
                }
                else
                {
                    msgSys.ShowMessageToUser("danger", "Error", "Could not find the News Item to delete!", 120000);
                }
            }
            else
            {
                msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000);
            }
        }
        /// <summary>
        /// This method executes when the user clicks the delete button for a Benchmarks of Quality FCC form
        /// and it deletes the form information from the database
        /// </summary>
        /// <param name="sender">The lbDeleteBOQFCC LinkButton</param>
        /// <param name="e">The Click event</param>
        protected void lbDeleteBOQFCC_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value)
            {
                //Get the PK from the hidden field
                int?removeBOQFCCPK = String.IsNullOrWhiteSpace(hfDeleteBOQFCCPK.Value) ? (int?)null : Convert.ToInt32(hfDeleteBOQFCCPK.Value);

                if (removeBOQFCCPK.HasValue)
                {
                    using (PyramidContext context = new PyramidContext())
                    {
                        //Get the BOQ to remove
                        var BOQFCCToRemove = context.BenchmarkOfQualityFCC.Where(x => x.BenchmarkOfQualityFCCPK == removeBOQFCCPK).FirstOrDefault();

                        //Remove the BOQ from the database
                        context.BenchmarkOfQualityFCC.Remove(BOQFCCToRemove);
                        context.SaveChanges();

                        //Show a delete success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully deleted Benchmarks of Quality FCC form!", 1000);

                        //Bind the gridview
                        bsGRBOQFCCs.DataBind();
                    }
                }
                else
                {
                    msgSys.ShowMessageToUser("danger", "Error", "Could not find the Benchmarks of Quality FCC form to delete!", 120000);
                }
            }
            else
            {
                //Not allowed to delete, show a message
                msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000);
            }
        }
Пример #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Log the user out
            Context.GetOwinContext().Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie);

            //Record the logout if a record for the login existed
            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.LogoutTime = DateTime.Now;
                    history.LogoutType = "Session timeout expired and user was logged out automatically.";
                    context.SaveChanges();
                }
            }

            //Ensure that the user's session is clear
            Session.Abandon();
        }
Пример #15
0
        /// <summary>
        /// This method executes when the user clicks the delete button for an Report Catalog Item
        /// and it deletes the Report Catalog Item from the database
        /// </summary>
        /// <param name="sender">The lbDeleteReportCatalogItem LinkButton</param>
        /// <param name="e">The Click event</param>
        protected void lbDeleteReportCatalogItem_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value)
            {
                //Get the PK from the hidden field
                int?removeReportCatalogItemPK = String.IsNullOrWhiteSpace(hfDeleteReportCatalogItemPK.Value) ? (int?)null : Convert.ToInt32(hfDeleteReportCatalogItemPK.Value);

                if (removeReportCatalogItemPK.HasValue)
                {
                    using (PyramidContext context = new PyramidContext())
                    {
                        //Get the ReportCatalogItem to remove
                        ReportCatalog ReportCatalogItemToRemove = context.ReportCatalog.Where(rc => rc.ReportCatalogPK == removeReportCatalogItemPK).FirstOrDefault();

                        //Remove the ReportCatalogItem from the database
                        context.ReportCatalog.Remove(ReportCatalogItemToRemove);
                        context.SaveChanges();

                        //Show a delete success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully deleted the Report Catalog Item!", 1000);

                        //Bind the gridview
                        bsGRReports.DataBind();
                    }
                }
                else
                {
                    msgSys.ShowMessageToUser("danger", "Error", "Could not find the Report Catalog Item to delete!", 120000);
                }
            }
            else
            {
                //Not allowed to delete, show a message
                msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000);
            }
        }
Пример #16
0
        /// <summary>
        /// This method fires when the user clicks the Save button in the
        /// submitNewsItem user control
        /// </summary>
        /// <param name="sender">The submitNewsItem control</param>
        /// <param name="e">The Click event</param>
        protected void submitNewsItem_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value || currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.HUB_DATA_VIEWER)
            {
                //Get the item pk
                int itemPK = Convert.ToInt32(hfAddEditNewsItemPK.Value);

                if (itemPK > 0)
                {
                    //This is an edit
                    using (PyramidContext context = new PyramidContext())
                    {
                        //The current news item
                        NewsItem currentNewsItem = context.NewsItem.Find(itemPK);

                        //Fill the NewsItem fields from the form
                        currentNewsItem.ItemNum     = Convert.ToInt32(txtItemNum.Value);
                        currentNewsItem.Contents    = txtNewsItemContents.Value.ToString();
                        currentNewsItem.NewsEntryFK = currentNewsEntryPK;

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

                        //Get the existing NewsItem record
                        Models.NewsItem existingNewsItem = context.NewsItem.Find(currentNewsItem.NewsItemPK);

                        //Overwrite the existing NewsItem record with the values from the form
                        context.Entry(existingNewsItem).CurrentValues.SetValues(currentNewsItem);
                        context.SaveChanges();
                    }

                    //Show the user a success message
                    msgSys.ShowMessageToUser("success", "News Item Added", "News Item successfully edited!", 5000);
                }
                else
                {
                    //This is an add
                    using (PyramidContext context = new PyramidContext())
                    {
                        //The current news item
                        NewsItem currentNewsItem = new NewsItem();

                        //Fill the NewsItem fields from the form
                        currentNewsItem.ItemNum     = Convert.ToInt32(txtItemNum.Value);
                        currentNewsItem.Contents    = txtNewsItemContents.Value.ToString();
                        currentNewsItem.NewsEntryFK = currentNewsEntryPK;

                        //Set the create-only fields
                        currentNewsItem.Creator    = User.Identity.Name;
                        currentNewsItem.CreateDate = DateTime.Now;

                        //Add the NewsItem to the database
                        context.NewsItem.Add(currentNewsItem);
                        context.SaveChanges();
                    }

                    //Show the user a success message
                    msgSys.ShowMessageToUser("success", "News Item Added", "News Item successfully added!", 5000);
                }

                //Reset the values in the hidden field and hide the div
                hfAddEditNewsItemPK.Value  = "0";
                divAddEditNewsItem.Visible = false;

                //Bind the news items
                BindNewsItems();
            }
        }
Пример #17
0
        /// <summary>
        /// This method fires when the user clicks the Save button in the
        /// submitCustomizationOptions user control
        /// </summary>
        /// <param name="sender">The submitCustomizationOptions control</param>
        /// <param name="e">The Click event</param>
        protected void submitCustomizationOptions_Click(object sender, EventArgs e)
        {
            try {
                List <spGetUserCustomizationOptions_Result> userCustomizationOptions = new List <spGetUserCustomizationOptions_Result>();
                using (PyramidContext context = new PyramidContext())
                {
                    //Get the user's customization options
                    userCustomizationOptions = context.spGetUserCustomizationOptions(CurrentUser.UserName).ToList();

                    //Get the selected fireworks option
                    spGetUserCustomizationOptions_Result selectedFireworksOption = userCustomizationOptions
                                                                                   .Where(uco => uco.OptionTypeDescription.ToLower() == "fireworks")
                                                                                   .FirstOrDefault();

                    //Update the customization options

                    //------------------ Fireworks --------------------------
                    UserCustomizationOption fireworksOption;
                    if (selectedFireworksOption.UserCustomizationOptionPK.HasValue &&
                        selectedFireworksOption.UserCustomizationOptionPK.Value > 0)
                    {
                        //Edit the fireworks option
                        fireworksOption = context.UserCustomizationOption
                                          .Where(uco => uco.UserCustomizationOptionPK == selectedFireworksOption.UserCustomizationOptionPK.Value)
                                          .FirstOrDefault();

                        fireworksOption.Editor   = User.Identity.Name;
                        fireworksOption.EditDate = DateTime.Now;
                        fireworksOption.CustomizationOptionValueCodeFK = Convert.ToInt32(ddFireworks.Value);
                        context.SaveChanges();
                    }
                    else
                    {
                        //Create the fireworks option
                        fireworksOption            = new UserCustomizationOption();
                        fireworksOption.Creator    = User.Identity.Name;
                        fireworksOption.CreateDate = DateTime.Now;
                        fireworksOption.Username   = CurrentUser.UserName;
                        fireworksOption.CustomizationOptionTypeCodeFK  = selectedFireworksOption.OptionTypePK;
                        fireworksOption.CustomizationOptionValueCodeFK = Convert.ToInt32(ddFireworks.Value);
                        context.UserCustomizationOption.Add(fireworksOption);
                        context.SaveChanges();
                    }
                    //------------------ End Fireworks --------------------------


                    //Refresh the user's customization options
                    userCustomizationOptions = context.spGetUserCustomizationOptions(CurrentUser.UserName).ToList();
                }

                //Set the customization options cookie
                bool isCookieSaved = Utilities.SetCustomizationOptionCookie(userCustomizationOptions);

                //Check to see if the cookie saved
                if (isCookieSaved)
                {
                    //Show a success message
                    msgSys.ShowMessageToUser("success", "Options Saved", "The customization options have been saved!", 10000);
                }
                else
                {
                    //Tell the user it failed
                    msgSys.ShowMessageToUser("warning", "Save Failed", "The customization options failed to save.", 10000);
                }
            }
            catch (Exception ex)
            {
                //Log any exceptions
                Utilities.LogException(ex);

                //Tell the user it failed
                msgSys.ShowMessageToUser("warning", "Save Failed", "The customization options failed to save.", 10000);
            }
        }
Пример #18
0
        /// <summary>
        /// This method executes when the user clicks the save button for the programs
        /// and it saves the program information to the database
        /// </summary>
        /// <param name="sender">The submitProgram control</param>
        /// <param name="e">The Click event</param>
        protected void submitProgram_Click(object sender, EventArgs e)
        {
            if (ASPxEdit.AreEditorsValid(this, submitProgram.ValidationGroup))
            {
                //Get the program information
                int programPK = Convert.ToInt32(hfAddEditProgramPK.Value);

                using (PyramidContext context = new PyramidContext())
                {
                    Program currentProgram;
                    //Check to see if this is an add or an edit
                    if (programPK == 0)
                    {
                        //Add
                        currentProgram                  = new Program();
                        currentProgram.ProgramName      = txtProgramName.Value.ToString();
                        currentProgram.Location         = txtProgramLocation.Value.ToString();
                        currentProgram.ProgramStartDate = (Convert.ToDateTime(deProgramStartDate.Value));
                        currentProgram.ProgramEndDate   = (deProgramEndDate.Value == null ? (DateTime?)null : Convert.ToDateTime(deProgramEndDate.Value));
                        currentProgram.CohortFK         = Convert.ToInt32(ddProgramCohort.Value);
                        currentProgram.HubFK            = Convert.ToInt32(ddProgramHub.Value);
                        currentProgram.StateFK          = Convert.ToInt32(ddProgramState.Value);
                        currentProgram.CreateDate       = DateTime.Now;
                        currentProgram.Creator          = User.Identity.Name;

                        //Save to the database
                        context.Program.Add(currentProgram);
                        context.SaveChanges();

                        //Clear the program type rows
                        var currentProgramTypes = context.ProgramType.Where(pt => pt.ProgramFK == currentProgram.ProgramPK).ToList();
                        context.ProgramType.RemoveRange(currentProgramTypes);

                        //Save the program type rows
                        foreach (BootstrapListEditItem item in lstBxProgramType.Items)
                        {
                            if (item.Selected)
                            {
                                ProgramType newProgramType = new ProgramType();
                                newProgramType.CreateDate = DateTime.Now;
                                newProgramType.Creator    = User.Identity.Name;
                                newProgramType.ProgramFK  = currentProgram.ProgramPK;
                                newProgramType.TypeCodeFK = Convert.ToInt32(item.Value);
                                context.ProgramType.Add(newProgramType);
                            }
                        }
                        context.SaveChanges();

                        //Show a success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully added program!", 10000);
                    }
                    else
                    {
                        //Edit
                        currentProgram                  = context.Program.Find(programPK);
                        currentProgram.ProgramName      = txtProgramName.Value.ToString();
                        currentProgram.Location         = txtProgramLocation.Value.ToString();
                        currentProgram.ProgramStartDate = (Convert.ToDateTime(deProgramStartDate.Value));
                        currentProgram.ProgramEndDate   = (deProgramEndDate.Value == null ? (DateTime?)null : Convert.ToDateTime(deProgramEndDate.Value));
                        currentProgram.CohortFK         = Convert.ToInt32(ddProgramCohort.Value);
                        currentProgram.HubFK            = Convert.ToInt32(ddProgramHub.Value);
                        currentProgram.StateFK          = Convert.ToInt32(ddProgramState.Value);
                        currentProgram.EditDate         = DateTime.Now;
                        currentProgram.Editor           = User.Identity.Name;

                        //Clear the program type rows
                        var currentProgramTypes = context.ProgramType.Where(pt => pt.ProgramFK == currentProgram.ProgramPK).ToList();
                        context.ProgramType.RemoveRange(currentProgramTypes);

                        //Save the program type rows
                        foreach (BootstrapListEditItem item in lstBxProgramType.Items)
                        {
                            if (item.Selected)
                            {
                                ProgramType newProgramType = new ProgramType();
                                newProgramType.CreateDate = DateTime.Now;
                                newProgramType.Creator    = User.Identity.Name;
                                newProgramType.ProgramFK  = currentProgram.ProgramPK;
                                newProgramType.TypeCodeFK = Convert.ToInt32(item.Value);
                                context.ProgramType.Add(newProgramType);
                            }
                        }
                        context.SaveChanges();

                        //Show a success message
                        msgSys.ShowMessageToUser("success", "Success", "Successfully edited program!", 10000);
                    }

                    //Reset the values in the hidden field and hide the div
                    hfAddEditProgramPK.Value  = "0";
                    divAddEditProgram.Visible = false;

                    //Re-bind the program controls
                    BindPrograms();
                }
            }
        }
Пример #19
0
        /// <summary>
        /// This method executes when the user clicks the delete button for a child
        /// and it deletes the child information from the database
        /// </summary>
        /// <param name="sender">The lbDeleteChild LinkButton</param>
        /// <param name="e">The Click event</param>
        protected void lbDeleteChild_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value)
            {
                //Get the PK from the hidden field
                int?removeChildProgramPK = (String.IsNullOrWhiteSpace(hfDeleteChildProgramPK.Value) ? (int?)null : Convert.ToInt32(hfDeleteChildProgramPK.Value));

                //Remove the role if the PK is not null
                if (removeChildProgramPK != null)
                {
                    try
                    {
                        using (PyramidContext context = new PyramidContext())
                        {
                            //Get the child program row to remove
                            ChildProgram childProgramToRemove = context.ChildProgram
                                                                .Find(removeChildProgramPK);

                            //Get the child to remove
                            Models.Child childToRemove = context.Child
                                                         .Where(c => c.ChildPK == childProgramToRemove.ChildFK).FirstOrDefault();

                            //Get the notes to remove and remove them
                            List <ChildNote> notesToRemove = context.ChildNote.Where(cn => cn.ChildFK == childProgramToRemove.ChildFK).ToList();
                            context.ChildNote.RemoveRange(notesToRemove);

                            //Get the status rows to remove and remove them
                            List <ChildStatus> statusToRemove = context.ChildStatus.Where(cs => cs.ChildFK == childProgramToRemove.ChildFK).ToList();
                            context.ChildStatus.RemoveRange(statusToRemove);

                            //Get the classroom assignments to remove and remove them
                            List <ChildClassroom> classroomAssignmentsToRemove = context.ChildClassroom.Where(cc => cc.ChildFK == childProgramToRemove.ChildFK).ToList();
                            context.ChildClassroom.RemoveRange(classroomAssignmentsToRemove);

                            //Remove the child program row
                            context.ChildProgram.Remove(childProgramToRemove);

                            //Remove the child
                            context.Child.Remove(childToRemove);

                            //Save all the changes to the database
                            context.SaveChanges();

                            //Show a success message
                            msgSys.ShowMessageToUser("success", "Success", "Successfully deleted child!", 10000);
                        }
                    }
                    catch (DbUpdateException dbUpdateEx)
                    {
                        //Check if it is a foreign key error
                        if (dbUpdateEx.InnerException?.InnerException is SqlException)
                        {
                            //If it is a foreign key error, display a custom message
                            SqlException sqlEx = (SqlException)dbUpdateEx.InnerException.InnerException;
                            if (sqlEx.Number == 547)
                            {
                                msgSys.ShowMessageToUser("danger", "Error", "Could not delete the child, there are related records in the system!<br/><br/>If you do not know what related records exist, please contact tech support via ticket.", 120000);
                            }
                            else
                            {
                                msgSys.ShowMessageToUser("danger", "Error", "An error occurred while deleting the child!", 120000);
                            }
                        }
                        else
                        {
                            msgSys.ShowMessageToUser("danger", "Error", "An error occurred while deleting the child!", 120000);
                        }

                        //Log the error
                        Elmah.ErrorSignal.FromCurrentContext().Raise(dbUpdateEx);
                    }

                    //Rebind the child controls
                    bsGRChildren.DataBind();
                    BindRaceChart();
                }
                else
                {
                    msgSys.ShowMessageToUser("danger", "Error", "Could not find the child to delete!", 120000);
                }
            }
            else
            {
                msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000);
            }
        }
        /// <summary>
        /// This method executes when the user clicks the delete button for a employee
        /// and it deletes the employee information from the database
        /// </summary>
        /// <param name="sender">The lbDeleteEmployee LinkButton</param>
        /// <param name="e">The Click event</param>
        protected void lbDeleteEmployee_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value)
            {
                //Get the PK from the hidden field
                int?removeEmployeePK = (String.IsNullOrWhiteSpace(hfDeleteEmployeePK.Value) ? (int?)null : Convert.ToInt32(hfDeleteEmployeePK.Value));

                //Remove the role if the PK is not null
                if (removeEmployeePK != null)
                {
                    try
                    {
                        using (PyramidContext context = new PyramidContext())
                        {
                            //Get the employee to remove
                            Models.ProgramEmployee employeeToRemove = context.ProgramEmployee.Find(removeEmployeePK);

                            //Get the trainings to remove
                            List <Training> trainingsToRemove = context.Training
                                                                .Include(t => t.CodeTraining)
                                                                .Where(t => t.ProgramEmployeeFK == removeEmployeePK &&
                                                                       t.CodeTraining.RolesAuthorizedToModify.Contains((currentProgramRole.RoleFK.Value.ToString() + ",")))
                                                                .ToList();
                            context.Training.RemoveRange(trainingsToRemove);

                            //Get the job functions to remove and remove them
                            List <JobFunction> jobFunctionsToRemove = context.JobFunction
                                                                      .Include(jf => jf.CodeJobType)
                                                                      .Where(jf => jf.ProgramEmployeeFK == removeEmployeePK &&
                                                                             jf.CodeJobType.RolesAuthorizedToModify.Contains((currentProgramRole.RoleFK.Value.ToString() + ",")))
                                                                      .ToList();
                            context.JobFunction.RemoveRange(jobFunctionsToRemove);

                            //Get the classroom assignments to remove
                            List <EmployeeClassroom> classroomAssignmentsToRemove = context.EmployeeClassroom
                                                                                    .Include(ec => ec.CodeJobType)
                                                                                    .Where(ec => ec.EmployeeFK == removeEmployeePK &&
                                                                                           ec.CodeJobType.RolesAuthorizedToModify.Contains((currentProgramRole.RoleFK.Value.ToString() + ",")))
                                                                                    .ToList();
                            context.EmployeeClassroom.RemoveRange(classroomAssignmentsToRemove);

                            //Remove the employee
                            context.ProgramEmployee.Remove(employeeToRemove);
                            context.SaveChanges();

                            //Show a success message
                            msgSys.ShowMessageToUser("success", "Success", "Successfully deleted employee!", 10000);
                        }
                    }
                    catch (DbUpdateException dbUpdateEx)
                    {
                        //Check if it is a foreign key error
                        if (dbUpdateEx.InnerException?.InnerException is SqlException)
                        {
                            //If it is a foreign key error, display a custom message
                            SqlException sqlEx = (SqlException)dbUpdateEx.InnerException.InnerException;
                            if (sqlEx.Number == 547)
                            {
                                msgSys.ShowMessageToUser("danger", "Error", "Could not delete the employee, there are related records in the system!<br/><br/>If you do not know what related records exist, please contact tech support via ticket.", 120000);
                            }
                            else
                            {
                                msgSys.ShowMessageToUser("danger", "Error", "An error occurred while deleting the employee!", 120000);
                            }
                        }
                        else
                        {
                            msgSys.ShowMessageToUser("danger", "Error", "An error occurred while deleting the employee!", 120000);
                        }

                        //Log the error
                        Elmah.ErrorSignal.FromCurrentContext().Raise(dbUpdateEx);
                    }

                    //Rebind the employee controls
                    bsGREmployees.DataBind();
                }
                else
                {
                    msgSys.ShowMessageToUser("danger", "Error", "Could not find the employee to delete!", 120000);
                }
            }
            else
            {
                msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000);
            }
        }
Пример #21
0
        /// <summary>
        /// This method fires when the user clicks the Save button in the
        /// submitBOQFCC user control
        /// </summary>
        /// <param name="sender">The submitBOQFCC control</param>
        /// <param name="e">The Click event</param>
        protected void submitBOQFCC_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value)
            {
                //To hold the success message
                string successMessageType = null;

                //Fill the fields of the object from the form
                currentBOQFCC.FormDate    = deFormDate.Date;
                currentBOQFCC.Indicator1  = Convert.ToInt32(ddIndicator1.Value);
                currentBOQFCC.Indicator2  = Convert.ToInt32(ddIndicator2.Value);
                currentBOQFCC.Indicator3  = Convert.ToInt32(ddIndicator3.Value);
                currentBOQFCC.Indicator4  = Convert.ToInt32(ddIndicator4.Value);
                currentBOQFCC.Indicator5  = Convert.ToInt32(ddIndicator5.Value);
                currentBOQFCC.Indicator6  = Convert.ToInt32(ddIndicator6.Value);
                currentBOQFCC.Indicator7  = Convert.ToInt32(ddIndicator7.Value);
                currentBOQFCC.Indicator8  = Convert.ToInt32(ddIndicator8.Value);
                currentBOQFCC.Indicator9  = Convert.ToInt32(ddIndicator9.Value);
                currentBOQFCC.Indicator10 = Convert.ToInt32(ddIndicator10.Value);
                currentBOQFCC.Indicator11 = Convert.ToInt32(ddIndicator11.Value);
                currentBOQFCC.Indicator12 = Convert.ToInt32(ddIndicator12.Value);
                currentBOQFCC.Indicator13 = Convert.ToInt32(ddIndicator13.Value);
                currentBOQFCC.Indicator14 = Convert.ToInt32(ddIndicator14.Value);
                currentBOQFCC.Indicator15 = Convert.ToInt32(ddIndicator15.Value);
                currentBOQFCC.Indicator16 = Convert.ToInt32(ddIndicator16.Value);
                currentBOQFCC.Indicator17 = Convert.ToInt32(ddIndicator17.Value);
                currentBOQFCC.Indicator18 = Convert.ToInt32(ddIndicator18.Value);
                currentBOQFCC.Indicator19 = Convert.ToInt32(ddIndicator19.Value);
                currentBOQFCC.Indicator20 = Convert.ToInt32(ddIndicator20.Value);
                currentBOQFCC.Indicator21 = Convert.ToInt32(ddIndicator21.Value);
                currentBOQFCC.Indicator22 = Convert.ToInt32(ddIndicator22.Value);
                currentBOQFCC.Indicator23 = Convert.ToInt32(ddIndicator23.Value);
                currentBOQFCC.Indicator24 = Convert.ToInt32(ddIndicator24.Value);
                currentBOQFCC.Indicator25 = Convert.ToInt32(ddIndicator25.Value);
                currentBOQFCC.Indicator26 = Convert.ToInt32(ddIndicator26.Value);
                currentBOQFCC.Indicator27 = Convert.ToInt32(ddIndicator27.Value);
                currentBOQFCC.Indicator28 = Convert.ToInt32(ddIndicator28.Value);
                currentBOQFCC.Indicator29 = Convert.ToInt32(ddIndicator29.Value);
                currentBOQFCC.Indicator30 = Convert.ToInt32(ddIndicator30.Value);
                currentBOQFCC.Indicator31 = Convert.ToInt32(ddIndicator31.Value);
                currentBOQFCC.Indicator32 = Convert.ToInt32(ddIndicator32.Value);
                currentBOQFCC.Indicator33 = Convert.ToInt32(ddIndicator33.Value);
                currentBOQFCC.Indicator34 = Convert.ToInt32(ddIndicator34.Value);
                currentBOQFCC.Indicator35 = Convert.ToInt32(ddIndicator35.Value);
                currentBOQFCC.Indicator36 = Convert.ToInt32(ddIndicator36.Value);
                currentBOQFCC.Indicator37 = Convert.ToInt32(ddIndicator37.Value);
                currentBOQFCC.Indicator38 = Convert.ToInt32(ddIndicator38.Value);
                currentBOQFCC.Indicator39 = Convert.ToInt32(ddIndicator39.Value);
                currentBOQFCC.Indicator40 = Convert.ToInt32(ddIndicator40.Value);
                currentBOQFCC.Indicator41 = Convert.ToInt32(ddIndicator41.Value);
                currentBOQFCC.Indicator42 = Convert.ToInt32(ddIndicator42.Value);
                currentBOQFCC.Indicator43 = Convert.ToInt32(ddIndicator43.Value);
                currentBOQFCC.Indicator44 = Convert.ToInt32(ddIndicator44.Value);
                currentBOQFCC.Indicator45 = Convert.ToInt32(ddIndicator45.Value);
                currentBOQFCC.Indicator46 = Convert.ToInt32(ddIndicator46.Value);
                currentBOQFCC.Indicator47 = Convert.ToInt32(ddIndicator47.Value);
                currentBOQFCC.TeamMembers = txtTeamMembers.Text;

                //Check to see if this is an add or edit
                if (BOQFCCPK > 0)
                {
                    using (PyramidContext context = new PyramidContext())
                    {
                        //This is an edit
                        successMessageType = "BOQFCCEdited";

                        //Fill the edit-specific fields
                        currentBOQFCC.EditDate = DateTime.Now;
                        currentBOQFCC.Editor   = User.Identity.Name;

                        //Get the existing database values
                        BenchmarkOfQualityFCC existingBOQFCC = context.BenchmarkOfQualityFCC.Find(currentBOQFCC.BenchmarkOfQualityFCCPK);

                        //Set the BOQ object to the new values
                        context.Entry(existingBOQFCC).CurrentValues.SetValues(currentBOQFCC);

                        //Save the changes
                        context.SaveChanges();
                    }

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

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

                        //Add the Benchmark to the database and save
                        context.BenchmarkOfQualityFCC.Add(currentBOQFCC);
                        context.SaveChanges();
                    }

                    //Redirect the user to the dashboard with the success message
                    Response.Redirect(string.Format("/Pages/BOQFCCDashboard.aspx?messageType={0}", successMessageType));
                }
            }
            else
            {
                msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000);
            }
        }
Пример #22
0
        /// <summary>
        /// This method executes when the user clicks the save button for the  UserFileUploads
        /// and it saves the UserFileUpload information to the database
        /// </summary>
        /// <param name="sender">The submitUserFileUpload submit user control</param>
        /// <param name="e">The Click event</param>
        protected void submitFileUpload_Click(object sender, EventArgs e)
        {
            //Allow editors and hub data viewers to add files
            if (currentProgramRole.AllowedToEdit.Value ||
                currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.HUB_DATA_VIEWER)
            {
                //Get the file to upload
                UploadedFile file = bucUploadFile.UploadedFiles[0];

                if (file.ContentLength > 0 && file.IsValid)
                {
                    //Get the actual file name
                    string actualFileName = Path.GetFileNameWithoutExtension(file.FileName) + "-" +
                                            Path.GetRandomFileName().Substring(0, 6) +
                                            Path.GetExtension(file.FileName);

                    //Get the display file name
                    string displayFileName = Path.GetFileNameWithoutExtension(file.FileName);

                    //Get the file type
                    string fileExtension = Path.GetExtension(file.FileName).ToLower();
                    string fileType;
                    switch (fileExtension)
                    {
                    case ".pdf":
                        fileType = "pdf";
                        break;

                    case ".doc":
                    case ".docx":
                        fileType = "word";
                        break;

                    case ".ppt":
                    case ".pptx":
                        fileType = "powerpoint";
                        break;

                    case ".xls":
                    case ".xlsx":
                        fileType = "excel";
                        break;

                    case ".jpeg":
                    case ".jpg":
                    case ".png":
                        fileType = "image";
                        break;

                    default:
                        fileType = "alt";
                        break;
                    }

                    //Upload the file to Azure storage
                    string filePath = Utilities.UploadFileToAzureStorage(file.FileBytes, actualFileName,
                                                                         Utilities.ConstantAzureStorageContainerName.UPLOADED_FILES.ToString());

                    if (!String.IsNullOrWhiteSpace(filePath))
                    {
                        PyramidUser currentUser = null;
                        // Validate the user password
                        using (var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>())
                        {
                            //Try to get the user
                            currentUser = manager.FindByName(User.Identity.Name);
                        }

                        using (PyramidContext context = new PyramidContext())
                        {
                            //Create the database object for the file
                            UserFileUpload currentUserFileUpload = new UserFileUpload();
                            currentUserFileUpload.CreateDate      = DateTime.Now;
                            currentUserFileUpload.Creator         = User.Identity.Name;
                            currentUserFileUpload.UploadedBy      = currentUser.FirstName + " " + currentUser.LastName;
                            currentUserFileUpload.Description     = txtFileDescription.Value.ToString();
                            currentUserFileUpload.FileType        = fileType;
                            currentUserFileUpload.DisplayFileName = displayFileName;
                            currentUserFileUpload.FileName        = actualFileName;
                            currentUserFileUpload.FilePath        = filePath;
                            currentUserFileUpload.TypeCodeFK      = Convert.ToInt32(ddFileType.Value);

                            //Set the proper FKs
                            if (currentUserFileUpload.TypeCodeFK == (int)Utilities.FileTypeFKs.PROGRAM_WIDE)
                            {
                                currentUserFileUpload.ProgramFK = Convert.ToInt32(ddProgram.Value);
                                currentUserFileUpload.HubFK     = null;
                                currentUserFileUpload.StateFK   = null;
                                currentUserFileUpload.CohortFK  = null;
                            }
                            else if (currentUserFileUpload.TypeCodeFK == (int)Utilities.FileTypeFKs.HUB_WIDE)
                            {
                                currentUserFileUpload.ProgramFK = null;
                                currentUserFileUpload.HubFK     = Convert.ToInt32(ddHub.Value);
                                currentUserFileUpload.StateFK   = null;
                                currentUserFileUpload.CohortFK  = null;
                            }
                            else if (currentUserFileUpload.TypeCodeFK == (int)Utilities.FileTypeFKs.STATE_WIDE)
                            {
                                currentUserFileUpload.ProgramFK = null;
                                currentUserFileUpload.HubFK     = null;
                                currentUserFileUpload.StateFK   = Convert.ToInt32(ddState.Value);
                                currentUserFileUpload.CohortFK  = null;
                            }
                            else if (currentUserFileUpload.TypeCodeFK == (int)Utilities.FileTypeFKs.COHORT_WIDE)
                            {
                                currentUserFileUpload.ProgramFK = null;
                                currentUserFileUpload.HubFK     = null;
                                currentUserFileUpload.StateFK   = null;
                                currentUserFileUpload.CohortFK  = Convert.ToInt32(ddCohort.Value);
                            }

                            //Save to the database
                            context.UserFileUpload.Add(currentUserFileUpload);
                            context.SaveChanges();

                            //Redirect the user back to this page with a message
                            Response.Redirect("/Pages/UploadedFiles.aspx?messageType=UploadSuccess");
                        }
                    }
                    else
                    {
                        msgSys.ShowMessageToUser("danger", "Upload Failed", "The file failed to upload properly, please try again.", 10000);
                    }
                }
                else
                {
                    msgSys.ShowMessageToUser("danger", "Error", "No valid file was selected to be uploaded!", 120000);
                }
            }
            else
            {
                msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000);
            }
        }
Пример #23
0
        /// <summary>
        /// This method fires when the user clicks the save button for a row and it saves the trainings
        /// for the user to the database
        /// </summary>
        /// <param name="sender">The lbSaveTrainings LinkButton</param>
        /// <param name="e">The click event</param>
        protected void lbSaveTrainings_Click(object sender, EventArgs e)
        {
            try
            {
                //To hold the training dates
                DateTime?PBCDate = null, ICECPDate = null, TPOTDate = null, TPITOSDate = null;

                //Get the calling button
                LinkButton thisButton = (LinkButton)sender;

                //Get the calling button container
                GridViewDataItemTemplateContainer buttonContainer = (GridViewDataItemTemplateContainer)thisButton.NamingContainer;

                //Get the DateEdits from the row in which the button resides
                BootstrapDateEdit dePBC                = (BootstrapDateEdit)bsGREmployees.FindRowCellTemplateControl(buttonContainer.VisibleIndex, (GridViewDataColumn)bsGREmployees.Columns["CoachColumn"], "dePBCDate");
                BootstrapDateEdit deICECPDate          = (BootstrapDateEdit)bsGREmployees.FindRowCellTemplateControl(buttonContainer.VisibleIndex, (GridViewDataColumn)bsGREmployees.Columns["CoachColumn"], "deICECPDate");
                BootstrapDateEdit deTPOTTrainingDate   = (BootstrapDateEdit)bsGREmployees.FindRowCellTemplateControl(buttonContainer.VisibleIndex, (GridViewDataColumn)bsGREmployees.Columns["ObserverColumn"], "deTPOTTrainingDate");
                BootstrapDateEdit deTPITOSTrainingDate = (BootstrapDateEdit)bsGREmployees.FindRowCellTemplateControl(buttonContainer.VisibleIndex, (GridViewDataColumn)bsGREmployees.Columns["ObserverColumn"], "deTPITOSTrainingDate");

                //Get the employee PK and name
                int    employeePK   = Convert.ToInt32(bsGREmployees.GetRowValues(buttonContainer.VisibleIndex, "ProgramEmployeePK"));
                string employeeName = Convert.ToString(bsGREmployees.GetRowValues(buttonContainer.VisibleIndex, "Name"));

                //Get the training dates from the DateEdits
                PBCDate    = (dePBC.Value == null ? (DateTime?)null : Convert.ToDateTime(dePBC.Value));
                ICECPDate  = (deICECPDate.Value == null ? (DateTime?)null : Convert.ToDateTime(deICECPDate.Value));
                TPOTDate   = (deTPOTTrainingDate.Value == null ? (DateTime?)null : Convert.ToDateTime(deTPOTTrainingDate.Value));
                TPITOSDate = (deTPITOSTrainingDate.Value == null ? (DateTime?)null : Convert.ToDateTime(deTPITOSTrainingDate.Value));

                //Only continue if the employee PK has a value
                if (employeePK > 0)
                {
                    using (PyramidContext context = new PyramidContext())
                    {
                        //To hold the training acronyms of the added trainings
                        List <string> trainingsAdded = new List <string>();

                        //Check each training date to see if it was added
                        if (PBCDate.HasValue)
                        {
                            //Add the PBC training to the database
                            Training PBCTraining = new Training();
                            PBCTraining.CreateDate        = DateTime.Now;
                            PBCTraining.Creator           = User.Identity.Name;
                            PBCTraining.ProgramEmployeeFK = employeePK;
                            PBCTraining.TrainingCodeFK    = (int)Utilities.TrainingFKs.PRACTICE_BASED_COACHING;
                            PBCTraining.TrainingDate      = PBCDate.Value;
                            context.Training.Add(PBCTraining);

                            //Add the PBC training to the list
                            trainingsAdded.Add("PBC");
                        }
                        if (ICECPDate.HasValue)
                        {
                            //Add the ICECP training to the database
                            Training ICECPTraining = new Training();
                            ICECPTraining.CreateDate        = DateTime.Now;
                            ICECPTraining.Creator           = User.Identity.Name;
                            ICECPTraining.ProgramEmployeeFK = employeePK;
                            ICECPTraining.TrainingCodeFK    = (int)Utilities.TrainingFKs.INTRODUCTION_TO_COACHING;
                            ICECPTraining.TrainingDate      = ICECPDate.Value;
                            context.Training.Add(ICECPTraining);

                            //Add the ICECP training to the list
                            trainingsAdded.Add("ICECP");
                        }
                        if (TPOTDate.HasValue)
                        {
                            //Add the TPOT observer training to the database
                            Training TPOTTraining = new Training();
                            TPOTTraining.CreateDate        = DateTime.Now;
                            TPOTTraining.Creator           = User.Identity.Name;
                            TPOTTraining.ProgramEmployeeFK = employeePK;
                            TPOTTraining.TrainingCodeFK    = (int)Utilities.TrainingFKs.TPOT_OBSERVER;
                            TPOTTraining.TrainingDate      = TPOTDate.Value;
                            context.Training.Add(TPOTTraining);

                            //Add the TPOT observer training to the list
                            trainingsAdded.Add("TPOT Observer");
                        }
                        if (TPITOSDate.HasValue)
                        {
                            //Add the TPITOS observer training to the database
                            Training TPITOSTraining = new Training();
                            TPITOSTraining.CreateDate        = DateTime.Now;
                            TPITOSTraining.Creator           = User.Identity.Name;
                            TPITOSTraining.ProgramEmployeeFK = employeePK;
                            TPITOSTraining.TrainingCodeFK    = (int)Utilities.TrainingFKs.TPITOS_OBSERVER;
                            TPITOSTraining.TrainingDate      = TPITOSDate.Value;
                            context.Training.Add(TPITOSTraining);

                            //Add the TPITOS observer training to the list
                            trainingsAdded.Add("TPITOS Observer");
                        }

                        //Check to see if any changes were made
                        if (trainingsAdded.Count > 0)
                        {
                            //Save the trainings to the database
                            context.SaveChanges();

                            //Refresh the gridview
                            bsGREmployees.DataBind();

                            //Show the user a message
                            msgSys.ShowMessageToUser("success", "Trainings Added", string.Join(",", trainingsAdded) + " trainings were added for " + employeeName, 10000);
                        }
                        else
                        {
                            //Show the user a warning
                            msgSys.ShowMessageToUser("warning", "No Dates Detected", "No training dates were entered, and no changes have been saved.", 5000);
                        }
                    }
                }
                else
                {
                    //Show the user a warning
                    msgSys.ShowMessageToUser("warning", "No Employee Info Found", "The system was unable to determine the employee, please try again.", 5000);
                }
            }
            catch (Exception ex)
            {
                //Log the exception
                Utilities.LogException(ex);

                //Show the user the message
                msgSys.ShowMessageToUser("danger", "Error!", "An error occurred.  Message: " + ex.Message, 5000);
            }
        }
        /// <summary>
        /// This method fires when the user clicks the Save button in the
        /// submitBehaviorIncident user control
        /// </summary>
        /// <param name="sender">The submitBehaviorIncident control</param>
        /// <param name="e">The Click event</param>
        protected void submitBehaviorIncident_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value)
            {
                //To hold the success message
                string successMessageType = null;

                //Fill the fields of the object from the form
                currentBehaviorIncident.IncidentDatetime          = Convert.ToDateTime(deIncidentDatetime.Value);
                currentBehaviorIncident.BehaviorDescription       = txtBehaviorDescription.Value.ToString();
                currentBehaviorIncident.ProblemBehaviorCodeFK     = Convert.ToInt32(ddProblemBehavior.Value);
                currentBehaviorIncident.ProblemBehaviorSpecify    = (txtProblemBehaviorSpecify.Value == null ? null : txtProblemBehaviorSpecify.Value.ToString());
                currentBehaviorIncident.ActivityCodeFK            = Convert.ToInt32(ddActivity.Value);
                currentBehaviorIncident.ActivitySpecify           = (txtActivitySpecify.Value == null ? null : txtActivitySpecify.Value.ToString());
                currentBehaviorIncident.OthersInvolvedCodeFK      = Convert.ToInt32(ddOthersInvolved.Value);
                currentBehaviorIncident.OthersInvolvedSpecify     = (txtOthersInvolvedSpecify.Value == null ? null : txtOthersInvolvedSpecify.Value.ToString());
                currentBehaviorIncident.PossibleMotivationCodeFK  = Convert.ToInt32(ddPossibleMotivation.Value);
                currentBehaviorIncident.PossibleMotivationSpecify = (txtPossibleMotivationSpecify.Value == null ? null : txtPossibleMotivationSpecify.Value.ToString());
                currentBehaviorIncident.StrategyResponseCodeFK    = Convert.ToInt32(ddStrategyResponse.Value);
                currentBehaviorIncident.StrategyResponseSpecify   = (txtStrategyResponseSpecify.Value == null ? null : txtStrategyResponseSpecify.Value.ToString());
                currentBehaviorIncident.AdminFollowUpCodeFK       = Convert.ToInt32(ddAdminFollowUp.Value);
                currentBehaviorIncident.AdminFollowUpSpecify      = (txtAdminFollowUpSpecify.Value == null ? null : txtAdminFollowUpSpecify.Value.ToString());
                currentBehaviorIncident.Notes       = (txtNotes.Value == null ? null : txtNotes.Value.ToString());
                currentBehaviorIncident.ChildFK     = Convert.ToInt32(ddChild.Value);
                currentBehaviorIncident.ClassroomFK = Convert.ToInt32(ddClassroom.Value);

                //Check to see if this is an add or edit
                if (behaviorIncidentPK > 0)
                {
                    using (PyramidContext context = new PyramidContext())
                    {
                        //This is an edit
                        successMessageType = "BehaviorIncidentEdited";

                        //Fill the edit-specific fields
                        currentBehaviorIncident.EditDate = DateTime.Now;
                        currentBehaviorIncident.Editor   = User.Identity.Name;

                        //Get the existing database values
                        Models.BehaviorIncident existingBehaviorIncident = context.BehaviorIncident.Find(currentBehaviorIncident.BehaviorIncidentPK);

                        //Set the behavior incident object to the new values
                        context.Entry(existingBehaviorIncident).CurrentValues.SetValues(currentBehaviorIncident);

                        //Save the changes
                        context.SaveChanges();
                    }

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

                        //Set the create-specific fields
                        currentBehaviorIncident.CreateDate = DateTime.Now;
                        currentBehaviorIncident.Creator    = User.Identity.Name;

                        //Add the behavior incident to the database and save
                        context.BehaviorIncident.Add(currentBehaviorIncident);
                        context.SaveChanges();
                    }

                    //Redirect the user to the dashboard with the success message
                    Response.Redirect(string.Format("/Pages/BehaviorIncidentDashboard.aspx?messageType={0}", successMessageType));
                }
            }
            else
            {
                msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000);
            }
        }
Пример #25
0
        /// <summary>
        /// This method fires when the user clicks the Save button in the
        /// submitNewsEntry user control
        /// </summary>
        /// <param name="sender">The submitNewsEntry control</param>
        /// <param name="e">The Click event</param>
        protected void submitNewsEntry_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value || currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.HUB_DATA_VIEWER)
            {
                //To hold the success message type
                string successMessageType = null;

                //Fill the NewsEntry fields from the form
                currentNewsEntry.EntryDate           = Convert.ToDateTime(deEntryDate.Value);
                currentNewsEntry.NewsEntryTypeCodeFK = Convert.ToInt32(ddEntryType.Value);

                //Set the proper FKs
                if (currentNewsEntry.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.APPLICATION)
                {
                    currentNewsEntry.ProgramFK = null;
                    currentNewsEntry.HubFK     = null;
                    currentNewsEntry.StateFK   = null;
                    currentNewsEntry.CohortFK  = null;
                }
                else if (currentNewsEntry.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.PROGRAM_WIDE)
                {
                    currentNewsEntry.ProgramFK = Convert.ToInt32(ddProgram.Value);
                    currentNewsEntry.HubFK     = null;
                    currentNewsEntry.StateFK   = null;
                    currentNewsEntry.CohortFK  = null;
                }
                else if (currentNewsEntry.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.HUB_WIDE)
                {
                    currentNewsEntry.ProgramFK = null;
                    currentNewsEntry.HubFK     = Convert.ToInt32(ddHub.Value);
                    currentNewsEntry.StateFK   = null;
                    currentNewsEntry.CohortFK  = null;
                }
                else if (currentNewsEntry.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.STATE_WIDE)
                {
                    currentNewsEntry.ProgramFK = null;
                    currentNewsEntry.HubFK     = null;
                    currentNewsEntry.StateFK   = Convert.ToInt32(ddState.Value);
                    currentNewsEntry.CohortFK  = null;
                }
                else if (currentNewsEntry.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.COHORT_WIDE)
                {
                    currentNewsEntry.ProgramFK = null;
                    currentNewsEntry.HubFK     = null;
                    currentNewsEntry.StateFK   = null;
                    currentNewsEntry.CohortFK  = Convert.ToInt32(ddCohort.Value);
                }

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

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

                        //Get the existing NewsEntry record
                        Models.NewsEntry existingNewsEntry = context.NewsEntry.Find(currentNewsEntry.NewsEntryPK);

                        //Overwrite the existing NewsEntry record with the values from the form
                        context.Entry(existingNewsEntry).CurrentValues.SetValues(currentNewsEntry);
                        context.SaveChanges();
                    }

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

                        //Set the create-only fields
                        currentNewsEntry.Creator    = User.Identity.Name;
                        currentNewsEntry.CreateDate = DateTime.Now;

                        //Add the NewsEntry to the database
                        context.NewsEntry.Add(currentNewsEntry);
                        context.SaveChanges();
                    }

                    //Redirect the user to the  this page
                    Response.Redirect(string.Format("/Pages/NewsManagement.aspx?NewsEntryPK={0}&Action=Edit&messageType={1}",
                                                    currentNewsEntry.NewsEntryPK.ToString(), successMessageType));
                }
            }
        }
Пример #26
0
        /// <summary>
        /// This method executes when the user clicks the delete button for a classroom
        /// and it deletes the classroom information from the database
        /// </summary>
        /// <param name="sender">The lbDeleteClassroom LinkButton</param>
        /// <param name="e">The Click event</param>
        protected void lbDeleteClassroom_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value)
            {
                //Get the PK from the hidden field
                int?removeClassroomPK = (String.IsNullOrWhiteSpace(hfDeleteClassroomPK.Value) ? (int?)null : Convert.ToInt32(hfDeleteClassroomPK.Value));

                //Remove the role if the PK is not null
                if (removeClassroomPK != null)
                {
                    try
                    {
                        using (PyramidContext context = new PyramidContext())
                        {
                            //Get the classroom program row to remove
                            Models.Classroom classroomToRemove = context.Classroom.Find(removeClassroomPK);

                            //Remove the classroom
                            context.Classroom.Remove(classroomToRemove);
                            context.SaveChanges();

                            //Show a success message
                            msgSys.ShowMessageToUser("success", "Success", "Successfully deleted classroom!", 10000);
                        }
                    }
                    catch (DbUpdateException dbUpdateEx)
                    {
                        //Check if it is a foreign key error
                        if (dbUpdateEx.InnerException?.InnerException is SqlException)
                        {
                            //If it is a foreign key error, display a custom message
                            SqlException sqlEx = (SqlException)dbUpdateEx.InnerException.InnerException;
                            if (sqlEx.Number == 547)
                            {
                                msgSys.ShowMessageToUser("danger", "Error", "Could not delete the classroom, there are related records in the system!<br/><br/>If you do not know what related records exist, please contact tech support via ticket.", 120000);
                            }
                            else
                            {
                                msgSys.ShowMessageToUser("danger", "Error", "An error occurred while deleting the classroom!", 120000);
                            }
                        }
                        else
                        {
                            msgSys.ShowMessageToUser("danger", "Error", "An error occurred while deleting the classroom!", 120000);
                        }

                        //Log the error
                        Elmah.ErrorSignal.FromCurrentContext().Raise(dbUpdateEx);
                    }

                    //Rebind the classroom controls
                    bsGRClassrooms.DataBind();

                    //Bind the chart
                    BindClassroomChart();
                }
                else
                {
                    msgSys.ShowMessageToUser("danger", "Error", "Could not find the classroom to delete!", 120000);
                }
            }
            else
            {
                msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000);
            }
        }
Пример #27
0
        /// <summary>
        /// This method fires when the user clicks the Save button in the
        /// submitCoachingLog user control
        /// </summary>
        /// <param name="sender">The submitCoachingLog control</param>
        /// <param name="e">The Click event</param>
        protected void submitCoachingLog_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value)
            {
                //To hold the success message type
                string successMessageType = null;

                //Fill the CoachingLog fields from the form
                //Basic info
                currentCoachingLog.LogDate         = Convert.ToDateTime(deLogDate.Value);
                currentCoachingLog.CoachFK         = Convert.ToInt32(ddCoach.Value);
                currentCoachingLog.TeacherFK       = Convert.ToInt32(ddTeacher.Value);
                currentCoachingLog.DurationMinutes = Convert.ToInt32(txtDurationMinutes.Value);

                //Observations
                currentCoachingLog.OBSObserving              = Convert.ToBoolean(ddOBSObserving.Value);
                currentCoachingLog.OBSModeling               = Convert.ToBoolean(ddOBSModeling.Value);
                currentCoachingLog.OBSVerbalSupport          = Convert.ToBoolean(ddOBSVerbalSupport.Value);
                currentCoachingLog.OBSSideBySide             = Convert.ToBoolean(ddOBSSideBySide.Value);
                currentCoachingLog.OBSProblemSolving         = Convert.ToBoolean(ddOBSProblemSolving.Value);
                currentCoachingLog.OBSReflectiveConversation = Convert.ToBoolean(ddOBSReflectiveConversation.Value);
                currentCoachingLog.OBSEnvironment            = Convert.ToBoolean(ddOBSEnvironment.Value);
                currentCoachingLog.OBSOtherHelp              = Convert.ToBoolean(ddOBSOtherHelp.Value);
                currentCoachingLog.OBSConductTPOT            = Convert.ToBoolean(ddOBSConductTPOT.Value);
                currentCoachingLog.OBSConductTPITOS          = Convert.ToBoolean(ddOBSConductTPITOS.Value);
                currentCoachingLog.OBSOther        = Convert.ToBoolean(ddOBSOther.Value);
                currentCoachingLog.OBSOtherSpecify = (txtOBSOtherSpecify.Value == null ? null : txtOBSOtherSpecify.Value.ToString());

                //Meetings
                currentCoachingLog.MEETProblemSolving         = Convert.ToBoolean(ddMEETProblemSolving.Value);
                currentCoachingLog.MEETReflectiveConversation = Convert.ToBoolean(ddMEETReflectiveConversation.Value);
                currentCoachingLog.MEETEnvironment            = Convert.ToBoolean(ddMEETEnvironment.Value);
                currentCoachingLog.MEETRoleplay      = Convert.ToBoolean(ddMEETRoleplay.Value);
                currentCoachingLog.MEETVideo         = Convert.ToBoolean(ddMEETVideo.Value);
                currentCoachingLog.MEETGraphic       = Convert.ToBoolean(ddMEETGraphic.Value);
                currentCoachingLog.MEETGoalSetting   = Convert.ToBoolean(ddMEETGoalSetting.Value);
                currentCoachingLog.MEETPerformance   = Convert.ToBoolean(ddMEETPerformance.Value);
                currentCoachingLog.MEETMaterial      = Convert.ToBoolean(ddMEETMaterial.Value);
                currentCoachingLog.MEETDemonstration = Convert.ToBoolean(ddMEETDemonstration.Value);
                currentCoachingLog.MEETOther         = Convert.ToBoolean(ddMEETOther.Value);
                currentCoachingLog.MEETOtherSpecify  = (txtMEETOtherSpecify.Value == null ? null : txtMEETOtherSpecify.Value.ToString());

                //Follow-up
                currentCoachingLog.FUEmail    = Convert.ToBoolean(ddFUEmail.Value);
                currentCoachingLog.FUPhone    = Convert.ToBoolean(ddFUPhone.Value);
                currentCoachingLog.FUInPerson = Convert.ToBoolean(ddFUInPerson.Value);

                if (currentCoachingLog.FUEmail || currentCoachingLog.FUPhone || currentCoachingLog.FUInPerson)
                {
                    currentCoachingLog.FUNone = false;
                }
                else
                {
                    currentCoachingLog.FUNone = true;
                }

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

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

                        //Get the existing CoachingLog record
                        Models.CoachingLog existingCoachingLog = context.CoachingLog.Find(currentCoachingLog.CoachingLogPK);

                        //Overwrite the existing CoachingLog record with the values from the form
                        context.Entry(existingCoachingLog).CurrentValues.SetValues(currentCoachingLog);
                        context.SaveChanges();
                    }

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

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

                        //Add the CoachingLog to the database
                        context.CoachingLog.Add(currentCoachingLog);
                        context.SaveChanges();
                    }

                    //Redirect the user to the CoachingLog dashboard
                    Response.Redirect(string.Format("/Pages/CoachingLogDashboard.aspx?messageType={0}", successMessageType));
                }
            }
        }
Пример #28
0
        /// <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));
                }
            }
        }
Пример #29
0
        /// <summary>
        /// This method executes when the user clicks the save button for the report catalog item
        /// and it saves the information to the database
        /// </summary>
        /// <param name="sender">The submitReportCatalogItem submit user control</param>
        /// <param name="e">The Click event</param>
        protected void submitReportCatalogItem_Click(object sender, EventArgs e)
        {
            //To hold the success message type, file path, and file name
            string successMessageType = null;

            //Ensure user is allowed to edit
            if (currentProgramRole.AllowedToEdit.Value)
            {
                //Get the relative file path
                string relativePath = "~/Reports/Documentation/" + txtDocumentationFileName.Value.ToString();

                //Set the field values
                currentReportCatalog.CriteriaOptions         = tbCriteriaOptions.Text + ",";
                currentReportCatalog.CriteriaDefaults        = tbCriteriaDefaults.Text + ",";
                currentReportCatalog.DocumentationLink       = relativePath;
                currentReportCatalog.Keywords                = tbKeywords.Text + ",";
                currentReportCatalog.OptionalCriteriaOptions = tbOptionalCriteriaOptions.Text + ",";
                currentReportCatalog.ReportCategory          = (ddReportCategory.Value.ToString().ToLower().Contains("other") ? txtReportCategorySpecify.Value.ToString() : ddReportCategory.Value.ToString());
                currentReportCatalog.ReportClass             = txtReportClass.Value.ToString();
                currentReportCatalog.ReportDescription       = txtReportDescription.Value.ToString();
                currentReportCatalog.ReportName              = txtReportName.Value.ToString();
                currentReportCatalog.RolesAuthorizedToRun    = tbRolesAuthorizedToRun.Value.ToString() + ",";

                //Check to see if this is an edit or add
                if (currentReportCatalog.ReportCatalogPK > 0)
                {
                    //This is an edit
                    using (PyramidContext context = new PyramidContext())
                    {
                        //Set the success message
                        successMessageType = "ReportCatalogItemEdited";

                        //Get the existing ReportCatalog record
                        Models.ReportCatalog existingReportCatalog = context.ReportCatalog.Find(currentReportCatalog.ReportCatalogPK);

                        //Overwrite the existing ReportCatalog record with the values from the form
                        context.Entry(existingReportCatalog).CurrentValues.SetValues(currentReportCatalog);
                        context.SaveChanges();
                    }

                    //Redirect the user to the report catalog maintenance page
                    Response.Redirect(string.Format("/Admin/ReportCatalogMaintenance.aspx?messageType={0}", successMessageType));
                }
                else
                {
                    //This is an add
                    using (PyramidContext context = new PyramidContext())
                    {
                        //Set the success message
                        successMessageType = "ReportCatalogItemAdded";

                        //Set the edit-only fields
                        currentReportCatalog.Creator    = User.Identity.Name;
                        currentReportCatalog.CreateDate = DateTime.Now;

                        //Add the ReportCatalog record to the database
                        context.ReportCatalog.Add(currentReportCatalog);
                        context.SaveChanges();
                    }

                    //Redirect the user to the report catalog maintenance page
                    Response.Redirect(string.Format("/Admin/ReportCatalogMaintenance.aspx?messageType={0}", successMessageType));
                }
            }
            else
            {
                msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000);
            }
        }
Пример #30
0
        /// <summary>
        /// This method executes when the user clicks the delete button for a UserFileUpload
        /// and it deletes the UserFileUpload information from the database
        /// </summary>
        /// <param name="sender">The lbDeleteUserFileUpload LinkButton</param>
        /// <param name="e">The Click event</param>
        protected void lbDeleteUserFileUpload_Click(object sender, EventArgs e)
        {
            if (currentProgramRole.AllowedToEdit.Value ||
                currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.HUB_DATA_VIEWER)
            {
                //Get the PK from the hidden field
                int?removeUserFileUploadPK = (String.IsNullOrWhiteSpace(hfDeleteUserFileUploadPK.Value) ? (int?)null : Convert.ToInt32(hfDeleteUserFileUploadPK.Value));

                //Remove the role if the PK is not null
                if (removeUserFileUploadPK != null)
                {
                    try
                    {
                        using (PyramidContext context = new PyramidContext())
                        {
                            //Get the UserFileUpload program row to remove
                            Models.UserFileUpload fileToRemove = context.UserFileUpload
                                                                 .Include(ufu => ufu.CodeFileUploadType)
                                                                 .Where(ufu => ufu.UserFileUploadPK == removeUserFileUploadPK)
                                                                 .FirstOrDefault();

                            //Ensure the user is allowed to delete this file
                            if (!fileToRemove.CodeFileUploadType.RolesAuthorizedToModify.Contains((currentProgramRole.RoleFK.Value.ToString() + ",")) ||
                                (fileToRemove.TypeCodeFK == (int)Utilities.FileTypeFKs.PROGRAM_WIDE &&
                                 currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.HUB_DATA_VIEWER &&
                                 fileToRemove.Creator != User.Identity.Name))
                            {
                                msgSys.ShowMessageToUser("danger", "Delete Failed", "You are not authorized to delete this file!", 10000);
                            }
                            else
                            {
                                //Remove the file from Azure storage
                                Utilities.DeleteFileFromAzureStorage(fileToRemove.FileName,
                                                                     Utilities.ConstantAzureStorageContainerName.UPLOADED_FILES.ToString());

                                //Remove the UserFileUpload
                                context.UserFileUpload.Remove(fileToRemove);
                                context.SaveChanges();

                                //Show a success message
                                msgSys.ShowMessageToUser("success", "Delete Succeeded", "Successfully deleted file!", 10000);
                            }
                        }
                    }
                    catch (DbUpdateException dbUpdateEx)
                    {
                        //Check if it is a foreign key error
                        if (dbUpdateEx.InnerException?.InnerException is SqlException)
                        {
                            //If it is a foreign key error, display a custom message
                            SqlException sqlEx = (SqlException)dbUpdateEx.InnerException.InnerException;
                            if (sqlEx.Number == 547)
                            {
                                msgSys.ShowMessageToUser("danger", "Error", "Could not delete the file, there are related records in the system!<br/><br/>If you do not know what related records exist, please contact tech support via ticket.", 120000);
                            }
                            else
                            {
                                msgSys.ShowMessageToUser("danger", "Error", "An error occurred while deleting the file!", 120000);
                            }
                        }
                        else
                        {
                            msgSys.ShowMessageToUser("danger", "Error", "An error occurred while deleting the file!", 120000);
                        }

                        //Log the error
                        Elmah.ErrorSignal.FromCurrentContext().Raise(dbUpdateEx);
                    }

                    //Rebind the UserFileUpload controls
                    bsGRUserFileUploads.DataBind();
                }
                else
                {
                    msgSys.ShowMessageToUser("danger", "Error", "Could not find the file to delete!", 120000);
                }
            }
            else
            {
                msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000);
            }
        }