Пример #1
0
        private void BindGroups()
        {
            drpForums.Items.Add(new ListItem(Utilities.GetSharedResource("DropDownSelect"), "-1"));
            Data.ForumsDB   fdb            = new Data.ForumsDB();
            ForumCollection allForums      = fdb.Forums_List(PortalId, ModuleId);
            ForumCollection filteredForums = new ForumCollection();

            foreach (Forum f in allForums)
            {
                if (f.ForumGroup.Active && f.Active && f.ParentForumId == 0)
                {
                    f.TabId     = TabId;
                    f.SubForums = GetSubForums(allForums, f.ForumID);
                    filteredForums.Add(f);
                }
            }
            int tmpGroupId = -1;

            foreach (Forum f in filteredForums)
            {
                if (!(tmpGroupId == f.ForumGroupId))
                {
                    drpForums.Items.Add(new ListItem(f.GroupName, "GROUP" + f.ForumGroupId.ToString()));
                    tmpGroupId = f.ForumGroupId;
                }
                drpForums.Items.Add(new ListItem(" - " + f.ForumName, "FORUM" + f.ForumID.ToString()));
                if (f.SubForums != null && f.SubForums.Count > 0)
                {
                    foreach (Forum ff in f.SubForums)
                    {
                        drpForums.Items.Add(new ListItem(" ---- " + ff.ForumName, "FORUM" + ff.ForumID.ToString()));
                    }
                }
            }
            //Dim dr As IDataReader = DataProvider.Instance.Forums_List(PortalId, ModuleId, -1, -1, False)


            //While dr.Read
            //    If Not tmpGroupId = CInt(dr("ForumGroupId")) Then
            //        drpForums.Items.Add(New ListItem(dr("GroupName").ToString, "GROUP" & dr("ForumGroupId").ToString))
            //        tmpGroupId = CInt(dr("ForumGroupId"))
            //    End If
            //    If Not CInt(dr("ForumId")) = 0 Then
            //        If CInt(dr("ParentForumID")) = 0 Then
            //            drpForums.Items.Add(New ListItem(" - " & dr("ForumName").ToString, "FORUM" & dr("ForumId").ToString))
            //        End If
            //        'If CInt(dr("ParentForumID")) > 0 Then
            //        '    drpForums.Items.Add(New ListItem(" ---- " & dr("ForumName").ToString, "FORUM" & dr("ForumId").ToString))
            //        'End If
            //    End If
            //End While
            //dr.Close()
        }
Пример #2
0
        private ForumCollection GetSubForums(ForumCollection forums, int forumId)
        {
            ForumCollection subforums = null;

            foreach (Forum s in forums)
            {
                if (s.ParentForumId == forumId)
                {
                    if (subforums == null)
                    {
                        subforums = new ForumCollection();
                    }
                    s.TabId = TabId;
                    subforums.Add(s);
                }
            }
            return(subforums);
        }
		private ForumCollection GetSubForums(ForumCollection forums, int forumId)
		{
			ForumCollection subforums = null;
			foreach (Forum s in forums)
			{
				if (s.ParentForumId == forumId)
				{
					if (subforums == null)
					{
						subforums = new ForumCollection();
					}
					s.TabId = TabId;
					subforums.Add(s);
				}
			}
			return subforums;
		}
		private void BindGroups()
		{
			drpForums.Items.Add(new ListItem(Utilities.GetSharedResource("DropDownSelect"), "-1"));
			Data.ForumsDB fdb = new Data.ForumsDB();
			ForumCollection allForums = fdb.Forums_List(PortalId, ModuleId);
			ForumCollection filteredForums = new ForumCollection();
			foreach (Forum f in allForums)
			{
				if (f.ForumGroup.Active && f.Active && f.ParentForumId == 0)
				{
					f.TabId = TabId;
					f.SubForums = GetSubForums(allForums, f.ForumID);
					filteredForums.Add(f);
				}
			}
			int tmpGroupId = -1;
			foreach (Forum f in filteredForums)
			{
				if (! (tmpGroupId == f.ForumGroupId))
				{
					drpForums.Items.Add(new ListItem(f.GroupName, "GROUP" + f.ForumGroupId.ToString()));
					tmpGroupId = f.ForumGroupId;
				}
				drpForums.Items.Add(new ListItem(" - " + f.ForumName, "FORUM" + f.ForumID.ToString()));
				if (f.SubForums != null && f.SubForums.Count > 0)
				{
					foreach (Forum ff in f.SubForums)
					{
						drpForums.Items.Add(new ListItem(" ---- " + ff.ForumName, "FORUM" + ff.ForumID.ToString()));
					}
				}
			}
			//Dim dr As IDataReader = DataProvider.Instance.Forums_List(PortalId, ModuleId, -1, -1, False)


			//While dr.Read
			//    If Not tmpGroupId = CInt(dr("ForumGroupId")) Then
			//        drpForums.Items.Add(New ListItem(dr("GroupName").ToString, "GROUP" & dr("ForumGroupId").ToString))
			//        tmpGroupId = CInt(dr("ForumGroupId"))
			//    End If
			//    If Not CInt(dr("ForumId")) = 0 Then
			//        If CInt(dr("ParentForumID")) = 0 Then
			//            drpForums.Items.Add(New ListItem(" - " & dr("ForumName").ToString, "FORUM" & dr("ForumId").ToString))
			//        End If
			//        'If CInt(dr("ParentForumID")) > 0 Then
			//        '    drpForums.Items.Add(New ListItem(" ---- " & dr("ForumName").ToString, "FORUM" & dr("ForumId").ToString))
			//        'End If
			//    End If
			//End While
			//dr.Close()
		}