51 lines
1.6 KiB
C#
51 lines
1.6 KiB
C#
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 MySql.Data.MySqlClient;
|
|
|
|
namespace WindowsFormsApp13
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
private string connectionString = "server=cfif31.ru;database=ISPr24-57_ZuevES_Testing;uid=ISPr24-57_ZuevES;password=ISPr24-57_ZuevES;";
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void btnLogin_Click(object sender, EventArgs e)
|
|
{
|
|
string username = usernameTB.Text;
|
|
string password = passwordTB.Text;
|
|
using (MySqlConnection connection = new MySqlConnection(connectionString))
|
|
{
|
|
connection.Open();
|
|
string query = "SELECT * FROM Users WHERE username = @Username AND password = @Password";
|
|
MySqlCommand cmd = new MySqlCommand(query, connection);
|
|
cmd.Parameters.AddWithValue("@Username", username);
|
|
cmd.Parameters.AddWithValue("@Password", password);
|
|
MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
|
|
DataTable dt = new DataTable();
|
|
adapter.Fill(dt);
|
|
if(dt.Rows.Count > 0)
|
|
{
|
|
MessageBox.Show("Success");
|
|
Form2 form2 = new Form2(dt);
|
|
this.Hide();
|
|
form2.Show();
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Wrong");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|