private void Authorization1_Click(object sender, RoutedEventArgs e)
 {
     ServiceReference1.Service1Client Service = new ServiceReference1.Service1Client();
     if (Service.Authentication(Convert.ToString(Email.Text), Convert.ToString(Password.Password)).role_id == 1 && Service.Authentication(Convert.ToString(Email.Text), Convert.ToString(Password.Password)).error == false)
     {
         IDUser = Service.Authentication(Convert.ToString(Email.Text), Convert.ToString(Password.Password)).id_user;
         MenuClient Window = new MenuClient();
         Window.Show();
         this.Close();
     }
     else if (Service.Authentication(Convert.ToString(Email.Text), Convert.ToString(Password.Password)).role_id == 2 && Service.Authentication(Convert.ToString(Email.Text), Convert.ToString(Password.Password)).error == false)
     {
         IDUser = Service.Authentication(Convert.ToString(Email.Text), Convert.ToString(Password.Password)).id_user;
         MenuRealtor Window = new MenuRealtor();
         Window.Show();
         this.Close();
     }
     else if (Service.Authentication(Convert.ToString(Email.Text), Convert.ToString(Password.Password)).role_id == 3 && Service.Authentication(Convert.ToString(Email.Text), Convert.ToString(Password.Password)).error == false)
     {
         IDUser = Service.Authentication(Convert.ToString(Email.Text), Convert.ToString(Password.Password)).id_user;
         MenuDirector Window = new MenuDirector();
         Window.Show();
         this.Close();
     }
     else
     {
         MessageBox.Show(Service.Authentication(Convert.ToString(Email.Text), Convert.ToString(Password.Password)).error_message, "Внимание");
     }
 }
Ejemplo n.º 2
0
        private void Back_Click(object sender, RoutedEventArgs e)
        {
            MenuClient Window = new MenuClient();

            Window.Show();
            this.Close();
        }
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            var input = Password.Text;

            var hasNumber        = new Regex(@"[0-9]+");
            var hasUpperChar     = new Regex(@"[A-Z]+");
            var hasMinimum8Chars = new Regex(@".{6,}");
            var hasCymbols       = new Regex(@"[+]{1}[1-9]{1} [0-9]{3} [0-9]{3} [0-9]{2} [0-9]{2}");

            var isValidated = hasNumber.IsMatch(input) && hasUpperChar.IsMatch(input) && hasMinimum8Chars.IsMatch(input);

            var inputTepelhone = Telephone.Text;
            var hasTelephone   = new Regex(@"^((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}$");
            var TelephoneValid = hasCymbols.IsMatch(inputTepelhone);

            if (E_mail.Text == "" || LastName.Text == "" || FirstName.Text == "" || Patronomyc.Text == "" || Adress.Text == "" || Telephone.Text == "" || Password.Text == "" || PasswordRepeat.Text == "")
            {
                MessageBox.Show("Заполните все поля!", "Внимание");
            }
            else if (TelephoneValid == false)
            {
                MessageBox.Show("Телефон должен быть записан в международном формате: +Х ХХХ ХХХ ХХ ХХ", "Внимание");
            }
            else if (isValidated == false || (Password.Text.Contains('!') == false && Password.Text.Contains('@') == false && Password.Text.Contains('#') == false && Password.Text.Contains('$') == false && Password.Text.Contains('%') == false && Password.Text.Contains('^') == false))
            {
                MessageBox.Show("Пароль должен соответствовать следующим требованиям: Минимум 6 символов, Минимум 1 прописная буква, Минимум 1 цифра, По крайней мере один из следующих символов : !@#$%^", "Внимание");
            }
            else if (Password.Text != PasswordRepeat.Text)
            {
                MessageBox.Show("Пароль и повтор пароля не совпадают", "Внимание");
            }
            else if (DateTime.Now.Year - DateBirth.SelectedDate.Value.Year < 18)
            {
                MessageBox.Show("Нельзя регистрировать клиентов младше 18");
            }
            else
            {
                ServiceReference1.Users SaveClient = new ServiceReference1.Users();
                SaveClient.Email      = Convert.ToString(E_mail.Text);
                SaveClient.LastName   = Convert.ToString(LastName.Text);
                SaveClient.FirstName  = Convert.ToString(FirstName.Text);
                SaveClient.Patronymic = Convert.ToString(Patronomyc.Text);
                SaveClient.DateBirth  = Convert.ToDateTime(DateBirth.SelectedDate);
                SaveClient.Adress     = Convert.ToString(Adress.Text);
                SaveClient.Telephone  = Convert.ToString(Telephone.Text);
                SaveClient.Password   = Convert.ToString(PasswordRepeat.Text);
                SaveClient.Role_ID    = 1;
                SaveClient.id         = Authorization.IDUser;
                ServiceReference1.Service1Client Service = new ServiceReference1.Service1Client();
                Service.UpdateUsers(SaveClient);
                MenuClient Window = new MenuClient();
                Window.Show();
                this.Close();
            }
        }