protected void Page_Load(object sender, EventArgs e)
        {
            bool foundStudent = false;
            int  studentID    = 0;

            try
            {
                if (String.IsNullOrWhiteSpace(this.ParentPortlet.PortletViewState[ciHelper.VIEWSTATE_SEARCH_STUDENTID].ToString()))
                {
                    //this.ParentPortlet.PortletViewState[ciHelper.VIEWSTATE_MESSAGE] = String.Format("No ID (or invalid ID) was passed to the detail screen. Value of ID: '{0}'.", this.ParentPortlet.PortletViewState[ciHelper.VIEWSTATE_SEARCH_STUDENTID].ToString());
                    //Return to Search_Student screen with error message
                    //this.ParentPortlet.NextScreen(ciHelper.VIEW_SEARCH);
                    this.ParentPortlet.ShowFeedback(FeedbackType.Error, String.Format("No ID (or invalid ID) was passed to the detail screen. Value of ID: '{0}'.", this.ParentPortlet.PortletViewState[ciHelper.VIEWSTATE_SEARCH_STUDENTID].ToString()));
                    //return;
                }

                int.TryParse(this.ParentPortlet.PortletViewState[ciHelper.VIEWSTATE_SEARCH_STUDENTID].ToString(), out studentID);
                this.ltlStudentID.Text = studentID.ToString();

                //Set flag for remainder of page
                foundStudent = studentID != 0;
            }
            catch (Exception ex)
            {
                this.ParentPortlet.ShowFeedback(FeedbackType.Error, ciHelper.FormatException("An exception occurred while retrieving the student's ID", ex, null, null, studentID, LogEventType.Error, LogScreen.DetailStudent));
            }

            if (foundStudent)
            {
                //OdbcConnectionClass3 jicsConn = helper.CONNECTION_JICS;
                //DataTable dtStudent = null;
                //Exception exStudent = null;
                //string sqlStudent = String.Format("SELECT FirstName, LastName FROM FWK_User WHERE CAST(HostID AS INT) = {0}", studentID);

                //try
                //{
                //    dtStudent = jicsConn.ConnectToERP(sqlStudent, ref exStudent);
                //    if (exStudent != null) { throw exStudent; }
                //    if (dtStudent != null && dtStudent.Rows.Count > 0)
                //    {
                //        //this.ltlStudentName.Text = String.Format("{0} {1}", dtStudent.Rows[0]["FirstName"].ToString(), dtStudent.Rows[0]["LastName"].ToString());
                //        this.shDetail.Text = String.Format("Student Detail View for {0} {1} (ID: {2})",
                //            dtStudent.Rows[0]["FirstName"].ToString(), dtStudent.Rows[0]["LastName"].ToString(), studentID);
                //    }
                //}
                //catch (Exception ex)
                //{
                //    this.ParentPortlet.ShowFeedback(FeedbackType.Error, ciHelper.FormatException("An error occurred while retrieving student name", ex));
                //}
                //finally
                //{
                //    if (jicsConn.IsNotClosed()) { jicsConn.Close(); }
                //}

                LoadStudentProgress(studentID);
            }
        }
