Beispiel #1
0
        protected void Add_Link(object sender, EventArgs e)
        {
            if (YoutubeLink.Text == "")
            {
                youtube_link_error.Text = "you must input a valid youtube link";
                return;
            }
            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            localhost.Links full_link = new localhost.Links();
            string          link      = full_link.GetYoutubeId(YoutubeLink.Text).ToString();
            OleDbConnection con1      = new OleDbConnection();

            con1.ConnectionString = @"Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " + Request.PhysicalApplicationPath + "\\Yoav_DB.accdb";
            con1.Open();
            string       sqlstring = @"INSERT INTO links_tbl (Username ,Link, Link_Order, List_number) values (@usr,@link,@count,@num)";
            OleDbCommand conSer    = new OleDbCommand(sqlstring, con1);

            conSer.Parameters.AddWithValue("@usr", Request.QueryString["Username"]);
            conSer.Parameters.AddWithValue("@link", link);
            conSer.Parameters.AddWithValue("@count", (count + 1));
            conSer.Parameters.AddWithValue("@num", Current.Text);
            int Check = 0;

            Check = conSer.ExecuteNonQuery();
            con1.Close();
            YoutubeLink.Text = "";
            Response.Redirect(Request.RawUrl);
        }
Beispiel #2
0
 protected void Like_PL(object sender, EventArgs e)
 {
     ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
     localhost.Links item = new localhost.Links();
     item.AddLike(Request.QueryString["Username"], int.Parse(Current.Text));
     Label3.Text   = "you have liked this playlist!";
     PL_likes.Text = item.GetLikes(Request.QueryString["Username"], int.Parse(Current.Text)).ToString();
 }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            localhost.Links item = new localhost.Links();
            DataTable       dt   = item.MostLikes();

            DataListLikes.DataSource = dt;
            DataListLikes.DataBind();
        }
Beispiel #4
0
        protected void Delete_PL(object sender, EventArgs e)
        {
            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            localhost.Links item = new localhost.Links();
            OleDbConnection con2 = new OleDbConnection();

            con2.ConnectionString = @"Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " + Request.PhysicalApplicationPath + "\\Yoav_DB.accdb";
            con2.Open();
            string       sqlstring2 = @"Delete * FROM links_tbl WHERE Username = @usr AND List_number = @num";
            OleDbCommand conSer2    = new OleDbCommand(sqlstring2, con2);

            conSer2.Parameters.AddWithValue("@usr", Request.QueryString["Username"]);
            conSer2.Parameters.AddWithValue("@num", Current.Text);
            OleDbDataReader Drdr2 = conSer2.ExecuteReader();

            con2.Close();
            //--------------------------
            OleDbConnection con4 = new OleDbConnection();

            con4.ConnectionString = @"Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " + Request.PhysicalApplicationPath + "\\Yoav_DB.accdb";
            con4.Open();
            string       sqlstring4 = @"SELECT List_number FROM links_tbl WHERE Username = @usr";
            OleDbCommand conSer4    = new OleDbCommand(sqlstring4, con4);

            conSer4.Parameters.AddWithValue("@usr", Request.QueryString["Username"]);
            OleDbDataReader Drdr4 = conSer4.ExecuteReader();
            DataTable       dt    = new DataTable("temp");

            dt.Load(Drdr4);

            foreach (DataRow dr in dt.Rows)
            {
                if (int.Parse(dr["List_number"].ToString()) > int.Parse(Current.Text))
                {
                    OleDbConnection con3 = new OleDbConnection();
                    con3.ConnectionString = @"Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " + HttpContext.Current.Request.PhysicalApplicationPath + "\\Yoav_DB.accdb";
                    con3.Open();
                    string sqlstring3 = @"UPDATE links_tbl SET List_number = @num WHERE Username = @usr AND List_number = @num2";
                    using (OleDbCommand conSer3 = new OleDbCommand(sqlstring3, con3))
                    {
                        conSer3.Parameters.AddWithValue("@num", (int.Parse(dr["List_number"].ToString()) - 1).ToString());
                        conSer3.Parameters.AddWithValue("@usr", Request.QueryString["Username"]);
                        conSer3.Parameters.AddWithValue("@num", dr["List_number"].ToString());
                        int Check = 0;
                        Check = conSer3.ExecuteNonQuery();
                    }
                    con3.Close();
                }
            }
            con4.Close();
            item.DeletePlaylist(Request.QueryString["Username"], int.Parse(Current.Text));
            Response.Redirect("UserProfile?Username=" + query);
        }
