FinalDemo/Hard_Demo/MainWindow.axaml.cs
2025-03-09 18:00:01 +03:00

43 lines
1.0 KiB
C#

using System;
using System.Linq;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Hard_Demo.Models;
//using demo_hard.Models;
using Tmds.DBus.Protocol;
namespace Hard_Demo;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void TogglePasswordVisibility(object? sender, RoutedEventArgs e)
{
PasswordBox.PasswordChar = PasswordBox.PasswordChar == '*' ? '\0' : '*';
}
private void AuthorizeButton(object? sender, RoutedEventArgs e)
{
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
{
WrongData.Text = "Неверный логин или пароль";
}
}
}