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; namespace TrainingBeforeExams { /// /// Interaction logic for Auth.xaml /// public partial class Auth : Window { testEntities entity; public Auth() { InitializeComponent(); entity = new testEntities(); } private void Button_Click(object sender, RoutedEventArgs e) { if(string.IsNullOrWhiteSpace(loginBox.Text) || string.IsNullOrWhiteSpace(passBox.Text)) { MessageBox.Show("Поля не заполнены."); return; } if (entity.User.Select(x => x.Login + "" + x.Password).Contains(loginBox.Text + "" + passBox.Text)) { var id = entity.User.Where(x => x.Login == loginBox.Text).Select(x => x.IdUser).FirstOrDefault(); var role = entity.User.Where(x => x.Login == loginBox.Text).Select(x => x.RoleID).FirstOrDefault(); if(role == 1) { WaiterWindow waiterWindow = new WaiterWindow(loginBox.Text, id); waiterWindow.Show(); this.Hide(); } if(role == 2) { CookerWindow cookerWindow = new CookerWindow(); cookerWindow.Show(); this.Hide(); } if(role == 3) { MainWindow mainWindow = new MainWindow(); mainWindow.Show(); this.Hide(); } } else { MessageBox.Show("Логин или пароль не совпадают."); return; } } } }