123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- 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 InteractiveKiosk
- {
- /// <summary>
- /// Interaction logic for AuthorizationWindow.xaml
- /// </summary>
- public partial class AuthorizationWindow : Window
- {
- InteractiveKioskEntities db = new InteractiveKioskEntities();
- public AuthorizationWindow()
- {
- InitializeComponent();
- }
- //public void TextBox_GotFocus(object sender, RoutedEventArgs e)
- //{
- // TextBox tb = (TextBox)sender;
- // tb.Text = string.Empty;
- // tb.GotFocus -= TextBox_GotFocus;
- //}
- private void username_TextChanged(object sender, RoutedEventArgs e)
- {
- if (username.Text == "Логин")
- {
- username.Foreground = Brushes.Gray;
- }
- else if (username.Text == "")
- {
- username.Foreground = Brushes.Black;
- }
- }
- private void password_TextChanged(object sender, RoutedEventArgs e)
- {
- if (password.Text == "Пароль")
- {
- password.Foreground = Brushes.Gray;
- }
- else if (password.Text == "")
- {
- password.Foreground = Brushes.Black;
- }
- }
- private const string defaultText = "Логин";
- private const string defaultText1 = "Пароль";
- private void Username_GotFocus(object sender, RoutedEventArgs e)
- {
- username.Text = username.Text == defaultText ?
- string.Empty : username.Text;
- }
- private void Password_GotFocus(object sender, RoutedEventArgs e)
- {
- password.Text = password.Text == defaultText1 ?
- string.Empty : password.Text;
- }
- private void Username_LostFocus(object sender, RoutedEventArgs e)
- {
- username.Text = username.Text == string.Empty ?
- defaultText : username.Text;
-
- }
- private void Password_LostFocus(object sender, RoutedEventArgs e)
- {
- password.Text = password.Text == string.Empty ?
- defaultText1 : password.Text;
- }
- private void LoginButton(object sender, RoutedEventArgs e)
- {
- if (username.Text == "" || password.Text == "")
- {
- MessageBox.Show("Введено неверное значение!");
- return;
- }
- if (db.ParkManagers.Select(item => item.Username + " " + item.Password).Contains(username.Text + " " + password.Text))
- {
- MessageBox.Show("Добро пожаловать, вы авторизированы");
- this.Close();
- }
- else
- {
- MessageBox.Show("Введено неверное значение логина/пароля1");
- }
- }
- }
- }
|