Ejemplo n.º 1
0
        protected void DeleteTrack_Click(object sender, EventArgs e)
        {
            //code to go here

            string username = "******";

            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Missing Data", "Enter the playlist name");
            }
            else
            {
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("Missing Data", "You require a playlist to select song(s) to remove.");
                }
                else
                {
                    //Gather the song(s) to remove. (TrackID)
                    List <int> trackstodelete    = new List <int>();
                    int        rowsSelected      = 0;
                    CheckBox   playlistselection = null;

                    for (int i = 0; i < PlayList.Rows.Count; i++)
                    {
                        //
                        playlistselection = PlayList.Rows[i].FindControl("Selected") as CheckBox;
                        if (playlistselection.Checked)
                        {
                            rowsSelected++;
                            //step for this
                            // The Playlist.Rows.... is pointing to the control
                            //then I turn it into a string
                            //then I parse it into an int.
                            trackstodelete.Add(int.Parse((PlayList.Rows[i].FindControl("TrackID") as Label).Text));
                        }
                    }

                    //Check if a song was selected
                    if (rowsSelected == 0)
                    {
                        MessageUserControl.ShowInfo("Missing Data", "You are required to select at least one song to remove");
                    }
                    else
                    {
                        //ready to process
                        MessageUserControl.TryRun(() =>
                        {
                            PlaylistTracksController sysmgr = new PlaylistTracksController();
                            sysmgr.DeleteTracks(username, PlaylistName.Text, trackstodelete);
                            List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username);
                            PlayList.DataSource           = info;
                            PlayList.DataBind();
                        }, "Song Removal", "Song(s) have been removed");
                    }
                }
            }
        }
Ejemplo n.º 2
0
 protected void DeleteTrack_Click(object sender, EventArgs e)
 {
     //code to go here
     if (string.IsNullOrEmpty(PlaylistName.Text))
     {
         MessageUserControl.ShowInfo("Required Data",
                                     "Play list name is required to add a track");
     }
     else
     {
         if (PlayList.Rows.Count == 0)
         {
             MessageUserControl.ShowInfo("Required Data",
                                         "No playlist is available. Retreive your playlist.");
         }
         else
         {
             //traverse the geidview and collect the list of tracks to remove
             List <int> trackstodelete    = new List <int>();
             int        rowsSelected      = 0;
             CheckBox   playlistselection = null;
             for (int rowindex = 0; rowindex < PlayList.Rows.Count; rowindex++)
             {
                 //access the checkbox control on the indexed GridViewRow
                 //set the CheckBox pointer to this checkbox control
                 playlistselection = PlayList.Rows[rowindex].FindControl("Selected") as CheckBox;
                 if (playlistselection.Checked)
                 {
                     //increase selected number of rows
                     rowsSelected++;
                     //gather the data needed for the BLL call
                     trackstodelete.Add(int.Parse((PlayList.Rows[rowindex].FindControl("TrackID")
                                                   as Label).Text));
                 }
             }
             if (rowsSelected == 0)
             {
                 MessageUserControl.ShowInfo("Required Data",
                                             "You must select at least on track to remove.");
             }
             else
             {
                 //send list of tracks to be remove by BLL
                 MessageUserControl.TryRun(() =>
                 {
                     PlaylistTracksController sysmgr = new PlaylistTracksController();
                     //there is ONLY one call to remove the data to the database
                     sysmgr.DeleteTracks(User.Identity.Name, PlaylistName.Text, trackstodelete);
                     //refresh the playlist is a READ
                     List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(
                         PlaylistName.Text, User.Identity.Name);
                     PlayList.DataSource = datainfo;
                     PlayList.DataBind();
                 }, "Remove Track(s)", "Track has been removed from the playlist");
             }
         }
     }
 }
