private void ChangePasswordButton_Click(object sender, EventArgs e)
        {
            string oldhashedPass = MySQLFunctions.getPass(userInfo.getCurrentEmail());;

            if (ChangePasswordCurrentPassword.Text != "" && ChangePasswordNew.Text != "" && ChangePasswordConfirmNew.Text != "")
            {
                if (ChangePasswordNew.Text == ChangePasswordConfirmNew.Text)
                {
                    if (MySQLFunctions.GenerateHash(ChangePasswordNew.Text, userInfo.getCurrentEmail()) == oldhashedPass)
                    {
                        MySQLFunctions.SQLCommand($"UPDATE usertable SET password = "******"'{MySQLFunctions.GenerateHash(ChangePasswordNew.Text, userInfo.getCurrentEmail())}' WHERE userID = {userInfo.getCurrentUser()}");
                    }
                    else
                    {
                        MessageBox.Show("Current password is incorrect");
                    }
                }
                else
                {
                    MessageBox.Show("Passwords must match");
                }
            }
            else
            {
                MessageBox.Show("Please fill in all the fields");
            }
        }
Exemple #2
0
        private bool DuplicateFriends(string userID, object sender)
        {
            var    btn      = (Button)sender;
            string friendID = btn.Name;
            var    test     = new List <string>();

            MySQLFunctions.getInfo($"SELECT * FROM friendtable WHERE userID = {userID} AND friendID = {friendID}", ref test);

            if (friendID == userID)
            {
                MessageBox.Show("You cannot be friends with yourself");
                return(false);
            }
            if (test.Count == 0)
            {
                return(true);
            }

            DialogResult dialogResult = MessageBox.Show("Would you like to remove them?", "You are currently friends,", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                MySQLFunctions.SQLCommand($"DELETE FROM friendtable WHERE userID = {userInfo.getCurrentUser()} AND friendID = {friendID}");
                btn.BackColor = areNOTFriendsColor;
                btn.ForeColor = areNOTFriendsColor;
            }

            return(false);
        }
 private void ChangeNameButton_Click(object sender, EventArgs e)
 {
     if (ChangeNameFirstName.Text != "" && ChangeNameLastName.Text != "")
     {
         MySQLFunctions.SQLCommand($"UPDATE usertable SET firstname = '{ChangeNameFirstName.Text}' WHERE userID = {userInfo.getCurrentUser()}");
         MySQLFunctions.SQLCommand($"UPDATE usertable SET lastname = '{ChangeNameLastName.Text}' WHERE userID = {userInfo.getCurrentUser()}");
     }
     else
     {
         MessageBox.Show("Name cannot be blank");
     }
 }
        private void ChangeEmailButton_Click(object sender, EventArgs e)
        {
            var comparedPassword = MySQLFunctions.GenerateHash(ChangeEmailPassword.Text, ChangeEmailCurrentEmail.Text);

            if (ChangeEmailNewEmail.Text.Contains("@snhu.edu"))
            {
                if (comparedPassword == MySQLFunctions.getPass(ChangeEmailCurrentEmail.Text))
                {
                    MySQLFunctions.SQLCommand($"UPDATE usertable SET email = '{ChangeEmailNewEmail.Text}' WHERE userID = {userInfo.getCurrentUser()}");

                    MySQLFunctions.SQLCommand($"UPDATE usertable SET password = '******' WHERE userID = {userInfo.getCurrentUser()}");
                }
                else
                {
                    MessageBox.Show("Current Email or password is wrong");
                }
            }
            else
            {
                MessageBox.Show("New email is invalid");
            }
        }
Exemple #5
0
        void MyButtonHandler(object sender, EventArgs e)
        {
            Button btn = (Button)sender;


            if (DuplicateFriends(userInfo.getCurrentUser().ToString(), btn))
            {
                bool success = true;
                try
                {
                    MySQLFunctions.SQLCommand($"INSERT INTO friendtable VALUES ('{userInfo.getCurrentUser()}', '{btn.Name}')");
                }
                catch
                {
                    success = false;
                }

                if (success)
                {
                    btn.ForeColor = areFriendsColor;
                    btn.BackColor = areFriendsColor;
                }
            }
        }
Exemple #6
0
        //add class button
        private void button1_Click(object sender, EventArgs e)
        {
            if (classIDInput.Text != "")
            {
                foreach (var r in classesToDelete)
                {
                    MySQLFunctions.SQLCommand($"DELETE FROM timeblock WHERE day = '{r.day}' AND starttime = '{r.startTime}'");
                }

                foreach (var p in blockList)
                {
                    MySQLFunctions.SQLCommand($"INSERT INTO timeblock VALUES ({userInfo.getCurrentUser()}, '{classIDInput.Text}', " +
                                              $"'{p.startTime}', '{p.day}', '{buildingInput.Text}', '{roomInput.Text}', '{profInput.Text}', " +
                                              $"'{colorDialog1.Color.A}', '{colorDialog1.Color.R}', '{colorDialog1.Color.G}', '{colorDialog1.Color.B}')");
                }
                blockList.Clear();

                //Allow user to see entire schedule old bocks are turned to orangered
                foreach (Button s in this.Controls.OfType <Button>())
                {
                    if (s.BackColor == Color.Green)
                    {
                        s.BackColor = colorDialog1.Color;
                    }
                }

                classIDInput.Text  = "";
                profInput.Text     = "";
                buildingInput.Text = "";
                roomInput.Text     = "";
            }
            else
            {
                MessageBox.Show("The class name can not be blank");
            }
        }
Exemple #7
0
 private void NewUser(int uniqueID, string firstName, string lastName, string email, string password)
 {
     MySQLFunctions.SQLCommand($"INSERT INTO usertable VALUES ('{uniqueID}', '{firstName}', '{lastName}', '{email}', '{password}')");
 }