private void ButtonOk_Click(object sender, RoutedEventArgs e) { textBoxLogin.Focus(); if (textBoxLogin.Text.Trim().Length == 0 || textBoxPassword.Text.Trim().Length == 0 || textBoxPasswordRep.Text.Trim().Length == 0) { return; } if (textBoxLogin.Text.Length <= 4 || textBoxPassword.Text.Length <= 4) { MessageBox.Show("Your login and password must contain at least five characters!"); textBoxLogin.Text = null; textBoxPassword.Text = null; textBoxPasswordRep.Text = null; return; } if (textBoxPassword.Text != textBoxPasswordRep.Text) { MessageBox.Show("Your passwords don't match!"); textBoxLogin.Text = null; textBoxPassword.Text = null; textBoxPasswordRep.Text = null; return; } NewAccount = new User { Login = textBoxLogin.Text.Trim(), Password = security.GetHash(textBoxPassword.Text.Trim()) }; DialogResult = false; }
private void ButtonEnter_Click(object sender, RoutedEventArgs e) { if (_users.Count == 0) { MessageBox.Show("Wrong login or password!"); textBoxLogin.Text = null; textBoxPassword.Password = null; return; } if (_users.Any(account => account.Login == textBoxLogin.Text)) { if (_users.Any(account => account.Password == _security.GetHash(textBoxPassword.Password))) { var tableWindow = new TableWindow(Account.Favourites, _routes); tableWindow.NewFavsAcc += NewFavouriteRoutes; if (tableWindow.ShowDialog() == false) { textBoxLogin.Text = null; textBoxPassword.Password = null; } } } else { MessageBox.Show("Wrong login or password!"); textBoxLogin.Text = null; textBoxPassword.Password = null; return; } }