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.Data.SqlClient;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using как_хочешь.Classes;
- using как_хочешь.Forms;
- namespace как_хочешь
- {
- public partial class Avtorization : Form
- {
- public Avtorization()
- {
- InitializeComponent();
- }
- SqlClass sql = new SqlClass();
- GlobalParam param = new GlobalParam();
- int cheack_login = 0;
- private void Avtorization_Load(object sender, EventArgs e)
- {
- sql.OpenConnection();
- }
- private void Avtorization_FormClosed(object sender, FormClosedEventArgs e)
- {
- sql.CloseConnection();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- if (textBox1.Text != "" && textBox1.Text != "")
- {
- SqlCommand command = new SqlCommand($"SELECT COUNT(*) from [dbo].[users] WHERE login = '{textBox1.Text}' AND pass = '{textBox2.Text}'", sql.connestion);
- SqlDataReader reader = command.ExecuteReader();
- while (reader.Read())
- {
- cheack_login = Convert.ToInt32(reader[0]);
- }
- reader.Close();
- if(cheack_login == 1)
- {
- SqlCommand command_user = new SqlCommand($"SELECT * from [dbo].[users] WHERE login = '{textBox1.Text}' AND pass = '{textBox2.Text}'", sql.connestion);
- SqlDataReader reader_user = command_user.ExecuteReader();
- while (reader_user.Read())
- {
- param.user_surname = Convert.ToString(reader_user[1]);
- param.user_patronymic = Convert.ToString(reader_user[3]);
- param.user_name = Convert.ToString(reader_user[2]);
- param.user_role = Convert.ToInt32(reader_user[6]);
- }
- reader_user.Close();
- MessageBox.Show("Добро пожаловать!!!!!!!!!");
- this.Hide();
- MainPanel mp = new MainPanel();
- mp.Show();
- }
- else if (cheack_login == 0)
- {
- MessageBox.Show("Введите данные", "Ошибка");
- }
- }
- else
- {
- MessageBox.Show("Пошёл нахуй");
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace как_хочешь.Classes
- {
- public class GlobalParam
- {
- public string user_surname = "";
- public string user_patronymic = "";
- public string user_name = "";
- public int user_role = 0;
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace как_хочешь.Classes
- {
- public class SqlClass
- {
- public SqlConnection connestion = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=sobaka;Integrated Security=True");
- public void OpenConnection()
- {
- connestion.Open();
- }
- public void CloseConnection()
- {
- connestion.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement