示例#1
0
        /// <summary>
        /// Bind the hub repeater and dropdowns
        /// </summary>
        private void BindHubs()
        {
            using (PyramidContext context = new PyramidContext())
            {
                //Get all hubs
                List <Hub> allHubs;
                if (currentProgramRole.RoleFK.Value != (int)Utilities.ProgramRoleFKs.SUPER_ADMIN)
                {
                    allHubs = context.Hub
                              .Include(h => h.Program)
                              .Where(h => h.StateFK == currentProgramRole.StateFK)
                              .OrderBy(h => h.Name)
                              .AsNoTracking()
                              .ToList();
                }
                else
                {
                    allHubs = context.Hub
                              .Include(h => h.Program)
                              .OrderBy(h => h.Name)
                              .AsNoTracking()
                              .ToList();
                }

                //Bind the hub gridview
                bsGRHubs.DataBind();

                //Bind the hub drop-down
                ddProgramHub.DataSource = allHubs;
                ddProgramHub.DataBind();
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Get the user's selected role
            currentProgramRole = Utilities.GetProgramRoleFromSession(Session);

            //Hide the states if the user is not a super admin
            if (currentProgramRole.RoleFK.Value != (int)Utilities.ProgramRoleFKs.SUPER_ADMIN)
            {
                divStates.Visible = false;
            }

            if (!IsPostBack)
            {
                //Bind the cohort, hub, and state data-bound controls
                BindCohorts();
                BindHubs();
                BindPrograms();
                BindStates();

                using (PyramidContext context = new PyramidContext())
                {
                    //Get the program types
                    var programTypes = context.CodeProgramType.AsNoTracking().OrderBy(cpt => cpt.OrderBy).ToList();
                    lstBxProgramType.DataSource = programTypes;
                    lstBxProgramType.DataBind();
                }
            }
        }
示例#3
0
        /// <summary>
        /// This method fires when the data source for the child DevExpress GridView is selecting
        /// and it handles the select
        /// </summary>
        /// <param name="sender">The efChildDataSource control</param>
        /// <param name="e">The LinqServerModeDataSourceSelectEventArgs event</param>
        protected void efChildDataSource_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e)
        {
            //Set the key expression
            e.KeyExpression = "ChildProgramPK";

            //Set the source to a LINQ query
            PyramidContext context = new PyramidContext();

            e.QueryableSource = from c in context.Child.Include(c => c.ChildProgram).AsNoTracking()
                                join cp in context.ChildProgram.Include(cp => cp.CodeDischargeReason).Include(cp => cp.Program) on c.ChildPK equals cp.ChildFK
                                where currentProgramRole.ProgramFKs.Contains(cp.ProgramFK)
                                select new {
                c.ChildPK,
                Name = c.FirstName + " " + c.LastName,
                c.BirthDate,
                cp.ChildProgramPK,
                cp.ProgramSpecificID,
                cp.HasIEP,
                cp.IsDLL,
                cp.EnrollmentDate,
                cp.DischargeDate,
                DischargeReason = cp.CodeDischargeReason.Description,
                cp.DischargeReasonSpecify,
                cp.ProgramFK,
                cp.Program.ProgramName
            };
        }
        /// <summary>
        /// This method fires when the data source for the OtherSEScreen DevExpress GridView is selecting
        /// and it handles the select
        /// </summary>
        /// <param name="sender">The efOtherSEScreenDataSource control</param>
        /// <param name="e">The LinqServerModeDataSourceSelectEventArgs event</param>
        protected void efOtherSEScreenDataSource_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e)
        {
            //Set the key expression
            e.KeyExpression = "OtherSEScreenPK";

            //Set the source to a LINQ query
            PyramidContext context = new PyramidContext();

            e.QueryableSource = from ose in context.OtherSEScreen.AsNoTracking()
                                .Include(ose => ose.Program)
                                .Include(ose => ose.Child)
                                .Include(ose => ose.CodeScoreType)
                                .Include(ose => ose.CodeScreenType)
                                join cp in context.ChildProgram on ose.ChildFK equals cp.ChildFK
                                where currentProgramRole.ProgramFKs.Contains(ose.ProgramFK) &&
                                cp.ProgramFK == ose.ProgramFK &&
                                cp.EnrollmentDate <= ose.ScreenDate &&
                                (cp.DischargeDate.HasValue == false || cp.DischargeDate >= ose.ScreenDate)
                                select new
            {
                ose.OtherSEScreenPK,
                ScreenType = ose.CodeScreenType.Description,
                ose.ScreenDate,
                ose.Score,
                ChildIdAndName = "(" + cp.ProgramSpecificID + ") " + ose.Child.FirstName + " " + ose.Child.LastName,
                ose.Program.ProgramName,
                ScoreType = ose.CodeScoreType.Description
            };
        }
        /// <summary>
        /// This method fires when the data source for the Behavior Incident DevExpress GridView is selecting
        /// and it handles the select
        /// </summary>
        /// <param name="sender">The efBehaviorIncidentDataSource control</param>
        /// <param name="e">The LinqServerModeDataSourceSelectEventArgs event</param>
        protected void efBehaviorIncidentDataSource_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e)
        {
            //Set the key expression
            e.KeyExpression = "BehaviorIncidentPK";

            //Set the source to a LINQ query
            PyramidContext context = new PyramidContext();

            e.QueryableSource = from bi in context.BehaviorIncident.AsNoTracking()
                                .Include(bi => bi.Child)
                                .Include(bi => bi.Classroom)
                                .Include(bi => bi.Classroom.Program)
                                .Include(bi => bi.CodeProblemBehavior)
                                join cp in context.ChildProgram on bi.ChildFK equals cp.ChildFK
                                where currentProgramRole.ProgramFKs.Contains(bi.Classroom.ProgramFK) &&
                                cp.ProgramFK == bi.Classroom.ProgramFK &&
                                cp.EnrollmentDate <= bi.IncidentDatetime &&
                                (cp.DischargeDate.HasValue == false || cp.DischargeDate >= bi.IncidentDatetime)
                                select new
            {
                bi.BehaviorIncidentPK,
                bi.Creator,
                bi.CreateDate,
                bi.IncidentDatetime,
                ChildName       = "(" + cp.ProgramSpecificID + ") " + bi.Child.FirstName + " " + bi.Child.LastName,
                ClassroomName   = "(" + bi.Classroom.ProgramSpecificID + ") " + bi.Classroom.Name,
                ProblemBehavior = bi.CodeProblemBehavior.Description,
                bi.Classroom.Program.ProgramName
            };
        }
        /// <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));
                }
            }
        }
示例#7
0
        /// <summary>
        /// This method fires when the data source for the ASQSE DevExpress GridView is selecting
        /// and it handles the select
        /// </summary>
        /// <param name="sender">The efASQSEDataSource control</param>
        /// <param name="e">The LinqServerModeDataSourceSelectEventArgs event</param>
        protected void efASQSEDataSource_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e)
        {
            //Set the key expression
            e.KeyExpression = "ASQSEPK";

            //Set the source to a LINQ query
            PyramidContext context = new PyramidContext();

            e.QueryableSource = from a in context.ASQSE.AsNoTracking()
                                .Include(a => a.Program)
                                .Include(a => a.Child)
                                .Include(a => a.CodeASQSEInterval)
                                join cp in context.ChildProgram on a.ChildFK equals cp.ChildFK
                                join sa in context.ScoreASQSE on a.IntervalCodeFK equals sa.IntervalCodeFK
                                where currentProgramRole.ProgramFKs.Contains(a.ProgramFK) &&
                                cp.ProgramFK == a.ProgramFK &&
                                cp.EnrollmentDate <= a.FormDate &&
                                (cp.DischargeDate.HasValue == false || cp.DischargeDate >= a.FormDate) &&
                                a.Version == sa.Version
                                select new
            {
                a.ASQSEPK,
                a.FormDate,
                a.TotalScore,
                ChildIdAndName = "(" + cp.ProgramSpecificID + ") " + a.Child.FirstName + " " + a.Child.LastName,
                a.Program.ProgramName,
                Interval  = a.CodeASQSEInterval.Description,
                ScoreType = (a.TotalScore > sa.CutoffScore ? "Above Cutoff"
                                                    : a.TotalScore >= sa.MonitoringScoreStart && a.TotalScore <= sa.MonitoringScoreEnd ? "Monitor"
                                                    : a.TotalScore >= 0 && a.TotalScore < sa.MonitoringScoreStart ? "Well Below"
                                                    : "Error!")
            };
        }
        /// <summary>
        /// This method binds the coach dropdown by getting all the coaches in
        /// the program that were active at the point of time passed to this method.
        /// </summary>
        /// <param name="logDate">The date and time to check against</param>
        /// <param name="programFK">The program FK</param>
        /// <param name="coachFK">The coach's FK to be selected</param>
        private void BindCoachDropDown(DateTime?logDate, int programFK, int?coachFK)
        {
            if (logDate.HasValue)
            {
                using (PyramidContext context = new PyramidContext())
                {
                    //Get all the coaches in the program that were active as of the log date
                    var allCoaches = context.spGetAllCoaches(programFK, logDate).ToList();

                    //Bind the coach dropdown to the list of coaches
                    ddCoach.DataSource = allCoaches;
                    ddCoach.DataBind();
                }

                //Try to select the coach passed to this method
                ddCoach.SelectedItem = ddCoach.Items.FindByValue(coachFK);

                //Enable the coach dropdown
                ddCoach.ReadOnly = false;
            }
            else
            {
                //No date was passed, clear and disable the coach dropdown
                ddCoach.Value    = "";
                ddCoach.ReadOnly = true;
            }
        }
