123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- 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 InfoTrack
- {
- public partial class FormAutorization : Form
- {
- DataBase dataBase = new DataBase();
- public FormAutorization()
- {
- InitializeComponent();
- StartPosition = FormStartPosition.CenterScreen;
- }
- private void buttonEnter_Click(object sender, EventArgs e)
- {
- SqlDataAdapter adapter = new SqlDataAdapter();
- DataTable table = new DataTable();
- var login = textBoxForLogin.Text;
- var password = textBoxForPass.Text;
- if (login == "логин")
- {
- MessageBox.Show("Введите логин");
- return;
- }
- if (password == "пароль")
- {
- MessageBox.Show("Введите пароль");
- return;
- }
- string zapros = $"select Login from Users where Login = '{login}' and Password = '{password}'";
- SqlCommand command = new SqlCommand(zapros, dataBase.getConnection());
- adapter.SelectCommand = command;
- adapter.Fill(table);
- if (table.Rows.Count == 1)
- {
- GlobalValues.login = login;
- this.Hide();
- FormMenu form = new FormMenu();
- form.Show();
- }
- else
- {
- MessageBox.Show("Неверный логин или пароль");
- }
- }
- private void textBoxForLogin_TextChanged(object sender, EventArgs e)
- {
- if (textBoxForLogin.Text == "логин")
- {
- textBoxForLogin.Text = "";
- }
- if (textBoxForPass.Text == "")
- {
- textBoxForPass.UseSystemPasswordChar = false;
- textBoxForPass.Text = "пароль";
- }
- }
- private void textBoxForPass_TextChanged(object sender, EventArgs e)
- {
- if (textBoxForPass.Text == "пароль")
- {
- textBoxForPass.Text = "";
- textBoxForPass.UseSystemPasswordChar = true;
- }
- if (textBoxForLogin.Text == "")
- {
- textBoxForLogin.Text = "логин";
- }
- }
- private void labelForExit_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- }
- }
|