private void Button_Click(object sender, RoutedEventArgs e) { var a = context.User.Where(i => i.Email == Login.Text && i.Password == PasswordTxt.Password).ToList(); if (a.Count > 0) { if (a.FirstOrDefault().RoleId == "C") { CoordinatorMenu coordinatorMenu = new CoordinatorMenu(); coordinatorMenu.Show(); this.Close(); } else if (a.FirstOrDefault().RoleId == "R") { MenuRunner menuRunner = new MenuRunner(); menuRunner.Show(); this.Close(); } else if (a.FirstOrDefault().RoleId == "A") { MenuAdministrator menuAdministrator = new MenuAdministrator(); menuAdministrator.Show(); this.Close(); } } else { MessageBox.Show("Неправильный логин или пароль"); } }
private void Button_Click(object sender, RoutedEventArgs e) { var a = context.User.Where(i => i.Email == Login.Text && i.Password == PasswordTxt.Password).ToList(); if (a.Any()) { if (a.Where(i => i.RoleId == "C").Any()) { CoordinatorMenu coordinatorMenu = new CoordinatorMenu(); coordinatorMenu.Show(); this.Close(); } else if (a.Where(i => i.RoleId == "R").Any()) { var b = context.Runner.Where(i => i.Email == Login.Text).Select(i => i.RunnerId).First(); var c = context.Registration.Where(i => i.RunnerId == b).Select(i => i.RunnerId).First(); UserClass.UserId = b; UserClass.RegId = c; MenuRunner menuRunner = new MenuRunner(); menuRunner.Show(); this.Close(); } else if (a.Where(i => i.RoleId == "A").Any()) { MenuAdministrator menuAdministrator = new MenuAdministrator(); menuAdministrator.Show(); this.Close(); } } }
private void RegistrationRunner_Click(object sender, RoutedEventArgs e) { try { context1.User.Add(new User { Email = Email.Text, Password = Pass.Text, FirstName = FirstName.Text, LastName = LastName.Text, RoleId = "R" }); context1.SaveChanges(); context.Runner.Add(new Runner { Email = Email.Text, Gender = Gender.Text, DateOfBirth = DateOfBirth.SelectedDate, CountryCode = Country.Text }); context.SaveChanges(); MenuRunner runner = new MenuRunner(); runner.Show(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Exit(object sender, RoutedEventArgs e) { MenuRunner runner = new MenuRunner(); runner.Show(); this.Close(); }
private void Save_Click(object sender, RoutedEventArgs e) { try { var a = context.User.Where(i => i.Email == UserMail.Content.ToString()).First(); a.FirstName = NameUser.Text; a.LastName = SurName.Text; a.Password = PasUser.Text; var b = context.Runner.Where(i => i.Email == UserMail.Content.ToString()).First(); b.CountryCode = CountryUser.Text; b.DateOfBirth = DateOfBirthUser.SelectedDate; b.Gender = GenderUser.Text; context.SaveChanges(); MenuRunner runner = new MenuRunner(); runner.Show(); this.Close(); } catch (Exception) { MessageBox.Show("Неверные данные"); } }