Ejemplo n.º 3
0
        protected void DeleteTrack_Click(object sender, EventArgs e)
        {
            //code to go here
            string username = "******"; //until security

            //form event validation - presence
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("missing data", "enter a playlist name to playlist name field");
            }
            else
            {
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("track removal", "no rows to select from");
                }
                else
                {
                    //collect the selected tracks
                    List <int> trackids       = new List <int>();
                    int        rowselected    = 0;
                    CheckBox   trackSelection = null;

                    //traverse the gridview controll playlist
                    //could use FOREACH here
                    for (int i = 0; i < PlayList.Rows.Count; i++)
                    {
                        //point to the checkbox control on the gridview row
                        trackSelection = PlayList.Rows[i].FindControl("Selected") as CheckBox;

                        //Test the setting of the Checkbox
                        if (trackSelection.Checked)
                        {
                            rowselected++;
                            trackids.Add(int.Parse((PlayList.Rows[i].FindControl("TrackId") as Label).Text));
                        }
                    }
                    //was a song selected?
                    if (rowselected == 0)
                    {
                        MessageUserControl.ShowInfo("missing data", "no selected tracks");
                    }
                    else
                    {
                        //data collected - send for processing
                        MessageUserControl.TryRun(() =>
                        {
                            PlaylistTracksController sysmgr = new PlaylistTracksController();

                            sysmgr.DeleteTracks(username, PlaylistName.Text, trackids);

                            RefreshPlaylist(sysmgr, username);
                        }, "track removal", "great success");
                    }
                }
            }
        }
    protected void DeleteTrack_Click(object sender, EventArgs e)
    {
        if (PlayList.Rows.Count == 0)
        {
            MessageUserControl.ShowInfo("Information", "you need to retrive a play list before deleting");
        }
        else
        {
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Information", "you need to supply the play list name");
            }
            else
            {
                //colection the tracks to delete
                List <int> trackstodelete = new List <int>();
                int        selectedrows   = 0;
                CheckBox   theBox         = null;

                for (int i = 0; i < PlayList.Rows.Count; i++)
                {
                    theBox = PlayList.Rows[i].FindControl("Selected") as CheckBox;

                    if (theBox.Checked)
                    {
                        //Label agvrow = PlayList.Rows[i].FindControl("Selected") as Label;
                        //int trackid = int.Parse(agvrow.Text);
                        //trackstodelete.Add(trackid);


                        trackstodelete.Add(int.Parse((PlayList.Rows[i].FindControl("Selected") as Label).Text));

                        selectedrows++;
                    }
                    if (selectedrows == 0)
                    {
                        MessageUserControl.ShowInfo("Information", "you need to select one or more tracks to remove");
                    }
                    else
                    {
                        //at this point you have your data for BLL processing
                        MessageUserControl.TryRun(() =>
                        {
                            PlaylistTracksController sysmgr = new PlaylistTracksController();

                            sysmgr.DeleteTracks(User.Identity.Name, PlaylistName.Text, trackstodelete);

                            List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, User.Identity.Name);

                            PlayList.DataSource = info;
                            PlayList.DataBind();
                        }, "Success", "Tracks Removed");
                    }
                }
            }
        }
    }
Ejemplo n.º 5
0
        protected void DeleteTrack_Click(object sender, EventArgs e)
        {
            //code to go here

            string username = "******";

            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Missing Data", "Enter a playlist name");
            }
            else
            {
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("Track Removal", "You must a have a playlist");
                }
                else
                {
                    List <int> trackids = new List <int>();

                    int rowsSelected = 0;

                    CheckBox trackSelection = null;

                    //treverse the grid view control PlayList
                    //you could do the same code using foreach()



                    foreach (GridViewRow row in PlayList.Rows)
                    {
                        trackSelection = row.FindControl("Selected") as CheckBox;
                        if (trackSelection.Checked)
                        {
                            rowsSelected++;
                            trackids.Add(int.Parse((row.FindControl("TrackId") as Label).Text));
                        }
                    }


                    if (rowsSelected == 0)
                    {
                        MessageUserControl.ShowInfo("Delete Concern", "You must select at least on song to remove");
                    }
                    else
                    {
                        MessageUserControl.TryRun(() =>
                        {
                            var sysmgr = new PlaylistTracksController();

                            sysmgr.DeleteTracks(username, PlaylistName.Text, trackids);
                            RefreshPlayList(sysmgr, username);
                        }, "Track Removal", "Record(s) successfully deleted");
                    }
                }
            }
        }
        protected void DeleteTrack_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Playlist name is required.");
            }
            else
            {
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("Playlist is empty.");
                }
                else
                {
                    // Retrieve all rows marked for deletion
                    List <int> TracksToDelete = new List <int>(); // Delete by track number
                    int        rowSelections  = 0;
                    CheckBox   playlistRow    = null;

                    for (int i = 0; i < PlayList.Rows.Count; i++)
                    {
                        playlistRow = PlayList.Rows[i].FindControl("Selected") as CheckBox;

                        if (playlistRow.Checked)
                        {
                            rowSelections++;
                            TracksToDelete.Add(int.Parse(
                                                   (PlayList.Rows[i].FindControl("TrackID") as Label)
                                                   .Text));
                        }
                    }

                    // Ensure one or more tracks were selected
                    if (rowSelections > 0)
                    {
                        MessageUserControl.TryRun(() =>
                        {
                            PlaylistTracksController sysmgr = new PlaylistTracksController();
                            sysmgr.DeleteTracks("HansenB", PlaylistName.Text, TracksToDelete);

                            // Refresh playlist track listing
                            List <UserPlaylistTrack> Info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, "HansenB");
                            PlayList.DataSource           = Info;
                            PlayList.DataBind();
                        },
                                                  "Track(s) Removed",
                                                  "Selected tracks successfully removed from the playlist.");
                    }
                    else
                    {
                        MessageUserControl.ShowInfo("Warning", "No track selections were made.");
                    }
                }
            }
        }
