protected void Remove_Click(object sender, EventArgs e) { //the validation that exists within the event is probably validation that // a) is not possible on the form // b) required for specific events only // c) for some reason, it was decided to the validation in code-behind if (string.IsNullOrEmpty(EditAlbumID.Text)) { MessageUserControl.ShowInfo("Removing", "Search for an exsiting album before removing"); } else { MessageUserControl.TryRun(() => { AlbumController sysmgr = new AlbumController(); int rowsaffected = sysmgr.Album_Delete(int.Parse(EditAlbumID.Text)); if (rowsaffected == 0) { throw new Exception("Album no longer on file. Refresh your search."); } else { EditAlbumID.Text = ""; AlbumList.DataBind(); } }, "Remove", "Action successful"); } }
protected void Remove_Click(object sender, EventArgs e) { int editalbumid = 0; string albumid = EditAlbumID.Text; if (string.IsNullOrEmpty(albumid)) { MessageUserControl.ShowInfo("Uh-oh!", "Look up the album before editing. Duh."); } else if (!int.TryParse(albumid, out editalbumid)) { MessageUserControl.ShowInfo("Attention!", "Current album id is invalid. Perform look up again."); } else { MessageUserControl.TryRun(() => { AlbumController sysmgr = new AlbumController(); int rowsaffected = sysmgr.Album_Delete(editalbumid); EditAlbumID.Text = albumid.ToString(); if (rowsaffected > 0) { AlbumList.DataBind(); EditAlbumID.Text = ""; } else { throw new Exception("Album was not found. Repeat look up and remove again."); } }, "Successful", "Album Deleted"); } }
protected void Remove_Click(object sender, EventArgs e) { int editalbumid = 0; string albumid = EditAlbumID.Text; if (string.IsNullOrEmpty(albumid)) { messageUserControl.ShowInfo("Attention, Actung! Arrividarchi!", "Lookup the album before editing, please."); } else if (!int.TryParse(albumid, out editalbumid)) { throw new Exception("Current albumid is invalid. Perform lookup again, please."); } else { messageUserControl.TryRun(() => { AlbumController sysmgr = new AlbumController(); int rowsaffected = sysmgr.Album_Delete(editalbumid); if (rowsaffected > 0) { AlbumList.DataBind(); //re-executes the ods for the album list EditAlbumID.Text = ""; } else { messageUserControl.ShowInfo("Hello, I am a title", "You monster!"); } }, "Successful", "Album removed, you monster!"); } }
protected void Remove_Click(object sender, EventArgs e) { // physical delete int editalbumid = 0; string albumid = EditAlbumID.Text; if (string.IsNullOrEmpty(albumid)) // if there is no album selected to edit { MessageUserControl.ShowInfo("Attention", "Look up the album before deleting"); // "Title", "Message" } else if (!int.TryParse(albumid, out editalbumid)) // if albumid is not a number { MessageUserControl.ShowInfo("Attention", "Current albumid is invalid"); } else { MessageUserControl.TryRun(() => { AlbumController sysmgr = new AlbumController(); int rowsaffected = sysmgr.Album_Delete(editalbumid); if (rowsaffected > 0) { AlbumList.DataBind(); } else { throw new Exception("Album was not found. Repeat lookup and remove again."); } }, "Successful", "Album Physically Deleted"); } }
protected void Remove_Click(object sender, EventArgs e) { string editID = EditAlbumID.Text; int albumID = 0; if (string.IsNullOrEmpty(editID)) { MessageUserControl.ShowInfo("Error", "Must have album to edit."); } else if (!int.TryParse(editID, out albumID)) { MessageUserControl.ShowInfo("Error", "Invalid album ID"); } else { MessageUserControl.TryRun(() => { AlbumController controller = new AlbumController(); int rows = controller.Album_Delete(albumID); if (rows > 0) { AlbumList.DataBind(); EditAlbumID.Text = ""; } else { throw new Exception("No album found. Try again."); } }, "Sucessful!", "Album deleted."); } }