Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 MaraphonSkills2
- {
- public partial class Authentification : Form
- {
- public Authentification()
- {
- InitializeComponent();
- }
- private void button7_Click(object sender, EventArgs e)
- {
- Form1 mainscreen = new Form1();
- mainscreen.Show();
- this.Hide();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- Form1 mainscreen = new Form1();
- mainscreen.Show();
- this.Hide();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- String login, password, role;
- String connectionString = "server=localhost;" +
- "database=wstest;" +
- "user=root;" +
- "password=524656bnm";
- String commandString = "select Email, Password, RoleId from user where Email=@email and Password=@pass;";
- MySqlConnection connection = new MySqlConnection(connectionString);
- MySqlCommand command = new MySqlCommand(commandString, connection);
- command.CommandText = commandString;
- DataTable dt = new DataTable();
- connection.Open();
- //adding parameters
- command.Parameters.Add("@email", MySqlDbType.VarChar, 100).Value = textBox1.Text;
- command.Parameters.Add("@pass", MySqlDbType.VarChar, 100).Value = textBox2.Text;
- command.ExecuteNonQuery();
- MySqlDataAdapter adapter = new MySqlDataAdapter(command);
- adapter.Fill(dt);
- dataGridView1.DataSource = dt;
- login = dt.Rows[0][0].ToString();
- password = dt.Rows[0][1].ToString();
- role = dt.Rows[0][2].ToString();
- MessageBox.Show(role);
- if (login == textBox1.Text && password == textBox2.Text)
- {
- //MessageBox.Show("Correct");
- //adminform af = new adminform();
- //af.Show();
- //this.Hide();
- }
- /*
- MySqlDataReader reader = command.ExecuteReader();
- try
- {
- MessageBox.Show(reader.GetString(0) + " " + reader.GetString(1));
- if (reader["Email"].ToString() == textBox1.Text && reader["Password"].ToString() == textBox2.Text)
- {
- adminform af = new adminform();
- af.Show();
- this.Hide();
- }
- }
- catch (MySqlException ex)
- {
- Console.WriteLine("Error: \r\n{0}", ex.ToString());
- }
- finally
- {
- command.Connection.Close();
- }*/
- connection.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement