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; namespace СУБД_Техносервис { public partial class FormMain : Form { public FormMain() { InitializeComponent(); } string Captcha; /// /// сгенерировать символы капчи /// void GetCapcha() { Captcha = Guid.NewGuid().ToString().Substring(0, 4); LblC1.Text = Captcha[0].ToString(); LblC2.Text = Captcha[1].ToString(); LblC3.Text = Captcha[2].ToString(); LblC4.Text = Captcha[3].ToString(); TbxCapcha.Clear(); } private void FormMain_Load(object sender, EventArgs e) { // TODO: данная строка кода позволяет загрузить данные в таблицу "techServiceBAUDataSet.Employee". При необходимости она может быть перемещена или удалена. this.employeeTableAdapter.Fill(this.techServiceBAUDataSet.Employee); } private void CbxShowPassw_CheckedChanged(object sender, EventArgs e) { TbxPassw.UseSystemPasswordChar = !TbxPassw.UseSystemPasswordChar; } private void BtnVhod_Click(object sender, EventArgs e) { if (TbxCapcha.Text != Captcha && PanelCapcha.Visible == true) { GetCapcha(); BtnVhod.Enabled = false; TimerForLogin.Start(); MessageBox.Show("Неверная капча.", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } BsEmployee.Filter = $"Password = '{TbxPassw.Text}' and Login = '{TbxLogin.Text}'"; if (BsEmployee.Count == 0) { if (!PanelCapcha.Visible) { PanelCapcha.Visible = true; } else { BtnVhod.Enabled = false; TimerForLogin.Start(); } GetCapcha(); MessageBox.Show("Неверный логин или пароль.", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } FormWorkPlace FrmWork = new FormWorkPlace(); this.Hide(); FrmWork.BsEmployee.Filter = $"Login = '{TbxLogin.Text}'"; FrmWork.ShowDialog(); this.Show(); GetCapcha(); TbxLogin.Clear(); TbxPassw.Clear(); PanelCapcha.Visible = false; TbxCapcha.Clear(); this.employeeTableAdapter.Fill(this.techServiceBAUDataSet.Employee); } private void PCapcha_Paint(object sender, PaintEventArgs e) { Random Rnd = new Random(); for (int i = 0; i < 7; i++) { e.Graphics.DrawLine(new Pen(Color.Black, 2), 0, Rnd.Next(PCapcha.Height), PCapcha.Width, Rnd.Next(PCapcha.Height)); } } private void button1_Click(object sender, EventArgs e) { GetCapcha(); } private void TimerForLogin_Tick(object sender, EventArgs e) { BtnVhod.Enabled = true; TimerForLogin.Stop(); } } }