示例#9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //Set the hidden field values for the customization cookie
                hfCustomizationOptionCookieName.Value    = Utilities.CustomizationOptionCookieName;
                hfCustomizationOptionCookieSection.Value = Utilities.CustomizationOptionCookieSection;

                try
                {
                    //Get the customization cookie
                    HttpCookie customizationCookie = Request.Cookies[Utilities.CustomizationOptionCookieName];

                    //If the customization cookie is null, refill from the database
                    if (customizationCookie == null)
                    {
                        //Get the user's customization options from the database
                        List <spGetUserCustomizationOptions_Result> userCustomizationOptions = new List <spGetUserCustomizationOptions_Result>();
                        using (PyramidContext databaseContext = new PyramidContext())
                        {
                            //Get the user's customization options
                            userCustomizationOptions = databaseContext.spGetUserCustomizationOptions(Context.User.Identity.Name).ToList();
                        }

                        //Set the customization cookie
                        Utilities.SetCustomizationOptionCookie(userCustomizationOptions);
                    }
                }
                catch (Exception ex)
                {
                    //Log the exception
                    Utilities.LogException(ex);
                }
            }
        }
示例#10
0
        /// <summary>
        /// Bind the state repeater and dropdowns
        /// </summary>
        private void BindStates()
        {
            using (PyramidContext context = new PyramidContext())
            {
                //Get all the states
                List <State> allStates;
                if (currentProgramRole.RoleFK.Value != (int)Utilities.ProgramRoleFKs.SUPER_ADMIN)
                {
                    allStates = context.State
                                .Include(s => s.Program)
                                .Where(s => s.StatePK == currentProgramRole.StateFK)
                                .OrderBy(s => s.Name)
                                .AsNoTracking()
                                .ToList();
                }
                else
                {
                    allStates = context.State
                                .Include(s => s.Program)
                                .OrderBy(s => s.Name)
                                .AsNoTracking()
                                .ToList();
                }

                //Bind the state drop-downs
                ddProgramState.DataSource = allStates;
                ddProgramState.DataBind();

                ddHubState.DataSource = allStates;
                ddHubState.DataBind();

                ddCohortState.DataSource = allStates;
                ddCohortState.DataBind();
            }
        }
        /// <summary>
        /// This method binds the child dropdown by getting all the children in
        /// the program that were active at the point of time passed to this method.
        /// </summary>
        /// <param name="incidentDateTime">The date and time to check against</param>
        /// <param name="programFK">The program FK</param>
        /// <param name="childFK">The child's FK to be selected</param>
        private void BindChildDropDown(DateTime?incidentDateTime, int programFK, int?childFK)
        {
            //Only continue if the date has a value
            if (incidentDateTime.HasValue)
            {
                using (PyramidContext context = new PyramidContext())
                {
                    //Get all the children in the program
                    var allChildren = from c in context.Child.Include(c => c.ChildProgram).AsNoTracking()
                                      join cp in context.ChildProgram on c.ChildPK equals cp.ChildFK
                                      where cp.ProgramFK == programFK &&
                                      cp.EnrollmentDate <= incidentDateTime.Value &&
                                      (cp.DischargeDate.HasValue == false || cp.DischargeDate >= incidentDateTime.Value)
                                      orderby cp.ProgramSpecificID ascending
                                      select new
                    {
                        c.ChildPK,
                        cp.ChildProgramPK,
                        IdAndName = "(" + cp.ProgramSpecificID + ") "
                                    + c.FirstName + " " + c.LastName
                    };
                    ddChild.DataSource = allChildren.ToList();
                    ddChild.DataBind();
                }

                //Check to see how many kids there are
                if (ddChild.Items.Count > 0)
                {
                    //There are kids in the list, enable the child and classroom dropdown
                    ddChild.ReadOnly     = false;
                    ddClassroom.ReadOnly = false;

                    //Show the edit child link
                    lbEditChild.Visible = true;

                    //Try to select the child passed to this method
                    ddChild.SelectedItem = ddChild.Items.FindByValue(childFK);
                }
                else
                {
                    //There are no kids in the list, disable the child and classroom dropdown
                    ddChild.ReadOnly     = true;
                    ddClassroom.ReadOnly = true;

                    //Hide the edit child link
                    lbEditChild.Visible = false;
                }
            }
            else
            {
                //No date was passed, clear and disable the child and classroom dropdowns
                ddChild.Value        = "";
                ddChild.ReadOnly     = true;
                ddClassroom.Value    = "";
                ddClassroom.ReadOnly = true;

                //Hide the edit child link
                lbEditChild.Visible = false;
            }
        }
