2021-03-28 00:23:01 +04:00
using DesktopTools.BusinessLogics ;
2021-03-28 00:26:26 +04:00
using ModelTools.Extensions ;
2021-03-28 00:23:01 +04:00
using SecurityBusinessLogic.BusinessLogics ;
2021-03-26 20:09:52 +04:00
using System ;
2021-03-28 00:23:01 +04:00
using System.Collections.Generic ;
2021-03-26 20:09:52 +04:00
using System.Threading.Tasks ;
using System.Windows.Forms ;
namespace DepartmentPortalDesctop
{
/// <summary>
/// Форма входа в систему
/// </summary>
public partial class FormEnter : Form
{
public FormEnter ( )
{
InitializeComponent ( ) ;
}
2021-03-28 00:26:26 +04:00
private void Login ( )
2021-03-26 20:09:52 +04:00
{
2021-03-28 00:26:26 +04:00
if ( textBoxLogin . Text . IsEmpty ( ) )
{
MessageBox . Show ( "Введите логин" , "Ошибка" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
if ( textBoxPassword . Text . IsEmpty ( ) )
{
MessageBox . Show ( "Введите пароль" , "Ошибка" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
2021-03-26 20:09:52 +04:00
try
{
Task . WaitAll ( Task . Run ( async ( ) = > await UserManager . GetInstance . LoginAsync ( textBoxLogin . Text , textBoxPassword . Text ) ) ) ;
DialogResult = DialogResult . OK ;
Close ( ) ;
}
catch ( Exception ex )
{
2021-03-28 00:23:01 +04:00
ErrorMessanger . PrintErrorMessage ( "При аутентфикации возникла ошибка: " , new List < KeyValuePair < string , string > > { new KeyValuePair < string , string > ( "Аутентфикация" , ex . Message ) } ) ;
2021-03-26 20:09:52 +04:00
}
}
2021-03-28 00:26:26 +04:00
private void ButtonEnter_Click ( object sender , EventArgs e ) = > Login ( ) ;
private void TextBoxPassword_KeyDown ( object sender , KeyEventArgs e )
{
if ( e . KeyCode = = Keys . Enter )
{
Login ( ) ;
}
}
2021-03-26 20:09:52 +04:00
}
}