45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using ModuleTools.BusinessLogics;
|
|
using ModuleTools.Extensions;
|
|
using ModuleTools.Interfaces;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace DepartmentPortalDesctop
|
|
{
|
|
/// <summary>
|
|
/// Форма входа в систему
|
|
/// </summary>
|
|
public partial class FormEnter : Form
|
|
{
|
|
public FormEnter()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void ButtonEnter_Click(object sender, EventArgs e)
|
|
{
|
|
if (textBoxLogin.Text.IsEmpty())
|
|
{
|
|
MessageBox.Show("Введите логин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
if (textBoxPassword.Text.IsEmpty())
|
|
{
|
|
MessageBox.Show("Введите пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
try
|
|
{
|
|
var securityManager = DependencyManager.Instance.Resolve<ISecurityManager>();
|
|
Task.WaitAll(Task.Run(async () => await securityManager.LoginAsync(textBoxLogin.Text, textBoxPassword.Text)));
|
|
DialogResult = DialogResult.OK;
|
|
Close();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorMessanger.PrintErrorMessage("При аутентфикации возникла ошибка: ", new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("Аутентфикация", ex.Message) });
|
|
}
|
|
}
|
|
}
|
|
}
|