private void B_Search_Click(object sender, EventArgs e) { // Method that initiates the search for students StudentAccessLayer SAL = new StudentAccessLayer(Session.Database); _searchResults = new List <Student>(); try { switch (CB_SearchBy.SelectedIndex) { case 1: _searchResults = SAL.GetStudentByForename(TB_StudentSearch.Text); break; case 2: _searchResults = SAL.GetStudentBySurname(TB_StudentSearch.Text); break; default: _searchResults.Add(SAL.GetStudentById(Convert.ToInt32(TB_StudentSearch.Text))); break; } } catch (ValidationException vEx) { MessageBox.Show("Record not loaded. There was an error with the student record: " + vEx.Message); } PopulateDT(_searchResults); }
private void B_Search_Click(object sender, EventArgs e) { // Method that initiates the search for students StudentAccessLayer SAL = new StudentAccessLayer(Session.Database); _searchResults = new List <Student>(); switch (CB_SearchBy.SelectedIndex) { case 1: _searchResults = SAL.GetStudentByForename(TB_StudentSearch.Text); break; case 2: _searchResults = SAL.GetStudentBySurname(TB_StudentSearch.Text); break; default: _searchResults.Add(SAL.GetStudentById(Convert.ToInt32(TB_StudentSearch.Text))); break; } PopulateDT(_searchResults); }