Ejemplo n.º 2
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrWhiteSpace(txtSearch.Text))
            {
                this.ParentPortlet.PortletViewState[ciHelper.VIEWSTATE_SEARCH_CRITERIA] = this.txtSearch.Text;

                string sqlSearch = "EXECUTE CUS_spCheckIn_AdminSearchUsers @strSearchTerm = ?";
                List <OdbcParameter> paramSearch = new List <OdbcParameter>()
                {
                    new OdbcParameter("search", txtSearch.Text)
                };

                OdbcConnectionClass3 spConn = helper.CONNECTION_SP;
                try
                {
                    DataTable dtSearch = null;
                    Exception exSearch = null;

                    dtSearch = spConn.ConnectToERP(sqlSearch, ref exSearch, paramSearch);
                    if (exSearch != null)
                    {
                        throw exSearch;
                    }
                    if (dtSearch != null)
                    {
                        //If the search results only return a single record, go immediately to the detail view
                        if (dtSearch.Rows.Count == 1)
                        {
                            this.ParentPortlet.PortletViewState[ciHelper.VIEWSTATE_SEARCH_STUDENTID] = dtSearch.Rows[0]["CX ID"].ToString(); //this.txtSearch.Text;
                            this.ParentPortlet.NextScreen("Detail_Student");
                        }
                        else
                        {
                            this.lblSearchResults.Text    = this.lblSearchResults2.Text = String.Format("Found {0} matches", dtSearch.Rows.Count.ToString());
                            this.lblSearchResults.Visible = this.lblSearchResults2.Visible = true;
                            gvSearchResults.DataSource    = dtSearch;
                            gvSearchResults.DataBind();
                        }
                    }
                }
                catch (Exception ex)
                {
                    //this.ParentPortlet.ShowFeedback(FeedbackType.Error, ciHelper.FormatException("An exception occurred while filtering search results", ex));
                    this.ParentPortlet.ShowFeedback(FeedbackType.Error,
                                                    ciHelper.FormatException("An exception occurred while filtering search results", ex, PortalUser.Current, null, null, LogEventType.Error, LogScreen.CheckInAdminHelper, sqlSearch)
                                                    );
                }
                finally
                {
                    if (spConn.IsNotClosed())
                    {
                        spConn.Close();
                    }
                }
            }
            else
            {
                this.ParentPortlet.ShowFeedback(FeedbackType.Message, "Please enter either a last name or student ID");
            }
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            OdbcConnectionClass3 spConn = helper.CONNECTION_SP;

            this.panelResultCount.Visible = this.btnExportExcel.Visible = false;

            #region Load Office Table

            if (IsFirstLoad)
            {
                #region Original Table Load

                //DataTable dtOffices = null;
                //Exception exOffices = null;
                //string sqlOffices = "EXECUTE CUS_spCheckIn_Offices";

                //try
                //{
                //    dtOffices = spConn.ConnectToERP(sqlOffices, ref exOffices);
                //    if (exOffices != null) { throw exOffices; }
                //    if (dtOffices != null && dtOffices.Rows.Count > 0)
                //    {
                //        foreach (DataRow drOffice in dtOffices.Rows)
                //        {
                //            string officeName = drOffice["OfficeName"].ToString();
                //            tblOffices.Rows.Add(OfficeRow(officeName, drOffice["OfficeID"].ToString()));

                //            DataTable dtTasks = ciHelper.GetTasks();
                //            List<string> taskNames = dtTasks.AsEnumerable().Where(tn => tn.Field<string>("OfficeName") == officeName).Select(tn => tn.Field<string>("ViewColumn")).ToList();
                //            Dictionary<string, string> tasks = dtTasks.AsEnumerable()
                //                .Where(task => task.Field<string>("OfficeName") == officeName)
                //                .ToDictionary(task => task.Field<string>("TaskName"), task => task.Field<string>("ViewColumn"));

                //            foreach(KeyValuePair<string, string> task in tasks)
                //            {
                //                tblOffices.Rows.Add(TaskRow(task.Key, drOffice["OfficeID"].ToString(), task.Value));
                //            }
                //        }
                //    }
                //}
                //catch (Exception ex)
                //{
                //    this.ParentPortlet.ShowFeedback(FeedbackType.Error, ciHelper.FormatException("An error occurred while retrieving office information", ex));
                //}
                //finally
                //{
                //    if (spConn.IsNotClosed()) { spConn.Close(); }
                //}

                #endregion

                #region New/Updated Table Load

                DataTable dtOffice = null;
                try
                {
                    dtOffice = ciHelper.GetOfficeAndTask();

                    string currentOffice = "";
                    foreach (DataRow drOffice in dtOffice.Rows)
                    {
                        string officeName     = drOffice["OfficeName"].ToString(),
                                     officeID = drOffice["OfficeID"].ToString();

                        //If the office has changed from the last iteration of the loop, create a new header row
                        if (currentOffice != officeName)
                        {
                            currentOffice = officeName;
                            tblOffices.Rows.Add(OfficeRow(currentOffice, officeID));
                        }

                        tblOffices.Rows.Add(TaskRow(drOffice["TaskName"].ToString(), officeID, drOffice["ViewColumn"].ToString()));
                    }
                }
                catch (Exception ex)
                {
                    //this.ParentPortlet.ShowFeedback(FeedbackType.Error, ciHelper.FormatException("An exception occurred while loading office/task table", ex));
                    this.ParentPortlet.ShowFeedback(FeedbackType.Error, ciHelper.FormatException("An exception occurred while loading office/task table", ex, null, null, null, null,
                                                                                                 LogEventType.Error, LogScreen.FacetSearch));
                }

                #endregion

                #region Load Dropdowns

                DataTable dtAthletics = ciHelper.GetAthletics();
                this.lbAthletics.DataSource     = dtAthletics;
                this.lbAthletics.DataTextField  = "involve_text";
                this.lbAthletics.DataValueField = "involve_code";
                this.lbAthletics.DataBind();

                #endregion
            }

            #endregion
        }
