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()); } } }