KalkulatorISP-31rrrrr/source/repos/Izukova/Form1.cs
2025-11-11 14:18:33 +04:00

65 lines
1.9 KiB
C#

using MySql.Data.MySqlClient;
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 Izukova
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
public void button1_Click(object sender, EventArgs e)
{
DataBase dataBase = DataBase.getInstance();
DataTable table = new DataTable();
MySqlDataAdapter adapter = new MySqlDataAdapter();
MySqlCommand command = new MySqlCommand("SELECT * FROM `authorization` WHERE " + "`login` = `" + TbLogin.Text + "`AND `password` = `" + TbPassword.Text
+ "`AND Role_id = `1`", dataBase.GetConnection());
adapter.SelectCommand = command;
adapter.Fill(table);
if (table.Rows.Count == 0)
{
AdminPanel AdmP = new AdminPanel();
AdmP.Show();
}
else
{
MySqlCommand command1 = new MySqlCommand("SELECT * FROM `authorization` WHERE " + "`login` = `" + TbLogin.Text + "`AND `password` = `" + TbPassword.Text
+ "`AND Role_id = `1`", dataBase.GetConnection());
adapter.SelectCommand = command1;
adapter.Fill(table);
if (table.Rows.Count == 1)
{
UserPanel UsP = new UserPanel();
UsP.Show();
}
else
{
MessageBox.Show("Неправильные данные");
}
}
}
}
}