63 lines
1.8 KiB
C#
63 lines
1.8 KiB
C#
using MySql.Data.MySqlClient;
|
|
using NeshinaPolina07_11;
|
|
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 Neshina13
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
string login = textBox1.Text;
|
|
string password = textBox2.Text;
|
|
try
|
|
{
|
|
var db = DB.GetInstance();
|
|
var connection = db.GetConnection();
|
|
string query = "select count(*) from Mangers where Manager_Login = @login AND Manager_Password = @password";
|
|
using (var cmd = new MySqlCommand(query, connection))
|
|
{
|
|
cmd.Parameters.AddWithValue("@login", login);
|
|
cmd.Parameters.AddWithValue("@password", password);
|
|
|
|
var result = cmd.ExecuteScalar();
|
|
|
|
if (result != null)
|
|
{
|
|
MessageBox.Show("Вход выполнен!");
|
|
Form2 form2 = new Form2();
|
|
form2.Show();
|
|
this.Hide(); // или Close(), если хотите закрыть форму
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Неверный логин или пароль");
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("Ошибка: " + ex.Message);
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|