public static string addFriend(string email, int ID, string listBoxText)
        {
            string idNum = getID(email);

            string          connectionString = null;
            MySqlConnection cnn;

            connectionString = $"server=localhost;database=SNHUBook;uid=root;pwd={MYSQLPassword};";
            cnn = new MySqlConnection(connectionString);
            int    newID     = ID + 1;
            string userEmail = MySQLFunctions.getEmail(newID.ToString());
            string query     = $"INSERT INTO friends (AccountID, ID, value, email) values ({idNum}, {ID}, '{listBoxText}', '{userEmail}');";

            MySqlCommand cmd = new MySqlCommand(query, cnn);

            MySqlDataReader dr;

            cnn.Open();
            dr = cmd.ExecuteReader();

            string home = string.Empty;


            while (dr.Read())
            {
                home = dr.GetString(0);
                Console.WriteLine(home);
            }

            dr.Close();
            cnn.Close();

            return(home);
        }
        private void removeFriendButton_Click(object sender, EventArgs e)
        {
            string friend = "";

            friend = MySQLFunctions.getFriend(email, friendsListBox.Items[friendsListBox.SelectedIndex].ToString());
            if (friendsListBox.SelectedIndex == -1)
            {
                MessageBox.Show("Please select an Item first!");
            }
            else
            {
                int totalFriends = int.Parse(MySQLFunctions.getTotalFriends(email));
                if (totalFriends == 0) //if user has no friends, just add the friend.
                {
                    MessageBox.Show("User is not your friend!");
                }
                //Search friends table to see if friend is already added.
                else if (friend == "")
                {
                    MessageBox.Show("User is not your friend!");
                }

                else if (friend == MySQLFunctions.getFriend(email, MySQLFunctions.getName(email)))
                {
                    MessageBox.Show("You cannot remove yourself as a friend!");
                }
                else
                {
                    MessageBox.Show("Friend removed.");
                    MySQLFunctions.removeFriend(email, friendsListBox.SelectedIndex, friendsListBox.Items[friendsListBox.SelectedIndex].ToString());
                }
            }
        }
        private void BackgroundImage4_Click(object sender, EventArgs e)
        {
            MySQLFunctions.SQLCommand($"UPDATE accounts set backgroundImage_path='Background4.jpg' where Email='{email}';");
            this.Hide();
            AccountPage d = new AccountPage(email);

            d.ShowDialog();
            this.Close();
        }
Exemple #4
0
 private void Add_bn_Click(object sender, EventArgs e)
 {
     Bio_lbl.Text = add_bio;
     AddBio_Text.Hide();
     Add_bn.Hide();
     Cancel_bn.Hide();
     hometown_text.Hide();
     cancel_home_bn.Hide();
     add_home_bn.Hide();
     MySQLFunctions.SQLCommand($"UPDATE accounts SET Bio='{add_bio}' where Email = '{email}'");
 }
Exemple #5
0
        public HomePage(string email) //Please use this one to transfer data.
        {
            InitializeComponent();
            this.email = email;


            //Below is checking which profile photo to load
            Image myimage = new Bitmap(MySQLFunctions.getProfileImage(email));

            pictureBox1.BackgroundImage = myimage;
            user_button.Text            = MySQLFunctions.getName(email);
        }
Exemple #6
0
        public AccountPage(String email)
        {
            InitializeComponent();

            this.email = email;
            Image myimage = new Bitmap(MySQLFunctions.getProfileImage(email));

            ProfilePicture.BackgroundImage = myimage;
            user_button.Text  = MySQLFunctions.getName(email);
            username_lbl.Text = MySQLFunctions.getName(email);
            Bio_lbl.Text      = MySQLFunctions.getBio(email);
            home_lbl.Text     = MySQLFunctions.getHome(email);
            Image backImage = new Bitmap(MySQLFunctions.getBackgroundImage(email));

            CoverPicture.BackgroundImage = backImage;

            panel4.Hide();
            if (MySQLFunctions.getTotalPosts(email) != "0")
            {
                int    totalPosts = int.Parse(MySQLFunctions.getTotalPosts(email));
                string post       = "";
                for (int i = totalPosts; i > 0; i--)
                {
                    post = MySQLFunctions.getPost(email, i.ToString());
                    if (post.Length != 0)
                    {
                        postsTooDelete.Items.Add(post);
                        AccountAddPost a = new AccountAddPost(i, isNewPage);
                        a.post_lbl.Text = post;
                        a.post_lbl.Size = new System.Drawing.Size(700, 25);

                        isNewPage      = false;
                        postCurrentNum = i;

                        this.Controls.Add(a.post_background);
                        a.post_background.Controls.Add(a.post_lbl);
                        a.post_background.Controls.Add(a.date_lbl);

                        a.date_lbl.Text = MySQLFunctions.getDate(email, i.ToString());

                        a.post_lbl.Show();
                        a.date_lbl.Show();
                        a.post_background.Show();
                        PanelLocation += 100; //Adding an amount
                    }
                    else
                    {
                        i--;
                    }
                }
            }
        }
        public static string[] getFriends(string email) //returns string array that contains emails of all friends
        {
            //CheckifUserhasfriends
            if (friendExists(MySQLFunctions.getAccountIDNext(email)) != "")                   //Returns 1 for 1 friend
            {
                string[]        returnString = new string[int.Parse(getTotalFriends(email))]; //Array of size 1
                string          connectionString;
                MySqlConnection cnn;
                string          query;
                MySqlCommand    cmd;
                MySqlDataReader dr;
                string          home;
                int             ID;
                int             j = 0;
                for (int i = 0; i < int.Parse(getTotalAccounts()); i++)
                {
                    ID = i + 1;
                    if (MySQLFunctions.innerFriendExists(ID.ToString()) != "")
                    {
                        connectionString = $"server=localhost;database=SNHUBook;uid=root;pwd={MYSQLPassword};";
                        cnn = new MySqlConnection(connectionString);

                        query = $"SELECT email FROM friends WHERE ID like {ID.ToString()};";

                        cmd = new MySqlCommand(query, cnn);

                        cnn.Open();
                        dr = cmd.ExecuteReader();

                        home = string.Empty;

                        while (dr.Read())
                        {
                            home = dr.GetString(0);
                            Console.WriteLine(home);
                        }

                        dr.Close();
                        cnn.Close();
                        returnString[j] = home;

                        j++;
                    }
                }
                return(returnString);
            }
            else
            {
                return(new string[0]);
            }
        }