Ejemplo n.º 7
0
        protected void DeleteTrack_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Required Data", "PlayList Name is Required to ADD a Track");
            }
            else
            {
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("Required Data", "No Play List is available. Retrieve your playlist");
                }
                else
                {
                    //Traverse the firdview and collect the list of tracks to remove.
                    List <int> tracktodelete     = new List <int>();
                    int        rowSelected       = 0;
                    CheckBox   playlistselection = null;
                    for (int rowindex = 0; rowindex < PlayList.Rows.Count; rowindex++)
                    {
                        //Access the control on the indexed GridViewRow
                        //Set the CheckBox pointer to this checkbox control
                        playlistselection = PlayList.Rows[rowindex].FindControl("Selected") as CheckBox;
                        if (playlistselection.Checked)
                        {
                            //Increment selected number of rows
                            rowSelected++;
                            //Gather the data needed for the BLL call.
                            tracktodelete.Add(int.Parse((PlayList.Rows[rowindex].FindControl("TrackID") as Label).Text));
                        }
                    }
                    if (rowSelected == 0)
                    {
                        MessageUserControl.ShowInfo("Required Data", "PlayList Name is Required to Remove a Track");
                    }
                    else
                    {
                        //Using the obtained data, issue your call to the BLL Method
                        //This work will be done whinin a TryRun()
                        MessageUserControl.TryRun(() =>
                        {
                            PlaylistTracksController sysmgr = new PlaylistTracksController();
                            //there is only one call to add the data to the database
                            sysmgr.DeleteTracks(User.Identity.Name, PlaylistName.Text, tracktodelete);

                            //Refresh the PlayList is a READ
                            List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(PlaylistName.Text, User.Identity.Name);
                            PlayList.DataSource = datainfo;
                            PlayList.DataBind();
                        }, "Deleting a Track", "Track Has been Deleted from the Play List");
                    }
                }
            }
        }
Ejemplo n.º 8
0
        protected void DeleteTrack_Click(object sender, EventArgs e)
        {
            string username = "******"; //until security is implemented

            //form event validation: presence
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Missing Data", "Enter a playlist name");
            }
            else
            {
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("Track Removal", "You must have a play list visible to choose removals. Select from the displayed playlist.");
                }
                else
                {
                    //collect the tracks indicated on the playlist for removal
                    List <int> trackids       = new List <int>();
                    int        rowsSelected   = 0;
                    CheckBox   trackSelection = null;
                    //traverse the gridview control PlayList
                    //you could do this same code using a foreah()
                    for (int i = 0; i < PlayList.Rows.Count; i++)
                    {
                        //point to the checkbox control on the gridview row
                        trackSelection = PlayList.Rows[i].FindControl("Selected") as CheckBox;
                        //test the setting of the checkbox
                        if (trackSelection.Checked)
                        {
                            rowsSelected++;
                            trackids.Add(int.Parse((PlayList.Rows[i].FindControl("TrackId") as Label).Text));
                        }
                    }

                    //was a song selected
                    if (rowsSelected == 0)
                    {
                        MessageUserControl.ShowInfo("Missing Data", "You must select at least one song to remove.");
                    }
                    else
                    {
                        //data collected, send for processing
                        MessageUserControl.TryRun(() =>
                        {
                            PlaylistTracksController sysmgr = new PlaylistTracksController();
                            sysmgr.DeleteTracks(username, PlaylistName.Text, trackids);
                            RefreshPlayList(sysmgr, username);
                        }, "Track removal", "Selected track(s) have been removed from the playlist.");
                    }
                }
            }
        }
