protected void PlayListFetch_Click(object sender, EventArgs e) { //username is coming from the system via security //since security has yet to be installed, a default will be setup for the // username value string username = "******"; if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Playlist Search", "No palylist name was supplied"); } else { //use some user friendly error handling //the way we are doing the error is using MessageUserControl instead of // using try/catch //MessageUserControl has the try/catch embedded within the control //within the MessageUserControl there exists a method called .TryRun() //syntax // MessageUserControl.TryRun(() =>{ // // coding block // // }[,"message title","success message"]); MessageUserControl.TryRun(() => { //code to execute under error handling control of MessageUserControl PlaylistTracksController sysmgr = new PlaylistTracksController(); List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username); PlayList.DataSource = info; PlayList.DataBind(); }, "Playlist Search", "View the requested playlist below."); } }
protected void PlayListFetch_Click(object sender, EventArgs e) { //code to go here //standard query if (string.IsNullOrEmpty(PlaylistName.Text)) { //put out an erro message //this form uses a User control called MessageUserControl //The user control will be the mechanism to display messages on this form MessageUserControl.ShowInfo("Warning", "Play List Name is required"); //Show info just puts out a message, there is also a bootstrap version as well } else //If we had something { string username = User.Identity.Name; //Underneath the user class, find the identity, and then take out Name //Message User control has the try/catch coding embedded in the control MessageUserControl.TryRun(() => { //this is the process coding bloack to be executed under the "watchful eye" of the MessagefeUserControl //obtain the user name from the security part of the application PlaylistTracksController sysmgr = new PlaylistTracksController(); List <UserPlaylistTrack> playlist = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username); PlayList.DataSource = playlist; PlayList.DataBind(); }, "", "Here is your current playlist."); } }
protected void PlayListFetch_Click(object sender, EventArgs e) { //security is yet to be implemented //this page needs to known the username of the currently logged user //temporarily we will hard core the username string username = "******"; if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Missing Data", "Enter the playlist name"); } else { //Your code does NOT need to have a try/catch //The try/catch is embedded within MessageUserControl //The syntax for executing with MessageUserControl // MessageUserControl.TryRun(() => { coding block},"Success Title","Success message"); MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username); PlayList.DataSource = info; PlayList.DataBind(); }, "Playlist", "View current songs on playlist"); } }
protected void TracksSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e) { //code to go here if (string.IsNullOrEmpty(PlaylistName.Text)) { //use the MessageUserControl method .ShowInf("title", "message") MessageUserControl.ShowInfo("Required data", "Play list name is required to add a track."); } else { //collect the needed data string playlistname = PlaylistName.Text; //string username = User.Identity.Name; //comes from security string username = "******"; //obtain the TrackId from the ListView //CommandArgument is an object int trackid = int.Parse(e.CommandArgument.ToString()); MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); sysmgr.Add_TrackToPLaylist(playlistname, username, trackid); List <UserPlaylistTrack> results = sysmgr.List_TracksForPlaylist(playlistname, username); PlayList.DataSource = results; PlayList.DataBind(); }, "Adding a Track", "Track has been added to the playlist."); } }
protected void TracksSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e) { //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 { //Reminder: MessageUserControl will do the error handling MessageUserControl.TryRun(() => { //coding block for your logic to be run under the error handling // control of MessageUserControl //a trx add to the database //connect to controller PlaylistTracksController sysmgr = new PlaylistTracksController(); //issue the call to the controller method sysmgr.Add_TrackToPLaylist(PlaylistName.Text, username, int.Parse(e.CommandArgument.ToString())); //refresh the playlist List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist (PlaylistName.Text, username); PlayList.DataSource = info; PlayList.DataBind(); }, "Add track to Playlist", "Track has been added to the playlist"); } }
protected void PlayListFetch_Click(object sender, EventArgs e) { //code to go here if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Required Data", "Playlist Name is required to retreive tracks."); } else { string username = "******"; string playlistname = PlaylistName.Text; MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); List <UserPlaylistTrack> results = sysmgr.List_TracksForPlaylist(playlistname, username); if (results.Count() == 0) { MessageUserControl.ShowInfo("Check playlist name"); } PlayList.DataSource = results; PlayList.DataBind(); }); } }
protected void TracksSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e) { if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Required data", "Play list name is required to add a track"); } else { //collect the required data for the event string playlistname = PlaylistName.Text; //the username will come from the security //so untill security is added, we will use HansenB string username = User.Identity.Name; //obtain the track id from the ListView //the track id will be in the commandArg property of the ListViewCommandEventArgs e instance //the commandarg in e is return as an object int trackid = int.Parse(e.CommandArgument.ToString()); MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); sysmgr.Add_TrackToPLaylist(playlistname, username, trackid); List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(playlistname, username); PlayList.DataSource = datainfo; PlayList.DataBind(); }, "Adding a Track", "Track has been added to the playlist"); } }
protected void TracksSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e) { //code to go here //do we have thge playlist name? if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Required Data", "Playlist name is required to add a track."); } else { //collect the required data for the event string playlistname = PlaylistName.Text; //the username will come from the form security //so until security is added, we will use HansenB string username = "******"; //obtain the track idea from the listview //the track id will be in the CommandArg property of the ListViewCommandEventArgs e instance. int trackid = (int.Parse(e.CommandArgument.ToString())); //using the obtained data, issue your call to the BLL method. //this work will be done within a TryRun() MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); sysmgr.Add_TrackToPLaylist(playlistname, username, trackid); //refresh the playlist List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist( playlistname, username); PlayList.DataSource = datainfo; PlayList.DataBind(); }, "Adding A Track", "Track has been added to the playlist"); } }
protected void TracksSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e) { if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Warning", "You must supply a playlist name."); } else { //obtain the user name. string username = User.Identity.Name; //obtain the playlist name string playlistname = PlaylistName.Text; int trackid = int.Parse(e.CommandArgument.ToString()); //contect to BLL controller //call required method //refresh the screen //do all this under the user friendly error handler MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); sysmgr.Add_TrackToPLaylist(playlistname, username, trackid); List <UserPlaylistTrack> results = sysmgr.List_TracksForPlaylist(playlistname, username); PlayList.DataSource = results; PlayList.DataBind(); }, "Playlist Track Added", "You have successfully added a new track to your list."); } }
protected void TracksSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e) { if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Required data", "play list name is required to add a track"); } else { string playlistname = PlaylistName.Text; string username = "******"; int trackid = int.Parse(e.CommandArgument.ToString()); MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); sysmgr.Add_TrackToPLaylist(playlistname, username, trackid); List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(playlistname, username); PlayList.DataSource = datainfo; PlayList.DataBind(); } , "Adding a Track", "Track has been added to the playlist"); } }
/// <summary> /// Executes on user intiated add track event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void TracksSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e) { if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo( "Playlist Name", "Playlist name is required when adding a track."); } else { string username = "******"; // (!) Find via security string playlist = PlaylistName.Text; // Note: TrackID is imbedded on each list row (with the CommandArgument parameter) int trackID = int.Parse(e.CommandArgument.ToString()); // Send data to the BLL MessageUserControl.TryRun(() => { // BLL connection PlaylistTracksController sysmgr = new PlaylistTracksController(); sysmgr.Add_TrackToPLaylist(playlist, username, trackID); // Refresh playlist track listing List <UserPlaylistTrack> Info = sysmgr.List_TracksForPlaylist(playlist, username); PlayList.DataSource = Info; PlayList.DataBind(); }, "Track Added", "Track successfully added to your playlist!"); } }
protected void PlayListFetch_Click(object sender, EventArgs e) { //code to go here if (string.IsNullOrEmpty(PlaylistName.Text)) { /* use the MessageUserControl method .ShowInfo("title","message")*/ MessageUserControl.ShowInfo("Required data", "Play list name is required to add a track."); } else { //collect the needed data string playlistname = PlaylistName.Text; //string username = User.Identity.Name; //comes from security string username = User.Identity.Name; // "HansenB"; MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); List <UserPlaylistTrack> results = sysmgr.List_TracksForPlaylist( playlistname, username); PlayList.DataSource = results; PlayList.DataBind(); }, "Playlist Tracks", "See current tracks on playlist below."); } }
protected void TracksSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e) { string username = "******"; if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Missing Data", "Enter the playlist name"); } else { //Your code does not need to have a try catch //the try catch is inbedded within MessageUserControl //the syntax for executing for MessageUserControl // MessageUserControl.TryRun(() => { coding block}, "Success Title","Success message"); MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); //e is the track id that is passed from the web page sysmgr.Add_TrackToPLaylist(PlaylistName.Text, username, int.Parse(e.CommandArgument.ToString())); List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username); PlayList.DataSource = info; PlayList.DataBind(); }, "Add track to playlsit", "Track has been added to the playlist"); } }
protected void PlayListFetch_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Missing Data", "Please Enter the playlist name"); } else { string username = "******"; //Username will come from security once implemented //MessageUserControl will be used to handle the code behind user friendly error handling //you will NOT be using try/catch //your try/catch is embedded within the MessageUserControl class MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); List <UserPlaylistTrack> playlistInfo = null; playlistInfo = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username); if (playlistInfo == null) { throw new Exception("Playlist no longer exists"); } else { PlayList.DataSource = playlistInfo; PlayList.DataBind(); } }, "Playlist", "Manage your playlist");//string after successful coding block } }
protected void RefreshPlayList(PlaylistTracksController sysmgr, string username) { List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username); PlayList.DataSource = info; PlayList.DataBind(); }
protected void PlayListFetch_Click(object sender, EventArgs e) { //code to go here //standard query lookup if (string.IsNullOrEmpty(PlaylistName.Text)) { //able to display a message to the user via the MessageUserControl //one of the methods of MessageUserControl is .ShowInfo() MessageUserControl.ShowInfo("Warning", "Playlist Name is required."); } else { //obtain the username from the security Identity class string username = User.Identity.Name; //the MessageUserControl has embedded in its code the try/catch logic //you do not need to code your own try/catch MessageUserControl.TryRun(() => { //code to be run under the "watchful eyes" of the user control //this is the try{your code} of the try/catch PlaylistTracksController sysmgr = new PlaylistTracksController(); List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username); PlayList.DataSource = info; PlayList.DataBind(); }, "", "Here is your current playlist."); } }
protected void PlayListFetch_Click(object sender, EventArgs e) { //standard query if (string.IsNullOrEmpty(PlaylistName.Text)) { //put out error message //this form uses a user control called MessageUserControl MessageUserControl.ShowInfo("Warning", "Playlist Name is required"); } else { //MessageUserControl has Try Catch coding embedded in the control MessageUserControl.TryRun(() => { //this is the process coding block to be executed under the "watchful eye" of the MessageUSerControl //obtain the username from the security part of the application string username = User.Identity.Name; PlaylistTracksController sysmgr = new PlaylistTracksController(); List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username); PlayList.DataSource = info; PlayList.DataBind(); }, "", "Here is your current playlist"); } }
protected void TracksSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e) { //validate incoming parameters if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Required Data ", "Adding a track requires a playlist name."); } else { string playlistName = PlaylistName.Text; //username eventually will come from security. Currently hardcoded string username = User.Identity.Name; //track id comes from the list view command arguments int trackID = int.Parse(e.CommandArgument.ToString()); //the command argument must be cast to a string, then parsed to an int. MessageUserControl.TryRun(() => { PlaylistTracksController controller = new PlaylistTracksController(); controller.Add_TrackToPLaylist(playlistName, username, trackID); //add data here - there can only be one call to the database List <UserPlaylistTrack> info = controller.List_TracksForPlaylist(playlistName, username); //read data back to user PlayList.DataSource = info; PlayList.DataBind(); }, "Added track", "Track has been added to playlist."); } }
protected void PlayListFetch_Click(object sender, EventArgs e) { //verify if the data is there if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Required Data", "Play list name is required."); } else { //call BLL string playlistname = PlaylistName.Text; //until we do security, we will use a hard coded username //string username = "******"; once, security is implemented, you can obtain the user name from user.identity class property .name string username = User.Identity.Name; //do a standard query lookup to your controller, use MessageUserControl for error handling MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(playlistname, username); PlayList.DataSource = datainfo; //if nothing is coming back it will show the template PlayList.DataBind(); }, "Playlist Tracks", "See current tracks on playlist below" ); } }
//this is different than a straight click. Notice the CommandEventArgs parameter. protected void TracksSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e) { //do we have the playlist name if (string.IsNullOrEmpty(PlaylistName.Text)) { //if we don't... MessageUserControl.ShowInfo("Required Data", "You need a play list name to add a track."); } else { //collect the required data for the event string playlistname = PlaylistName.Text; //the user name will come from the form security, so instead we will just use a hardcoded string until we add the security //string username = "******"; string username = User.Identity.Name; //obtain the track id from the ListView. //the track ID will be in the CommandArg property of the ListViewCommandEventArgs e instance int trackid = int.Parse(e.CommandArgument.ToString()); //<-- what comes back is actually an object, so we need to type cast this thing. //the Commandarg in e is returned as an object. Cast it to a string, then you can Parse the string. //using the obtained data, issue your call to the BLL method, this work will be done within a TryRun MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); //there is ONLY one call to add the data to the database. sysmgr.Add_TrackToPLaylist(playlistname, username, trackid); //refresh the playlist, and we already have the method to do that, so we are borrowing from our playlist fetch //the REFRESH of the playlist is a READ. List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(playlistname, username); PlayList.DataSource = datainfo; PlayList.DataBind(); }, "Adding a Track", "Success! Track added to playlist!"); } }
protected void TracksSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e) { //code to go here if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Required Data", "Playlist Name is required to add a track to a playlist"); } else { string playlistname = PlaylistName.Text; string username = User.Identity.Name; // change when security implemented //obtain track id from the ListView line that was selected //for the line I have created a CommandArgument //this value is available via the ListViewCommandEventArgs parameter e int trackid = int.Parse(e.CommandArgument.ToString()); MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); sysmgr.Add_TrackToPLaylist(playlistname, username, trackid); List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(playlistname, username); PlayList.DataSource = datainfo; PlayList.DataBind(); }, "Adding a Track", "Track has been added to the playlist."); } }
protected void PlayListFetch_Click(object sender, EventArgs e) { //code to go here //standard query implementation if (string.IsNullOrEmpty(PlaylistName.Text)) { //throw error message //use usercontrolmessage. MessageUserControl MessageUserControl.ShowInfo("Warning...", "Playlist Name is required..."); //the user control will be the mechanism to display messages on this form } else { //no need for try catches, the MEssageUserControl has the trycatch coding built inside it // MessageUserControl.TryRun(() => { //this is the process coding block to be executed under the "watchful eye" of the MUC // //obtain username from the security part of the application string username = User.Identity.Name; PlaylistTracksController sysmgr = new PlaylistTracksController(); List <UserPlaylistTrack> playlist = sysmgr.List_TracksForPlaylist(PlaylistName.Text, username); PlayList.DataSource = playlist; PlayList.DataBind(); }, "", "Here is your current playlist"); } }
protected void PlayListFetch_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Required Data", "Play list name is required to fetch a play list"); } else { string playlistname = PlaylistName.Text; //until we do security, we will use a hard coded username //string username = "******"; //Once security is Implemented you can obtain the //User name from User.Identity Class Property .Name string username = User.Identity.Name; //do a standard query lookup to your control //use MessageUserControl for error handling MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist( playlistname, username); PlayList.DataSource = datainfo; PlayList.DataBind(); }, "Playlist Tracks", "See current tracks on playlist below"); } }
protected void PlayListFetch_Click(object sender, EventArgs e) { //code to go here //standard query if (string.IsNullOrEmpty(PlaylistName.Text)) { //put out an error message //this form uses a user control called MessageUserControl //the user control will be the mechanism to display messages on this form MessageUserControl.ShowInfo("Warning", "Playlist name is required"); } else { //MessageUserControl already has the try/catch cosing embedded in the control MessageUserControl.TryRun(() => { //this is the process coding block to be executed under the //"watchful eye" of the MessageUser control //obtain the user name from the security part of the application string username = User.Identity.Name; PlaylistTracksController sysmgr = new PlaylistTracksController(); List <UserPlaylistTrack> playlist = sysmgr.List_TracksForPlaylist (PlaylistName.Text, username); PlayList.DataSource = playlist; PlayList.DataBind(); }, "//title", "here is yout current plalist."); } }
protected void TracksSelectionList_ItemCommand(object sender, ListViewCommandEventArgs e) { //this method will only execute if the user has pressed the plus sign on a visible row from the display if (string.IsNullOrEmpty(PlaylistName.Text)) { MessageUserControl.ShowInfo("Playlist Name", "You must supply a playlist name"); } else { //via security, one can obtain the username string username = "******"; string playlistname = PlaylistName.Text; //the trackid is attached to each listview row via the CommandArgument parameter //access to the trackid is done via the ListViewCommandEventArgs e parameter //the e parameter is treated as an object //some e parameters need to be cast as strings int trackid = int.Parse(e.CommandArgument.ToString()); //all required data can now be sent to the BLL for further processing //user friendly error handling MessageUserControl.TryRun(() => { //connect to BLL PlaylistTracksController sysmgr = new PlaylistTracksController(); sysmgr.Add_TrackToPLaylist(playlistname, username, trackid); //code to retrieve the up to date playlist and tracks for refreshing the playlist track list List <UserPlaylistTrack> info = sysmgr.List_TracksForPlaylist(playlistname, username); PlayList.DataSource = info; PlayList.DataBind(); }, "Track Added", "The track has been added, check your list below"); } }
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"); } } } }
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"); } } } }
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"); } } } } }
protected void MoveTrack(int trackid, int tracknumber, string direction) { messageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); sysmgr.MoveTrack(User.Identity.Name, PlaylistName.Text, trackid, tracknumber, direction); List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(PlaylistName.Text, User.Identity.Name); PlayList.DataSource = datainfo; PlayList.DataBind(); }, "Success", "Track has been moved"); }
protected void MoveTrack(int trackid, int tracknumber, string direction) { //call BLL to move track MessageUserControl.TryRun(() => { PlaylistTracksController sysmgr = new PlaylistTracksController(); sysmgr.MoveTrack("HansenB", PlaylistName.Text, trackid, tracknumber, direction); List <UserPlaylistTrack> datainfo = sysmgr.List_TracksForPlaylist(PlaylistName.Text, "HansenB"); PlayList.DataSource = datainfo; PlayList.DataBind(); }, "Success", "track has been moved"); }