Beispiel #5
0
 protected void DataListPlaylists_ItemCommand(object source, DataListCommandEventArgs e)
 {
     if (e.CommandName == "Update_command")
     {
         DataListPlaylists.SelectedIndex = e.Item.ItemIndex;
         string name = ((TextBox)DataListPlaylists.SelectedItem.FindControl("Name")).Text;
         ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
         localhost.Links item = new localhost.Links();
         item.Update_Name(Request.QueryString["Username"], int.Parse(((Label)DataListPlaylists.SelectedItem.FindControl("Number")).Text), ((TextBox)DataListPlaylists.SelectedItem.FindControl("Name")).Text);
         Response.Redirect("Edit_playlists?Username="******"Username"]);
     }
 }
Beispiel #6
0
        protected void Load_Playlists()
        {
            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            localhost.Links item             = new localhost.Links();
            int             num_of_playlists = item.GetPlaylistNumber(Request.QueryString["Username"].ToString());
            DataTable       dt = new DataTable("playlists");
            DataColumn      dc = new DataColumn("number");

            dt.Columns.Add(dc);
            for (int i = 0; i < num_of_playlists; i++)
            {
                DataRow dr = dt.NewRow();
                dr["number"] = i + 1;
                dt.Rows.Add(dr);
            }
            Playlist_lists.DataSource = dt;
            Playlist_lists.DataBind();
        }
Beispiel #7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string username = Request.QueryString["Username"];
         if (Session["user"] == null)
         {
             Response.Redirect("Login.aspx");
         }
         if (!(Session["user"].ToString() == username || Session["admin"] == "true"))
         {
             Response.Redirect("Errorpage.aspx");
         }
         ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
         localhost.Links item = new localhost.Links();
         DataTable       dt   = item.GetDB(Request.QueryString["Username"]);
         DataListPlaylists.DataSource = dt;
         DataListPlaylists.DataBind();
     }
 }
Beispiel #8
0
        protected void Copy_PL(object sender, EventArgs e)
        {
            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            localhost.Links item = new localhost.Links();
            int             num  = item.GetPlaylistNumber(Session["user"].ToString());
            OleDbConnection con2 = new OleDbConnection();

            con2.ConnectionString = @"Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " + Request.PhysicalApplicationPath + "\\Yoav_DB.accdb";
            con2.Open();
            string       sqlstring2 = @"SELECT * FROM links_tbl WHERE Username = @usr AND List_number = @num";
            OleDbCommand conSer2    = new OleDbCommand(sqlstring2, con2);

            conSer2.Parameters.AddWithValue("@usr", Request.QueryString["Username"]);
            conSer2.Parameters.AddWithValue("@num", Current.Text);
            OleDbDataReader Drdr2 = conSer2.ExecuteReader();

            while (Drdr2.Read())
            {
                OleDbConnection con1 = new OleDbConnection();
                con1.ConnectionString = @"Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " + HttpContext.Current.Request.PhysicalApplicationPath + "\\Yoav_DB.accdb";
                con1.Open();
                string       sqlstring = @"INSERT INTO links_tbl (Username, Link, Link_order, List_number) values (@usr,@link,@order,@num)";
                OleDbCommand conSer    = new OleDbCommand(sqlstring, con1);
                conSer.Parameters.AddWithValue("@usr", Session["user"]);
                conSer.Parameters.AddWithValue("@link", Drdr2["Link"]);
                conSer.Parameters.AddWithValue("@order", Drdr2["Link_order"]);
                conSer.Parameters.AddWithValue("@num", num + 1);
                int Check = 0;
                Check = conSer.ExecuteNonQuery();
                con1.Close();
            }
            con2.Close();
            string name = item.GetPlaylistName(Request.QueryString["Username"], int.Parse(Current.Text));

            item.AddPlaylist(Session["user"].ToString(), name);
        }
