Esempio n. 1
0
        mList[] getmList()
        {
            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                // Code for calling the table data
                string       query = "SELECT * FROM isad157_jharrison.messages_list";
                MySqlCommand cmd   = new MySqlCommand(query, connection);
                connection.Open();
                MySqlDataAdapter sqlDA = new MySqlDataAdapter(cmd);
                DataTable        facebookmListTable = new DataTable();
                sqlDA.Fill(facebookmListTable);
                int endOfRecord = facebookmListTable.Rows.Count;

                // Declaring each variable before being used
                int senderID = 0000; int messageID = 0000; int count = 0;

                foreach (DataRow row in facebookmListTable.Rows)
                {
                    senderID  = (int)row["MUserID"];
                    messageID = (int)row["MessID"];
                    Array.Resize(ref fbmList, fbmList.Length + 1);
                    fbmList[count] = new mList(senderID, messageID);
                    count++;
                }
                connection.Close();
                return(fbmList);
            }
        }
Esempio n. 2
0
        private void getFBUser(string userIDF) // Calling currently selected User ID for reference
        {
            if (userIDF != "Prototype.facebookUsers")
            {
                // Emptying boxes and lists in case any info isn't updated
                lbUserInfoName.Text     = " ";
                lbUserInfoGender.Text   = " ";
                lbUserInfoHometown.Text = " ";
                lbUserInfoCity.Text     = " ";
                lbUserInfoUni.Text      = " ";
                lstUserFriends.Items.Clear();
                lstUserMessages.Items.Clear();

                // User info being called
                facebookUsers selectedfbuser = fbUsers.FirstOrDefault(i => i.identifier == userIDF);
                lbUserInfoName.Text     = selectedfbuser.getFirstName() + " " + selectedfbuser.getLastName();
                lbUserInfoGender.Text   = selectedfbuser.getGender();
                lbUserInfoCity.Text     = selectedfbuser.getCity();
                lbUserInfoHometown.Text = selectedfbuser.getHometown();

                // User uni being called
                universities tempuni = fbUni.FirstOrDefault(u => u.identifier == userIDF.ToString());
                if (tempuni.uniName != " ")
                {
                    lbUserInfoUni.Text = tempuni.uniName;
                }

                // User work place being called
                workplace tempwork = fbWork.FirstOrDefault(w => w.identifier == userIDF.ToString());
                if (tempwork.workName != " ")
                {
                    lbUserInfoWork.Text = tempwork.workName;
                }

                // Message list being called before calling messages
                mList tempList = fbmList.FirstOrDefault(l => l.identifier2 == userIDF.ToString());
                if (tempList.identifier2 == null)
                {
                    lbUserInfoName.Text = "Nope";
                }
                else
                {
                    // Putting each identifier in string
                    string messID = tempList.identifier2;
                    string uID    = tempList.identifier;
                    string combo  = tempList.identifier3;
                    using (MySqlConnection connection = new MySqlConnection(connectionString))
                    {
                        string       query = "SELECT * FROM isad157_jharrison.messagesn WHERE UMessageID =" + messID;
                        MySqlCommand cmd   = new MySqlCommand(query, connection);
                        connection.Open();
                        MySqlDataAdapter sqlDA = new MySqlDataAdapter(cmd);
                        DataTable        facebookUserMessTable = new DataTable();
                        sqlDA.Fill(facebookUserMessTable);
                        int endOfRecord = facebookUserMessTable.Rows.Count;

                        foreach (DataRow row in facebookUserMessTable.Rows)
                        {
                            // User Messages being called
                            messages tempmessages = fbMessages.FirstOrDefault(m => m.identifier == messID.ToString());
                            lstUserMessages.Items.Add(tempmessages.getsetRecipient);
                            lstUserMessages.Items.Add(tempmessages.getsetDateTime);
                            lstUserMessages.Items.Add(tempmessages.getsetMessage);
                        }
                        connection.Close();
                    }
                }

                using (MySqlConnection connection = new MySqlConnection(connectionString))
                {
                    string       query = "SELECT * FROM isad157_jharrison.facebook_friendshipsn WHERE UserID =" + userIDF;
                    MySqlCommand cmd   = new MySqlCommand(query, connection);
                    connection.Open();
                    MySqlDataAdapter sqlDA = new MySqlDataAdapter(cmd);
                    DataTable        facebookFriendsTable = new DataTable();
                    sqlDA.Fill(facebookFriendsTable);
                    int endOfRecord = facebookFriendsTable.Rows.Count;

                    int fbID1 = 0000;
                    int fbID2 = 0000;

                    foreach (DataRow row in facebookFriendsTable.Rows)
                    {
                        fbID1 = (int)row["UserID"];
                        fbID2 = (int)row["UserID_2"];

                        // User Friends being called
                        facebookUsers tempfbuser = fbUsers.FirstOrDefault(i => i.identifier == fbID2.ToString());
                        string        fbfName    = tempfbuser.displayFormat;
                        lstUserFriends.Items.Add(fbfName);
                    }
                    connection.Close();
                }
            }
        }