Пример #1
0
        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");
            }
        }
Пример #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);
        }
Пример #3
0
 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");
     }
 }
Пример #4
0
        public ComparisonPage()
        {
            InitializeComponent();



            var friendList         = new List <Student>();   //List of all the users friends
            var timeBlocks         = new List <timeBlock>(); //List of all friends available times
            var selectedFriendList = new List <string>();    // List of all friends you have selected to comapare
            var friendIDs          = new List <string>();    //List of IDs of all friends of current user

            selectedFriendList.Add(userInfo.getCurrentUser().ToString());

            MySQLFunctions.getInfo($"SELECT friendID FROM friendtable WHERE userID = {userInfo.getCurrentUser()};", ref friendIDs);

            foreach (var p in friendIDs)
            {
                MySQLFunctions.getFriendInfo($"SELECT userID, firstname, lastname, email FROM usertable WHERE userID = {p};", ref friendList);
            }

            showOverlap(ref timeBlocks, ref selectedFriendList);

            foreach (var t in friendList)
            {
                Button button = new Button();
                button.Name      = t.StudentID;
                button.Text      = t.firstName + " " + t.lastName;
                button.Location  = new Point(10, friendPanel.Controls.Count * 25);
                button.Size      = new Size(120, 25);
                button.Font      = new Font(button.Font.FontFamily, 12);
                button.BackColor = friendNOTSelected;
                button.ForeColor = Color.Black;
                button.Click    += (s, e) =>
                {
                    //Changes color of buttons to show election
                    if (button.BackColor == friendNOTSelected)
                    {
                        selectedFriendList.Add(t.StudentID.ToString());
                        button.BackColor = friendSelected;
                    }
                    else
                    {
                        selectedFriendList.Remove(t.StudentID.ToString());
                        button.BackColor = friendNOTSelected;
                    }
                    showOverlap(ref timeBlocks, ref selectedFriendList);
                };

                friendPanel.Controls.Add(button);
            }
        }
Пример #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (usernameInput.Text != "" && passwordInput.Text != "")
            {
                if (MySQLFunctions.GenerateHash(passwordInput.Text, usernameInput.Text) == MySQLFunctions.getPass(usernameInput.Text))
                {
                    userInfo.setCurrentUser(MySQLFunctions.getUserIDFromEmail(usernameInput.Text));
                    userInfo.setCurrentEmail(usernameInput.Text);

                    this.Hide();
                    transition.openClassView();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Email and password do not match");
                }
            }
        }
Пример #6
0
        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");
            }
        }
Пример #7
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;
                }
            }
        }
Пример #8
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");
            }
        }
Пример #9
0
        private void showOverlap(ref List <timeBlock> timeBlocks, ref List <string> friends)
        {
            foreach (Label s in this.Controls.OfType <Label>())
            {
                if (s.Name[3] == '1' || s.Name[3] == '2' || s.Name[3] == '3' || s.Name[3] == '4' || s.Name[3] == '5' ||
                    s.Name[3] == '6' || s.Name[3] == '7' || s.Name[3] == '8')
                {
                    s.BackColor = buttonBackgroundColor;
                }
            }
            timeBlocks.Clear();

            foreach (var f in friends)
            {
                MySQLFunctions.getTimeInfo($"SELECT startTime, day FROM timeblock WHERE userID = {f};", ref timeBlocks);

                foreach (var l in timeBlocks)
                {
                    string day = "", time = "", combined = "";
                    switch (l.day)
                    {
                    case "Monday":
                        day = "mon";
                        break;

                    case "Tuesday":
                        day = "tue";
                        break;

                    case "Wednesday":
                        day = "wed";
                        break;

                    case "Thursday":
                        day = "thu";
                        break;

                    case "Friday":
                        day = "fri";
                        break;
                    }
                    switch (l.startTime)
                    {
                    case "8:00am":
                        time = "1";
                        break;

                    case "9:30am":
                        time = "2";
                        break;

                    case "11:00am":
                        time = "3";
                        break;

                    case "12:30pm":
                        time = "4";
                        break;

                    case "2:00pm":
                        time = "5";
                        break;

                    case "3:30pm":
                        time = "6";
                        break;

                    case "5:00pm":
                        time = "7";
                        break;

                    case "6:30pm":
                        time = "8";
                        break;
                    }

                    combined = day + time;

                    try
                    {
                        this.Controls[combined].BackColor = color;
                    }
                    catch (ArgumentException k)
                    {
                        MessageBox.Show(k.Message);
                    }
                }
            }
        }