Ejemplo n.º 4
0
        private void BindGrid()
        {
            OdbcConnectionClass3 jicsConn = helper.CONNECTION_SP;
            DataTable            dtConfig = null;
            Exception            exConfig = null;
            string sqlConfig = String.Format("SELECT ID, [Key] AS ConfigKey, [Value] AS ConfigValue, DefaultValue AS ConfigDefaultValue FROM FWK_ConfigSettings WHERE Category = ? ORDER BY [Key]");
            List <OdbcParameter> paramConfig = new List <OdbcParameter>()
            {
                new OdbcParameter("checkInCategory", "C_CheckIn")
            };

            try
            {
                dtConfig = jicsConn.ConnectToERP(sqlConfig, ref exConfig, paramConfig);
                if (exConfig != null)
                {
                    throw exConfig;
                }
                gvConfigSettings.DataSource = dtConfig;
                gvConfigSettings.DataBind();
            }
            catch (Exception ex)
            {
                //this.ParentPortlet.ShowFeedback(FeedbackType.Error, ciHelper.FormatException("Unable to load configuration data", ex));
                this.ParentPortlet.ShowFeedback(FeedbackType.Error,
                                                ciHelper.FormatException("Unable to load configuration data", ex, null, null, null, null, LogEventType.Error, LogScreen.SiteAdminTools, sqlConfig)
                                                );
            }
            finally
            {
                if (jicsConn.IsNotClosed())
                {
                    jicsConn.Close();
                }
            }
        }
