<!--#include file="Top.asp" -->
<%
Dim ClassName,ClassID,Values
GetErrInfo=" 【下面是您的日志分类列表,你可以对相应的分类进行修改或删除操作,如果没有分类,请加入或使用默认分类】"

IF CblogObj.FormRequest("Submit")="加入" Then
	ClassName=LEFT(CblogObj.FormRequest("Blog_Class"),20)
	IF ClassName="" Then
		GetErrInfo="<div class=""err""> 【操作失败提示：分类名不能为空】</div>"
	Else
		set rs=conn.execute("Select count(id) From [Tb_User_Class] Where User_id="& Session("UserID") &"")
		SqlCount=SqlCount+1
		IF RS(0)>=10 THEN
			GetErrInfo="<div class=""err""> 【操作失败提示：每个用户最多只能创建十个分类(日志+相册)!】</div>"
		ELSE
			ClassName=LEFT(CblogObj.FormRequest("Blog_Class"),20)
			Conn.Execute("INSERT INTO [Tb_User_Class](User_id,Blog_Class) VALUES("& Session("UserID") &",'"& ClassName &"')")
			SqlCount=SqlCount+1
			CblogObj.SaveUserClassXml(Session("UserID"))
			GetErrInfo=" <div class=""doen"">【操作成功提示:新增分类成功! 】</div>"
		END IF
		RS.CLOSE:SET RS=NOTHING
	End IF
End If

IF CblogObj.FormRequest("Submit")="修改" Then
	DIM ClassName2
	ClassName=LEFT(CblogObj.FormRequest("Blog_Class"),20)
	ClassName2=CblogObj.FormRequest("ClassName")
	ClassID=CblogObj.FormRequest("ClassID")
	IF ClassName="" Then
		GetErrInfo="<div class=""err""> 【操作失败提示：分类名不能为空】</div>"
	Else
		IF ISNUMERIC(ClassID) THEN
			Conn.Execute("UpDate [Tb_User_Class] Set Blog_Class='"& ClassName &"' Where User_ID="& Session("UserID") &" AND ID="& ClassID &"")
			ClassName=Right("0000000"&ClassID,7)&ClassName
			ClassName2=Right("0000000"&ClassID,7)&ClassName2
			Conn.execute "Update [Article] Set Article_ByClass='"& ClassName &"' Where User_id="& Session("UserID") &" And Article_ByClass='"& ClassName2 &"'"
			SqlCount=SqlCount+2
			CblogObj.SaveUserClassXml(Session("UserID"))
			GetErrInfo="<div class=""doen"">【 操作成功提示:你已成功将分类 ("& ClassName2 &") 修改成 ("& ClassName & ") 】</div>"
		Else
			GetErrInfo="<div class=""err"">【 操作失败提示：您的ID号错误!】</div>"
		End IF
	End IF
End If

IF CblogObj.GetRequest("ActIon")="DelClass" Then
	ClassID=CblogObj.IsCInt(CblogObj.GetRequest("ClassID"))
	Conn.Execute "Update [Article] Set Article_ByClass='0000000默认分类' Where Mid(Article_ByClass,8) = (Select Blog_Class FROM Tb_User_Class Where User_id="& Session("UserID") &" and ID ="& ClassID &")"
	Conn.Execute "Delete From Tb_User_Class Where User_id="& Session("UserID") &" and ID ="& ClassID &""
	CblogObj.SaveUserClassXml(Session("UserID"))
	SqlCount=SqlCount+2
	GetErrInfo="<div class=""doen"">【 操作成功提示:您已成功删除您所选中的分类,并且系统已将属于该分类的日志归档到默认分类下 】</div>"
End IF

Set Rs=Conn.execute("Select ID,Blog_Class from Tb_User_Class where User_id="& Session("UserID") &" And Photo=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

If CblogObj.GetRequest("ClassID")<>"" Then
	ClassName = CblogObj.GetRequest("ClassName")
	ClassID = CblogObj.GetRequest("ClassID")
	Values="修改"
Else
	ClassName = ""
	ClassID = ""
	Values="加入"
End If
%>

<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_GroupByClass.Asp">日志分类</a></div></td>
          <td>-</td>
          <td width="120" class="box3"> <div align="center"><a href="Article_Add.Asp">发布日志</a></div></td>
          <td>-</td>
          <td width="120" class="box3"> <div align="center"><a href="Article_List.Asp">日志列表</a></div></td>
          <td>-</td>
          <td width="120" class="box3"> <div align="center"><a href="Comments_List.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/user.gif" width="20" height="20"></div></td>
                <td width="456"><%=ClassArr(1,iii)%></td>
                <td width="30"> <div align="center"><a href="?ClassID=<%=ClassArr(0,iii)%>&ClassName=<%=server.URLEncode(ClassArr(1,iii))%>">修改</a></div></td>
                <td width="30"> <div align="center"><a href="?Action=DelClass&ClassID=<%=ClassArr(0,iii)%>"><img src="img/cross.gif" alt="删除" width="14" height="13" border="0" /></a></div></td>
              </tr>
              <%
		Next
		ClassArr=Empty
		Else
			Response.Write ("<tr bgcolor=""#efefef""><td width=""17""><div align=""center""><img src=""img/user.gif"" width=""20"" height=""20""></div></td><td>默认分类</td><td width=""30""><div align=""center""><a href=""#"" title=""默认分类不需修改，你创建新分类后会自动删除"">修改</a></div></td>")
			Response.Write ("<td width=""30""><div align=""center""><img src=""img/cross.gif"" width=""14"" height=""13"" alt=""默认分类不用删除，你创建分类后会自动删除"" /></div></td></tr>")
		End If
		%>
            </table></td>
        </tr>
        <tr> 
          <td><div align="center"> 
              <form name="form1" method="post" action="">
                <input name="ClassName" type="hidden" id="ClassName" value="<%=ClassName%>">
                <input name="ClassID" type="hidden" value="<%=ClassID%>">
                <input name="Blog_Class" type="text" value="<%=ClassName%>" maxlength="20">
                <input name="Submit" type="submit" value="<%=Values%>">
                <%IF Values="修改" Then Response.Write "<input name=""Submit"" type=""submit"" value=""加入"">"%>
              </form>
            </div></td>
        </tr>
      </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" -->
