12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- 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
- {
- /// <summary>
- /// Interaction logic for Auth.xaml
- /// </summary>
-
- 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;
- }
- }
- }
- }
|