/* * Pre: id must be an integer or the empty string * Post: The input parameters are used to search for existing students. 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 districtId is the id of the district to search in * @returns true if results were found and false otherwise */ private bool searchStudents(GridView gridView, string id, string firstName, string lastName, string session, int districtId) { bool result = true; try { DataTable table = DbInterfaceStudent.GetStudentSearchResults(id, firstName, lastName, districtId); //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", "searchStudents", "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 district admin * Post: The only student's shown in the student dropdowns belong to th current district admin * @param districtId is the id of the district to get students from */ private void showDistrictStudentsOnly(int districtId) { DataTable table = DbInterfaceStudent.GetStudentSearchResults("", "", "", districtId); ddlStudent1.DataSourceID = null; ddlStudent1.DataSource = table; ddlStudent1.DataBind(); ddlStudent2.DataSourceID = null; ddlStudent2.DataSource = table; ddlStudent2.DataBind(); }