private void pictureBox2_Click(object sender, EventArgs e) { if (this.tbLogin.Text == "" && this.tbPassword.Text == "") { MessageBox.Show("Вы не ввели логин или пароль! Пожалуйста, заполните поля!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } this.counter++; if (string.IsNullOrEmpty(this.tbLogin.Text)) { this.tbLogin.Focus(); return; } if (string.IsNullOrEmpty(this.tbPassword.Text)) { this.tbPassword.Focus(); return; } else if (this.counter >= 3) { this.tbLogin.Enabled = false; this.tbPassword.Enabled = false; } var user = this.FindUser(this.tbLogin.Text, this.tbPassword.Text); if (user != null) { this.counter = 0; this.tbLogin.Focus(); this.tbLogin.Clear(); this.tbPassword.Clear(); MessageBox.Show($"Привет, {user.Имя}!"); if (user.Является_администратором) { var формаАдминистратора = new Администратор(this); формаАдминистратора.Show(); } else { var открыть = new Клиент(user.Id, this); открыть.Show(); } this.Hide(); } else { MessageBox.Show("Вы ввели неверный логин или пароль!Пользователь в базе не найден!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Проверка входа в программу /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pictureBox2_Click(object sender, EventArgs e) { if (this.tbLogin.Text == "" && this.tbPassword.Text == "") { MessageBox.Show("Вы не ввели логин или пароль! Пожалуйста, заполните поля!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } this.counter++; if (string.IsNullOrEmpty(this.tbLogin.Text)) { this.tbLogin.Focus(); return; } if (string.IsNullOrEmpty(this.tbPassword.Text)) { this.tbPassword.Focus(); return; } else if (this.counter >= 3) { this.tbLogin.Enabled = false; this.tbPassword.Enabled = false; MessageBox.Show("По всем вопросам восстановления пароля свяжитесь с Вашим администратором по номеру " + "+7 (953) 489-65-32!", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } var user = this.FindUser(this.tbLogin.Text, this.tbPassword.Text); if (user != null) { MessageBox.Show($"Привет, {user.Имя}!"); if (user.Является_администратором) { var формаАдминистратора = new Администратор(); this.Hide(); формаАдминистратора.Show(); } else { var открыть = new абота_внутри_БД(user); this.Hide(); открыть.Show(); } } else { MessageBox.Show("Вы ввели неверный логин или пароль!Пользователь в базе не найден!", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } }