MainWindow.xaml.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using Exam.Pages;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace Exam
  17. {
  18. /// <summary>
  19. /// Логика взаимодействия для MainWindow.xaml
  20. /// </summary>
  21. public partial class MainWindow : Window
  22. {
  23. users user;
  24. public MainWindow()
  25. {
  26. DBContext.Connect = new ExamPm01Entities();
  27. InitializeComponent();
  28. }
  29. private void Autorisation_Click(object sender, RoutedEventArgs e)
  30. {
  31. user = DBContext.Connect.users.FirstOrDefault(x => (x.email.ToString() == TBLogin.Text) && (x.password == TBPassword.Text));
  32. if (user == null) MessageBox.Show("Пользователь не найден");
  33. else
  34. {
  35. SPAutorisation.Visibility = Visibility.Collapsed;
  36. SPButtons.Visibility = Visibility.Visible;
  37. if (DBContext.Connect.posts.FirstOrDefault(x => x.id == user.id_post).id_role == 1)
  38. {
  39. BRate.Visibility = Visibility.Visible;
  40. }
  41. MainFrame.Navigate(new UserActivity(user));
  42. }
  43. }
  44. private void Exit_Click(object sender, RoutedEventArgs e)
  45. {
  46. MainWindow mw = new MainWindow();
  47. mw.Show();
  48. this.Close();
  49. }
  50. private void ToRatePage_Click(object sender, RoutedEventArgs e)
  51. {
  52. BRate.Visibility = Visibility.Collapsed;
  53. BMain.Visibility = Visibility.Visible;
  54. MainFrame.Navigate(new RatePage());
  55. }
  56. private void MainPage_Click(object sender, RoutedEventArgs e)
  57. {
  58. BRate.Visibility = Visibility.Visible;
  59. BMain.Visibility = Visibility.Collapsed;
  60. MainFrame.Navigate(new UserActivity(user));
  61. }
  62. }
  63. }