Форма вход enter на пароле

This commit is contained in:
kotcheshir73 2021-03-28 00:26:26 +04:00
parent 74549aa18d
commit 525add0260
2 changed files with 21 additions and 1 deletions

View File

@ -72,6 +72,7 @@ namespace DepartmentPortalDesctop
this.textBoxPassword.Size = new System.Drawing.Size(242, 23);
this.textBoxPassword.TabIndex = 3;
this.textBoxPassword.UseSystemPasswordChar = true;
this.textBoxPassword.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxPassword_KeyDown);
//
// buttonEnter
//

View File

@ -1,4 +1,5 @@
using DesktopTools.BusinessLogics;
using ModelTools.Extensions;
using SecurityBusinessLogic.BusinessLogics;
using System;
using System.Collections.Generic;
@ -17,8 +18,16 @@ namespace DepartmentPortalDesctop
InitializeComponent();
}
private void ButtonEnter_Click(object sender, EventArgs e)
private void Login()
{
if (textBoxLogin.Text.IsEmpty())
{
MessageBox.Show("Введите логин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
if (textBoxPassword.Text.IsEmpty())
{
MessageBox.Show("Введите пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
Task.WaitAll(Task.Run(async () => await UserManager.GetInstance.LoginAsync(textBoxLogin.Text, textBoxPassword.Text)));
@ -30,5 +39,15 @@ namespace DepartmentPortalDesctop
ErrorMessanger.PrintErrorMessage("При аутентфикации возникла ошибка: ", new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("Аутентфикация", ex.Message) });
}
}
private void ButtonEnter_Click(object sender, EventArgs e) => Login();
private void TextBoxPassword_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
Login();
}
}
}
}