// Check the status of a selected seat private void btnSeatStatus(object sender, EventArgs e) { // validation if user selected a seat // checks seat selection try { try { if (String.IsNullOrWhiteSpace(lstBoxRow.SelectedItem.ToString())) { throw new InvalidOperationException("Select a row"); } } catch (NullReferenceException) { throw new InvalidOperationException("Select a row"); } try { if (String.IsNullOrWhiteSpace(lstBoxSeat.SelectedItem.ToString())) { throw new InvalidOperationException("Select a seat"); } } catch (NullReferenceException) { throw new InvalidOperationException("Select a seat"); } lblMessages.Text = ""; // remove any warnings string seat = lstBoxRow.SelectedItem.ToString(); seat += lstBoxSeat.SelectedItem.ToString(); bool seatStatus = AirplaneService.SeatStatus(seat); if (seatStatus) { txtStatus.Text = "Seat available"; } else { txtStatus.Text = "Seat not available"; } } catch (InvalidOperationException ex) { lblMessages.Text = ex.Message; } }