private void ButtonAddJournalEntry_OnClick(object sender, RoutedEventArgs e) { try { DataAccessZoo dataAccess = new DataAccessZoo(); var animal = (AnimalSimple)ComboBoxCurrentPatient.SelectedItem; var diagnose = (Diagnosis)ComboBoxDiagnoses.SelectedItem; var medications = GetMedicationsAsNameStringList(); var booking = (AnimalBooking)ListBoxBookings.SelectedItem; ValidateRequiredFields(booking, animal, diagnose, medications); var journalEntry = new JournalEntry() { AnimalId = animal.AnimalId, AnimalName = animal.Name, JournalId = animal.AnimalId, DiagnoseId = diagnose.DiagnosisId, DiagnoseName = diagnose.Name, DiagnoseDescription = diagnose.Description, Medications = medications }; dataAccess.AddJournalEntryToJournals(journalEntry); MessageBox.Show("Journalanteckning inlagd"); PopulateOrUpdateJournalEntryList(dataAccess, animal.AnimalId); ClearDiagnoseAndMedicationFields(); } catch (RequiredFieldsNullException exception) { MessageBox.Show(exception.Message); } }
public MakeVetAppointment() { InitializeComponent(); DataAccessZoo dataAccess = new DataAccessZoo(); var list = dataAccess.GetVeterinaryList(); ComboBoxVeterinarians.ItemsSource = list; }
private void UpdateCurrentBookingsListBox() { var animal = (AnimalSimple)ListBoxNameResult.SelectedItem; DataAccessZoo dataAccess = new DataAccessZoo(); var list = dataAccess.GetBookingByAnimalIdList(animal.AnimalId); ListBoxCurrentBookings.ItemsSource = list; }
private void ButtonNameSearch_OnClick(object sender, RoutedEventArgs e) { string name = TextBoxNameSearch.Text; DataAccessZoo dataAccess = new DataAccessZoo(); var list = dataAccess.GetSimpleAnimalByName(name); ListBoxNameResult.ItemsSource = list; }
private void ComboBoxCurrentPatient_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { DataAccessZoo dataAccess = new DataAccessZoo(); var animal = (AnimalSimple)ComboBoxCurrentPatient.SelectedItem; var journalEntryList = dataAccess.GetJournalEntries(animal.AnimalId); ListBoxJournalEntries.ItemsSource = journalEntryList; PopulateOrUpdateBookingListByAnimalId(dataAccess, animal.AnimalId); }
private void ComboBoxDiagnoses_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (ComboBoxDiagnoses.SelectedItem != null) { DataAccessZoo dataAccess = new DataAccessZoo(); var diagnosis = (Diagnosis)ComboBoxDiagnoses.SelectedItem; LabelDiagnosisDescription.Text = diagnosis.Description; } }
private void ComboBoxVeterinarians_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (ComboBoxVeterinarians.SelectedItem != null) { DataAccessZoo dataAccess = new DataAccessZoo(); var veterinary = (Veterinary)ComboBoxVeterinarians.SelectedItem; PopulateOrUpdateBookingListByVeterinaryId(dataAccess, veterinary.Id); } }
private void ButtonPrescribeMedication_OnClick(object sender, RoutedEventArgs e) { DataAccessZoo dataAccess = new DataAccessZoo(); var medication = (Medication)ComboBoxMedications.SelectedItem; var prescribedMedsList = (BindingList <Medication>)ListBoxPrescribedMedication.ItemsSource; prescribedMedsList.Add(medication); ListBoxPrescribedMedication.ItemsSource = prescribedMedsList; PopulateOrUpdateComboBoxMedication(dataAccess); }
public VetHandlePatient() { InitializeComponent(); DataAccessZoo dataAccess = new DataAccessZoo(); ListBoxPrescribedMedication.ItemsSource = new BindingList <Medication>(); PopulateComboBoxVeterinarians(dataAccess); PopulateComboBoxAnimals(dataAccess); PopulateOrUpdateComboBoxDiagnoses(dataAccess); PopulateOrUpdateComboBoxMedication(dataAccess); }
private void ListBoxBookings_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (ListBoxBookings.SelectedItem != null) { DataAccessZoo dataAccess = new DataAccessZoo(); var booking = (AnimalBooking)ListBoxBookings.SelectedItem; var animalList = ComboBoxCurrentPatient.ItemsSource as BindingList <AnimalSimple>; var currentAnimal = from animal in animalList where animal.AnimalId == booking.AnimalId select animal; ComboBoxCurrentPatient.SelectedItem = currentAnimal.Single(); PopulateOrUpdateJournalEntryList(dataAccess, booking.AnimalId); } }
private void ButtonRemoveBooking_OnClick(object sender, RoutedEventArgs e) { var booking = (AnimalBooking)ListBoxCurrentBookings.SelectedItem; DataAccessZoo dataAccess = new DataAccessZoo(); try { dataAccess.RemoveBooking(booking.BookingId); MessageBox.Show("Bokningen borttagen!"); UpdateCurrentBookingsListBox(); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
private void ButtonAddNewMedication_OnClick(object sender, RoutedEventArgs e) { DataAccessZoo dataAccess = new DataAccessZoo(); var medicationName = TextBoxNewMedication.Text; try { var medication = dataAccess.AddOrUpdateAndGetMedication(medicationName); PopulateOrUpdateComboBoxMedication(dataAccess); ComboBoxMedications.Text = medication.Name; } catch (DbObjectNotFoundException exception) { MessageBox.Show(exception.Message); } }
private void ButtonAddNewDiagnosis_OnClick(object sender, RoutedEventArgs e) { DataAccessZoo dataAccess = new DataAccessZoo(); var diagnosisName = TextBoxNewDiagnosis.Text; var diagnosisDescription = TextBoxDiagnoseDescription.Text; try { var diagnosis = dataAccess.AddOrUpdateAndGetDiagnosis(diagnosisName, diagnosisDescription); PopulateOrUpdateComboBoxDiagnoses(dataAccess); ComboBoxDiagnoses.Text = diagnosis.Name; LabelDiagnosisDescription.Text = diagnosis.Description; } catch (DbObjectNotFoundException exception) { MessageBox.Show(exception.Message); } }
private void ButtonRemove_OnClick(object sender, RoutedEventArgs e) { if (ListBoxResultList.SelectedItem != null) { DataAccessZoo dataAccess = new DataAccessZoo(); var animal = (AnimalDetailed)ListBoxResultList.SelectedItem; try { dataAccess.RemoveAnimal(animal.AnimalId); var list = ListBoxResultList.ItemsSource as BindingList <AnimalDetailed>; list.Remove(animal); ClearAnimalDetailsLabels(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void ButtonRemoveBookingAndCloseWindow_OnClick(object sender, RoutedEventArgs e) { if (ListBoxBookings.SelectedItem != null) { DataAccessZoo dataAccess = new DataAccessZoo(); var booking = (AnimalBooking)ListBoxBookings.SelectedItem; try { dataAccess.RemoveBooking(booking.BookingId); MessageBox.Show("Mötet avslutat!"); this.Close(); } catch (DbObjectNotFoundException exception) { MessageBox.Show(exception.Message); } } }
private void ButtonSearch_OnClick(object sender, RoutedEventArgs e) { ClearAnimalDetailsLabels(); UserSearchModel search = new UserSearchModel() { Discrimination = ComboBoxDiscrimination.Text, Type = ComboBoxType.Text, SpeciesSearch = TextBoxSearchSpecies.Text, Environment = ComboBoxEnvironment.Text }; var access = new DataAccessZoo(); var detailedAnimalList = access.GetDetailedAnimalListBySearchTerms(search); detailedAnimalList.AllowEdit = false; detailedAnimalList.AllowNew = false; ListBoxResultList.ItemsSource = detailedAnimalList; }
private void ButtonMakeBooking_OnClick(object sender, RoutedEventArgs e) { try { var date = GetSelectedDateTime(); var vet = (Veterinary)ComboBoxVeterinarians.SelectedItem; var animal = (AnimalSimple)ListBoxNameResult.SelectedItem; ValidateRequriedBookingFields(date, vet, animal); var booking = new AnimalBooking() { AnimalId = animal.AnimalId, AnimalName = animal.Name, DateTime = date, VeterinaryId = vet.Id, VeterinaryName = vet.Name }; DataAccessZoo dataAccess = new DataAccessZoo(); dataAccess.AddBooking(booking); MessageBox.Show("Bokningen är inlagd!"); UpdateCurrentBookingsListBox(); } catch (AddingDuplicateException exception) { MessageBox.Show(exception.Message); } catch (InvalidBookingDateTimeException exception) { MessageBox.Show(exception.Message); } catch (RequiredFieldsNullException exception) { MessageBox.Show(exception.Message); } }
private void ButtonRemoveJournalEntry_OnClick(object sender, RoutedEventArgs e) { if (ListBoxJournalEntries.SelectedItem != null) { DataAccessZoo dataAccess = new DataAccessZoo(); var journalEntry = (JournalEntry)ListBoxJournalEntries.SelectedItem; try { dataAccess.RemoveJournalEntry(journalEntry); PopulateOrUpdateJournalEntryList(dataAccess, journalEntry.AnimalId); } catch (DbObjectNotFoundException exception) { MessageBox.Show(exception.Message); } } else { MessageBox.Show("Ingen journalanteckning är vald"); } }
private void ButtonSaveChanges_OnClick(object sender, RoutedEventArgs e) { DataAccessZoo access = new DataAccessZoo(); bool isValid = ValidateRequiredFields(out string message); if (!isValid) { MessageBox.Show(message); return; } AnimalDetailed animal = new AnimalDetailed() { AnimalId = LabelId.Content is int id ? id : 0, Name = TextBoxName.Text, Sex = TextBoxSex.Text, WeightInKilogram = float.Parse(TextBoxWeight.Text), CountryOfOrigin = TextBoxCountry.Text, Species = TextBoxSpecies.Text, Environment = TextBoxEnvironment.Text, Type = TextBoxType.Text, Mother = TextBoxMother.Text, Father = TextBoxFather.Text }; try { access.AddOrUpdateAnimal(animal); MessageBox.Show("Uppgifterna sparades!"); } catch (Exception exception) { MessageBox.Show(exception.Message + "\n\nIngen ändring sparades."); } }
private void PopulateOrUpdateBookingListByAnimalId(DataAccessZoo dataAccess, int animalId) { var bookingList = dataAccess.GetBookingListByAnimalId(animalId); ListBoxBookings.ItemsSource = bookingList; }
private void PopulateOrUpdateBookingListByVeterinaryId(DataAccessZoo dataAccess, int veterinaryId) { var bookingList = dataAccess.GetBookingListByVeterinaryId(veterinaryId); ListBoxBookings.ItemsSource = bookingList; }
private void PopulateOrUpdateComboBoxMedication(DataAccessZoo dataAccess) { var medicationList = dataAccess.GetMedications(); ComboBoxMedications.ItemsSource = medicationList; }
private void PopulateOrUpdateComboBoxDiagnoses(DataAccessZoo dataAccess) { var diagnosisList = dataAccess.GetDiagnoses(); ComboBoxDiagnoses.ItemsSource = diagnosisList; }
private void PopulateComboBoxAnimals(DataAccessZoo dataAccess) { var animalList = dataAccess.GetSimpleAnimalList(); ComboBoxCurrentPatient.ItemsSource = animalList; }
private void ListBoxBookings_OnMouseDoubleClick(object sender, MouseButtonEventArgs e) { DataAccessZoo dataAccess = new DataAccessZoo(); var booking = (AnimalBooking)ListBoxBookings.SelectedItem; var journalEntryList = dataAccess.GetJournalEntries(booking.AnimalId); }
private void PopulateComboBoxVeterinarians(DataAccessZoo dataAccess) { var veterinaryList = dataAccess.GetVeterinaryList(); ComboBoxVeterinarians.ItemsSource = veterinaryList; }
private void PopulateOrUpdateJournalEntryList(DataAccessZoo dataAccess, int animalId) { var journalEntryList = dataAccess.GetJournalEntries(animalId); ListBoxJournalEntries.ItemsSource = journalEntryList; }