using System;
using System.Collections.Generic;
using System.Linq;
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.Shapes;
using System.Data;
using System.Data.Entity;
using System.Data.SQLite;
using StudentGroups.Class;
namespace StudentGroups.Windows
{
/// <summary>
/// Логика взаимодействия для Authorize.xaml
/// </summary>
public partial class Authorize : Window
{
Class.AppContext db = Class.AppContext.GetContext();
public Authorize()
{
InitializeComponent();
}
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
DragMove();
}
private void PreCloseBT_Click(object sender, RoutedEventArgs e)
{
WindowState = WindowState.Minimized;
}
private void CloseBT_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void AuthorBt_Click(object sender, RoutedEventArgs e)
{
try
{
var AuthPerson = db.Authorize.FirstOrDefault(x => x.login == logBox.Text && x.user_pass == passBox.Password);
if (AuthPerson == null)
{
MessageBox.Show("Такого пользователя нет!", "Ошибка при авторизации", MessageBoxButton.OK, MessageBoxImage.Error);
}
else
{
switch (AuthPerson.ID_role)
{
case 1:
MessageBox.Show("Здравствуйте, Администратор " + "!", "Уведомление", MessageBoxButton.OK, MessageBoxImage.Information);
break;
case 2:
MessageBox.Show("Здравствуйте, Учитель " + "!", "Уведомление", MessageBoxButton.OK, MessageBoxImage.Information);
break;
case 3:
MessageBox.Show("Здравствуйте, Куратор " + "!", "Уведомление", MessageBoxButton.OK, MessageBoxImage.Information);
break;
}
// Author. = AuthPerson.ID_role;
MainWindow a = new MainWindow();
a.Show();
Close();
}
}
catch (Exception Ex)
{
MessageBox.Show("Ошибка!!! " + Ex.Message.ToString() + " Критическая работа приложения!!!", "Уведомление", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
}
}