Exemple #8
0
        public SettingsPage(int recievedform, string email)
        {
            InitializeComponent();
            returnform = recievedform;
            this.email = email;
            Image myimage = new Bitmap(MySQLFunctions.getProfileImage(email));

            pictureBox1.BackgroundImage = myimage;
            user_button.Text            = MySQLFunctions.getName(email);
            ChangePasswordPanel.Visible = false;
            ChangePasswordPanel.SendToBack();
            LogoutPanel.Visible = false;
            LogoutPanel.BringToFront();
        }
Exemple #9
0
 private void deletePostSubmitButton_Click(object sender, EventArgs e)
 {
     if (postsTooDelete.SelectedIndex == -1)
     {
         MessageBox.Show("Please select an Item first!");
     }
     else
     {
         MessageBox.Show("Post removed.");
         MySQLFunctions.deletePost(email, postsTooDelete.Text);
         this.Hide();
         AddProfileImage a = new AddProfileImage(2, email);
         this.Close();
     }
 }
Exemple #10
0
 private void login_bn_Click(object sender, EventArgs e)
 {
     if (password != "" && username != "")
     {
         if (password == MySQLFunctions.getPass(username))
         {
             this.Hide();
             HomePage d = new HomePage(username);
             d.ShowDialog();
             this.Close();
         }
         else
         {
             MessageBox.Show("Account does not exist / Password is not correct");
         }
     }
 }
Exemple #11
0
        public FriendRequest(string email, int recievedNum)
        {
            InitializeComponent();

            this.email = email;

            recievedform = recievedNum;

            string totalString   = MySQLFunctions.getTotalAccounts();
            int    totalAccounts = int.Parse(totalString);

            //Adds in all accounts
            for (int i = 1; i <= totalAccounts; i++)
            {
                friendsListBox.Items.Add(MySQLFunctions.getName(i));
            }
        }
Exemple #12
0
 private void profileImageFour_Click(object sender, EventArgs e)
 {
     if (isPersonalPage == false)
     {
         MySQLFunctions.SQLCommand($"UPDATE accounts set profImage_path='FemaleAvatar2.png' where Email='{email}';");
         this.Hide();
         HomePage d = new HomePage(email);
         d.ShowDialog();
         this.Close();
     }
     else
     {
         MySQLFunctions.SQLCommand($"UPDATE accounts set profImage_path='FemaleAvatar2.png' where Email='{email}';");
         this.Hide();
         AccountPage d = new AccountPage(email);
         d.ShowDialog();
         this.Close();
     }
 }
Exemple #13
0
 private void ChangePasswordButton_Click(object sender, EventArgs e)
 {
     if (passwordTextBox.Text.Length == 0)
     {
         invalid.Visible = true;
     }
     else if (!passwordTextBox.Text.Equals(retypeTextBox.Text))
     {
         pwDoesNotMatch.Visible = true;
     }
     else
     {
         //Change password
         MySQLFunctions.changePassword(email, passwordTextBox.Text);
         MessageBox.Show("Password has been changed!");
         passwordTextBox.Text        = "";
         retypeTextBox.Text          = "";
         ChangePasswordPanel.Visible = false;
     }
 }
Exemple #14
0
        private void Submit_post_button_Click(object sender, EventArgs e)
        {
            AccountAddPost ah = new AccountAddPost(postCurrentNum, isNewPage);

            ah.post_lbl.Text = textBox1.Text;
            ah.post_lbl.Size = new System.Drawing.Size(700, 25);

            this.Controls.Add(ah.post_background);
            ah.post_background.Controls.Add(ah.post_lbl);
            ah.post_background.Controls.Add(ah.date_lbl);

            ah.post_lbl.Show();
            ah.date_lbl.Show();
            ah.post_background.Show();

            PanelLocation += 100;

            MySQLFunctions.savePost(email, textBox1.Text, ah.date_lbl.Text);

            this.Hide();
            AddProfileImage a = new AddProfileImage(2, email);

            this.Close();
        }
