private void lstRequestor_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (lstRequestor.SelectedIndex == -1) { //MessageBox.Show("Please select a booking request", "No request selected", //MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } EventHelper client = new EventHelper(); AdminHelper admHelper = new AdminHelper(); try { FacilityBookingRequest fbr = (FacilityBookingRequest)lstRequestor.SelectedItem; txtEventName.Text = client.GetEventName(fbr.EventID); txtRequestor.Text = admHelper.GetUserName(fbr.RequestorID); lblStartTime.Content = fbr.RequestStartDateTime.ToString("dd MMM yyyy HH:mm"); lblEndTime.Content = fbr.RequestEndDateTime.ToString("dd MMM yyyy HH:mm"); dgLocation.ItemsSource = fbr.RequestDetails; lvTimeslot.Reset(); } catch (Exception ex) { MessageBox.Show("An error has occured: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } finally { client.Close(); admHelper.Close(); } }
private void lstRequest_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (lstRequest.SelectedIndex == -1) { //MessageBox.Show("Please Select a request!", "Invalid input", //MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { FacilityBookingRequest fbr = (FacilityBookingRequest)lstRequest.SelectedItem; EventHelper client = new EventHelper(); AdminHelper admHelper = new AdminHelper(); txtEventName.Text = client.GetEventName(fbr.EventID); txtRemarks.Text = fbr.Remarks; txtRequestor.Text = admHelper.GetUserName(fbr.RequestorID); txtStatus.Text = fbr.Status.ToString(); lblStartTime.Content = fbr.RequestStartDateTime.ToString("dd MMM yyyy HH:mm"); lblEndTime.Content = fbr.RequestEndDateTime.ToString("dd MMM yyyy HH:mm"); lvCurrentBooking.setSource(fbr); client.Close(); admHelper.Close(); if ((fbr.Status == BookingStatus.Pending) || (fbr.Status == BookingStatus.Approved)) { btnDrop.IsEnabled = true; } else { btnDrop.IsEnabled = false; } } }