// Back
        private void Button_Click_Back(object sender, RoutedEventArgs e)
        {
            var newWindow = new StartView();

            Close();
            newWindow.Show();
        }
        private void Button_Click_Save(object sender, RoutedEventArgs e)
        {
            // Validate
            string name        = TextBoxName.Text;
            string surname     = TextBoxSurname.Text;
            string phoneNumber = TextBoxPhone.Text;

            var newVolunteer = new Volunteer();

            // flags to check if we have all true to add Volunteer
            Boolean nameFlag        = nameValidation(name);
            Boolean surnameFlag     = surnameValidation(surname);
            Boolean phoneNumberFlag = phoneNumberValidation(phoneNumber);

            // if 3 validation methods are TRUE, pass new Volunteer to ViewModel
            if (nameFlag == true &&
                surnameFlag == true &&
                phoneNumberFlag == true)
            {
                // set fields for new Volunteer
                newVolunteer.Name        = name;
                newVolunteer.Surname     = surname;
                newVolunteer.PhoneNumber = phoneNumber;
                // pass to view model
                viewModel.AddNewVolunteer(newVolunteer);
                var newWindow = new StartView();
                newWindow.Show();
                Close();
            }
        }
Пример #3
0
        private void Button_Click_Save(object sender, RoutedEventArgs e)
        {
            // Validate
            string name        = TextBoxName.Text;
            string surname     = TextBoxSurname.Text;
            string phoneNumber = TextBoxPhone.Text;
            string street      = TextBoxStreet.Text;
            string houseNumber = TextBoxHouseNumber.Text;
            Adress adress      = (Adress)DataGridCity.SelectedItem;

            var newAdopter = new Adopter();

            // flags to check if we have all true to add Adopter
            Boolean nameFlag        = nameValidation(name);
            Boolean surnameFlag     = surnameValidation(surname);
            Boolean phoneNumberFlag = phoneNumberValidation(phoneNumber);
            Boolean streetFlag      = streetValidation(street);
            Boolean houseNumberFlag = houseNumberValidation(houseNumber);
            Boolean cityFlag        = cityValidation(ValidationRules.isSelectedDataGrid(DataGridCity));

            // if 5 validation methods are TRUE, pass new Adopter to ViewModel
            if (nameFlag == true &&
                surnameFlag == true &&
                phoneNumberFlag == true &&
                streetFlag == true &&
                houseNumberFlag == true &&
                cityFlag == true)
            {
                // set fields for new Volunteer
                newAdopter.Name        = name;
                newAdopter.Surname     = surname;
                newAdopter.PhoneNumber = phoneNumber;
                newAdopter.Street      = street;
                newAdopter.HouseNumber = houseNumber;
                newAdopter.IdAdress    = adress.IdAdress;
                // pass to view model
                viewModelAdopter.AddNewAdopter(newAdopter);
                var newWindow = new StartView();
                Close();
                newWindow.Show();
            }
        }
 // Creating new Adoption
 private void Button_Click_Create(object sender, RoutedEventArgs e)
 {
     if (DataGridAdopters.SelectedItems.Count != 0)
     {
         if (DataGridDogs.SelectedItems.Count != 0)
         {
             if (DataGridVolunteers.SelectedItems.Count != 0)
             {
                 viewModelAdoption.AddAdoption(
                     ((Dog)DataGridDogs.SelectedItem).IdDog,
                     ((Volunteer)DataGridVolunteers.SelectedItem).IdVolunteer,
                     ((AdopterWithAdress)DataGridAdopters.SelectedItem).IdAdopter
                     );
                 var newWindow = new StartView();
                 Close();
                 newWindow.Show();
             }
         }
     }
 }
        private void Button_Click_Save(object sender, RoutedEventArgs e)
        {
            // from TextBox to validate
            string name       = TextBoxName.Text;
            string chipNumber = TextBoxChipNumber.Text;

            // dog to add to DB
            Dog dogToAdd = new Dog();

            Boolean flagName       = nameValidation(name);
            Boolean flagChipNumber = chipNumberValidation(chipNumber);

            if (flagName == true && flagChipNumber == true)
            {
                // Setting SEX
                var whichSex = radioButtonsPanel.Children.OfType <RadioButton>()
                               .FirstOrDefault(r => r.IsChecked.HasValue && r.IsChecked.Value);
                if (whichSex == RadioButtonMale)
                {
                    dogToAdd.Sex = "M";
                }
                else
                {
                    dogToAdd.Sex = "K";
                }

                // Setting BornDate, JoinDate, LeaveDate
                dogToAdd.BornDate = DatePickerBornDate.Value;
                dogToAdd.JoinDate = DateTime.Today;

                // Setting Name, ChipNumber, Description
                dogToAdd.Name        = TextBoxName.Text;
                dogToAdd.ChipNumber  = TextBoxChipNumber.Text;
                dogToAdd.Description = TextBoxDescription.Text;

                // Setting 3x Attitudes
                Catsattitude catsattitude = (Catsattitude)ComboBoxCats.SelectedItem;
                dogToAdd.IdCatsAttitude = catsattitude.IdCatsAttitude;
                Dogsattitude dogssattitude = (Dogsattitude)ComboBoxDogs.SelectedItem;
                dogToAdd.IdDogsAttitude = dogssattitude.IdDogsAttitude;
                Kidsattitude kidsattitude = (Kidsattitude)ComboBoxKids.SelectedItem;
                dogToAdd.IdKidsAttitude = kidsattitude.IdKidsAttitude;

                // Setting Weight and Height
                dogToAdd.Weight = (Double)DoubleUpDownWeight.Value;
                dogToAdd.Height = (int)DoubleUpDownHeight.Value;

                // Setting Have Castration
                dogToAdd.HaveCastration = CheckBoxCastration.IsChecked;

                // COLORS - setting colors
                IList chosenColors = ListBoxColors.SelectedItems;

                // pass to viewmodel
                viewModel.AddNewDog(dogToAdd, chosenColors);

                var newWindow = new StartView();
                Close();
                newWindow.Show();
            }
        }