Exemple #15
0
        private void save_button_Click(object sender, EventArgs e)
        {
            signup a = new signup(email_textbox.Text, firstname_textbox.Text, lastname_textbox.Text, password_textbox.Text);

            a.firstname_check();
            a.lastname_check();
            a.Email();
            a.password_check();
            if (a.firstname_check() == true)
            {
                firstname_textbox.BackColor = Color.Green;
            }
            else if (a.firstname_check() == false)
            {
                firstname_textbox.BackColor = Color.Red;
            }

            if (a.lastname_check() == true)
            {
                lastname_textbox.BackColor = Color.Green;
            }
            else if (a.lastname_check() == false)
            {
                lastname_textbox.BackColor = Color.Red;
            }

            if (a.Email() == true)
            {
                email_textbox.BackColor = Color.Green;
            }
            else if (a.Email() == false)
            {
                email_textbox.BackColor = Color.Red;
            }
            if (a.password_check() == true)
            {
                password_textbox.BackColor = Color.Green;
            }
            else
            {
                password_textbox.BackColor = Color.Red;
            }

            if (email_textbox.BackColor != Color.Red && firstname_textbox.BackColor != Color.Red &&
                lastname_textbox.BackColor != Color.Red && password_textbox.BackColor != Color.Red)
            {
                string username = email_textbox.Text;
                if (password == MySQLFunctions.getPass(username))
                {
                    MessageBox.Show("Account Already exists");
                }
                else
                {
                    string tempString = "INSERT INTO accounts (FirstName, LastName, Email, Password, profImage_path, backgroundImage_path, Bio, Home) Values('";
                    tempString = tempString + firstName + "', '";
                    tempString = tempString + lastName + "', '";
                    tempString = tempString + email + "', '";
                    tempString = tempString + password + "','nyc.jpg','10759301728_IMG_9920.jpg', 'NULL', 'NULL')";

                    MySQLFunctions.SQLCommand(tempString);

                    MessageBox.Show("You Successfully Signed Up! You May Now LogIn");
                    this.Hide();
                    WelcomePage o = new WelcomePage();
                    o.ShowDialog();
                }
            }
            else
            {
                MessageBox.Show("Make Sure Everythings Valid and Submit again");
            }
        }
Exemple #16
0
        private void HomePage_Load(object sender, EventArgs e)
        {
            panel4.Hide();
            if (MySQLFunctions.getAllTotalPosts() != "0")
            {
                int    totalPosts = int.Parse(MySQLFunctions.getTotalPosts(email));
                string post       = "";
                string name       = "";
                for (int i = totalPosts; i > 0; i--) //will post all posts for your own email
                {
                    post = MySQLFunctions.getPost(email, i.ToString());
                    if (post.Length != 0)
                    {
                        AddPost a = new AddPost(i, isNewPage);

                        a.post_lbl.Text = post;
                        a.post_lbl.Size = new System.Drawing.Size(700, 25);

                        isNewPage      = false;
                        postCurrentNum = i;

                        this.Controls.Add(a.post_background);
                        a.post_background.Controls.Add(a.post_lbl);
                        a.post_background.Controls.Add(a.date_lbl);

                        name             = MySQLFunctions.getName(email);
                        a.date_lbl.Text  = MySQLFunctions.getDate(email, i.ToString()) + " - " + name;
                        a.date_lbl.Width = 500;

                        a.post_lbl.Show();
                        a.date_lbl.Show();
                        a.post_background.Show();
                        PanelLocation += 100; //Adding an amount
                    }
                    else
                    {
                        i--;
                    }
                }
                string[] friendsList = MySQLFunctions.getFriends(email); //Returns string array will all friends emails
                for (int i = 0; i < int.Parse(MySQLFunctions.getTotalFriends(email)); i++)
                {
                    int tPosts = friendsList.Length;

                    string p = "";
                    string n = "";
                    for (int j = tPosts; j > 0; j--)
                    {
                        p = MySQLFunctions.getPost(friendsList[j - 1], j.ToString());
                        if (p.Length != 0)
                        {
                            AddPost a = new AddPost(j, isNewPage);

                            a.post_lbl.Text = p;
                            a.post_lbl.Size = new System.Drawing.Size(700, 25);

                            isNewPage      = false;
                            postCurrentNum = j;

                            this.Controls.Add(a.post_background);
                            a.post_background.Controls.Add(a.post_lbl);
                            a.post_background.Controls.Add(a.date_lbl);

                            n = MySQLFunctions.getName(friendsList[j - 1]);
                            a.date_lbl.Text  = MySQLFunctions.getDate(friendsList[j - 1], j.ToString()) + " - " + n;
                            a.date_lbl.Width = 500;

                            a.post_lbl.Show();
                            a.date_lbl.Show();
                            a.post_background.Show();
                            PanelLocation += 100; //Adding an amount
                        }
                        else
                        {
                            j--;
                        }
                    }
                }
            }
        }