示例#12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //Get the program roles for the user
                using (PyramidContext context = new PyramidContext())
                {
                    var userProgramRoles = context.UserProgramRole
                                           .Include(upr => upr.Program)
                                           .Include(upr => upr.CodeProgramRole)
                                           .Where(upr => upr.Username == User.Identity.Name).ToList();
                    repeatUserRoles.DataSource = userProgramRoles;
                    repeatUserRoles.DataBind();
                }

                //Check to see if there are any messages
                if (Request.QueryString["message"] != null)
                {
                    //Get the message type
                    string messageType = Request.QueryString["message"].ToString();

                    //Get the message to display
                    switch (messageType)
                    {
                    case "LostSession":
                        msgSys.ShowMessageToUser("warning", "Role Lost", "Your selected role was lost, please choose your role again! <br/> <br/> If this occurs more than occasionally, please contact support via the ticketing system.", 12000);
                        break;

                    case "TwoFactorVerified":
                        msgSys.ShowMessageToUser("success", "Two-Factor Code Verified", "Your Two-Factor code was successfully verified!", 5000);
                        break;
                    }
                }
            }
        }
示例#13
0
        /// <summary>
        /// Initialize a Context with Strategy and Calcuate
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            try
            {
                //Initialize Pyramid Context with Default Strategy
                PyramidContext p = new PyramidContext(new DefaultPyramidStrategy());

                //Use Context Object to Build the Pyramid
                if (p.BuildPyramid(new PyramidData()))
                {
                    //On building the Pyramid
                    //Use Context Object to call the Strategy Method to Do the Calculation
                    ResultModel resultModel = p.WalkAndCalculate();

                    //Display the Result
                    if (null != resultModel)
                    {
                        resultModel.Display();
                    }
                }
                else
                {
                    Console.WriteLine("Building the Pyramid Failed");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception Occured: " + ex.Message.ToString());
            }
        }
        /// <summary>
        /// This method fires when the user clicks the lbEditChild LinkButton
        /// and it opens a new tab for the user to edit the child selected
        /// in the ddChild ComboBox
        /// </summary>
        /// <param name="sender">The lbEditChild LinkButton</param>
        /// <param name="e">The Click event</param>
        protected void lbEditChild_Click(object sender, EventArgs e)
        {
            //Get the incident datetime, the child FK, and the program FK
            DateTime?incidentDateTime = (deIncidentDatetime.Value == null ? (DateTime?)null : Convert.ToDateTime(deIncidentDatetime.Value));
            int?     childFK          = (ddChild.Value == null ? (int?)null : Convert.ToInt32(ddChild.Value));

            //Only continue if the incident datetime and child FK have values
            if (incidentDateTime.HasValue && childFK.HasValue)
            {
                using (PyramidContext context = new PyramidContext())
                {
                    //Get the ChildProgram record
                    var childProgram = context.ChildProgram
                                       .Where(cp => cp.ChildFK == childFK.Value &&
                                              cp.ProgramFK == programFK)
                                       .OrderBy(cp => cp.EnrollmentDate).FirstOrDefault();

                    //Check to see if the ChildProgram record exists and the user's edit permissions
                    if (childProgram.ChildProgramPK > 0 && currentProgramRole.AllowedToEdit.Value)
                    {
                        //The ChildProgram record exists and the user can edit, open a new tab for the user to edit the child
                        string urlToRedirect = "Child.aspx?ChildProgramPK=" + childProgram.ChildProgramPK.ToString() + "&Action=Edit";
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "OpenChildTab", "window.open('" + urlToRedirect + "')", true);
                    }
                }
            }
        }