Ejemplo n.º 9
0
        protected void DeleteTrack_Click(object sender, EventArgs e)
        {
            //code to go here
            //string username = "******";
            string username = User.Identity.Name;

            //validation of incoming data
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Missing data", "Enter the playlist name");
            }
            else
            {
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("Missing data", "You need to select from an displayed play list.");
                }
                else
                {
                    //collect all trackids that are to be removed
                    //at least one track must be selected
                    CheckBox   rowSelected = null;
                    List <int> trackids    = new List <int>();

                    for (int i = 0; i < PlayList.Rows.Count; i++)
                    {
                        rowSelected = PlayList.Rows[i].FindControl("Selected") as CheckBox;
                        if (rowSelected.Checked)
                        {
                            trackids.Add(int.Parse((PlayList.Rows[i].FindControl("TrackID") as Label).Text));
                        }
                    }

                    if (trackids.Count == 0)
                    {
                        MessageUserControl.ShowInfo("Remove Tracks", "You must select at least one track to remove");
                    }
                    else
                    {
                        MessageUserControl.TryRun(() => {
                            PlaylistTracksController sysmgr = new PlaylistTracksController();
                            sysmgr.DeleteTracks(username, PlaylistName.Text, trackids);
                            //refresh the playlist
                            List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist
                                                                (PlaylistName.Text, username);
                            PlayList.DataSource = info;
                            PlayList.DataBind();
                        }, "Remove Track(s)", "Track has been removed from the playlist");
                    }
                }
            }
        }
        protected void DeleteTrack_Click(object sender, EventArgs e)
        {
            string username = "******";

            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Missing Data", "Enter a Playlist name");
            }
            else
            {
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("Missing Data", "Playlist has no tracks to delete.");
                }
                else
                {
                    //gathering data
                    List <int> trackstodelete    = new List <int>();
                    int        rowsSelected      = 0;
                    CheckBox   playlistSelection = null;

                    //loop through entire rows that currently exist.
                    for (int i = 0; i < PlayList.Rows.Count; i++)
                    {
                        playlistSelection = PlayList.Rows[i].FindControl("Selected") as CheckBox;
                        if (playlistSelection.Checked)
                        {
                            rowsSelected++;
                            trackstodelete.Add(int.Parse((PlayList.Rows[i].FindControl("TrackID") as Label).Text));
                        }
                    }

                    //was at least one row selected ?
                    if (rowsSelected == 0)
                    {
                        MessageUserControl.ShowInfo("Missing data", "You must select at least one track to remove.");
                    }
                    else
                    {
                        //process delete
                        MessageUserControl.TryRun(() =>
                        {
                            PlaylistTracksController sysmgr = new PlaylistTracksController();
                            sysmgr.DeleteTracks(username, PlaylistName.Text, trackstodelete);
                            List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username);
                            PlayList.DataSource           = info;
                            PlayList.DataBind();
                        }, "Remove Tracks", "Tracks successfully removed.");
                    }
                }
            }
        }
