MainWindow.xaml.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using Practics.Model;
  2. using System.Text;
  3. using System.Windows;
  4. using System.Windows.Controls;
  5. using System.Windows.Data;
  6. using System.Windows.Documents;
  7. using System.Windows.Input;
  8. using System.Windows.Media;
  9. using System.Windows.Media.Imaging;
  10. using System.Windows.Navigation;
  11. using System.Windows.Shapes;
  12. namespace Practics
  13. {
  14. /// <summary>
  15. /// Interaction logic for MainWindow.xaml
  16. /// </summary>
  17. public partial class MainWindow : Window
  18. {
  19. Model.Model model = Model.Model.ModelInstance; // new Model.Model();
  20. //Model.Model registraionModel = Model.Model.ModelInstance; //new Model.Model();
  21. public MainWindow()
  22. {
  23. InitializeComponent();
  24. }
  25. private void btnRegistraion_Click(object sender, RoutedEventArgs e)
  26. {
  27. if (tbLastName.Text == "")
  28. {
  29. MessageBox.Show("Введите фамилию");
  30. return;
  31. }
  32. if (tbFirstName.Text == "")
  33. {
  34. MessageBox.Show("Введите имя");
  35. return;
  36. }
  37. if (tbMiddleName.Text == "")
  38. {
  39. MessageBox.Show("Введите отчество");
  40. return;
  41. }
  42. string outMessage;
  43. bool flag = model.Registration(tbEmail.Text, tbPassword.Password, tbFirstName.Text, tbLastName.Text, tbMiddleName.Text,out outMessage);
  44. MessageBox.Show(outMessage);
  45. if (flag)
  46. {
  47. User user;
  48. model.Login(tbEmail.Text, tbPassword.Password, out user);
  49. TicketWindow ticketWindow = new TicketWindow(user);
  50. ticketWindow.Show();
  51. this.Close();
  52. }
  53. //System.Diagnostics.Debug.WriteLine(Model.Model.HashPassword("admin"));
  54. }
  55. private void tbStatus_PreviewKeyUp(object sender, KeyEventArgs e)
  56. {
  57. Model.Model statusModel = Model.Model.ModelInstance;// new Model.Model();
  58. tbStatus.Text = !statusModel.CheckPassword(tbPassword.Password) ?"Пароль слишком простой!":"Пароль достаточно надежный!";
  59. }
  60. private void btnLogin_Click(object sender, RoutedEventArgs e)
  61. {
  62. int role;
  63. User user;
  64. if (model.Login(tbEmail2.Text, tbPassword2.Password,out user))
  65. {
  66. if (user.Role == 0)
  67. {
  68. AdminTicketWindow adminTicketWindow = new AdminTicketWindow(user);
  69. adminTicketWindow.Show();
  70. this.Close();
  71. }
  72. else
  73. {
  74. TicketWindow ticketWindow = new TicketWindow(user);
  75. ticketWindow.Show();
  76. this.Close();
  77. }
  78. }
  79. else
  80. MessageBox.Show("Не правильный логин или пароль");
  81. }
  82. private void tbStatus_PreviewKeyUp2(object sender, KeyEventArgs e)
  83. {
  84. if (tbPassword.Password!=tbPassword3.Password)
  85. {
  86. tbStatus.Text = "Пароли не совпадают";
  87. }
  88. else
  89. {
  90. tbStatus.Text = "Пароли совпадают";
  91. }
  92. }
  93. }
  94. }