1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Cryptography;
- using System.Text;
- using System.Threading.Tasks;
- 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 SneakersSkakunov
- {
- /// <summary>
- /// Логика взаимодействия для Authorization.xaml
- /// </summary>
- public partial class Authorization : Page
- {
- public Authorization()
- {
- InitializeComponent();
- }
- public void GoReg_Click(object sender, RoutedEventArgs e)
- {
- MainFrame.mframe.Navigate(new Registration());
- }
- private void Enter_Click(object sender, RoutedEventArgs e)
- {
- string CurPass = Pass.Password;
- using (SHA256 hash = SHA256.Create())
- {
- CurPass = BitConverter.ToString(hash.ComputeHash(Encoding.UTF8.GetBytes(CurPass))).Replace("-", "");
- }
- using (Sniker DB = new Sniker())
- {
- Users user = DB.Users.FirstOrDefault(x => x.Login == Login.Text && x.Password == CurPass);
- if (user != null)
- {
- switch (user.id_Role)
- {
- case 1:
- MainFrame.mframe.Navigate(new AdminPage(user.id_Users));
- break;
- case 2:
- MainFrame.mframe.Navigate(new UserPage(user.id_Users));
- break;
- default:
- MessageBox.Show("Вас не существует");
- break;
- }
- }
- else
- {
- MessageBox.Show("Вас не существует");
- }
- }
- }
- }
- }
|