Ejemplo n.º 11
0
        protected void DeleteTrack_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Track Removal",
                                            "You must have a play list name.");
            }
            else
            {
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("Track Removal",
                                                "You must have a play list to view.");
                }
                else
                {
                    //collect the tracks to remove
                    List <int> trackids       = new List <int>();
                    int        rowsSelected   = 0;
                    CheckBox   trackSelection = null;
                    for (int i = 0; i < PlayList.Rows.Count; i++)
                    {
                        trackSelection = PlayList.Rows[i].FindControl("Selected") as CheckBox;
                        if (trackSelection.Checked)
                        {
                            rowsSelected++;
                            trackids.Add(int.Parse((PlayList.Rows[i].FindControl("TrackId") as Label).Text));
                        }
                    }

                    //was a song selected
                    if (rowsSelected == 0)
                    {
                        MessageUserControl.ShowInfo("Tack Removal",
                                                    "You must select at least one track to remove");
                    }
                    else
                    {
                        //string username = "******";
                        string username = User.Identity.Name;
                        MessageUserControl.TryRun(() => {
                            PlaylistTracksController sysmgr = new PlaylistTracksController();
                            sysmgr.DeleteTracks(username, PlaylistName.Text, trackids);
                            List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username);
                            PlayList.DataSource           = info;
                            PlayList.DataBind();
                        }, "Track Removal", "Selected track(s) has been removed from the play lsit");
                    }
                }
            }
        }
Ejemplo n.º 12
0
        protected void DeleteTrack_Click(object sender, EventArgs e)
        {
            //check for playlist name
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Required Data ", "Deleting a track requires a playlist name.");
            }
            else
            {
                //check for tracks on playlist
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("Required Data ", "No playlist available. Fetch a playlist first.");
                }
                else
                {
                    //find playlist tracks
                    List <int> toDelete          = new List <int>();
                    int        rowSelected       = 0;
                    CheckBox   playlistSelection = null;

                    for (int index = 0; index < PlayList.Rows.Count; index++)
                    {
                        //set playlistSelection to the checkbox control on the gridview row
                        playlistSelection = PlayList.Rows[index].FindControl("Selected") as CheckBox;
                        if (playlistSelection.Checked)
                        {
                            rowSelected -= -1;
                            toDelete.Add(int.Parse((PlayList.Rows[index].FindControl("TrackID") as Label).Text));
                        }
                    }
                    //check for rows to delete
                    if (rowSelected == 0)
                    {
                        MessageUserControl.ShowInfo("Required Data ", "Select at least one track to remove.");
                    }
                    else
                    {
                        //send list to BLL controller
                        MessageUserControl.TryRun(() =>
                        {
                            PlaylistTracksController controller = new PlaylistTracksController();
                            controller.DeleteTracks(User.Identity.Name, PlaylistName.Text, toDelete);
                            List <UserPlaylistTrack> info = controller.List_TracksForPlaylist(PlaylistName.Text, User.Identity.Name); //read data back to user
                            PlayList.DataSource           = info;
                            PlayList.DataBind();
                        }, "Removed track", "Track has been removed from playlist.");
                    }
                }
            }
        }
Ejemplo n.º 13
0
        protected void DeleteTrack_Click(object sender, EventArgs e)
        {
            string username = "******";

            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Missing Data", "Enter the playlist name");
            }
            else
            {
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("Missing Data", "You required a play list from which to select song(s) to remove.");
                }
                else
                {
                    //gather the songs to remove (TrackID)
                    List <int> trackstodelete    = new List <int>();
                    int        rowsSelected      = 0;
                    CheckBox   playlistselection = null;
                    for (int i = 0; i < PlayList.Rows.Count; i++)
                    {
                        playlistselection = PlayList.Rows[i].FindControl("Selected") as CheckBox;
                        if (playlistselection.Checked)
                        {
                            rowsSelected++;
                            trackstodelete.Add(int.Parse((PlayList.Rows[i].FindControl("TrackID") as Label).Text));
                        }
                    }

                    //was a song selected
                    if (rowsSelected == 0)
                    {
                        MessageUserControl.ShowInfo("Missing Data",
                                                    "You required to select at least one song(s) to remove.");
                    }
                    else
                    {
                        //ready to process
                        MessageUserControl.TryRun(() => {
                            PlaylistTracksController sysmgr = new PlaylistTracksController();
                            sysmgr.DeleteTracks(username, PlaylistName.Text, trackstodelete);
                            List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username);
                            PlayList.DataSource           = info;
                            PlayList.DataBind();
                        }, "Track Removal", "Song(s) have been removed.");
                    }
                }
            }
        }
 protected void DeleteTrack_Click(object sender, EventArgs e)
 {
     //is there a playlist displayed
     if (PlayList.Rows.Count == 0)
     {
         MessageUserControl.ShowInfo("Warning", "No playlist has been retreived.");
     }
     else
     {
         //check playlist name is present
         if (string.IsNullOrEmpty(PlaylistName.Text))
         {
             MessageUserControl.ShowInfo("Warning", "You must have a playlist name.");
         }
         else
         {
             //check at least one item checked
             //collect trackids (hidden)
             List <int> trackstodelete    = new List <int>();
             int        rowsselected      = 0;
             CheckBox   playlistselection = null;
             for (int i = 0; i < PlayList.Rows.Count; i++)
             {
                 playlistselection = PlayList.Rows[i].FindControl("Selected") as CheckBox;
                 if (playlistselection.Checked)
                 {
                     trackstodelete.Add(int.Parse((PlayList.Rows[i].FindControl("TrackId") as Label).Text));
                     rowsselected++;
                 }
             }
             if (rowsselected == 0)
             {
                 MessageUserControl.ShowInfo("Warning", "Select one or more tracks to delete.");
             }
             else
             {
                 //call delete
                 MessageUserControl.TryRun(() =>
                 {
                     PlaylistTracksController sysmgr = new PlaylistTracksController();
                     sysmgr.DeleteTracks(User.Identity.Name, PlaylistName.Text, trackstodelete);
                     List <UserPlaylistTrack> playlistdata = sysmgr.List_TracksForPlaylist(PlaylistName.Text,
                                                                                           User.Identity.Name);
                     PlayList.DataSource = playlistdata;
                     PlayList.DataBind();
                 }, "Removed", "Tracks has been removed.");
             }
         }
     }
 }
        protected void DeleteTrack_Click(object sender, EventArgs e)
        {
            //code to go here
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Delete Tracks", "You need to look up your Playlist to select tracks to delete.");
            }
            else
            {
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("Delete Tracks", "Playlist is required.");
                }
                else
                {
                    //gather data neccessary for deleting
                    List <int> trackstodelete    = new List <int>();
                    int        rowsselected      = 0;
                    CheckBox   playlistselection = null;
                    for (int i = 0; i < PlayList.Rows.Count; i++)
                    {
                        playlistselection = PlayList.Rows[i].FindControl("Selected") as CheckBox;
                        if (playlistselection.Checked)
                        {
                            rowsselected++;
                            trackstodelete.Add(int.Parse((PlayList.Rows[i].FindControl("TrackID") as Label).Text));
                        }
                    }

                    //was atleast one track selected
                    if (rowsselected == 0)
                    {
                        MessageUserControl.ShowInfo("Delete Tracks", "Select atleast one track from the Playlist.");
                    }
                    else
                    {
                        MessageUserControl.TryRun(() =>
                        {
                            // pass on the data to do the delete in BLL when finished do refresh the list
                            PlaylistTracksController sysmgr = new PlaylistTracksController();
                            sysmgr.DeleteTracks(User.Identity.Name, PlaylistName.Text, trackstodelete);
                            List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(PlaylistName.Text, User.Identity.Name);
                            PlayList.DataSource = datainfo;
                            PlayList.DataBind();
                        }, "Delete Tracks", "Tracks have been removed");
                    }
                }
            }
        }
