54 lines
1.3 KiB
C#
54 lines
1.3 KiB
C#
//using Register_office.View.MenuV;
|
|
using Register_office.ViewModel.LoginVM;
|
|
using Npgsql;
|
|
using Register_office.View.MenuV;
|
|
|
|
namespace Register_office.View.LoginV
|
|
{
|
|
internal partial class LoginForm : Form
|
|
{
|
|
private readonly LoginViewModel _viewModel;
|
|
|
|
public LoginForm()
|
|
{
|
|
_viewModel = new();
|
|
InitializeComponent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Входит в систему
|
|
/// </summary>
|
|
private void btnEntry_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
// Проверяем логин и пароль
|
|
int personId = _viewModel.CheckEnter(tbLogin.Text, tbPassword.Text);
|
|
_viewModel.General.DoctorId = _viewModel.GetDoctorId(personId);
|
|
|
|
Hide();
|
|
OnlyMenuForm launchForm = new();
|
|
launchForm.ShowDialog();
|
|
|
|
Close();
|
|
}
|
|
catch (NpgsqlException ex)
|
|
{
|
|
MessageBox.Show(ex.Message.Split(':').Skip(1).FirstOrDefault()?.Trim(),
|
|
"Ошибка ввода данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// При нажатии enter - производит событие входа в систему
|
|
/// </summary>
|
|
private void RegistrationForm_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
btnEntry.PerformClick();
|
|
}
|
|
}
|
|
}
|
|
}
|