Beispiel #1
0
        //Column 1. Select person
        private void PersonComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (PersonComboBox.SelectedItem != null)
            {
                Id_Person = _personService.GetPerson()
                            .Where(x => (x.Name == PersonComboBox.SelectedItem.ToString()))
                            .Select(x => x.Id).FirstOrDefault();

                personName = PersonSetName.Text = _personService.GetPerson()
                                                  .Where(x => (x.Name == PersonComboBox.SelectedItem.ToString()))
                                                  .Select(x => x.Name).FirstOrDefault().ToString();

                personSurmane = PersonSetSurname.Text = _personService.GetPerson()
                                                        .Where(x => (x.Name == PersonComboBox.SelectedItem.ToString()))
                                                        .Select(x => x.Surname).FirstOrDefault().ToString();

                AddressComboBoxList();
                PhoneComboBoxList();

                AddresstSetStreet.Clear();
                AddressSetCity.Clear();
                AddressSetZipCode.Clear();
                AddressSetCountry.Clear();
                PhoneSetNumber.Clear();
            }
        }
Beispiel #2
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            string _personName    = PersonSetName.Text;
            string _personSurname = PersonSetSurname.Text;
            string _addressStreet = AddresstSetStreet.Text;
            string _addressCity   = AddressSetCity.Text;
            int    _addressZipCode;
            bool   _addressZipCodeBool = Int32.TryParse(AddressSetZipCode.Text, out _addressZipCode);
            string _addressCountry     = AddressSetCountry.Text;
            int    _phoneNumber;
            bool   _phoneNumberBool = Int32.TryParse(PhoneSetNumber.Text, out _phoneNumber);

            if (_personName == "" || _addressStreet == "")
            {
                MessageBox.Show("Wymagane jest podanie przynajmniej imienia i ulicy wprowadzanej osoby");
                return;
            }
            if (!_addressZipCodeBool || !_phoneNumberBool)
            {
                MessageBox.Show("Kod pocztowy oraz nr telefonu należy wprowadzić przy pomocy cyfr nie używając znaków specjalnychc oraz spacji");
                return;
            }

            if (_personName == personName && _personSurname == personSurmane)
            {
                if (_addressStreet == addressStreet && (_addressCity != addressCity || _addressZipCode != int.Parse(addressZipCode) || _addressCountry != addressCountry))
                {
                    _addressService.SaveAddress(_addressStreet, _addressCity, _addressZipCode, _addressCountry, Id_Person, Id_Address);
                }
                if (_addressStreet != addressStreet)
                {
                    _addressService.SaveAddress(_addressStreet, _addressCity, _addressZipCode, _addressCountry, Id_Person);
                }

                if (_phoneNumber != int.Parse(phoneNumber))
                {
                    _phoneService.SavePhone(_phoneNumber, Id_Person);
                }
            }
            else
            {
                _personService.SavePerson(_personName, _personSurname);
                Id_Person = _personService.GetPerson().Select(x => x.Id).LastOrDefault();
                _addressService.SaveAddress(_addressStreet, _addressCity, _addressZipCode, _addressCountry, Id_Person);
                _phoneService.SavePhone(_phoneNumber, Id_Person);
            }

            PersonComboBoxList();
            AddressComboBoxList();
            PhoneComboBoxList();

            PersonSetName.Clear();
            PersonSetSurname.Clear();
            AddresstSetStreet.Clear();
            AddressSetCity.Clear();
            AddressSetZipCode.Clear();
            AddressSetCountry.Clear();
            PhoneSetNumber.Clear();
        }
Beispiel #3
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            if (Id_Person != 0)
            {
                _deleteService.DeletePersonData(Id_Person);
            }
            PersonComboBoxList();
            AddressComboBoxList();
            PhoneComboBoxList();

            PersonSetName.Clear();
            PersonSetSurname.Clear();
            AddresstSetStreet.Clear();
            AddressSetCity.Clear();
            AddressSetZipCode.Clear();
            AddressSetCountry.Clear();
            PhoneSetNumber.Clear();
        }