Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            FormUser fu = new FormUser();

            fu.Show();
            this.Close();
        }
Example #2
0
        private void buttonEnter_Click(object sender, EventArgs e)
        {
            DBConnector.mySqlCommand.CommandText = $@"SELECT * FROM `administrators` WHERE `login` = '{textBoxLogin.Text}' AND `password` = '{ textBoxPassword.Text}'";
            MySqlDataReader reader = DBConnector.mySqlCommand.ExecuteReader();

            if (reader.HasRows)
            {
                reader.Close();
                Form form = new FormAdministrator();
                this.Visible = false;
                form.ShowDialog();
                this.Visible = true;
                textBoxLogin.Clear();
                textBoxPassword.Clear();
            }
            else
            {
                reader.Close();
                DBConnector.mySqlCommand.CommandText = $@"SELECT * FROM `users` WHERE `login` = '{textBoxLogin.Text}' AND `password` = '{ textBoxPassword.Text}'";
                reader = DBConnector.mySqlCommand.ExecuteReader();
                if (reader.HasRows)
                {
                    GlobalVariables.activeUserLogin    = textBoxLogin.Text;
                    GlobalVariables.activeUserPassword = textBoxPassword.Text;
                    reader.Close();
                    Form form = new FormUser();
                    this.Visible = false;
                    form.ShowDialog();
                    this.Visible = true;
                    textBoxLogin.Clear();
                    textBoxPassword.Clear();
                }
                else
                {
                    reader.Close();
                    MessageBox.Show("Такого пользователя не существует, проверьте правильность введённых данных или пройдите регистрацию!");
                    textBoxLogin.Clear();
                    textBoxPassword.Clear();
                }
            }
        }