Exemple #1
0
        /*
         * Pre:
         * Post: Update the list of available students
         */
        private void updateStudentDropdown()
        {
            ddlStudent.DataSource = null;
            ddlStudent.DataBind();
            ddlStudent.Items.Clear();

            if (ddlTeacher.SelectedIndex > 0 || HighestPermissionTeacher())
            {
                int teacherId = Convert.ToInt32(ddlTeacher.SelectedValue);

                DataTable table = DbInterfaceStudent.GetStudentSearchResultsForTeacher("", "", "", teacherId);

                if (table != null)
                {
                    //add empty item
                    ddlStudent.Items.Add(new ListItem("", ""));

                    //add students for teacher
                    ddlStudent.DataSource = table;

                    ddlStudent.DataTextField  = "ComboName";
                    ddlStudent.DataValueField = "StudentId";

                    ddlStudent.DataBind();
                }
                else
                {
                    showErrorMessage("Error: The students for the selected teacher could not be retrieved.");
                }
            }
        }
        /*
         * Pre:  id must be an integer or the empty string
         * Post:  The input parameters are used to search for existing students for the currently logged
         *        in teacher.  Matching student information is displayed in the input gridview.
         * @param gridView is the gridView in which the search results will be displayed
         * @param id is the id being searched for - must be an integer or the empty string
         * @param firstName is all or part of the first name being searched for
         * @param lastName is all or part of the last name being searched for
         * @param teacherContactId is the id of the current teacher
         * @returns true if results were found and false otherwise
         */
        private bool searchOwnStudents(GridView gridView, string id, string firstName, string lastName, string session, int teacherContactId)
        {
            bool result = true;

            try
            {
                DataTable table = DbInterfaceStudent.GetStudentSearchResultsForTeacher(id, firstName, lastName, teacherContactId);

                //If there are results in the table, display them.  Otherwise clear current
                //results and return false
                if (table != null && table.Rows.Count > 0)
                {
                    gridView.DataSource = table;
                    gridView.DataBind();

                    //save the data for quick re-binding upon paging
                    Session[session] = table;
                }
                else if (table != null && table.Rows.Count == 0)
                {
                    clearGridView(gridView);
                    result = false;
                }
                else if (table == null)
                {
                    if (gridView == gvStudent1Search)
                    {
                        lblStudent1SearchError.Text    = "An error occurred during the search";
                        lblStudent1SearchError.Visible = true;
                    }
                    else
                    {
                        lblStudent2SearchError.Text    = "An error occurred during the search";
                        lblStudent2SearchError.Visible = true;
                    }
                }
            }
            catch (Exception e)
            {
                if (gridView == gvStudent1Search)
                {
                    lblStudent1SearchError.Text    = "An error occurred during the search";
                    lblStudent1SearchError.Visible = true;
                }
                else
                {
                    lblStudent2SearchError.Text    = "An error occurred during the search";
                    lblStudent2SearchError.Visible = true;
                }

                Utility.LogError("Coordinate Students", "searchOwnStudents", "gridView: " + gridView.ID + ", id: " + id +
                                 ", firstName: " + firstName + ", lastName: " + lastName + ", session: " + session,
                                 "Message: " + e.Message + "   Stack Trace: " + e.StackTrace, -1);
            }

            return(result);
        }
        /*
         * Pre:  The current user's highest permission level is teacher
         * Post: The only student's shown in the student dropdowns belong to th current teacher
         * @param contactId is the id of the teachers whose students should be shown
         */
        private void showTeacherStudentsOnly(int contactId)
        {
            DataTable table = DbInterfaceStudent.GetStudentSearchResultsForTeacher("", "", "", contactId);

            ddlStudent1.DataSourceID = null;
            ddlStudent1.DataSource   = table;
            ddlStudent1.DataBind();

            ddlStudent2.DataSourceID = null;
            ddlStudent2.DataSource   = table;
            ddlStudent2.DataBind();
        }