// переход на форму Меню бегуна
        private void SwitchFormMenu()
        {
            ActiveForm.Hide();
            FormMenuRunner formMenuRunner = new FormMenuRunner();

            formMenuRunner.ShowDialog();
            Close();
        }
Ejemplo n.º 2
0
        private async void BtnLogin_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtEmail.Text) && !string.IsNullOrEmpty(txtPassword.Text))
            {
                try
                {
                    string query = "SELECT * FROM [UserPersonalInformation] WHERE Email = '" + txtEmail.Text.Trim() + "' and [Password] = '" + txtPassword.Text.Trim() + "'";

                    //string query1 = "SELECT * FROM [Administration] WHERE Email = '" + txtEmail.Text.Trim() + "' and [Password] = '" + txtPassword.Text.Trim() + "'";
                    using (SqlConnection connection = new SqlConnection(Connection.GetSetring()))
                    {
                        await connection.OpenAsync();

                        SqlCommand command = new SqlCommand(query, connection);
                        //SqlCommand command1 = new SqlCommand(query1, connection);
                        SqlDataReader dataReader = command.ExecuteReader();
                        //SqlDataReader dataReader1 = command1.ExecuteReader();
                        if (dataReader.HasRows)
                        {
                            while (dataReader.Read())
                            {
                                email = dataReader["Email"].ToString();
                            }
                            ActiveForm.Hide();
                            FormMenuRunner runner = new FormMenuRunner();
                            runner.ShowDialog();
                            Close();
                        }
                        //else if (dataReader1.HasRows)
                        //{
                        //    while (dataReader1.Read())
                        //    {
                        //        email = dataReader1["Email"].ToString();
                        //    }
                        //    ActiveForm.Hide();
                        //    FormAdmin admin = new FormAdmin();
                        //    admin.ShowDialog();
                        //    Close();
                        //}
                        else
                        {
                            MessageBox.Show("Не верный Email или Пароль. Пожалуйста, повторите попытку!", "Уведомление системы!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Уведомление системы!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Заполните поля!", "Уведомление системы!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }