123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- using Practics.Model;
- using System.Text;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace Practics
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- Model.Model model = Model.Model.ModelInstance; // new Model.Model();
- //Model.Model registraionModel = Model.Model.ModelInstance; //new Model.Model();
- public MainWindow()
- {
- InitializeComponent();
-
- }
- private void btnRegistraion_Click(object sender, RoutedEventArgs e)
- {
- if (tbLastName.Text == "")
- {
- MessageBox.Show("Введите фамилию");
- return;
- }
- if (tbFirstName.Text == "")
- {
- MessageBox.Show("Введите имя");
- return;
- }
- if (tbMiddleName.Text == "")
- {
- MessageBox.Show("Введите отчество");
- return;
- }
- string outMessage;
- bool flag = model.Registration(tbEmail.Text, tbPassword.Password, tbFirstName.Text, tbLastName.Text, tbMiddleName.Text,out outMessage);
- MessageBox.Show(outMessage);
- if (flag)
- {
- User user;
- model.Login(tbEmail.Text, tbPassword.Password, out user);
- TicketWindow ticketWindow = new TicketWindow(user);
- ticketWindow.Show();
- this.Close();
- }
- //System.Diagnostics.Debug.WriteLine(Model.Model.HashPassword("admin"));
- }
- private void tbStatus_PreviewKeyUp(object sender, KeyEventArgs e)
- {
- Model.Model statusModel = Model.Model.ModelInstance;// new Model.Model();
- tbStatus.Text = !statusModel.CheckPassword(tbPassword.Password) ?"Пароль слишком простой!":"Пароль достаточно надежный!";
- }
- private void btnLogin_Click(object sender, RoutedEventArgs e)
- {
- int role;
- User user;
- if (model.Login(tbEmail2.Text, tbPassword2.Password,out user))
- {
- if (user.Role == 0)
- {
- AdminTicketWindow adminTicketWindow = new AdminTicketWindow(user);
- adminTicketWindow.Show();
- this.Close();
- }
- else
- {
- TicketWindow ticketWindow = new TicketWindow(user);
- ticketWindow.Show();
- this.Close();
- }
- }
- else
- MessageBox.Show("Не правильный логин или пароль");
- }
- private void tbStatus_PreviewKeyUp2(object sender, KeyEventArgs e)
- {
- if (tbPassword.Password!=tbPassword3.Password)
- {
- tbStatus.Text = "Пароли не совпадают";
- }
- else
- {
- tbStatus.Text = "Пароли совпадают";
- }
- }
- }
- }
|