private void TryToLogInButton_Click(object sender, RoutedEventArgs e) { foreach (User u in users) { if (LogInTextBox.Text == u.Login && LogInPasswordBox.Password == u.Password) { TryLogin = true; UserLogin = u.Login; } } if (TryLogin == true) { AppWindow app = new AppWindow(UserLogin); app.Show(); Application.Current.MainWindow.Close(); } if (TryLogin == false) { ErrorTextBox.Text = "Вы ввели неверный логин или пароль"; } }
private void TryToRegistrButton_Click(object sender, RoutedEventArgs e) { if (LogInTextBox.Text == "" || RegistrPasswordBox.Text == "" || TelephoneNumberTextBox.Text == "") { ErrorTextBox.Visibility = Visibility.Visible; } else { using (CarentContext db = new CarentContext()) { User user = new User { Login = LogInTextBox.Text, Password = RegistrPasswordBox.Text, TelephoneNumber = TelephoneNumberTextBox.Text, Status = "user" }; db.Users.Add(user); db.SaveChanges(); } AppWindow app = new AppWindow("user"); app.Show(); Application.Current.MainWindow.Close(); } }
private void TryToLogInButton_Click(object sender, RoutedEventArgs e) { using (CarentContext user_db = new CarentContext()) { var users = user_db.Users; foreach (User u in users) { if (u.Login == LogInTextBox.Text) { if (u.Password == LogInPasswordBox.Password) { AppWindow app = new AppWindow(u.Status); app.Show(); Application.Current.MainWindow.Close(); } } else { ErrorTextBox.Text = "Вы ввели неверный логин или пароль"; } } } }