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 { /// /// Interaction logic for MainWindow.xaml /// 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 = "Пароли совпадают"; } } } }