Ejemplo n.º 16
0
        protected void DeleteTrack_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Required data", "playlist name is required to add a track");
            }
            else
            {
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("required data", "no playlist is available review you playlist");
                }

                else
                {
                    List <int> tracktodelete     = new List <int>();
                    int        rowselectd        = 0;
                    CheckBox   playlistselection = null;
                    for (int i = 0; i <= PlayList.Rows.Count; i++)
                    {
                        playlistselection = PlayList.Rows[i].FindControl("selectd") as CheckBox;

                        if (playlistselection.Checked)
                        {
                            rowselectd++;
                            tracktodelete.Add(int.Parse((PlayList.Rows[i].FindControl("trackid") as Label).Text));
                        }
                    }
                    if (rowselectd == 0)
                    {
                        MessageUserControl.ShowInfo("Requried Data", "you must select at least one track to remove.");
                    }


                    else
                    {
                        MessageUserControl.TryRun(() =>
                        {
                            PlaylistTracksController sysmgr = new PlaylistTracksController();
                            sysmgr.DeleteTracks("HansenB", PlaylistName.Text, tracktodelete);
                            List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(PlaylistName.Text, "HansenB");
                            PlayList.DataSource = datainfo;
                            PlayList.DataBind();
                        }
                                                  , "Adding a Track", "Track has been added to the playlist");
                    }
                }
            }
        }
        protected void DeleteTrack_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Enter a PlayList name");
            }
            else
            {
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("PlayList has no tracks to delete");
                }
                else
                {
                    //gather all selected rows
                    List <int> trackstodelete    = new List <int>();
                    int        rowselected       = 0;
                    CheckBox   playlistselection = null;
                    for (int rowindex = 0; rowindex < PlayList.Rows.Count; rowindex++)
                    {
                        playlistselection = PlayList.Rows[rowindex].FindControl("Selected") as CheckBox;
                        if (playlistselection.Checked)
                        {
                            rowselected++;
                            trackstodelete.Add(int.Parse((PlayList.Rows[rowindex].FindControl("TrackID") as Label).Text));
                        }
                    }

                    //was at least one track selected

                    if (rowselected == 0)
                    {
                        MessageUserControl.ShowInfo("Warning", "you must select atleast one track to delete");
                    }
                    else
                    {
                        //send the list of tracks to the the BLL to delete
                        MessageUserControl.TryRun(() =>
                        {
                            PlaylistTracksController sysmgr = new PlaylistTracksController();
                            sysmgr.DeleteTracks("HandyHansen", PlaylistName.Text, trackstodelete);
                            List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, "HandyHansen");
                            PlayList.DataSource           = info;
                            PlayList.DataBind();
                        }, "Removed", "Tracks have been removed");
                    }
                }
            }
        }
Ejemplo n.º 18
0
 protected void DeleteTrack_Click(object sender, EventArgs e)
 {
     //code to go here
     if (PlayList.Rows.Count == 0)
     {
         MessageUserControl.ShowInfo("Warning", "No playlist has been retrieved");
     }
     else
     {
         if (string.IsNullOrEmpty(PlaylistName.Text))
         {
             MessageUserControl.ShowInfo("Warning", "No playlist name has been entered.");
         }
         else
         {
             //collect the selected tracks to delete
             List <int> trackstodelete    = new List <int>();
             int        selectedrows      = 0;
             CheckBox   playlistselection = null;
             for (int i = 0; i < PlayList.Rows.Count; i++)
             {
                 playlistselection = PlayList.Rows[i].FindControl("Selected") as CheckBox;
                 if (playlistselection.Checked)
                 {
                     trackstodelete.Add(int.Parse((PlayList.Rows[i].FindControl("TrackId") as Label).Text));
                     selectedrows++;
                 }
             }
             if (selectedrows == 0)
             {
                 MessageUserControl.ShowInfo("Information", "No playlist tracks has been selected.");
             }
             else
             {
                 //at this point you have your required data
                 //send to bll for processing
                 MessageUserControl.TryRun(() =>
                 {
                     PlaylistTracksController sysmgr       = new PlaylistTracksController();
                     List <UserPlaylistTrack> playlistdata = sysmgr.DeleteTracks(User.Identity.Name, PlaylistName.Text, trackstodelete);
                     //refresh what you have to
                     PlayList.DataSource = playlistdata;
                     PlayList.DataBind();
                 }, "Removed", "Tracks have been removed");
             }
         }
     }
 }
