private void btnDelete_Click(object sender, RoutedEventArgs e) { FacilityHelper client = new FacilityHelper(); try { client.RemoveFacility(user, txtVenue.Text.Trim(), (Faculty)cboFaculty.SelectedIndex); MessageBox.Show("Facility successfully deleted", "Delete Success", MessageBoxButton.OK, MessageBoxImage.Information); lstVenue.ItemsSource = client.GetVenuesByFaculty((Faculty)cboFaculty.SelectedIndex); clearAllTextBoxes(); } catch (Exception ex) { MessageBox.Show("An error have occured: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } client.Close(); }
private void btnSave_Click(object sender, RoutedEventArgs e) { int cap; bool parseSuccess = Int32.TryParse(txtSeatCapacity1.Text.Trim(), out cap); if (cboFacAdmin.SelectedIndex == -1) { MessageBox.Show("Please select the facility admin!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } FacilityHelper client = new FacilityHelper(); if (parseSuccess) { try { client.UpdateFacility(user, txtVenue.Text.Trim(), (Faculty)cboEditFac.SelectedIndex, txtLocation.Text.Trim(), cboFacAdmin.SelectedValue.ToString(), txtTechContact.Text.Trim(), cap,(RoomTypes)cboEditFacType.SelectedIndex,(bool)chkRecordFacility.IsChecked,(bool)chkFlexibleSeating.IsChecked, (bool)chkVideoConference.IsChecked,(bool)chkMicrophone.IsChecked,(bool)chkProjector.IsChecked,(bool)chkVisualizer.IsChecked); MessageBox.Show("Facility successfully updated", "Update Success", MessageBoxButton.OK, MessageBoxImage.Information); lstVenue.ItemsSource = client.GetVenuesByFaculty((Faculty)cboFaculty.SelectedIndex); clearAllTextBoxes(); } catch (Exception ex) { MessageBox.Show("An error have occured: " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } client.Close(); } else { MessageBox.Show("Seat Capacity must be a numeric value!", "Invalid input", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { FacilityHelper client = new FacilityHelper(); cboEditFac.ItemsSource = cboFaculty.ItemsSource = System.Enum.GetValues(typeof(Faculty)); cboFacAdmin.ItemsSource = client.GetFacilityAdmins(); List<RoomTypes> rmTypes = System.Enum.GetValues(typeof(RoomTypes)).Cast<RoomTypes>().ToList(); cboEditFacType.Items.Clear(); foreach (RoomTypes rmType in rmTypes) { string type2display = rmType.ToString().Replace("_", " "); cboEditFacType.Items.Add(type2display); } if (user.isSystemAdmin) { cboFacAdmin.IsEnabled = cboEditFac.IsEnabled = cboFaculty.IsEnabled = true; cboEditFac.SelectedIndex = cboFaculty.SelectedIndex = 0; } else if (user.isFacilityAdmin) { Faculty f = client.GetFacilityAdmin(user.UserID); cboEditFac.SelectedIndex = cboFaculty.SelectedIndex = (int)f; cboFacAdmin.IsEnabled = cboEditFac.IsEnabled = cboFaculty.IsEnabled = false; cboFacAdmin.SelectedValue = user.UserID; } client.Close(); }
private void cboFaculty_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { FacilityHelper client = new FacilityHelper(); lstVenue.ItemsSource = client.GetVenuesByFaculty((Faculty)cboFaculty.SelectedIndex); client.Close(); cboEditFac.SelectedIndex = cboFaculty.SelectedIndex; clearAllTextBoxes(); if (user.isSystemAdmin) { cboFacAdmin.SelectedValue = -1; } }