Ejemplo n.º 5
0
        private void LoadStudentActivity()
        {
            //OdbcConnectionClass3 jicsConn = helper.CONNECTION_JICS;
            OdbcConnectionClass3 spConn = helper.CONNECTION_SP;

            DataTable dtStudentActivity = null;
            Exception exStudentActivity = null;

            string sqlStudentActivity = "EXECUTE CUS_spCheckIn_AdminStudentActivity";

            #region Obsolete - 4 hour block logic
            /* 4-hour blocks */
            //            string sqlStudentActivity = String.Format(@"
            //                SELECT
            //                    HT.minTime, COUNT(SP.ProgressID) AS Completed,
            //                    CASE
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 0 AND 3        THEN    1
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 4 AND 7        THEN    2
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 8 AND 11    THEN    3
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 12 AND 15    THEN    4
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 16 AND 19    THEN    5
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 20 AND 23    THEN    6
            //                    END AS CmplHourSection,
            //                    CASE
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 0 AND 3        THEN    'Midnight - 3 a.m.'
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 4 AND 7        THEN    '4 a.m. - 7 a.m.'
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 8 AND 11    THEN    '8 a.m. - 11 a.m.'
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 12 AND 15    THEN    '12 p.m. - 3 p.m.'
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 16 AND 19    THEN    '4 p.m. - 7 p.m.'
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 20 AND 23    THEN    '8 p.m. - 11 p.m.'
            //                    END AS CmplHour
            //                FROM
            //                    (
            //                        --Borrowed liberally from https://stackoverflow.com/questions/11479918/include-missing-months-in-group-by-query
            //                        SELECT
            //                            DATEADD(HOUR, n * 4, DATEADD(HOUR, DATEDIFF(HOUR, 0, (SELECT CAST(MIN(CompletedOn) AS DATE) FROM CI_StudentProgress)), 0)) AS minTime
            //                        FROM (
            //                            SELECT TOP ((DATEDIFF(DAY, (SELECT CAST(MIN(CompletedOn) AS DATE) FROM CI_StudentProgress), (SELECT CAST(MAX(CompletedOn) AS DATE) FROM CI_StudentProgress)) + 1) * 6)
            //                                n = ROW_NUMBER() OVER (ORDER BY [object_id]) - 1
            //                            FROM sys.all_objects ORDER BY [object_id]
            //                        ) hourTable
            //                    ) AS HT    LEFT JOIN    CI_StudentProgress    SP    ON    HT.minTime                        <    SP.CompletedOn
            //                                                                AND    DATEADD(HOUR, 4, HT.minTime)    >    SP.CompletedOn
            //                WHERE
            //                    ISNULL(SP.TaskStatus,'Y') = 'Y'
            //                GROUP BY
            //                    HT.minTime,
            //                    CASE
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 0 AND 3        THEN    1
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 4 AND 7        THEN    2
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 8 AND 11    THEN    3
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 12 AND 15    THEN    4
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 16 AND 19    THEN    5
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 20 AND 23    THEN    6
            //                    END,
            //                    CASE
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 0 AND 3        THEN    'Midnight - 3 a.m.'
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 4 AND 7        THEN    '4 a.m. - 7 a.m.'
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 8 AND 11    THEN    '8 a.m. - 11 a.m.'
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 12 AND 15    THEN    '12 p.m. - 3 p.m.'
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 16 AND 19    THEN    '4 p.m. - 7 p.m.'
            //                        WHEN    DATEPART(HOUR, HT.minTime)    BETWEEN 20 AND 23    THEN    '8 p.m. - 11 p.m.'
            //                    END
            //                ORDER BY
            //                    HT.minTime
            //            ");
            #endregion

            try
            {
                //dtStudentActivity = jicsConn.ConnectToERP(sqlStudentActivity, ref exStudentActivity);
                dtStudentActivity = spConn.ConnectToERP(sqlStudentActivity, ref exStudentActivity);
                if (exStudentActivity != null)
                {
                    throw exStudentActivity;
                }
                chartStudentActivity.DataSource = dtStudentActivity;
                chartStudentActivity.DataBind();
            }
            catch (Exception ex)
            {
                //this.ParentPortlet.ShowFeedback(FeedbackType.Error, ciHelper.FormatException("Error while drawing chart for student activity", ex));
                this.ParentPortlet.ShowFeedback(FeedbackType.Error,
                                                ciHelper.FormatException("Error while drawing chart for student activity", ex, null, null, null, null, LogEventType.Error, LogScreen.Dashboard, sqlStudentActivity)
                                                );
            }
            finally
            {
                if (spConn.IsNotClosed())
                {
                    spConn.Close();
                }
            }

            this.shStudentActivity.Text = String.Format("Student Activity for {0} {1}", helper.ACTIVE_SESSION_TEXT, helper.ACTIVE_YEAR);
        }