KalkulatorISP-31rrrrr/source/repos/Федосеев проект/Form1.cs
2025-11-11 14:18:33 +04:00

81 lines
2.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 Федосеев_проект
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load_1(object sender, EventArgs e)
{
Tb__Password.UseSystemPasswordChar = true;
}
private void checkBox_CheckedChanged(object sender, EventArgs e)
{
if (checkBox.Checked)
{
Tb__Password.UseSystemPasswordChar = false;
}
else
{
Tb__Password.UseSystemPasswordChar = true;
}
}
private void Bt__Authorization_Click(object sender, EventArgs e)
{
CL_Федосеев dataBase = CL_Федосеев.getInstance();
DataTable table = new DataTable();
MySqlDataAdapter adapter = new MySqlDataAdapter();
MySqlCommand command = new MySqlCommand("SELECT * FROM `Atorization` WHERE " +
"`Login` = '" + Tb__Login.Text + "'And `Password` = '" + Tb__Password.Text +
"' AND id_Role = '1'", dataBase.GetConnection());
adapter.SelectCommand = command;
adapter.Fill(table);
if (table.Rows.Count==1)
{
AdminPanel AdmP = new AdminPanel();
AdmP.Show();
}
else
{
MySqlCommand command1 = new MySqlCommand("SELECT * FROM `Atorization` " +
"WHERE `Login` = '" + Tb__Login.Text + "'And `Password` = '" + Tb__Password.Text +
"' AND id_Role = '2'", dataBase.GetConnection());
adapter.SelectCommand = command1;
adapter.Fill(table);
if (table.Rows.Count==1)
{
UserPanel Usp = new UserPanel();
Usp.Show();
}
else
{
MessageBox.Show("Неправельные данные");
}
}
}
}
}