Wednesday, May 02, 2007
RSS Reader: Day 8
Part of the day yesterday was taken up by creating a Console application that would access my database using typed-data sets. I managed to get that working, then migrated the code into the RSS application. I even pulled all the data access code out into its own DLL and created a facade layer in front of it so the UI doesn't call directly into the database code. However, I only got the code working that loads the TreeView and the DeleteSubscription function.
Here's the code from the facade class:
Today's project is to get all the remaining functionality working.
Here's the code from the facade class:
using System;And the code to load the TreeView:
using System.Collections.Generic;
using System.Text;
using Feedme.Data.FeedMeTableAdapters;
namespace Feedme.Data
{
public class DataFacade
{
FoldersTableAdapter taFolders = new FoldersTableAdapter();
FeedMe.FoldersDataTable dtFolders;
FeedsTableAdapter taFeeds = new FeedsTableAdapter();
FeedMe.FeedsDataTable dtFeeds;
public FeedMe.FoldersDataTable GetFolders()
{
dtFolders = taFolders.GetData();
return dtFolders;
}
public FeedMe.FeedsDataTable GetDataByFoldersPK(int folderPK)
{
dtFeeds = taFeeds.GetDataByFoldersPK(folderPK);
return dtFeeds;
}
public void DeleteFolder(int folderPK)
{
taFolders.Delete(folderPK);
}
}
}
private void LoadtvSubscriptions()
{
FeedMe.FoldersDataTable dtFolders;
dtFolders = dataFacade.GetFolders();
TreeNode root = new TreeNode();
root.Text = "Subscriptions";
root.ImageIndex = 0;
tvSubscriptions.Nodes.Add(root);
FeedMe.FeedsDataTable dtFeeds;
TreeNode nodeFolder;
TreeNode nodeFeeds;
foreach (FeedMe.FoldersRow folderRow in dtFolders)
{
nodeFolder = new TreeNode();
nodeFolder.Text = folderRow.Description;
nodeFolder.Tag = folderRow.PK;
nodeFolder.ImageIndex = 0;
dtFeeds = dataFacade.GetDataByFoldersPK(folderRow.PK);
foreach (FeedMe.FeedsRow feedRow in dtFeeds)
{
nodeFeeds = new TreeNode();
nodeFeeds.Text = feedRow.Title;
nodeFeeds.Tag = feedRow.PK;
nodeFeeds.ImageIndex = 1;
nodeFolder.Nodes.Add(nodeFeeds);
}
root.Nodes.Add(nodeFolder);
}
}
Today's project is to get all the remaining functionality working.
Subscribe to Posts [Atom]