Пример #1
0
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            var companyName = NameBox.Text;
            var nip         = NipBox.Text;
            var email       = EmailBox.Text;
            var street      = StreetBox.Text;
            var city        = CityBox.Text;
            var country     = CountryBox.Text;
            var zipCode     = ZipCodeBox.Text;
            var phone       = PhoneBox.Text;

            var nameValidator  = new NameValidator();
            var nipValidator   = new NipValidator();
            var mailValidator  = new MailValidator();
            var phoneValidator = new PhoneValidator();

            if (!nameValidator.ValidateName(companyName))
            {
                MessageBox.Show("Podałeś niedozwoloną nazwę firmy");
            }
            else if (!nipValidator.ValidateNip(nip))
            {
                MessageBox.Show("Podałeś nieprawidłowy nip");
            }
            else if (!mailValidator.ValidateMail(email))
            {
                MessageBox.Show("Podałeś nieprawidłowy adres Email");
            }

            else if (string.IsNullOrEmpty(street) || string.IsNullOrEmpty(zipCode) || string.IsNullOrEmpty(country) ||
                     string.IsNullOrEmpty(city))
            {
                MessageBox.Show("Pole adresowe nie może być puste");
            }


            else
            {
                var account        = new BankAccount();
                var companyAccount = new CompanyAccount(companyName, nip, email, zipCode, country,
                                                        phone, city, street, account)
                {
                    BankAccount = { Balance = 0.0 }
                };

                var filePath  = Environment.CurrentDirectory + @"\" + "Company_Accounts.xml";
                var listToXml = new ListToXml();
                listToXml.CompanyAccounts(companyAccount, filePath);
                Close();
            }
        }
Пример #2
0
        private void Create_Click(object sender, RoutedEventArgs e)
        {
            var firstName = FirstNameBox.Text;
            var lastName  = LastNameBox.Text;
            var pesel     = PeselBox.Text;
            var email     = EmailBox.Text;
            var doB       = DoB.Text;
            var street    = StreetBox.Text;
            var city      = CityBox.Text;
            var country   = CountryBox.Text;
            var zipCode   = ZipCodeBox.Text;
            var phone     = PhoneBox.Text;


            var nameValidator  = new NameValidator();
            var mailValidator  = new MailValidator();
            var peselValidator = new PeselValidator();
            var dobValidator   = new DateOfBirthValidator();
            var phoneValidator = new PhoneValidator();

            if (!nameValidator.ValidateName(firstName))
            {
                MessageBox.Show("Podałeś nieprawidłowę imię.");
            }
            else if (!nameValidator.ValidateName(lastName))
            {
                MessageBox.Show("Podałeś nieprawidłowe nazwisko");
            }
            else if (!peselValidator.ValidatePesel(pesel))
            {
                MessageBox.Show("Podałeś nieprawidłowy numer PESEL");
            }
            else if (!mailValidator.ValidateMail(email))
            {
                MessageBox.Show("Podałeś nieprawidłowy adres Email");
            }
            else if (!phoneValidator.ValidatePhoneNumber(phone))
            {
                MessageBox.Show("Nieprawidłowy numer telefonu");
            }

            else if (!dobValidator.ValidateDoB(doB))
            {
                MessageBox.Show("Nieprawidłowa data urodzenia");
            }
            else if (string.IsNullOrEmpty(street) || string.IsNullOrEmpty(zipCode) || string.IsNullOrEmpty(country) ||
                     string.IsNullOrEmpty(city))
            {
                MessageBox.Show("Pole adresowe nie może być puste");
            }


            else
            {
                var gender          = (Gender)Enum.Parse(typeof(Gender), GenderComboBox.Text);
                var account         = new BankAccount();
                var personalAccount = new PersonalAccount(firstName, lastName, doB, gender, pesel, email, street,
                                                          zipCode,
                                                          country, phone, city, account)
                {
                    BankAccount = { Balance = 0.0 }
                };

                var filePath  = Environment.CurrentDirectory + @"\" + "Personal_Accounts.xml";
                var listToXml = new ListToXml();
                listToXml.PersonalAccounts(personalAccount, filePath);

                Close();
            }
        }