12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- using System.Data.Entity;
- namespace KadroviYshot
- {
- public partial class FormAuthorization : Form
- {
- DataBase database = new DataBase();
- public FormAuthorization()
- {
- InitializeComponent();
- StartPosition = FormStartPosition.CenterScreen;
- }
- private void btnEnter_Click(object sender, EventArgs e)
- {
- var loginUser = textBoxLogin.Text;
- var passUser = textBoxPassword.Text;
- SqlDataAdapter adapter = new SqlDataAdapter();
- DataTable table = new DataTable();
- string querystring = $"select IdUser, Login, Password from Users where Login='{loginUser}' and Password='{passUser}'";
- SqlCommand command = new SqlCommand(querystring, database.getConnection());
- adapter.SelectCommand = command;
- adapter.Fill(table);
- if (table.Rows.Count == 1)
- {
- MessageBox.Show("Вы успешно вошли!", "Успешно!", MessageBoxButtons.OK, MessageBoxIcon.Information);
- FormAuthorization authorization = new FormAuthorization();
- this.Hide();
- authorization.ShowDialog();
- this.Show();
- }
- else
- MessageBox.Show("Такого аккаунта не существует!", "Аккаунта не существует!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- private void FormAuthorization_Load(object sender, EventArgs e)
- {
- textBoxLogin.MaxLength = 50;
- textBoxPassword.MaxLength = 50;
- }
- }
- }
|