Beispiel #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Label3.Text = "";
            query       = Request.QueryString["Username"];
            if (Request.QueryString["Username"] == null)
            {
                Response.Redirect("Errorpage.aspx");
            }
            if (Request.QueryString["playlist"] == null)
            {
                ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
                localhost.Links item = new localhost.Links();
                Current.Text  = "1";
                PL_name.Text  = item.GetPlaylistName(query, int.Parse(Current.Text));
                PL_likes.Text = item.GetLikes(query, int.Parse(Current.Text)).ToString();
            }
            else if (int.Parse(Request.QueryString["playlist"].ToString()) > 0 && int.Parse(Request.QueryString["playlist"].ToString()) < 100)
            {
                Current.Text = Request.QueryString["playlist"].ToString();
                ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
                localhost.Links item = new localhost.Links();
                PL_name.Text  = item.GetPlaylistName(query, int.Parse(Current.Text));
                PL_likes.Text = item.GetLikes(query, int.Parse(Current.Text)).ToString();
            }
            else
            {
                Response.Redirect("Errorpage.aspx");
            }
            if (Session["user"] != null)
            {
                Copy_playlist.Visible = true;
                if (Session["user"].ToString() == Request.QueryString["Username"].ToString() || Session["Admin"] == "true")
                {
                    Copy_playlist.Visible   = false;
                    Like.Visible            = false;
                    Add_link.Visible        = true;
                    User_update.Visible     = true;
                    YoutubeLink.Visible     = true;
                    Link_Edit.Visible       = true;
                    Edit_Delete.Visible     = true;
                    Add_playlist.Visible    = true;
                    Delete_playlist.Visible = true;
                    Edit_PL.Visible         = true;

                    if (Session["Admin"] == "true")
                    {
                        Copy_playlist.Visible = true;
                        Like.Visible          = true;
                        Add_playlist.Visible  = false;
                        if (Session["user"].ToString() == Request.QueryString["Username"].ToString())
                        {
                            Copy_playlist.Visible = false;
                            Like.Visible          = false;
                            Add_playlist.Visible  = true;
                        }
                    }
                }
            }
            current1       = Current.Text;
            User_Name.Text = Request.QueryString["Username"];
            if (!Page.IsPostBack)
            {
                OleDbConnection con1 = new OleDbConnection();
                con1.ConnectionString = @"Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " + Request.PhysicalApplicationPath + "\\Yoav_DB.accdb";
                con1.Open();
                string       sqlstring = @"SELECT FirstName, LastName FROM users_tbl WHERE Username = @usr";
                OleDbCommand conSer    = new OleDbCommand(sqlstring, con1);
                conSer.Parameters.AddWithValue("@usr", Request.QueryString["Username"]);
                OleDbDataReader Drdr = conSer.ExecuteReader();
                while (Drdr.Read())
                {
                    if (Drdr.HasRows)
                    {
                        First_Name.Text = Drdr.GetString(0);
                        Last_Name.Text  = Drdr.GetString(1);
                    }
                }
                con1.Close();

                Load_Images();
                Load_Playlists();
            }
            Load_Links();
        }
Beispiel #10
0
 protected void AddPL_Click(object sender, EventArgs e)
 {
     localhost.Links connect = new localhost.Links();
     connect.AddPlaylist(Session["user"].ToString(), PL_text.Text);
     Response.Redirect("UserProfile.aspx?Username="******"user"]);
 }