66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace samusev_42
|
|
{
|
|
public partial class AuthForm : Form
|
|
{
|
|
Ispr2522SamusevOvLazarev2Context context = new Ispr2522SamusevOvLazarev2Context();
|
|
|
|
public AuthForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void buttonLogin_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string inputLogin = textBoxLogin.Text.Trim();
|
|
string inputPassword = textBoxPassword.Text.Trim();
|
|
|
|
|
|
if (string.IsNullOrEmpty(inputLogin) || string.IsNullOrEmpty(inputPassword))
|
|
{
|
|
MessageBox.Show("Введите логин и пароль!", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
|
|
var user = context.Users.FirstOrDefault(x => x.Login == inputLogin && x.Password == inputPassword);
|
|
|
|
if (user != null)
|
|
{
|
|
|
|
this.Hide();
|
|
|
|
Form1 mainForm = new Form1();
|
|
mainForm.ShowDialog();
|
|
|
|
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
|
|
MessageBox.Show("Пользователь не найден! Проверьте правильность данных.",
|
|
"Ошибка авторизации", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
MessageBox.Show($"Ошибка подключения: {ex.Message}", "Критическая ошибка");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|