private void CreateAcc_Click(object sender, RoutedEventArgs e)
        {
            string login    = CreatePhone.Text;
            string password = CreatePassword.Text;
            string name     = CreateName.Text;
            string plate    = CreatePlate.Text;
            string logreg   = @"7\d+";

            userEntered?.Invoke(login, password, name, plate);
            if (name != null & login != null & plate != null & password != null & Regex.IsMatch(login, logreg) & password.Length >= 6)
            {
                if (_park.AddUser(name, login, plate, password))
                {
                    UserRegistrated mainwindow = new UserRegistrated();
                    mainwindow.Show();
                    this.Close();
                }
                else
                {
                    UserExists userexists = new UserExists();
                    userexists.Show();
                    this.Close();
                }
            }
            else
            {
                ErrorBlock.Text = "Fill all the fields, Phone number: 7NNNNNNNNNN,\npassword consists of 6 or more characters";
            }
        }
Esempio n. 2
0
        private void Button_Registration(object sender, RoutedEventArgs e)
        {
            if (manager.CheckUser(textBoxPhone.Text) == null)
            {
                var user = new User {
                    Name = textBoxName.Text
                };

                if (user.IsValid() && CheckPhoneFormat(textBoxPhone.Text) && ConfirmPassword(regPassword_1.Password, regPassword_2.Password))
                {
                    user.Phone          = textBoxPhone.Text;
                    user.CarPlateNumber = textCarPlate.Text;
                    user.Password       = regPassword_1.Password;
                    manager.AddUser(user);
                    MessageBox.Show("You have been successfully registered. Log in now.");
                    Close();
                }
                else
                {
                    MessageBox.Show("Incorrect name, phone number format or passwords don't match. Try again.");
                }
            }
            else
            {
                MessageBox.Show("You've signed up earlier");
            }
        }