<!--#include file="Top.asp" -->
<%
Dim ClassName,ClassID,Values,ClassCode,SysCode
GetErrInfo=" 【以下是您所加入的部落,如果您想退出您加入的部落,可以点退出而退出您原先所加入的部落】"

IF CblogObj.GetRequest("ActIon")="exit" Then
	ClassID=CblogObj.IsCInt(CblogObj.GetRequest("ClassID"))
	Conn.Execute "Update [Article] Set Article_Bl=Null Where Article_Bl = (Select ClassName FROM Tb_BuoLuo Where Userid="& Session("UserID") &" and ID ="& ClassID &")"
	SqlCount=SqlCount+1
	Conn.Execute "Delete FROM Tb_BuoLuo Where Userid="& Session("UserID") &" and ID ="& ClassID &""
	SqlCount=SqlCount+1
	GetErrInfo=" <div class=""doen""> 【操作成功提示:您已成功退出此群】</div>"
End IF

IF CblogObj.GetRequest("ActIon")="add" Then
	IF Conn.Execute("Select count(id) From [Tb_BuoLuo] Where Userid="& Session("UserID") &" And Bid>0")(0)>10 THEN
		SqlCount=SqlCount+1
		GetErrInfo="<div class=""err""> 【操作失败提示：每个用户最多只能加入十个部落!】</div>"
	ELSE
		ClassID=CblogObj.IsCInt(CblogObj.GetRequest("ClassID"))
		If Conn.Execute("Select Count(id) From [Tb_BuoLuo] Where (UserID="& Session("UserID") &" And BID="& ClassID &") Or (UserID="& Session("UserID") &" And ID="&ClassID&")")(0)>0 Then
			SqlCount=SqlCount+2
			GetErrInfo=" <div class=""err"">【操作失败提示:您已在此部落中! 】</div>"
		Else
			Set Rs=Conn.Execute("Select ClassName,UserID From [Tb_BuoLuo] Where ID="& ClassID &"")
			ClassName=Rs(0)
			Dim Uid
			Uid=Rs(1)
			Rs.Close:Set Rs=Nothing
			Conn.Execute("INSERT INTO [Tb_BuoLuo](UserID,ClassName,Bid,Uid) VALUES("& Session("UserID") &",'"& ClassName & "' ,"& ClassID &","& UID &")")
			SqlCount=SqlCount+2
			GetErrInfo=" <div class=""doen"">【操作成功提示:加入部落成功! 】</div>"
		End IF
	End IF
End IF

Set Rs=Conn.execute("Select ID,ClassName,ClassCode,Bid,UserID from Tb_BuoLuo Where UserID="&Session("UserID")&" And Bid>0")
SqlCount=SqlCount+1
If Not RS.Eof and Not Rs.Bof then
	Dim ClassArr
	ClassArr=Rs.GetRows()
End If
RS.Close:Set Rs=NotHing
%>

<table width="99%" border="0" align="center" cellpadding="5" cellspacing="0">
  <tr> 
    <td height="30" bgcolor="#FFFFFF"><table width="300" border="0" align="right" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="120" class="box3"> <div align="center"><a href="Article_GroupByBl.Asp">我创建的部落</a></div></td>
          <td>-</td>
          <td width="120" class="box3"> <div align="center"><a href="Article_GroupByAddBl.Asp">我加入的部落</a></div></td>
          <td>-</td>
          <td width="120" class="box3"> <div align="center"><a href="Article_GroupByBlList.Asp">部落文章管理</a></div></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td height="30" bgcolor="#FFFFFF" class="h1"><img src="img/GuestBook.gif" width="23" height="21"> 
      我加入的部落管理 
      <hr size="0"></td>
  </tr>
  <tr> 
    <td valign="top" bgcolor="#FFFFFF" class="h1"> <table width="100%" border="0" cellspacing="0" cellpadding="10">
        <tr> 
          <td class="box"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td width="2%" valign="middle"><img src="img/3.gif" width="16" height="16"></td>
                <td width="98%" valign="middle"><%=GetErrInfo%></td>
              </tr>
            </table></td>
        </tr>
        <tr> 
          <td><table width="578" border="0" align="center" cellpadding="5" cellspacing="1" class="box">
              <%
		  If IsArray(ClassArr) Then
		  For iii=0 TO Ubound(ClassArr,2)
		  %>
              <tr bgcolor="#EFEFEF"> 
                <td width="17"> <div align="center"><img src="img/hy.gif" width="16" height="16"></div></td>
                <td width="456"> <%=ClassArr(1,iii)%> </td>
                <td width="30"> <div align="center"> <a href="?ClassID=<%=ClassArr(0,iii)%>&Action=exit">退出</a> 
                  </div></td>
              </tr>
              <%
		Next
		ClassArr=Empty
		Else
			Response.Write ("<tr bgcolor=""#efefef""><td colspan=""4""><div align=""center"">对不起，您还没有加入任何部落！</div></td></tr>")
		End If
		%>
            </table></td>
        </tr>
        <form name="form1" method="get" action="">
          <tr> 
            <td class="box"> <div align="center"> 部落分类: 
                <%CBlogObj.ClassCodeList SESSION("User_Class"),"TB_SYS_CLASS","ClassCodelist","部落"%>
                <input name="key" type="text" size="10">
                <input type="submit" name="Submit" value="查询">
                您可以查询部落,查到后点加入即可加入部落!</div></td>
          </tr>
        </form>
      </table>
      <br> <table width="578" border="0" align="center" cellpadding="5" cellspacing="1" class="box">
        <%
		  Dim Sqlstring
		  IF CblogObj.GetRequest("key")<>"" Then
			  IF CblogObj.GetRequest("BlogClass")<>"" Then
				  ClassCode=CblogObj.GetRequest("BlogClass")
			  Else
				  ClassCode=SESSION("User_Class")
			  End IF
				Sqlstring="Select ID,ClassName,Bid from Tb_BuoLuo Where Bid=0 And ClassCode Like '"& ClassCode &"%' And ClassName like '%"&CblogObj.GetRequest("key")&"%'"
				Set Rs=Conn.execute(Sqlstring)
				SqlCount=SqlCount+1
				If Not RS.Eof and Not Rs.Bof then
					Dim ClassArrr
					ClassArrr=Rs.GetRows()
				End If
				RS.Close:Set Rs=NotHing
		  End IF
		  If IsArray(ClassArrr) Then
		  For iii=0 TO Ubound(ClassArrr,2)
		  %>
        <tr bgcolor="#EFEFEF"> 
          <td width="17"> <div align="center"><img src="img/hy.gif" width="16" height="16"></div></td>
          <td width="456"> <%=ClassArrr(1,iii)%> </td>
          <td width="30"> <div align="center"> <a href="?ClassID=<%=ClassArrr(0,iii)%>&Action=add">加入</a></div></td>
        </tr>
        <%
		Next
		ClassArrr=Empty
		End If
		%>
      </table></td>
  </tr>
  <tr> 
    <td bgcolor="#FFFFFF">&nbsp;</td>
  </tr>
  <tr bgcolor="#0066CC" height="2"> 
    <td height="2"></td>
  </tr>
</table>
<!--#include file="Foot.asp" -->