Пример #10
0
        private void searchButton_Click(object sender, EventArgs e)
        {
            resultsPanel.Controls.Clear();
            var studentList = new List <Student>();

            var studentIDs = new List <string>();

            studentList.Clear();


            MySQLFunctions.getInfo($"SELECT userID FROM usertable WHERE userID NOT LIKE '{userInfo.getCurrentUser()}';", ref studentIDs);

            foreach (var p in studentIDs)
            {
                string          connectionString = null;
                MySqlConnection cnn;
                connectionString = $"server=localhost;database=jacobdb;uid=root;pwd={MySQLFunctions.MYSQLPassword};";
                cnn = new MySqlConnection(connectionString);

                string query = $"SELECT userID, firstname, lastname, email FROM usertable WHERE userID = {p};";

                MySqlCommand cmd = new MySqlCommand(query, cnn);

                MySqlDataReader dr;

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

                while (dr.Read())
                {
                    var userID    = dr["userID"];
                    var firstname = dr["firstname"];
                    var lastname  = dr["lastname"];
                    var email     = dr["email"];

                    studentList.Add(new Student()
                    {
                        StudentID = userID.ToString(), firstName = firstname.ToString(), lastName = lastname.ToString(), email = email.ToString()
                    });
                }

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


            //Filter the list
            if (firstnameSearch.Text != "")
            {
                studentList = studentList.FindAll(s => s.firstName.Equals(firstnameSearch.Text));
            }
            if (lastnameSearch.Text != "")
            {
                studentList = studentList.FindAll(s => s.lastName.Equals(lastnameSearch.Text));
            }
            if (emailSearch.Text != "")
            {
                studentList = studentList.FindAll(s => s.email.Equals(emailSearch.Text));
            }


            int j = 0;

            foreach (var p in studentList)
            {
                var color         = areNOTFriendsColor;
                var alreadyFriend = new List <String>();
                //determin button color
                MySQLFunctions.getInfo($"SELECT * FROM friendtable WHERE userID = {userInfo.getCurrentUser()} AND friendID = {p.StudentID}", ref alreadyFriend);

                if (alreadyFriend.Count != 0)
                {
                    color = areFriendsColor;
                }
                else
                {
                    color = areNOTFriendsColor;
                }

                Button btn = new Button();
                btn.Name      = p.StudentID;
                btn.Text      = "";
                btn.Size      = new Size(20, 20);
                btn.Location  = new Point(10, j * 25 + 5);
                btn.BackColor = color;
                btn.ForeColor = color;
                btn.FlatStyle = FlatStyle.Flat;
                btn.Click    += new EventHandler(this.MyButtonHandler);
                resultsPanel.Controls.Add(btn);
                counter++;

                //Show names
                Label lbl = new Label();
                lbl.Text      = p.firstName + " " + p.lastName;
                lbl.Location  = new Point(400, j * 25); //here is the location of the box
                lbl.Size      = new Size(400, 30);      //here is the size of the box
                lbl.TextAlign = ContentAlignment.MiddleCenter;
                resultsPanel.Controls.Add(lbl);

                //Show emails
                Label lbl2 = new Label();
                lbl2.Text      = p.email;
                lbl2.Location  = new Point(50, j * 25); //here is the location of the box
                lbl2.Size      = new Size(400, 30);     //here is the size of the box
                lbl2.TextAlign = ContentAlignment.MiddleCenter;
                resultsPanel.Controls.Add(lbl2);
                j++;
            }
        }
Пример #11
0
        private void LoginHome_Load(object sender, EventArgs e)
        {
            var classList = new List <classInfo>();

            MySQLFunctions.getDetailedClassInfo($"SELECT classID, startTime, day, building, roomnumber, professor, colorA, colorR, colorG, colorB FROM timeblock WHERE userID LIKE " +
                                                $"{userInfo.getCurrentUser()} ORDER BY classID;", ref classList);

            foreach (var t in classList)
            {
                string day = "", time = "", combined = "";
                switch (t.day)
                {
                case "Monday":
                    day = "mon";
                    break;

                case "Tuesday":
                    day = "tue";
                    break;

                case "Wednesday":
                    day = "wed";
                    break;

                case "Thursday":
                    day = "thu";
                    break;

                case "Friday":
                    day = "fri";
                    break;
                }
                switch (t.startTime)
                {
                case "8:00am":
                    time = "1";
                    break;

                case "9:30am":
                    time = "2";
                    break;

                case "11:00am":
                    time = "3";
                    break;

                case "12:30pm":
                    time = "4";
                    break;

                case "2:00pm":
                    time = "5";
                    break;

                case "3:30pm":
                    time = "6";
                    break;

                case "5:00pm":
                    time = "7";
                    break;

                case "6:30pm":
                    time = "8";
                    break;
                }

                combined = day + time;

                try
                {
                    this.Controls[combined].BackColor = Color.FromArgb(t.a, t.r, t.g, t.b);;
                    this.Controls[combined].Text      = t.classID;
                    this.Controls[combined].Click    += (s, z) =>
                    {
                        classnameLabel.Text = t.classID + " Details:";
                        profLabel.Text      = "Professor: " + t.professor;
                        buildingLabel.Text  = "Building: " + t.building;
                        roomLabel.Text      = "Room: " + t.roomNumber;
                    };
                }
                catch (ArgumentException k)
                {
                    MessageBox.Show(k.Message);
                }
            }
        }
Пример #12
0
        private void SignUpButton_Click(object sender, EventArgs e)
        {
            if (SignUpButton.BackColor == goodInput)

            {
                //Get first and last name from email
                string email     = Email.Text;
                string firstName = email.Split('.')[0];
                string lastName  = email.Split('.')[1];
                lastName = lastName.Split('@')[0];


                try
                {
                    NewUser(Int32.Parse(StudentID.Text), firstName, lastName, Email.Text, MySQLFunctions.GenerateHash(Password.Text, Email.Text));
                } catch (ArgumentException)
                {
                    return;
                }


                userInfo.setCurrentUser(Int32.Parse(StudentID.Text));


                this.Hide();
                transition.openScheduleInput();
                this.Close();
            }
        }
Пример #13
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}')");
 }