示例#15
0
        /// <summary>
        /// This method populates the news div with the news that is after the limit date
        /// passed to this method
        /// </summary>
        /// <param name="limitDate">A limiting DateTime</param>
        private void BindNews(DateTime limitDate)
        {
            //To hold the news
            List <NewsEntry> newsEntries;

            using (PyramidContext context = new PyramidContext())
            {
                //Get the news entries that apply to this user's role (app, state, hub, and program)
                newsEntries = context.NewsEntry.Include(ne => ne.NewsItem)
                              .Include(ne => ne.CodeNewsEntryType)
                              .Where(ne => ((ne.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.PROGRAM_WIDE &&
                                             currentProgramRole.ProgramFKs.Contains(ne.ProgramFK.Value)) ||
                                            ne.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.APPLICATION ||
                                            (ne.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.STATE_WIDE &&
                                             currentProgramRole.StateFK.Value == ne.StateFK.Value) ||
                                            (ne.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.HUB_WIDE &&
                                             currentProgramRole.HubFK.Value == ne.HubFK.Value) ||
                                            (ne.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.COHORT_WIDE &&
                                             currentProgramRole.CohortFKs.Contains(ne.CohortFK.Value))) &&
                                     ne.EntryDate >= limitDate &&
                                     ne.EntryDate <= DateTime.Now)
                              .OrderByDescending(ne => ne.EntryDate)
                              .ThenByDescending(ne => ne.CreateDate)
                              .ToList();
            }

            //To hold the news HTML
            StringBuilder newsHTML = new StringBuilder();

            //Make sure there is news to show
            if (newsEntries.Count > 0)
            {
                //There is news to show
                //Loop through each news entry
                foreach (NewsEntry entry in newsEntries)
                {
                    //Add HTML for the entry
                    newsHTML.Append("<div class='news-entry'><label class='news-entry-date'>" + entry.EntryDate.ToString("MM/dd/yyyy") + "</label> (" + entry.CodeNewsEntryType.Description + ")");
                    newsHTML.Append("<ul class='news-list'>");

                    //Loop through each news item in the entry
                    foreach (NewsItem item in entry.NewsItem.OrderBy(ni => ni.ItemNum))
                    {
                        //Add HTML for the item
                        newsHTML.Append("<li>" + Server.HtmlEncode(item.Contents) + "</li>");
                    }

                    //Close the HTML tags
                    newsHTML.Append("</ul></div>");
                }
            }
            else
            {
                //There was no news to show
                newsHTML.Append("No news found...");
            }

            //Display the news
            ltlNews.Text = newsHTML.ToString();
        }
示例#16
0
        /// <summary>
        /// This method populates all the databound controls on the page
        /// </summary>
        private void BindDataBoundControls()
        {
            using (PyramidContext context = new PyramidContext())
            {
                //Get all the News Entry types
                List <CodeNewsEntryType> allNewsEntryTypes = context.CodeNewsEntryType.AsNoTracking()
                                                             .OrderBy(cnet => cnet.OrderBy)
                                                             .ToList();

                //Create a default filter for the type list
                CodeNewsEntryType defaultFilter = new CodeNewsEntryType();
                defaultFilter.CodeNewsEntryTypePK = 999;
                defaultFilter.Description         = "--All--";
                defaultFilter.OrderBy             = 0;

                //Add the default filter to the first point in the list
                allNewsEntryTypes.Insert(0, defaultFilter);

                //Bind the type dropdown
                ddEntryType.DataSource = allNewsEntryTypes;
                ddEntryType.DataBind();

                //Pre-select the default filter
                ddEntryType.SelectedIndex = 0;
            }
        }
示例#17
0
        /// <summary>
        /// This method fires when the value in the ddInterval ComboBox's selected index
        /// changes and it updates the cutoff and score type
        /// </summary>
        /// <param name="sender">The ddInterval ComboBox</param>
        /// <param name="e">The SelectedIndexChanged event</param>
        protected void ddInterval_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Get the total score, selected interval, and selected version number
            int totalScore         = (txtTotalScore.Value == null ? 0 : Convert.ToInt32(txtTotalScore.Value));
            int?selectedIntervalFK = (ddInterval.Value == null ? (int?)null : Convert.ToInt32(ddInterval.Value));
            int?selectedVersionNum = (ddVersion.Value == null ? (int?)null : Convert.ToInt32(ddVersion.Value));

            if (selectedIntervalFK.HasValue && selectedVersionNum.HasValue)
            {
                //Enable the total score text box
                txtTotalScore.ReadOnly = false;

                using (PyramidContext context = new PyramidContext())
                {
                    //Get the ScoreASQSE for the interval and version
                    currentScoreASQSE = context.ScoreASQSE.AsNoTracking()
                                        .Where(sa => sa.IntervalCodeFK == selectedIntervalFK && sa.Version == selectedVersionNum)
                                        .FirstOrDefault();
                }

                //Update the cutoff and score type
                UpdateCutoffAndMonitoringLabels(currentScoreASQSE);
                UpdateScoreType(totalScore, currentScoreASQSE);
            }
            else
            {
                txtTotalScore.ReadOnly = true;
            }
        }
示例#18
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");
        }
