@Override
	public void dialogFinished(DialogClient.operation requestedOperation) {
		
		int index = this.findSong();
		
		
		// Part A
		
		// TODO 
		if(requestedOperation == DialogClient.operation.UPDATE){
			//TO DO
			if (index == -1)
				System.out.println("Cannot find song. ID has changed");
			
			else
			{
				this.songList.set(index, songBeingEdited);
				
				try {
					PreparedStatement update = this.databaseConnection.prepareStatement("UPDATE songs SET bookcode = ?, page = ?, title = ? WHERE id = ?");
					update.setString(1, this.songBeingEdited.getBookCode());
					update.setInt(2, this.songBeingEdited.getPage());
					update.setString(3, this.songBeingEdited.getTitle());
					update.setInt(4, this.songBeingEdited.getID());
					update.executeUpdate();
					
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			
			
			//update song data in database
			System.out.println("UPDATE: " + songBeingEdited );
		}
		
		
		// Part B
		
		else if(requestedOperation == DialogClient.operation.DELETE){
			//TO DO
			
			if (index == -1)
				System.out.println("Cannot find song. ID has changed");
			
			else
			{
				this.songList.remove(index);
				
				try {
					PreparedStatement delete = this.databaseConnection.prepareStatement("DELETE from songs WHERE id = ?");
					delete.setInt(1, this.songBeingEdited.getID());
					delete.executeUpdate();
					
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			//delete song from database
			System.out.println("DELETE: " + songBeingEdited );
			
		}
		songBeingEdited = null;
		update();
	}