demo_hard/MainWindow.axaml.cs

43 lines
1021 B
C#
Raw Normal View History

2025-02-05 10:07:55 +00:00
using System;
using System.Linq;
2025-02-04 12:27:32 +00:00
using Avalonia.Controls;
using Avalonia.Interactivity;
2025-02-11 13:17:16 +00:00
using demo_hard.Model;
2025-02-05 10:07:55 +00:00
using Tmds.DBus.Protocol;
2025-02-04 12:27:32 +00:00
namespace demo_hard;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
2025-02-05 10:07:55 +00:00
2025-02-04 12:27:32 +00:00
private void TogglePasswordVisibility(object? sender, RoutedEventArgs e)
{
PasswordBox.PasswordChar = PasswordBox.PasswordChar == '*' ? '\0' : '*';
}
private void AuthorizeButton(object? sender, RoutedEventArgs e)
{
2025-02-05 10:07:55 +00:00
using var context = new User2Context();
var user = context.Employees.FirstOrDefault(it => it.EmployeLogin == LoginBox.Text && it.EmployePassword == PasswordBox.Text);
if (user != null)
{
var functionWindow = new FunctionWindow(user);
{
DataContext = user;
};
functionWindow.ShowDialog(this);
}
else
{
2025-02-11 13:17:16 +00:00
ErrorBlock.Text = "Неверный пароль";
2025-02-05 10:07:55 +00:00
}
2025-02-04 12:27:32 +00:00
}
2025-02-05 10:07:55 +00:00
}