private void populateStudentData()
{
SqlConnection comboBoxDatabaseConnection = DatabaseUtilities.GetDatabaseConnectionDetails();
string queryString = "select StudentNumber, Title, FirstName, MiddleName, LastName, NickName, GenderCode, EquityCode, HomeLanguageCode, NationalId, GroupId, PersonHomeAddress1, PersonHomeAddress2, PersonHomeAddress3, PersonalHomeAddressPostalCode, PersonPostalAddress1, PersonPostalAddress2, PersonalPostalAddress3, PersonalPostalAddressPostalCode, ProvinceCode, NationalityCode, PhoneNumber, WorkNumber, CellPhoneNumber, FaxNumber,EmailAddress, PersonAlternateId, AlternativeIdType, OldStudentNumber, OrganizationName, CitizenResidentStatusCode, SocioeconomicStatusCode, PersonBirthDate, Religion, Denomination, Supervisor, ProviderCode, ProviderId, PreviousLastName, PreviousProviderCode, PreviousEtqaId, SeeingRatingId, HearingRatingId, CommunicatingRatingId, WalkingRatingId, RememberingRatingId, SelfcareRatingId, Notes,PreviousAlternateId, PreviousAlternateIdType, ReferredBy, Archived from PersonalData where StudentNumber = @selectedStudentNumber";
SqlCommand command = new SqlCommand(queryString, comboBoxDatabaseConnection);
command.Parameters.AddWithValue("@selectedStudentNumber", selectedStudentNumber);
comboBoxDatabaseConnection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
if (reader.HasRows)
{
reader.Read();
editStudentStudentNumberTextBox.Text = reader.GetString(0);
titleString = reader.GetString(1);
if (titleString != "")
{
editStudentsTitleComboBox.DisplayMemberPath = titleString;
editStudentsTitleComboBox.SelectedValuePath = titleString;
}
editStudentsFirstNameTextBox.Text = reader.GetString(2);
MessageBox.Show(titleString);
reader.Close();
}
}
try
{
SqlCommand cmd = new SqlCommand("select * from Title", comboBoxDatabaseConnection);
comboBoxDatabaseConnection.Open();
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
adapter.Fill(dt);
editStudentsTitleComboBox.ItemsSource = dt.DefaultView;
editStudentsTitleComboBox.DisplayMemberPath = "Salutation";
editStudentsTitleComboBox.SelectedValuePath = "Salutation";
cmd.Dispose();
comboBoxDatabaseConnection.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}