1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- 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 olimp8
- {
- /// <summary>
- /// Interaction logic for AuthWindow.xaml
- /// </summary>
- public partial class AuthWindow : Window
- {
- olimp_8Entities entity = new olimp_8Entities();
- public AuthWindow()
- {
- InitializeComponent();
- }
- 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(LoginBox.Text);
- mainWindow.Show();
- this.Hide();
- }
- }
- else
- {
- MessageBox.Show("Неверный логин или пароль");
- return;
- }
- }
- }
- }
|