예제 #1
0
        private void senddatatohistory()
        {
            var connectionn = DBFunctions.OpenConnection();

            if (connectionn == null)
            {
                return;
            }

            string sqlText    = string.Format("SELECT cout(id) FROM historyvideo WHERE videoid = {0};", videoID);
            var    connection = DBFunctions.OpenConnection();

            if (connection == null)
            {
                return;
            }
            if ((ulong)DBFunctions.ExecuteSqlScalar(sqlText, connection) == 0)
            {
                sqlText = string.Format("INSERT INTO historyvideo VALUES(null, {0}, {1});", user.user_ID, videoID);
                DBFunctions.ExecuteSqlNoReturn(sqlText, connection);
                connection.Close();
                connection.Dispose();
            }
            else
            {
                sqlText = string.Format("UPDATE historyvideo SET id=null WHERE videoid='{0}';", videoID);
                DBFunctions.ExecuteSqlNoReturn(sqlText, connection);
                connection.Close();
                connection.Dispose();
            }
        }
예제 #2
0
        private void label10_Click(object sender, EventArgs e)
        {
            if (CheckFields() == true)
            {
                //checking if registration data is unique or is not empty
                string komanda1 = string.Format("SELECT count(id) FROM logins WHERE UserName = '******';", textBox1.Text);
                string komanda2 = string.Format("SELECT count(id) FROM logins WHERE email = '{0}';", textBox4.Text);

                var connection = DBFunctions.OpenConnection(); //get connection to server
                if (connection == null)
                {
                    return;
                }

                var cmd1 = DBFunctions.ExecuteSqlScalar(komanda1, connection);
                var cmd2 = DBFunctions.ExecuteSqlScalar(komanda2, connection);

                int countuser  = Convert.ToInt32(cmd1);
                int countemail = Convert.ToInt32(cmd2);

                if (countuser != 0)
                {
                    MessageBox.Show("User with this username already exists");

                    label1.Enabled = true;
                    return;
                }

                if (countemail != 0)
                {
                    MessageBox.Show("User with this email already exists");

                    label1.Enabled = true;
                    return;
                }
                try
                {
                    sendRegInfoToDatabase(textBox1.Text, textBox2.Text, textBox4.Text, "red", 0);
                    MessageBox.Show("User created successfully!", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception)
                {
                    MessageBox.Show("Test");
                }


                this.ResetText();
                this.Close();
            }
            else
            {
                MessageBox.Show("Wrong SIGN UP info");
            }
        }
예제 #3
0
        private void label7_Click(object sender, EventArgs e)
        {
            if (active == false)
            {
                MessageBox.Show("You need to login first!");
                return;
            }
            if (label7.ForeColor == Color.WhiteSmoke)
            {
                string sqlText    = "SELECT DislikeCount from videos where videolink='" + axShockwaveFlash1.Movie + "';";
                var    connection = DBFunctions.OpenConnection();
                if (connection == null)
                {
                    return;
                }
                ulong dislikes = (ulong)DBFunctions.ExecuteSqlScalar(sqlText, connection);
                dislikes++;
                string sqlText2 = string.Format("UPDATE videos SET dislikecount='{0}' WHERE videolink='{1}';", dislikes, axShockwaveFlash1.Movie);

                DBFunctions.ExecuteSqlNoReturn(sqlText2, connection);
                connection.Close();
                connection.Dispose();
                label7.ForeColor = Color.Red;
                like.Enabled     = false;
                connection.Close();
                connection.Dispose();
                updatelikesandviews();
                addtodislikedvideos();
            }
            else if (label7.ForeColor == Color.Red)
            {
                string sqlText    = "select dislikecount from videos where videolink='" + axShockwaveFlash1.Movie + "';";
                var    connection = DBFunctions.OpenConnection();
                if (connection == null)
                {
                    return;
                }
                ulong dislikes = (ulong)DBFunctions.ExecuteSqlScalar(sqlText, connection);
                dislikes--;
                string sqlText2 = string.Format("UPDATE videos SET dislikecount='{0}' WHERE videolink='{1}';", dislikes, axShockwaveFlash1.Movie);

                DBFunctions.ExecuteSqlNoReturn(sqlText2, connection);
                connection.Close();
                connection.Dispose();
                label7.ForeColor = Color.WhiteSmoke;
                like.Enabled     = true;
                connection.Close();
                connection.Dispose();
                updatelikesandviews();
                deletefromdislikedvideos();
            }
        }
예제 #4
0
        private void coutviews()
        {
            string sqlText    = "select views from videos where videolink='" + axShockwaveFlash1.Movie + "';";
            var    connection = DBFunctions.OpenConnection();

            if (connection == null)
            {
                return;
            }
            ulong views = (ulong)DBFunctions.ExecuteSqlScalar(sqlText, connection);

            views++;
            string sqlText2 = string.Format("UPDATE videos SET views='{0}' WHERE videolink='{1}';", views, axShockwaveFlash1.Movie);

            DBFunctions.ExecuteSqlNoReturn(sqlText2, connection);
            connection.Close();
            connection.Dispose();
        }
예제 #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == textBox2.Text)
            {
                string sqlText    = string.Format("select password from logins where email='{0}';", emailas);
                var    connection = DBFunctions.OpenConnection();
                if (connection == null)
                {
                    return;
                }
                OldPassword = (string)DBFunctions.ExecuteSqlScalar(sqlText, connection);

                sqlText = string.Format("UPDATE logins SET Password='******' WHERE Password='******';", PasswordClass.GetMD5hash(textBox2.Text), OldPassword);

                DBFunctions.ExecuteSqlNoReturn(sqlText, connection);
                connection.Close();
                connection.Dispose();
            }
        }