示例#19
0
        /// <summary>
        /// Bind the cohort repeater and dropdowns
        /// </summary>
        private void BindCohorts()
        {
            using (PyramidContext context = new PyramidContext())
            {
                //Get all cohorts
                List <Cohort> allCohorts;
                if (currentProgramRole.RoleFK.Value != (int)Utilities.ProgramRoleFKs.SUPER_ADMIN)
                {
                    allCohorts = context.Cohort
                                 .Include(c => c.Program)
                                 .Where(c => c.StateFK == currentProgramRole.StateFK)
                                 .OrderBy(c => c.CohortName)
                                 .AsNoTracking()
                                 .ToList();
                }
                else
                {
                    allCohorts = context.Cohort
                                 .Include(c => c.Program)
                                 .OrderBy(c => c.CohortName)
                                 .AsNoTracking()
                                 .ToList();
                }

                //Bind the cohort gridview
                bsGRCohort.DataBind();

                //Bind the cohort drop-down
                ddProgramCohort.DataSource = allCohorts;
                ddProgramCohort.DataBind();
            }
        }
        /// <summary>
        /// This method populates the dropdowns from the database
        /// </summary>
        private void BindDropDowns()
        {
            //Bind the child and interval dropdowns
            if (currentOtherSEScreen.OtherSEScreenPK > 0)
            {
                //If this is an edit, use the program fk from the behavior incident's classroom to filter
                BindChildDropDown(currentOtherSEScreen.ScreenDate, currentProgramFK, currentOtherSEScreen.ChildFK);
            }
            else
            {
                //If this is an add, use the program FKs array from the program role to filter
                BindChildDropDown((DateTime?)null, currentProgramFK, (int?)null);
            }

            using (PyramidContext context = new PyramidContext())
            {
                //Get all the screen types and bind them to the screen type dropdown
                var allScreenTypes = context.CodeScreenType.AsNoTracking().OrderBy(cst => cst.OrderBy).ToList();
                ddScreenType.DataSource = allScreenTypes;
                ddScreenType.DataBind();

                //Get all the score types and bind them to the score type dropdown
                var allScoreTypes = context.CodeScoreType.AsNoTracking().OrderBy(cst => cst.OrderBy).ToList();
                ddScoreType.DataSource = allScoreTypes;
                ddScoreType.DataBind();
            }
        }
        /// <summary>
        /// This method fires when the data source for the employee DevExpress GridView is selecting
        /// and it handles the select
        /// </summary>
        /// <param name="sender">The efEmployeeDataSource control</param>
        /// <param name="e">The LinqServerModeDataSourceSelectEventArgs event</param>
        protected void efEmployeeDataSource_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e)
        {
            //Set the key expression
            e.KeyExpression = "ProgramEmployeePK";

            //Set the source to a LINQ query
            PyramidContext context = new PyramidContext();

            e.QueryableSource = (from pe in context.ProgramEmployee.AsNoTracking().Include(pe => pe.CodeTermReason).Include(pe => pe.Program)
                                 join jf in context.JobFunction.AsNoTracking().Include(jf => jf.CodeJobType) on pe.ProgramEmployeePK equals jf.ProgramEmployeeFK into jobFunctions
                                 join t in context.Training.AsNoTracking().Include(t => t.CodeTraining) on pe.ProgramEmployeePK equals t.ProgramEmployeeFK into trainings
                                 where currentProgramRole.ProgramFKs.Contains(pe.ProgramFK)
                                 select new
            {
                pe.ProgramEmployeePK,
                Name = pe.FirstName + " " + pe.LastName,
                pe.EmailAddress,
                JobFunctions = from jf in jobFunctions where jf.EndDate.HasValue == false select jf.CodeJobType.Description,
                Trainings = from t in trainings where t.TrainingCodeFK == (int)Utilities.TrainingFKs.INTRODUCTION_TO_COACHING ||
                            t.TrainingCodeFK == (int)Utilities.TrainingFKs.PRACTICE_BASED_COACHING ||
                            t.TrainingCodeFK == (int)Utilities.TrainingFKs.TPITOS_OBSERVER ||
                            t.TrainingCodeFK == (int)Utilities.TrainingFKs.TPOT_OBSERVER
                            orderby t.TrainingDate ascending
                            select(t.CodeTraining.Abbreviation + ": " + SqlFunctions.DatePart("month", t.TrainingDate) + "/" + SqlFunctions.DatePart("day", t.TrainingDate) + "/" + SqlFunctions.DatePart("year", t.TrainingDate)),
                pe.HireDate,
                pe.TermDate,
                TermReason = pe.CodeTermReason.Description + " " + (pe.TermReasonSpecify == null ? "" : "(" + pe.TermReasonSpecify + ")"),
                pe.ProgramFK,
                pe.Program.ProgramName
            });
        }
