Example #1
0
        private void buttonBack_Click(object sender, EventArgs e)
        {
            FormMenuAdmin formMenuAdmin = new FormMenuAdmin(email);

            formMenuAdmin.Show();
            this.Hide();
        }
Example #2
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            if (textBoxEmail.Text == "" && textBoxPassword.Text == "")
            {
                MessageBox.Show("Введите данные!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                SqlConnection conn = new SqlConnection(Connection.GetString());
                conn.Open();

                SqlCommand command = new SqlCommand("SELECT * FROM Users WHERE Email = '" + textBoxEmail.Text + "' AND Password = '******'", conn);

                using (SqlDataReader reader = command.ExecuteReader())
                {
                    if (!reader.HasRows)
                    {
                        MessageBox.Show("Пользователь с таким email и паролем не найден!. Удостоверьтесь в корректности введенных данных.", "Оповещение системы");
                    }
                    else
                    {
                        email = textBoxEmail.Text;
                        while (reader.Read())
                        {
                            if (reader["RoleId"].ToString() == "R")
                            {
                                MessageBox.Show("Вы вошли в систему, как бегун!", "Авторизация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                FormRunnerMenu fm = new FormRunnerMenu(reader["Email"].ToString());
                                fm.Show();
                                this.Hide();
                            }
                            if (reader["RoleId"].ToString() == "A")
                            {
                                MessageBox.Show("Вы вошли в систему, как администратор!", "Авторизация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                FormMenuAdmin fm = new FormMenuAdmin(reader["Email"].ToString());
                                fm.Show();
                                this.Hide();
                            }
                            if (reader["RoleId"].ToString() == "C")
                            {
                                MessageBox.Show("Вы вошли в систему, как координаторы!", "Авторизация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                FormCoordinator fm = new FormCoordinator(reader["Email"].ToString());
                                fm.Show();
                                this.Hide();
                            }
                        }
                    }
                }
            }
        }