<!--#include file="../conn.asp" -->
<%
if session("username")="" then
response.Redirect("merr.asp?action=err")
response.End()
else
username=session("username")
userid=session("userid")
end if
%>
<%
userid=session("userid")
if request("a")="edit" then
set rs=server.CreateObject("adodb.Recordset")
sql2="select * from diarytype where userid="&userid&" and id="&request("flmcid")
Rs.Open Sql2,conn,1,3
IF Not Rs.Eof Then
rs("type")=request("flmc")
rs.update
else
response.Write("<script language=JavaScript>alert('找不到要修改的分类,请重试.')</script>")
end if
rs.close
set rs=nothing
set sql2=nothing
end if
if request("a")="add" then
set rs=server.CreateObject("adodb.Recordset")
sql2="select * from diarytype"
Rs.Open Sql2,conn,1,3
Rs.addnew
rs("type")=request("addflmc")
rs("userid")=userid
rs.update
rs.close
set rs=nothing
set sql2=nothing
end if
if request("a")="del" then
set rs=server.CreateObject("adodb.Recordset")
SQL22 = "SELECT count(*) FROM diarytype WHERE userid="&userid&""
Rs.Open Sql22,conn,1,1
Count = rs(0)
if Count=1 then response.Write("<script language=JavaScript>alert('禁止删除最后一个分类!');history.back();</script>")
set sql22=nothing
rs.close
set rs=nothing

set rs=server.CreateObject("adodb.Recordset")
sql222="SELECT count(*) FROM diary WHERE userid="&userid&" and typeid="&request("fid")
Rs.Open Sql222,conn,1,1
Countrj = rs(0)
if Countrj>0 then response.Write("<script language=JavaScript>alert('此"&sql222&"分类下还有文章!');history.back();</script>")
set sql222=nothing
rs.close
set rs=nothing

set rs=server.CreateObject("adodb.Recordset")
sql2="select * from diarytype where userid="&userid&" and id="&request("fid")
Rs.Open Sql2,conn,1,3
IF Not Rs.Eof Then
Rs.delete
else
response.Write("<script language=JavaScript>alert('找不到要删除的分类,请重试.')</script>")
end if
rs.close
set rs=nothing
set sql2=nothing
end if
set rs=server.CreateObject("adodb.Recordset")
sql2="select * from diaryuser where userid="&userid&""
Rs.Open Sql2,conn,1,1
IF Not Rs.Eof Then
money=rs("money")
fenmian=rs("fenmian")
shuyu=rs("shuyu")
name=rs("username")
bookname=rs("bookname")
gongao=rs("gongao")
amount=rs("amount")
showinfo=rs("showinfo")
showbook=rs("showbook")
Musicyesno=rs("musicyesno")
rs.close
sql2="select * from diarytype where userid="&userid&" order by id desc"
%>
<html>
<head>
<title>我的日记管理列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<link href="../diary/css.css" rel="stylesheet" type="text/css">
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0"  style="background-color=transparent">
<table width="284" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td height="370" width="284" align="right">
      <table border="0" width="278" id="table8" cellspacing="0" cellpadding="0" height="370">
        <tr> 
          <td height="19" colspan="3">　</td>
        </tr>
        <tr> 
          <td height="19" width="16"></td>
          <td height="19" width="200">日记分类</td>
          <td height="19" width="62" align="right"><a href="#" onclick="document.all.editfl.style.display='none';document.all.addfl.style.display='block';">添加</a>&nbsp;</td>
        </tr>
        <tr> 
          <td background="<%=alltubg%>linebg2.gif" colspan="3" height="1"><img border="0" src="<%=alltubg%>linebg2.gif" width="4" height="1"></td>
        </tr>
        <tr valign="top"> 
          <td colspan="3"> 
            <table border="0" width="100%" id="table9" cellspacing="0" cellpadding="0">
              <tr> 
                <td> 
                  <table width="100%" border="0" cellspacing="0" cellpadding="0" id="table10">
                    <tr> 
                      <td align="center" style="font-size: 9pt; font-family: Verdana; color: #000000; letter-spacing: 1pt; word-break: break-all" background="img/bg_line.gif"> 
<%
Rs.Open Sql2,conn,3,1
IF Rs.Eof and rs.bof Then
response.Write("<br><font color=FF6600>你还没有填写任何日记！<a href=add.asp target=_parent>填写</a></font><br><br><br><br><br><br>")
else


rs.pagesize=showdiary
maxpage=rs.pagecount
page=clng(request("page"))


if page="" or page=0 then
   page=1
end if
if page>maxpage then
    page=maxpage
end if

rs.absolutepage = page