示例#22
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();
                }
            }
        }
        /// <summary>
        /// This method executes when the user clicks the verify button in
        /// the verify code section and it attempts to log the user in with
        /// the code they entered
        /// </summary>
        /// <param name="sender">The btnVerifyCode DevEx button</param>
        /// <param name="e">The Click event</param>
        protected void btnVerifyCode_Click(object sender, EventArgs e)
        {
            //Only continue if the validation is successful
            if (ASPxEdit.AreEditorsValid(this, btnVerifyCode.ValidationGroup))
            {
                //Try to sign the user in
                var result = signinManager.TwoFactorSignIn <PyramidUser, string>(hfSelectedProvider.Value, txtCode.Text, isPersistent: false, rememberBrowser: chkRememberBrowser.Checked);
                switch (result)
                {
                case SignInStatus.Success:
                    //Get the user ID
                    string userID = signinManager.GetVerifiedUserId <PyramidUser, string>();

                    //Get the user
                    var user = manager.FindById(userID);

                    //Get the user's program roles
                    List <UserProgramRole> userProgramRoles;
                    using (PyramidContext context = new PyramidContext())
                    {
                        userProgramRoles = context.UserProgramRole.Where(upr => upr.Username == user.UserName).ToList();
                    }

                    //Redirect the user based on the number of roles they have
                    if (userProgramRoles.Count > 1)
                    {
                        //Redirect the user to the select role page
                        Response.Redirect(String.Format("/Account/SelectRole.aspx?ReturnUrl={0}&message={1}",
                                                        (Request.QueryString["ReturnUrl"] != null ? Request.QueryString["ReturnUrl"].ToString() : "/Default.aspx"),
                                                        "TwoFactorVerified"));
                    }
                    else
                    {
                        //Get the UserProgramRole
                        UserProgramRole programRole = userProgramRoles.FirstOrDefault();

                        //Set the session variables
                        Session["CodeProgramRoleFK"] = programRole.CodeProgramRole.CodeProgramRolePK;
                        Session["ProgramRoleName"]   = programRole.CodeProgramRole.RoleName;
                        Session["ProgramFK"]         = programRole.ProgramFK;
                        Session["ProgramName"]       = programRole.Program.ProgramName;

                        //Redirect the user
                        Response.Redirect(Request.QueryString["ReturnUrl"] != null ? Request.QueryString["ReturnUrl"].ToString() : "/Default.aspx?message=TwoFactorVerified");
                    }
                    break;

                case SignInStatus.LockedOut:
                    Response.Redirect("/Account/Lockout");
                    break;

                case SignInStatus.Failure:
                default:
                    msgSys.ShowMessageToUser("danger", "Invalid Code", "The code you entered is invalid!", 25000);
                    break;
                }
            }
        }
        public void CheckInvalidTriangle()
        {
            string filePath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                            ConfigurationManager.AppSettings["relativeFilePath"].ToString() + "InvalidTriangleTest.txt"));

            PyramidContext pyramidContext = new PyramidContext();

            Assert.AreEqual(false, pyramidContext.BuildPyramid(new PyramidData(filePath)));
        }
示例#25
0
        /// <summary>
        /// This method populates the interval dropdown from the database
        /// </summary>
        private void BindIntervalDropdown()
        {
            using (PyramidContext context = new PyramidContext())
            {
                var allintervals = context.CodeASQSEInterval.AsNoTracking().OrderBy(cai => cai.OrderBy).ToList();

                ddInterval.DataSource = allintervals;
                ddInterval.DataBind();
            }
        }
示例#26
0
        /// <summary>
        /// This method fires when the data source for the reports DevExpress GridView is selecting
        /// and it handles the select
        /// </summary>
        /// <param name="sender">The efReportDataSource control</param>
        /// <param name="e">The LinqServerModeDataSourceSelectEventArgs event</param>
        protected void efReportDataSource_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e)
        {
            //Set the primary key
            e.KeyExpression = "ReportCatalogPK";

            //Set the source to a LINQ query
            PyramidContext context = new PyramidContext();

            e.QueryableSource = context.ReportCatalog.AsNoTracking();
        }
