private void btnrepeat_Click(object sender, EventArgs e)
        {
            WhoWantsToBeAMillionaire_form2.points = 0;
            WhoWantsToBeAMillionaire_form2 mainform = new WhoWantsToBeAMillionaire_form2(); // establishing 2nd form as main

            this.Hide();
            mainform.Show();
        }
        private void nextform()                                                         // New form
        {
            //MessageBox.Show(Convert.ToString(chosenone));
            WhoWantsToBeAMillionaire_form2 mainform = new WhoWantsToBeAMillionaire_form2();                                                     // definiraj formo the end kot glavno formo

            this.Hide();                                                                                                                        // skrij to formo
            mainform.Show();
        }
Пример #3
0
        int connectionmejebe           = 0;                                                                                 // For closing connection

        private void btnSin_Click(object sender, EventArgs e)                                                               // Singin function
        {
            user     = textBoxUsername.Text;                                                                                // Variable user change to textbox text
            password = textBoxPassword.Text;                                                                                // Variable password change to textbox text

            if (user == "" && password == "")                                                                               // Demo user  condition
            {
                user = "******";
                WhoWantsToBeAMillionaire_form2 mainform = new WhoWantsToBeAMillionaire_form2();                             // Set Game form as main
                this.Hide();
                mainform.Show();
            }
            else                                                                                                            // database section
            {
                connection.Open();                                                                                          // Open database
                using (SQLiteCommand command = new SQLiteCommand(connection))                                               // Create imput for command  connection
                {
                    command.CommandText = "SELECT * FROM users;";
                    SQLiteDataReader reader = command.ExecuteReader();                                                      // define reading part of code
                    while (reader.Read())
                    {
                        if (user == reader.GetString(1))                                                                    // In case of same name in DB
                        {
                            nepravilnouporabniskoime++;                                                                     // Add to variable, so it does not pass thoru as not repeated name
                            if (password == reader.GetString(2))                                                            // If user mathches with user's password
                            {
                                newform();                                                                                  // Redirect to newform
                            }
                            else
                            {
                                MessageBox.Show("Geslo je nepravilno! ");                                                   // sporočilo, da je geslo, ki je v passwordBox.text neujemljivo z geslom iz podatkovne baze
                            }
                        }
                    }
                    if (nepravilnouporabniskoime == 0)                                                                      // If username is 0 then it did not passed the check
                    {
                        MessageBox.Show("Uporabniško ime je neobstoječe!");                                                 // Username does not exist
                    }
                }
                connection.Close();
            }
        }