Esempio n. 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            SQLCommands sql      = new SQLCommands();
            string      username = txtUser.Text;
            string      password = txtPass.Text;
            string      stuff    = username + " " + password;
            string      spaces   = "";

            for (int i = 0; i <= rawTimes.Count - 1; i++) //add numbers like 55,33,5,2
            {
                spaces += rawTimes[i];
                if (i != rawTimes.Count - 1)
                {
                    spaces += ",";
                }
            }
            chance = sql.login(username, password, spaces);
            bool passed = chance >= -1;

            if (passed)
            {
                frmAccount account = new frmAccount();
                account.Show(); // need to pass info later!!
                Close();
            }
            else
            {
                switch (sql.login(username, password, spaces))
                {
                case -2:
                    MessageBox.Show("We don't have that username. Make an account, loser.");
                    break;

                case -3:
                    MessageBox.Show("Your password is incorrect.");
                    rawTimes.Clear();
                    prevTime = 0;
                    this.txtPass.Clear();     //needed this
                    break;

                case -4:
                    MessageBox.Show("Your password doesn't have the right timing....  :(");
                    rawTimes.Clear();
                    prevTime = 0;
                    this.txtPass.Clear();
                    break;

                default:
                    MessageBox.Show("something default went wrong (STOP BREAKING OUR PROGRAM!!!)");
                    break;
                }
            }
        }
Esempio n. 2
0
        private void btnCreateAcc_Click(object sender, EventArgs e)
        {
            string username  = txtUser.Text;
            string password  = txtPass.Text;
            string password2 = txtPass2.Text;

            if (!usernameMatchesConstraints(username))
            {
                if (password == "")
                {
                    MessageBox.Show("Yeah nice try, noname");
                }
                else
                {
                    MessageBox.Show("Username does not fit constraints. Please try again. >:(");
                }
            }
            else if (!passMatchesConstraints(password))
            {
                if (password == "")
                {
                    MessageBox.Show("You can't just put nothing in there. You don't want a password? :/");
                }
                else
                {
                    MessageBox.Show("Password does not fit constraints. Please try again. >:(");
                    txtPass.Clear();
                    rawTimes.Clear();
                    prevTime = 0;
                    txtPass2.Clear();
                    rawTimes2.Clear();
                    prevTime2 = 0;
                }
            }
            else if (!usernameMatchesConstraints(username))
            {
                if (password == "")
                {
                    MessageBox.Show("Yeah nice try, noname");
                }
                else
                {
                    MessageBox.Show("Username does not fit constraints. Please try again. >:(");
                }
            }
            else if (password.Equals(password2)) //check if two passwords match
            {
                string spaces = "";
                //set up times
                for (int i = 0; i <= rawTimes.Count - 1; i++) //add numbers like 55,33,5,2
                {
                    long average = (long)Math.Round(((long)rawTimes[i] + (long)rawTimes2[i]) / 2.0);
                    spaces += average;
                    if (i != rawTimes.Count - 1)
                    {
                        spaces += ",";
                    }
                }
                string      stuff = username + " " + password;
                SQLCommands sql   = new SQLCommands();
                if (sql.createUser(username, password, spaces) == 1)
                {
                    MessageBox.Show("Username already exists");
                }
                else
                {
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Passwords do not match. Please try again. >:(");
                txtPass.Clear();
                rawTimes.Clear();
                prevTime = 0;
                txtPass2.Clear();
                rawTimes2.Clear();
                prevTime2 = 0;
            }
        }