public override void OnPreRender() { // Determine whether we are in flat view or tree view mode. This setting is // stored in a cookie, but should probably be moved in to the user's profile // which is stored in the database. if (!_viewDropDownSelected) _forumView = ForumUtils.GetForumView(Page); ListItem listItem = _viewDropDownList.Items.FindByValue(_forumView.ToString()); if (listItem != null) listItem.Selected = true; // _threadID identifies the thread we are currently viewing. _postID identifies // the post within the thread that is currently being shown. (i.e. in tree view, // only one post can be viewed at a time). _threadID can be obtained from the value // of _postID. We will also determine what page we are looking at. _threadID = ForumDB.GetThreadFromPost(_postID); _threadPage = ForumDB.GetSortOrderFromPost(_postID, _forumView)/ForumUtils.GetPostsPerPage(); // If looking at the first post in a thread, then increment the thread view count if (_threadID == _postID) ForumDB.IncrementThreadViews(_threadID); // Get page of posts that will be rendered _forumPostCollection = ForumDB.GetThread(_threadID, _threadPage, ForumUtils.GetPostsPerPage(), _forumView); // Register javascript for dynamically showing threads in tree view if (_forumView == ForumUtils.ForumView.TreeViewDynamic) RegisterJavascript(); }
private void ViewDropDownList_SelectedIndexChanged(Object sender, EventArgs e) { // Either tree view or flat view has been selected from the view drop down list. // We need to update the user's preference in the Forum_View cookie. Maybe this // setting would be better stored in a user profile (in the database). _forumView = ForumUtils.GetForumViewFromString(_viewDropDownList.SelectedItem.Value); ForumUtils.SetForumView(Page, _forumView); _viewDropDownSelected = true; }
public static int GetSortOrderFromPost(int postID, ForumUtils.ForumView forumView) { SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["RiversideInternetForumsConnectionString"]); SqlCommand cmd = new SqlCommand("WS_GetSortOrderFromPost", conn); bool flatView = (forumView == ForumUtils.ForumView.FlatView); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@PostID", SqlDbType.Int, 4); cmd.Parameters.Add("@FlatView", SqlDbType.Bit, 1); cmd.Parameters.Add("@SortOrder", SqlDbType.Int, 4); cmd.Parameters[0].Value = postID; cmd.Parameters[1].Value = flatView; cmd.Parameters[2].Direction = ParameterDirection.Output; conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); return((int)cmd.Parameters[2].Value); }
public override void OnPreRender() { // Determine whether we are in flat view or tree view mode. This setting is // stored in a cookie, but should probably be moved in to the user's profile // which is stored in the database. if (!_viewDropDownSelected) { _forumView = ForumUtils.GetForumView(Page); } ListItem listItem = _viewDropDownList.Items.FindByValue(_forumView.ToString()); if (listItem != null) { listItem.Selected = true; } // _threadID identifies the thread we are currently viewing. _postID identifies // the post within the thread that is currently being shown. (i.e. in tree view, // only one post can be viewed at a time). _threadID can be obtained from the value // of _postID. We will also determine what page we are looking at. _threadID = ForumDB.GetThreadFromPost(_postID); _threadPage = ForumDB.GetSortOrderFromPost(_postID, _forumView) / ForumUtils.GetPostsPerPage(); // If looking at the first post in a thread, then increment the thread view count if (_threadID == _postID) { ForumDB.IncrementThreadViews(_threadID); } // Get page of posts that will be rendered _forumPostCollection = ForumDB.GetThread(_threadID, _threadPage, ForumUtils.GetPostsPerPage(), _forumView); // Register javascript for dynamically showing threads in tree view if (_forumView == ForumUtils.ForumView.TreeViewDynamic) { RegisterJavascript(); } }
public void Render(HtmlTextWriter writer, int threadsPerPage, DateTime lastVisited, Page page, string images, string document, int postsPerPage, ForumUtils.ForumView forumView) { // Start row writer.RenderBeginTag(HtmlTextWriterTag.Tr); // Render thread image. If the total number of posts in this thread is great than the // number of posts that can be displayed on one page, then we display a special image that // indicates this thread is "on fire". int totalPosts = (int)Replies + 1; writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRow"); writer.AddAttribute(HtmlTextWriterAttribute.Width, "25"); writer.AddAttribute(HtmlTextWriterAttribute.Valign, "middle"); writer.AddAttribute(HtmlTextWriterAttribute.Align, "center"); writer.RenderBeginTag(HtmlTextWriterTag.Td); if (totalPosts > threadsPerPage) { writer.AddAttribute(HtmlTextWriterAttribute.Src, images + "board_thread_fire.gif"); } else { writer.AddAttribute(HtmlTextWriterAttribute.Src, images + "board_thread.gif"); } writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); // Img writer.RenderEndTag(); // Td // Thread subject with link (and indicate whether or not this thread is pinned) writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRow"); writer.AddAttribute(HtmlTextWriterAttribute.Valign, "middle"); writer.AddAttribute(HtmlTextWriterAttribute.Valign, "left"); writer.AddAttribute(HtmlTextWriterAttribute.Height, "25"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal"); writer.RenderBeginTag(HtmlTextWriterTag.Span); if (PinnedDate > DateTime.Now) { writer.RenderBeginTag(HtmlTextWriterTag.B); writer.Write("Sticky: "); writer.RenderEndTag(); // B } writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}", ThreadID), "forumaction=&searchpage=&threadspage=") + string.Format("#{0}", ThreadID)); writer.RenderBeginTag(HtmlTextWriterTag.A); ForumText subjectForumText = new ForumText(Subject); writer.Write(subjectForumText.ProcessSingleLine(images)); writer.RenderEndTag(); // A // If thread spans several pages, then we need to indicate this in the thread list // by displaying text like (Page 1, 2, 3, ..., 5) if (totalPosts > threadsPerPage) { writer.Write(" (Page: "); int pageCount = ((totalPosts - 1) / threadsPerPage) + 1; int pageCountCapped = Math.Min(pageCount, 4); bool showFinalPage = (pageCountCapped < pageCount); for (int threadPage = 0; threadPage < pageCountCapped; threadPage++) { int postID = ForumDB.GetPostFromThreadAndPage(ThreadID, threadPage, postsPerPage, forumView); writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}", postID), "forumaction=&searchpage=&threadspage=")); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write(string.Format("{0}", threadPage + 1)); writer.RenderEndTag(); // A if ((threadPage < pageCountCapped - 1) || showFinalPage) { writer.Write(", "); } } if (showFinalPage) { if (pageCount > 5) { writer.Write("..., "); } int postID = ForumDB.GetPostFromThreadAndPage(ThreadID, pageCount - 1, postsPerPage, forumView); writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}", postID), "forumaction=&searchpage=&threadspage=")); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write(pageCount.ToString()); writer.RenderEndTag(); // A } writer.Write(")"); } // Display new image if this thread is new since last time user visited if (lastVisited < _dateLastPost) { writer.AddAttribute(HtmlTextWriterAttribute.Src, images + "new.gif"); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); } writer.RenderEndTag(); // Span writer.RenderEndTag(); // Td // Started by writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRowHighlight"); writer.AddAttribute(HtmlTextWriterAttribute.Align, "center"); writer.AddAttribute(HtmlTextWriterAttribute.Width, "100"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal"); writer.RenderBeginTag(HtmlTextWriterTag.Span); ForumText startedByAliasForumText = new ForumText(StartedByAlias); writer.Write(startedByAliasForumText.ProcessSingleLine(images)); writer.RenderEndTag(); // Span writer.RenderEndTag(); // Td // Replies writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRowHighlight"); writer.AddAttribute(HtmlTextWriterAttribute.Align, "center"); writer.AddAttribute(HtmlTextWriterAttribute.Width, "50"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal"); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(Replies); writer.RenderEndTag(); // Span writer.RenderEndTag(); // Td // Views writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRowHighlight"); writer.AddAttribute(HtmlTextWriterAttribute.Align, "center"); writer.AddAttribute(HtmlTextWriterAttribute.Width, "50"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal"); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(Views); writer.RenderEndTag(); // Span writer.RenderEndTag(); // Td // Last Post writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRowHighlight"); writer.AddAttribute(HtmlTextWriterAttribute.Align, "center"); writer.AddAttribute(HtmlTextWriterAttribute.Width, "140"); writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "nowrap"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal"); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionSmallerFont"); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(DateLastPost.ToString("dd MMM yy")); writer.Write(" "); writer.Write(DateLastPost.ToString("t")); writer.Write("<BR>"); ForumText lastPostAliasForumText = new ForumText(LastPostAlias); writer.Write(lastPostAliasForumText.ProcessSingleLine(images)); writer.Write(" "); writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}", LastPostID), "forumaction=&searchpage=&threadspage=") + string.Format("#{0}", LastPostID)); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.AddAttribute(HtmlTextWriterAttribute.Src, images + "last_post.gif"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); // Img writer.RenderEndTag(); // A writer.RenderEndTag(); // Span writer.RenderEndTag(); // Span writer.RenderEndTag(); // Td // End row writer.RenderEndTag(); // Tr }
public void Render(HtmlTextWriter writer, bool displayActions, ForumUtils.ForumView forumView, bool selected, DateTime lastVisited, Page page, int loggedOnUserID, string avatar, string images, string document) { // New row writer.RenderBeginTag(HtmlTextWriterTag.Tr); // Left hand side contains user information (user alias, avatar, number of posts etc) writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRow"); writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "nowrap"); writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top"); writer.AddAttribute(HtmlTextWriterAttribute.Width, "160"); writer.RenderBeginTag(HtmlTextWriterTag.Td); // We will put this user information in its own table in the first column writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "3"); writer.AddAttribute(HtmlTextWriterAttribute.Width, "160"); writer.RenderBeginTag(HtmlTextWriterTag.Table); // User alias and number of posts writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.AddAttribute(HtmlTextWriterAttribute.Align, "center"); writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderBeginTag(HtmlTextWriterTag.B); ForumText userAliasForumText = new ForumText(User.Alias); writer.Write(userAliasForumText.ProcessSingleLine(images)); writer.RenderEndTag(); // B writer.RenderBeginTag(HtmlTextWriterTag.Br); writer.Write(string.Format("Posts: {0}", User.PostCount)); writer.RenderEndTag(); // Br writer.RenderEndTag(); // Td writer.RenderEndTag(); // Tr // Avatar if (forumView == ForumUtils.ForumView.TreeViewDynamic) { writer.AddAttribute(HtmlTextWriterAttribute.Id, PostID.ToString() + "_avatarrow"); if (!selected) { writer.AddStyleAttribute("display", "none"); } } if ((selected && forumView == ForumUtils.ForumView.TreeView) || forumView != ForumUtils.ForumView.TreeView) { writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.AddAttribute(HtmlTextWriterAttribute.Align, "center"); writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal"); writer.RenderBeginTag(HtmlTextWriterTag.Td); if (avatar != string.Empty) { writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Src, avatar); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); // Img } writer.RenderEndTag(); // Td writer.RenderEndTag(); // Tr } // End user information table writer.RenderEndTag(); // Table writer.RenderEndTag(); // Td // Start row which will display subject, body and actions (reply, edit, etc) writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRow"); writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top"); writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); if (forumView != ForumUtils.ForumView.FlatView && !selected) { writer.AddAttribute(HtmlTextWriterAttribute.Height, "100%"); } if (forumView == ForumUtils.ForumView.TreeViewDynamic) { writer.AddAttribute(HtmlTextWriterAttribute.Id, PostID.ToString() + "_headercell"); } writer.RenderBeginTag(HtmlTextWriterTag.Td); // Start a new table for this information writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "3"); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); if (forumView != ForumUtils.ForumView.FlatView && !selected) { writer.AddAttribute(HtmlTextWriterAttribute.Height, "100%"); } writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); if (forumView == ForumUtils.ForumView.TreeViewDynamic) { writer.AddAttribute(HtmlTextWriterAttribute.Id, PostID.ToString() + "_messagetable"); } writer.RenderBeginTag(HtmlTextWriterTag.Table); // Highlighted row (subject and when posted information) writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal"); writer.RenderBeginTag(HtmlTextWriterTag.Tr); if (forumView != ForumUtils.ForumView.FlatView) { RenderLevelIndentCell(writer); } writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRowHighlight"); writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.RenderBeginTag(HtmlTextWriterTag.B); writer.AddAttribute(HtmlTextWriterAttribute.Name, PostID.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.RenderEndTag(); // Provide link to select a different post writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}", PostID), "forumaction=&searchpage=&threadspage=") + "#" + PostID); if (forumView == ForumUtils.ForumView.TreeViewDynamic) { writer.AddAttribute(HtmlTextWriterAttribute.Id, "DynMessLink"); writer.AddAttribute(HtmlTextWriterAttribute.Name, PostID.ToString()); } writer.RenderBeginTag(HtmlTextWriterTag.A); ForumText subjectForumText = new ForumText(Subject); writer.Write(subjectForumText.ProcessSingleLine(images)); writer.RenderEndTag(); // A writer.RenderEndTag(); // B // Display new image if this post is new since last time user visited if (lastVisited < PostDate) { writer.AddAttribute(HtmlTextWriterAttribute.Src, images + "new.gif"); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); } writer.RenderBeginTag(HtmlTextWriterTag.Br); writer.Write(string.Format("Posted: {0} {1}", PostDate.ToString("dd MMM yy"), PostDate.ToString("t"))); writer.RenderEndTag(); // Br writer.RenderEndTag(); // Td writer.RenderEndTag(); // Tr // Message row if ((selected && forumView == ForumUtils.ForumView.TreeView) || forumView != ForumUtils.ForumView.TreeView) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal"); if (forumView == ForumUtils.ForumView.TreeViewDynamic) { writer.AddAttribute(HtmlTextWriterAttribute.Id, PostID.ToString() + "_messagerow"); if (!selected) { writer.AddStyleAttribute("display", "none"); } } writer.RenderBeginTag(HtmlTextWriterTag.Tr); if (forumView != ForumUtils.ForumView.FlatView) { RenderLevelIndentCell(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Td); ForumText bodyForumText = new ForumText(Body); writer.Write(bodyForumText.Process(images)); writer.RenderEndTag(); // Td writer.RenderEndTag(); // Tr } // Reply, Quote, Edit, Get Link row if (displayActions && ((selected && forumView == ForumUtils.ForumView.TreeView) || forumView != ForumUtils.ForumView.TreeView)) { if (forumView == ForumUtils.ForumView.TreeViewDynamic) { writer.AddAttribute(HtmlTextWriterAttribute.Id, PostID.ToString() + "_actionsrow"); if (!selected) { writer.AddStyleAttribute("display", "none"); } } writer.RenderBeginTag(HtmlTextWriterTag.Tr); if (forumView != ForumUtils.ForumView.FlatView) { RenderLevelIndentCell(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Td); writer.AddAttribute(HtmlTextWriterAttribute.Border, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal"); writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); writer.AddAttribute(HtmlTextWriterAttribute.Align, "Left"); writer.RenderBeginTag(HtmlTextWriterTag.Td); // Reply link writer.Write("["); writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}&forumaction=reply", PostID), "searchpage=&threadspage=")); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write("Reply"); writer.RenderEndTag(); // A writer.Write("]"); // Quote link writer.Write("["); writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}&forumaction=quote", PostID), "searchpage=&threadspage=")); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write("Quote"); writer.RenderEndTag(); // A writer.Write("]"); if (forumView == ForumUtils.ForumView.TreeViewDynamic) { // Get Link writer.Write("["); writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}", PostID), "forumaction=&searchpage=&threadspage=") + "#" + PostID); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write("Get Link"); writer.RenderEndTag(); // A writer.Write("]"); } writer.RenderEndTag(); // Td writer.AddAttribute(HtmlTextWriterAttribute.Align, "Right"); writer.RenderBeginTag(HtmlTextWriterTag.Td); // Edit link (only allowed if this post by currently logged on user or an administrator) if (User.UserID == loggedOnUserID || page.User.IsInRole("ForumAdmin")) { writer.Write("["); writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}&forumaction=edit", PostID), "searchpage=&threadspage=")); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write("Edit"); writer.RenderEndTag(); // A writer.Write("]"); } writer.RenderEndTag(); // Td writer.RenderEndTag(); // Tr writer.RenderEndTag(); // Table writer.RenderEndTag(); // Td writer.RenderEndTag(); // Tr } // Close out table and this row writer.RenderEndTag(); // Table writer.RenderEndTag(); // Td writer.RenderEndTag(); // Tr }
public static ForumPostCollection GetThread(int threadID, int threadPage, int postsPerPage, ForumUtils.ForumView forumView) { SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["RiversideInternetForumsConnectionString"]); SqlCommand cmd = new SqlCommand("WS_GetThread", conn); bool flatView = (forumView == ForumUtils.ForumView.FlatView); // Populate parameters cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ThreadID", SqlDbType.Int, 4); cmd.Parameters.Add("@ThreadPage", SqlDbType.Int, 4); cmd.Parameters.Add("@PostsPerPage", SqlDbType.Int, 4); cmd.Parameters.Add("@FlatView", SqlDbType.Bit, 1); cmd.Parameters[0].Value = threadID; cmd.Parameters[1].Value = threadPage; cmd.Parameters[2].Value = postsPerPage; cmd.Parameters[3].Value = flatView; conn.Open(); ForumPostCollection forumPostCollection = new ForumPostCollection(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ForumPost forumPost = PopulateForumPost(dr); forumPost.PostID = Convert.ToInt32(dr["PostID"]); forumPostCollection.Add(forumPost); } dr.Close(); conn.Close(); return(forumPostCollection); }
private void ViewDropDownList_SelectedIndexChanged(Object sender, EventArgs e) { // Either tree view or flat view has been selected from the view drop down list. // We need to update the user's preference in the Forum_View cookie. Maybe this // setting would be better stored in a user profile (in the database). _forumView = ForumUtils.GetForumViewFromString(_viewDropDownList.SelectedItem.Value); ForumUtils.SetForumView(Page, _forumView); _viewDropDownSelected = true; }
public static int GetPostFromThreadAndPage(int threadID, int threadPage, int postsPerPage, ForumUtils.ForumView forumView) { SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["RiversideInternetForumsConnectionString"]); SqlCommand cmd = new SqlCommand("WS_GetPostFromThreadAndPage", conn); bool flatView = (forumView == ForumUtils.ForumView.FlatView); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@ThreadID", SqlDbType.Int, 4); cmd.Parameters.Add("@ThreadPage", SqlDbType.Int, 4); cmd.Parameters.Add("@PostsPerPage", SqlDbType.Int, 4); cmd.Parameters.Add("@FlatView", SqlDbType.Bit, 1); cmd.Parameters.Add("@PostID", SqlDbType.Int, 4); cmd.Parameters[0].Value = threadID; cmd.Parameters[1].Value = threadPage; cmd.Parameters[2].Value = postsPerPage; cmd.Parameters[3].Value = flatView; cmd.Parameters[4].Direction = ParameterDirection.Output; conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); return((int)cmd.Parameters[4].Value); }