Пример #14
0
        public Schedule_Input2()
        {
            InitializeComponent();

            ColorButton.BackColor = Color.Red;
            colorDialog1.Color    = Color.Red; //Default block color

            MySQLFunctions.getClassInfo($"SELECT day, starttime, colorA, colorR, colorG,colorB FROM timeblock WHERE userID = {userInfo.getCurrentUser()}", ref blockList);

            foreach (var l in blockList)
            {
                string day = "", time = "", combined = "";
                switch (l.day)
                {
                case "Monday":
                    day = "mon";
                    break;

                case "Tuesday":
                    day = "tue";
                    break;

                case "Wednesday":
                    day = "wed";
                    break;

                case "Thursday":
                    day = "thu";
                    break;

                case "Friday":
                    day = "fri";
                    break;
                }
                switch (l.startTime)
                {
                case "8:00am":
                    time = "1";
                    break;

                case "9:30am":
                    time = "2";
                    break;

                case "11:00am":
                    time = "3";
                    break;

                case "12:30pm":
                    time = "4";
                    break;

                case "2:00pm":
                    time = "5";
                    break;

                case "3:30pm":
                    time = "6";
                    break;

                case "5:00pm":
                    time = "7";
                    break;

                case "6:30pm":
                    time = "8";
                    break;
                }

                combined = day + time;

                try
                {
                    this.Controls[combined].BackColor = Color.FromArgb(l.a, l.r, l.g, l.b);;
                }
                catch (ArgumentException k)
                {
                    MessageBox.Show(k.Message);
                }
            }
            blockList.Clear();
        }