示例#27
0
        /// <summary>
        /// This method populates the data bound controls from the database
        /// </summary>
        private void BindDataBoundControls()
        {
            using (PyramidContext context = new PyramidContext())
            {
                //Get all the news entry types
                var allNewsEntryTypes = context.CodeNewsEntryType.AsNoTracking()
                                        .Where(cnet => cnet.RolesAuthorizedToModify.Contains(currentProgramRole.RoleFK.Value.ToString() + ","))
                                        .OrderBy(cnet => cnet.OrderBy)
                                        .ToList();

                //Bind the type dropdown
                ddEntryType.DataSource = allNewsEntryTypes;
                ddEntryType.DataBind();

                //Get all the programs
                var allPrograms = context.Program.AsNoTracking()
                                  .Include(p => p.Hub)
                                  .Include(p => p.State)
                                  .Include(p => p.Cohort)
                                  .Where(p => currentProgramRole.ProgramFKs.Contains(p.ProgramPK))
                                  .OrderBy(p => p.ProgramName)
                                  .ToList();

                //Bind the program dropdown
                ddProgram.DataSource = allPrograms.Select(p => new {
                    p.ProgramPK,
                    p.ProgramName
                });
                ddProgram.DataBind();

                //Bind the hub dropdown
                ddHub.DataSource = allPrograms.Select(p => new {
                    p.Hub.HubPK,
                    p.Hub.Name
                }).Distinct().OrderBy(h => h.Name);
                ddHub.DataBind();

                //Bind the state dropdown
                ddState.DataSource = allPrograms.Select(p => new {
                    p.State.StatePK,
                    p.State.Name
                }).Distinct().OrderBy(s => s.Name);
                ddState.DataBind();

                //Bind the cohort dropdown
                ddCohort.DataSource = allPrograms.Select(p => new {
                    p.Cohort.CohortPK,
                    p.Cohort.CohortName
                }).Distinct().OrderBy(c => c.CohortName);
                ddCohort.DataBind();

                //Bind the news items
                BindNewsItems();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Get the current program role
            currentProgramRole = Utilities.GetProgramRoleFromSession(Session);

            if (!IsPostBack)
            {
                ApplicationDbContext appContext = new ApplicationDbContext();

                using (PyramidContext context = new PyramidContext())
                {
                    //Get the program list
                    var programs = context.Program.AsNoTracking().Include(p => p.Hub).OrderBy(p => p.ProgramName).Select(p => new {
                        p.ProgramPK,
                        ProgramName = p.ProgramName + " (" + p.Hub.Name + ")"
                    })
                                   .ToList();
                    ddProgram.DataSource = programs;
                    ddProgram.DataBind();

                    //Get the program role list, limited to the roles the user is allowed to add
                    var programRoles = context.CodeProgramRole.AsNoTracking()
                                       .Where(cpr => cpr.RolesAuthorizedToModify.Contains((currentProgramRole.RoleFK.Value.ToString() + ",")))
                                       .OrderBy(cpr => cpr.RoleName)
                                       .ToList();
                    ddProgramRole.DataSource = programRoles;
                    ddProgramRole.DataBind();
                }

                //Get the identity roles
                var identityRoles = appContext.Roles.OrderBy(r => r.Name).ToList();

                //Remove the guest role because it is not implemented in any way
                IdentityRole guestRole = identityRoles.Where(ir => ir.Name == "Guest").FirstOrDefault();
                if (guestRole != null)
                {
                    identityRoles.Remove(guestRole);
                }

                //Only allow super admins to add admin identity roles
                if (currentProgramRole.RoleFK.Value != (int)Utilities.ProgramRoleFKs.SUPER_ADMIN)
                {
                    //Remove the Admin identity role from the list
                    IdentityRole adminRole = identityRoles.Where(ir => ir.Name == "Admin").FirstOrDefault();
                    identityRoles.Remove(adminRole);
                }

                //Bind the identity role dropdown
                ddIdentityRole.DataSource = identityRoles;
                ddIdentityRole.DataBind();

                //Set focus to the username field
                txtUsername.Focus();
            }
        }
        /// <summary>
        /// This method fires when the data source for the Benchmarks of Quality FCC DevExpress GridView is selecting
        /// and it handles the select
        /// </summary>
        /// <param name="sender">The efBOQFCCDataSource control</param>
        /// <param name="e">The LinqServerModeDataSourceSelectEventArgs event</param>
        protected void efBOQFCCDataSource_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e)
        {
            //Set the primary key
            e.KeyExpression = "BenchmarkOfQualityFCCPK";

            //Set the source to a LINQ query
            PyramidContext context = new PyramidContext();

            e.QueryableSource = context.BenchmarkOfQualityFCC.AsNoTracking().Include(boqfcc => boqfcc.Program)
                                .Where(boqfcc => currentProgramRole.ProgramFKs.Contains(boqfcc.ProgramFK));
        }
示例#30
0
        /// <summary>
        /// This method fires when the data source for the classroom DevExpress GridView is selecting
        /// and it handles the select
        /// </summary>
        /// <param name="sender">The efClassroomDataSource control</param>
        /// <param name="e">The LinqServerModeDataSourceSelectEventArgs event</param>
        protected void efClassroomDataSource_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e)
        {
            //Set the key expression
            e.KeyExpression = "ClassroomPK";

            //Set the source to a LINQ query
            PyramidContext context = new PyramidContext();

            e.QueryableSource = context.Classroom.AsNoTracking().Include(c => c.Program)
                                .Where(c => currentProgramRole.ProgramFKs.Contains(c.ProgramFK));
        }