예제 #6
0
        private void label10_Click(object sender, EventArgs e)
        {
            string link;

            link = textBox2.Text.Replace("watch?v=", "v/");

            if (CheckFields() == true)
            {
                //checking if registration data is unique or is not empty
                string komanda1 = string.Format("SELECT count(id) FROM videos WHERE videolink = '{0}';", textBox2.Text);

                var connection = DBFunctions.OpenConnection(); //get connection to server
                if (connection == null)
                {
                    return;
                }

                var cmd1 = DBFunctions.ExecuteSqlScalar(komanda1, connection);

                int countlinks = Convert.ToInt32(cmd1);

                if (countlinks != 0)
                {
                    MessageBox.Show("This video already exists");
                    return;
                }
                try
                {
                    sendRegInfoToDatabase(user.user_ID, textBox1.Text, link, 0, 0, 0, textBox3.Text, DateTime.Now);
                }
                catch (Exception)
                {
                }
                MessageBox.Show("Video upoloaded successfully!", "Welcome", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                MessageBox.Show("Failed to upload video");
            }
        }
예제 #7
0
        private void loadlikeordislike()
        {
            string sqlText    = string.Format("select count(id) from likes where videoid={0} AND userID = {1};", videoID, user.user_ID);
            var    connection = DBFunctions.OpenConnection();

            if (connection == null)
            {
                return;
            }

            var cmd       = DBFunctions.ExecuteSqlScalar(sqlText, connection);
            int countuser = Convert.ToInt32(cmd);

            if (countuser == 1)
            {
                like.ForeColor = Color.Red;
                label7.Enabled = false;
            }


            sqlText    = string.Format("select count(id) from dislikes where videoid={0} AND userID = {1};", videoID, user.user_ID);
            connection = DBFunctions.OpenConnection();
            if (connection == null)
            {
                return;
            }

            cmd       = DBFunctions.ExecuteSqlScalar(sqlText, connection);
            countuser = Convert.ToInt32(cmd);
            if (countuser == 1)
            {
                label7.ForeColor = Color.Red;
                like.Enabled     = false;
            }
            connection.Close();
            connection.Dispose();
        }
예제 #8
0
        private void label10_Click(object sender, EventArgs e)
        {
            string sqlText    = "select count(id) from logins where UserName='******';";
            var    connection = DBFunctions.OpenConnection();

            if (connection == null)
            {
                return;
            }
            if ((long)DBFunctions.ExecuteSqlScalar(sqlText, connection) == 0)
            {
                MessageBox.Show("User does not exist");
                return;
            }

            sqlText = string.Format("select id,username,password,email,ChannelColour,subscribers from logins where Username='******' and Password='******';", textBox1.Text, PasswordClass.GetMD5hash(textBox2.Text));
            var reader = DBFunctions.ExecuteSqlSelect(sqlText, connection);

            if (reader == null)
            {
                return;
            }
            if (!reader.HasRows)
            {
                MessageBox.Show("Wrong password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            userData user = new userData();

            while (reader.Read())
            {
                user.user_ID          = (ulong)reader[0];
                user.user_username    = reader[1].ToString();
                user.user_password    = reader[2].ToString();
                user.user_email       = reader[3].ToString();
                user.user_colour      = reader[4].ToString();
                user.user_subscribers = reader[5].ToString();
            }
            reader.Close();
            reader.Dispose();
            connection.Close();
            connection.Dispose();
            //open main form
            prnt.loaduser(user);

            prnt.label2.Visible = false;

            prnt.panel2.Visible = true;

            prnt.label12.Text = user.user_username;
            Color red = Color.FromName(user.user_colour);

            prnt.label6.BackColor = red;
            prnt.active           = true;

            if (prnt.Controls.ContainsKey("hmw"))
            {
                prnt.Controls.RemoveByKey("hmw");
                prnt.loadtrends();
            }
            if (prnt.Controls.ContainsKey("wthvid"))
            {
                prnt.loadtrends();
            }

            this.Close();
        }