76 lines
2.3 KiB
C#
76 lines
2.3 KiB
C#
using MySql.Data.MySqlClient;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Data.SqlClient;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using System.Windows.Forms;
|
||
|
||
namespace Musical
|
||
{
|
||
public partial class Form1 : Form
|
||
{
|
||
public Form1()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
private void Form1_Load(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void btnLogin_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
|
||
|
||
|
||
|
||
using (MySqlConnection conn = new MySqlConnection("Server=192.168.201.207;Database=ISP41_Gusarov_Musical;Uid=ISP41_Gusarov;Pwd=ISP41_Gusarov;"))
|
||
{
|
||
string Seller_Login = txtUsername.Text;
|
||
string Seller_Password = txtPassword.Text;
|
||
|
||
|
||
{
|
||
try
|
||
{
|
||
conn.Open();
|
||
|
||
// Проверяем, есть ли такой пользователь с таким паролем
|
||
string query = "SELECT COUNT(*) FROM Seller WHERE Seller_Login = @username AND Seller_Password = @password";
|
||
MySqlCommand cmd = new MySqlCommand(query, conn);
|
||
cmd.Parameters.AddWithValue("@username", Seller_Login);
|
||
cmd.Parameters.AddWithValue("@password", Seller_Password);
|
||
|
||
int count = Convert.ToInt32(cmd.ExecuteScalar());
|
||
|
||
if (count > 0)
|
||
{
|
||
MessageBox.Show("Вход выполнен успешно!");
|
||
// Здесь можно открыть следующую форму
|
||
// this.Hide();
|
||
// MainForm mainForm = new MainForm();
|
||
// mainForm.Show();
|
||
}
|
||
else
|
||
{
|
||
lblError.Text = "Неверный логин или пароль!";
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
lblError.Text = "Ошибка: " + ex.Message;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|