do while not rs.eof
%>
                        <table width="98%" border="0" cellpadding="0" cellspacing="0"  id="table11">
                          <tr bordercolor="DDE7AB"> 
                            <td width="2"></td>
                            <td width="16">&nbsp;</td>
                            <td width="151"><font color="#51300C"><a target="_blank" href="#"> 
                              <font color="#800000"><%= rs("type") %></font></a></font></td>
                            <td width="33">&nbsp;</td>
                            <td width="39"><a href="#" onclick="document.all.addfl.style.display='none';document.all.editfl.style.display='block';document.all.flmc.value='<%= rs("type") %>';document.all.flmcid.value='<%= rs("id") %>';"> 
                              <font color="#51300C">改</font></a>&nbsp;<a href="?a=del&fid=<%=rs("id")%>" onClick="{if(confirm('您真的要删除此分类吗?此操作不可恢复!')){return true;}return false;}" target="_self"><font color="#51300C">删</font></a> 
                            </td>
                          </tr>
                        </table>
                        <%
n=n+1
rs.movenext
if n>=rs.pagesize then exit do    
loop
%>
                        <br>
                        <table width="98%" border="0" cellspacing="0" cellpadding="0" id="table13">
                          <tr> 
                            <td> 
                              <p align="right"> 
                                <%
if cstr(page)=1 then
Response.Write("<font color=#808080>首页&nbsp;上页&nbsp;</font>")
else
if page>1 and page=maxpage then%>
                                <a href="mdiarylist.asp?page=1"> <font color="#5690BE">首页</font></a> 
                                <a href="mdiarylist.asp?page=<%=page-1%>"> <font color="#5690BE">上页</font></a> 
                                <%end if%>
                                <% if page<>1 and page<>maxpage then%>
                                <a href="mdiarylist.asp?page=1"> <font color="#5690BE">首页</font></a><a href="mdiarylist.asp?page=<%=page-1%>"> 
                                <font color="#5690BE">上页</font></a> 
                                <%end if
end if


if cstr(page)=cstr(rs.pagecount) then%>
                                <font color="#808080">下页</font> <font color="#808080">尾页</font> 
                                <%else%>
                                <%
			if cstr(page)=1 and cstr(page)<>cstr(rs.pagecount) and cstr(rs.pagecount)<>0 then%>
                                <a href="mdiarylist.asp?page=<%=page+1%>" > <font color="#5690BE">下页</font></a> 
                                <a href="mdiarylist.asp?page=<%=maxpage%>"> <font color="#5690BE">尾页</font></a> 
                                <%end if%>
                                <%
			if cstr(page)<>1 and cstr(page)<>cstr(rs.pagecount) and cstr(rs.pagecount)<>0 then%>
                                <a href="mdiarylist.asp?page=<%=page+1%>" > <font color="#5690BE">下页</font></a> 
                                <a href="mdiarylist.asp?page=<%=maxpage%>"> <font color="#5690BE">尾页</font></a> 
                                <%end if%>
                                <%end if%>
                                <font color="#5690BE"> 页次:<%=page%>/<%=maxpage%>&nbsp; 
                                &nbsp; </font> 
                            </td>
                          </tr>
                        </table>
                        <%
Rs.Close
Set Rs=Nothing
End IF
else%>
                        <table width="98%" border="0" cellspacing="0" cellpadding="0" id="table14">
                          <tr> 
                            <td align="center" style="font-size: 9pt; font-family: Verdana; color: #000000; letter-spacing: 1pt; word-break: break-all">　</td>
                          </tr>
                        </table>
                        <%
end if
%>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<div id="editfl" style="display:none;position:absolute;left:80px;top:10px;padding:5px;width:220px;height:15px;"><form name="form1" method="post" action="?a=edit">
    <input type="text" id="flmc" name="flmc" size="12" maxlength="12"><input type="hidden" id="flmcid" name="flmcid" size="12" maxlength="12">
    <input type="submit" name="Submit" value="更改分类"> <input type="button" onclick="document.all.editfl.style.display='none';" name="Submit" value="取消">
</form>
</div>
<div id="addfl" style="display:none;position:absolute;left:80px;top:10px;padding:5px;width:220px;height:15px;"><form name="form1" method="post" action="?a=add">
    <input type="text" id="addflmc" name="addflmc" size="12" maxlength="12"><input type="hidden" id="addflmcid" name="addflmcid" size="12" maxlength="12">
    <input type="submit" name="Submit" value="添加名称"> <input type="button" onclick="document.all.addfl.style.display='none';" name="Submit" value="取消">
</form>
</div>
</body>
</html>



