106 lines
3.3 KiB
C#
106 lines
3.3 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;
|
|||
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|||
|
|
|
|||
|
|
namespace KursovayaDvornikovAM
|
|||
|
|
{
|
|||
|
|
public partial class LoginForm : Form
|
|||
|
|
{
|
|||
|
|
public LoginForm()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void CloseButton_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
Application.Exit();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void CloseButton_MouseEnter(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
CloseButton.ForeColor = Color.Red;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void CloseButton_MouseLeave(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
CloseButton.ForeColor = Color.Black;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Point lastPoint;
|
|||
|
|
private void LoginForm_MouseMove(object sender, MouseEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.Button == MouseButtons.Left)
|
|||
|
|
{
|
|||
|
|
this.Left += e.X - lastPoint.X;
|
|||
|
|
this.Top += e.Y - lastPoint.Y;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void LoginForm_MouseDown(object sender, MouseEventArgs e)
|
|||
|
|
{
|
|||
|
|
lastPoint = new Point(e.X, e.Y);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void buttonLogin_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
string connectionString = "server=cfif31.ru;user=ISPr24-37_DvornikovAM;database=ISPr24-37_DvornikovAM_Kursovaya;password=ISPr24-37_DvornikovAM;";
|
|||
|
|
MySqlConnection DBconnection = new MySqlConnection(connectionString);
|
|||
|
|
MySqlCommand command = new MySqlCommand("SELECT * FROM `ISPr24-37_DvornikovAM_Kursovaya`.Polzovatel WHERE Login = @login and Password=@password;", DBconnection);
|
|||
|
|
command.Parameters.AddWithValue("@login", LoginField.Text);
|
|||
|
|
command.Parameters.AddWithValue("@password", PassField.Text);
|
|||
|
|
DBconnection.Open();
|
|||
|
|
MySqlDataReader reader = command.ExecuteReader();
|
|||
|
|
if (reader.HasRows)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
MainForm main = new MainForm();
|
|||
|
|
main.Show();
|
|||
|
|
this.Hide();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Неверный логин или пароль!");
|
|||
|
|
}
|
|||
|
|
reader.Close();
|
|||
|
|
DBconnection.Close();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void RegisterLabel_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
this.Hide();
|
|||
|
|
RegisterForm registerForm = new RegisterForm();
|
|||
|
|
registerForm.Show();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void HideButton_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
this.WindowState = FormWindowState.Minimized;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void HideButton_MouseEnter(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
HideButton.ForeColor = Color.Red;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void HideButton_MouseLeave(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
HideButton.ForeColor = Color.Black;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void LoginField_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|