Ejemplo n.º 19
0
 protected void DeleteTrack_Click(object sender, EventArgs e)
 {
     if (PlayList.Rows.Count == 0)
     {
         MessageUserControl.ShowInfo("BAD", "No playlist has been retrieved");
     }
     else
     {
         if (String.IsNullOrEmpty(PlaylistName.Text))
         {
             MessageUserControl.ShowInfo("bad", "no playlist name. gimee");
         }
         else
         {
             //colelct the selecte tracks to delete
             //amke sure there are at least 1
             List <int> tracktodelete     = new List <int>();
             int        selectedrows      = 0;
             CheckBox   playlistselection = null;
             for (int i = 0; i < PlayList.Rows.Count; i++)
             {
                 playlistselection = PlayList.Rows[i].FindControl("Selected") as CheckBox;
                 if (playlistselection.Checked)
                 {
                     tracktodelete.Add(int.Parse((PlayList.Rows[i].FindControl("TrackId") as Label).Text));
                     selectedrows++;
                 }
             }
             if (selectedrows == 0)
             {
                 MessageUserControl.ShowInfo("bad", "no track selected to delete");
             }
             else
             {
                 //you got what you need
                 //send to bll for processing
                 MessageUserControl.TryRun(() =>
                 {
                     PlaylistTracksController sysmgr       = new PlaylistTracksController();
                     List <UserPlaylistTrack> playlistdata = sysmgr.DeleteTracks(User.Identity.Name, PlaylistName.Text, tracktodelete);
                     PlayList.DataSource = playlistdata;
                     PlayList.DataBind();
                 }, "Removed", "Tracks have been removed from playlist");
             }
         }
     }
 }
Ejemplo n.º 20
0
 protected void DeleteTrack_Click(object sender, EventArgs e)
 {
     //code to go here
     if (string.IsNullOrEmpty(PlaylistName.Text))
     {
         MessageUserControl.ShowInfo("Required data", "Play list name is required to add a track");
     }
     else
     {
         if (PlayList.Rows.Count == 0)
         {
             MessageUserControl.ShowInfo("Required Data", "No playlist is avaiblis.");
         }
         else
         {
             //traverse the gridview and collect the list of tracks to revmoce
             List <int> trackstodelete    = new List <int>();
             int        rowselected       = 0;
             CheckBox   playlistselection = null;
             for (int rowindex = 0; rowindex < PlayList.Rows.Count; rowindex++)
             {
                 playlistselection = PlayList.Rows[rowindex].FindControl("Selected") as CheckBox;
                 if (playlistselection.Checked)
                 {
                     rowselected++;
                     trackstodelete.Add(int.Parse((PlayList.Rows[rowindex].FindControl("TrackID") as Label).Text));
                 }
             }
             if (rowselected == 0)
             {
                 MessageUserControl.ShowInfo("Required data", "Selected at least one track to remove");
             }
             else
             {
                 //send list of tracks to be removed by BLL
                 MessageUserControl.TryRun(() =>
                 {
                     PlaylistTracksController sysmgr = new PlaylistTracksController();
                     sysmgr.DeleteTracks(User.Identity.Name, PlaylistName.Text, trackstodelete);
                     List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(PlaylistName.Text, User.Identity.Name);
                     PlayList.DataSource = datainfo;
                     PlayList.DataBind();
                 }, "Removing a Track", "Track has been removed from playlist");
             }
         }
     }
 }
Ejemplo n.º 21
0
        protected void DeleteTrack_Click(object sender, EventArgs e)
        {
            //code to go here
            string username = "******";

            if (string.IsNullOrEmpty(PlaylistName.Text))
            {
                MessageUserControl.ShowInfo("Missing Data", "Enter a playlist name");
            }
            else
            {
                if (PlayList.Rows.Count == 0)
                {
                    MessageUserControl.ShowInfo("Missing Data", "Playlist has no tracks to remove.");
                }
                else
                {
                    List <int> tracksToDelete    = new List <int>();
                    int        rowsSelected      = 0;
                    CheckBox   playlistSelection = null;
                    for (int i = 0; i < PlayList.Rows.Count; i++)
                    {
                        playlistSelection = PlayList.Rows[i].FindControl("Selected") as CheckBox;
                        if (playlistSelection.Checked)
                        {
                            rowsSelected++;
                            tracksToDelete.Add(int.Parse((PlayList.Rows[i].FindControl("TrackID") as Label).Text));
                            if (rowsSelected == 0)
                            {
                                MessageUserControl.ShowInfo("No data", "You must select at least one track to remove");
                            }
                            else
                            {
                                MessageUserControl.TryRun(() => {
                                    PlaylistTracksController sysmgr = new PlaylistTracksController();
                                    sysmgr.DeleteTracks(username, PlaylistName.Text, tracksToDelete);
                                    List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username);
                                    PlayList.DataSource           = info;
                                    PlayList.DataBind();
                                }, "Remove Tracks", "Track(s) have been Removed");
                            }
                        }
                    }
                }
            }
        }