Ejemplo n.º 1
0
 private void Password2_GotFocus(object sender, RoutedEventArgs e)
 {
     Password.Visibility = System.Windows.Visibility.Visible;
     Password2.Focus();
     Password2.Visibility = System.Windows.Visibility.Collapsed;
     Password2.Focus();
 }
Ejemplo n.º 2
0
        public bool unosLozinke(string lozinka)
        {
            var lozinka1 = new Password1();
            var lozinka2 = new Password2();
            var lozinka3 = new Password3();

            lozinka1.SetNext(lozinka2).SetNext(lozinka3);
            return(lozinka1.isAuthorised(lozinka));
        }
Ejemplo n.º 3
0
        private void Register_Click(object sender, RoutedEventArgs e)
        {
            strUsername  = Username.Text;
            strPassword  = Password.Password;
            strPassword2 = Password2.Password;
            strEmail     = Email.Text;
            if (string.IsNullOrEmpty(strUsername))
            {
                MessageBox.Show("请输入用户名!");
                Username.Focus();
                return;
            }
            else if (string.IsNullOrEmpty(strPassword))
            {
                MessageBox.Show("请输入密码!");
                Password.Focus();
                return;
            }
            else if (!strPassword.Equals(strPassword2))
            {
                MessageBox.Show("两次密码不一致!,请重输。");
                Password2.Focus();
                return;
            }
            else if (!Regex.IsMatch(strPassword, regex))
            {
                MessageBox.Show("请输入规范的密码,密码长度6-20位。");
                Password.Focus();
                return;
            }
            else
            {
                MessageBox.Show("恭喜您注册成功!" + '\n' + "您的信息如下:" + '\n' + strUsername + '\n' + strGender + '\n' + strPassword);

                this.Close();
            }
        }
Ejemplo n.º 4
0
 private void Password2TextBoxClick(object sender, MouseButtonEventArgs e)
 {
     Password2.Clear();
 }
Ejemplo n.º 5
0
        private void RegisterButtonSubmitClick(object sender, RoutedEventArgs e)
        {
            if (Password1.Password.Length > 4 && Password1.Password.Length < 10 && Password1.Password == Password2.Password && Name.Text.Length > 4 && Name.Text.Length < 16)
            {
                BinaryWriter writer = new BinaryWriter(App.getStream());
                BinaryReader reader = new BinaryReader(App.getStream());

                try
                {
                    string login    = Name.Text;
                    string password = Password1.Password.ToString();
                    writer.Write(2);
                    writer.Flush();
                    writer.Write(login);
                    writer.Flush();
                    writer.Write(password);
                    writer.Flush();


                    var res = reader.ReadInt32();
                    switch (res)
                    {
                    case 1:
                        MessageBox.Show("Ви успішно зареєструвалися");
                        Name.Clear();
                        Password1.Clear();
                        Password2.Clear();
                        break;

                    case 2:
                        MessageBox.Show("Користувач з таким логіном вже існує");
                        break;

                    case 0:
                        MessageBox.Show("Сталася помилка на сервері");
                        break;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Something is wrong. \n\n\n" + ex.ToString());
                }
                finally
                {
                    writer.Close();
                    reader.Close();
                    App.closeClient();
                }
            }

            if (Name.Text == "")
            {
                NameErrorLabel.Content    = "Name is empty";
                NameErrorLabel.Visibility = Visibility.Visible;
            }

            if (Password1.Password.ToString() == "")
            {
                PasswordErrorLabel.Content    = "Password is empty";
                PasswordErrorLabel.Visibility = Visibility.Visible;
            }

            if (Password2.Password.ToString() == "")
            {
                Password2ErrorLabel.Content    = "Password is empty";
                Password2ErrorLabel.Visibility = Visibility.Visible;
            }
        }