MainWindow.xaml.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace Cafe11
  16. {
  17. /// <summary>
  18. /// Interaction logic for MainWindow.xaml
  19. /// </summary>
  20. public partial class MainWindow : Window
  21. {
  22. gr671_mkyuEntities entities;
  23. public MainWindow()
  24. {
  25. InitializeComponent();
  26. entities = new gr671_mkyuEntities();
  27. }
  28. private void btnlog_Click(object sender, RoutedEventArgs e)
  29. {
  30. if (string.IsNullOrWhiteSpace(txtlog.Text) || string.IsNullOrWhiteSpace(txtpass.Password))
  31. {
  32. MessageBox.Show("Поля не заполнены");
  33. return;
  34. }
  35. if (entities.Users.Select(x => x.Login + "" + x.Password).Contains(txtlog.Text + "" + txtpass.Password))
  36. {
  37. var role = entities.Users.Where(x => x.Login == txtlog.Text).Select(x => x.IdRole).FirstOrDefault();
  38. if (role == 1)
  39. {
  40. povar pov = new povar();
  41. pov.Show();
  42. this.Close();
  43. }
  44. if (role == 2)
  45. {
  46. ofic of = new ofic();
  47. of.Show();
  48. this.Close();
  49. }
  50. if (role == 3)
  51. {
  52. admin ad = new admin();
  53. ad.Show();
  54. this.Close();
  55. }
  56. }
  57. }
  58. }
  59. }