Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        public MakeVetAppointment()
        {
            InitializeComponent();
            DataAccessZoo dataAccess = new DataAccessZoo();
            var           list       = dataAccess.GetVeterinaryList();

            ComboBoxVeterinarians.ItemsSource = list;
        }
Esempio n. 3
0
        private void UpdateCurrentBookingsListBox()
        {
            var           animal     = (AnimalSimple)ListBoxNameResult.SelectedItem;
            DataAccessZoo dataAccess = new DataAccessZoo();
            var           list       = dataAccess.GetBookingByAnimalIdList(animal.AnimalId);

            ListBoxCurrentBookings.ItemsSource = list;
        }
Esempio n. 4
0
        private void ButtonNameSearch_OnClick(object sender, RoutedEventArgs e)
        {
            string        name       = TextBoxNameSearch.Text;
            DataAccessZoo dataAccess = new DataAccessZoo();
            var           list       = dataAccess.GetSimpleAnimalByName(name);

            ListBoxNameResult.ItemsSource = list;
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
 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;
     }
 }
Esempio n. 7
0
 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);
     }
 }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        public VetHandlePatient()
        {
            InitializeComponent();
            DataAccessZoo dataAccess = new DataAccessZoo();

            ListBoxPrescribedMedication.ItemsSource = new BindingList <Medication>();

            PopulateComboBoxVeterinarians(dataAccess);
            PopulateComboBoxAnimals(dataAccess);
            PopulateOrUpdateComboBoxDiagnoses(dataAccess);
            PopulateOrUpdateComboBoxMedication(dataAccess);
        }
Esempio n. 10
0
        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);
            }
        }
Esempio n. 11
0
        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);
            }
        }
Esempio n. 12
0
        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);
            }
        }
Esempio n. 13
0
        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);
            }
        }
Esempio n. 14
0
 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);
         }
     }
 }
Esempio n. 15
0
        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);
                }
            }
        }
Esempio n. 16
0
        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;
        }
Esempio n. 17
0
        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);
            }
        }
Esempio n. 18
0
        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");
            }
        }
Esempio n. 19
0
        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.");
            }
        }
Esempio n. 20
0
        private void PopulateOrUpdateBookingListByAnimalId(DataAccessZoo dataAccess, int animalId)
        {
            var bookingList = dataAccess.GetBookingListByAnimalId(animalId);

            ListBoxBookings.ItemsSource = bookingList;
        }
Esempio n. 21
0
        private void PopulateOrUpdateBookingListByVeterinaryId(DataAccessZoo dataAccess, int veterinaryId)
        {
            var bookingList = dataAccess.GetBookingListByVeterinaryId(veterinaryId);

            ListBoxBookings.ItemsSource = bookingList;
        }
Esempio n. 22
0
        private void PopulateOrUpdateComboBoxMedication(DataAccessZoo dataAccess)
        {
            var medicationList = dataAccess.GetMedications();

            ComboBoxMedications.ItemsSource = medicationList;
        }
Esempio n. 23
0
        private void PopulateOrUpdateComboBoxDiagnoses(DataAccessZoo dataAccess)
        {
            var diagnosisList = dataAccess.GetDiagnoses();

            ComboBoxDiagnoses.ItemsSource = diagnosisList;
        }
Esempio n. 24
0
        private void PopulateComboBoxAnimals(DataAccessZoo dataAccess)
        {
            var animalList = dataAccess.GetSimpleAnimalList();

            ComboBoxCurrentPatient.ItemsSource = animalList;
        }
Esempio n. 25
0
 private void ListBoxBookings_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     DataAccessZoo dataAccess       = new DataAccessZoo();
     var           booking          = (AnimalBooking)ListBoxBookings.SelectedItem;
     var           journalEntryList = dataAccess.GetJournalEntries(booking.AnimalId);
 }
Esempio n. 26
0
        private void PopulateComboBoxVeterinarians(DataAccessZoo dataAccess)
        {
            var veterinaryList = dataAccess.GetVeterinaryList();

            ComboBoxVeterinarians.ItemsSource = veterinaryList;
        }
Esempio n. 27
0
        private void PopulateOrUpdateJournalEntryList(DataAccessZoo dataAccess, int animalId)
        {
            var journalEntryList = dataAccess.GetJournalEntries(animalId);

            ListBoxJournalEntries.ItemsSource = journalEntryList;
        }