80 lines
2.2 KiB
C#
80 lines
2.2 KiB
C#
![]() |
using Avalonia.Controls;
|
||
|
using Avalonia.Interactivity;
|
||
|
using Avalonia.Markup.Xaml;
|
||
|
using Demka_Snova_1.Hardik.Conect.Dao;
|
||
|
using Demka_Snova_1.OknaRoley;
|
||
|
namespace Demka_Snova_1;
|
||
|
|
||
|
public partial class MainWindow : Window
|
||
|
{
|
||
|
private bool _isPasswordVisible = false;
|
||
|
|
||
|
public MainWindow()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
}
|
||
|
|
||
|
private void TogglePasswordButton_Click(object sender, RoutedEventArgs e)
|
||
|
{
|
||
|
_isPasswordVisible = !_isPasswordVisible;
|
||
|
PasswordTextBox.PasswordChar = _isPasswordVisible ? '\0' : '*';
|
||
|
}
|
||
|
|
||
|
private void SelerTest_Click(object sender, RoutedEventArgs e)
|
||
|
{
|
||
|
var login = new SellerWindow();
|
||
|
login.Show();
|
||
|
this.Close();
|
||
|
}
|
||
|
|
||
|
private void LoginButton_Click(object sender, RoutedEventArgs e)
|
||
|
{
|
||
|
string username = UsernameTextBox.Text;
|
||
|
string password = PasswordTextBox.Text;
|
||
|
if (IsValidUser(username, password))
|
||
|
{
|
||
|
Window nextWindow = null;
|
||
|
switch (SotrudnikDao.Pozition)
|
||
|
{
|
||
|
case "Продавец":
|
||
|
nextWindow = new SellerWindow();
|
||
|
break;
|
||
|
case "Старший смены":
|
||
|
nextWindow = new StarshiyWindow();
|
||
|
break;
|
||
|
case "Администратор":
|
||
|
nextWindow = new AdminWindow();
|
||
|
break;
|
||
|
default:
|
||
|
ShowError("Неизвестная роль пользователя");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
nextWindow.Show();
|
||
|
this.Close();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ShowError("Неверный логин или пароль");
|
||
|
}
|
||
|
|
||
|
async void ShowError(string mes)
|
||
|
{
|
||
|
var dialog = new Window
|
||
|
{
|
||
|
Title = "Ошибка",
|
||
|
Content = mes,
|
||
|
Width = 300,
|
||
|
Height = 200
|
||
|
};
|
||
|
await dialog.ShowDialog(this);
|
||
|
}
|
||
|
|
||
|
bool IsValidUser(string username, string password)
|
||
|
{
|
||
|
return username == SotrudnikDao.Login && password == SotrudnikDao.Pass;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|