123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace proba
- {
- public partial class PosleVHODA : Form
- {
- DataBase dataBase = new DataBase();
- public static string login;
- public PosleVHODA()
- {
- InitializeComponent();
- }
- private void PosleVHODA_Load(object sender, EventArgs e)
- {
- this.Size = new Size(500, 300);
- this.MaximumSize = new Size(500, 300);
- this.MinimumSize = new Size(500, 300);
- }
- private void buttonlogin(object sender, EventArgs e)
- {
- Shifr.phraze = polePassword.Text;
- Shifr myTeloInfo = new Shifr();
- myTeloInfo.ShifrCode();
- string password = "";
- for (int i = 0; i < Shifr.codePhraze.Length; i++)
- {
- password = password + Shifr.codePhraze[i];
- }
- if (polelogina.Text.Replace(" ", "") == "") MessageBox.Show("Поле логин не может быть пустым");
- else if (polePassword.Text.Replace(" ", "") == "") MessageBox.Show("Поле пароль не может быть пустым");
- else
- {
- dataBase.openConnection();
- string admin = "Select * from Employee where login = '" + polelogina.Text.Trim() + "' and password = '" + password + "' and id_role = 1";
- SqlDataAdapter sda1 = new SqlDataAdapter(admin, dataBase.GetConnection());
- DataTable dtbl1 = new DataTable();
- sda1.Fill(dtbl1);
- if (dtbl1.Rows.Count == 1)
- {
- login = polelogina.Text.Trim();
- this.Hide();
- MainMenu mainmenu = new MainMenu();
- mainmenu.ShowDialog();
- }
- else
- {
- string query = "Select * from Employee where login = '" + polelogina.Text.Trim() + "' and password = '" + password + "' and id_role = 2";
- SqlDataAdapter sda = new SqlDataAdapter(query, dataBase.GetConnection());
- DataTable dtbl = new DataTable();
- sda.Fill(dtbl);
- if (dtbl.Rows.Count == 1)
- {
- login = polelogina.Text.Trim();
- this.Hide();
- MainMenu mainmenu = new MainMenu();
- mainmenu.ShowDialog();
- }
- else
- {
- MessageBox.Show("Неверный логин и/или пароль");
- }
- }
- }
- }
- private void button_back_Click(object sender, EventArgs e)
- {
- this.Hide();
- Autorization autorization = new Autorization();
- autorization.ShowDialog();
- }
- public void global_FormClosed(object sender, EventArgs e)
- {
- Application.Exit();
- }
- private void polelogina_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (e.KeyChar == (int)Keys.Space)
- e.KeyChar = '\0';
- }
- private void polePassword_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (e.KeyChar == (int)Keys.Space)
- e.KeyChar = '\0';
- }
-
- }
- }
|