<!--#include file="../include/Conn.jsp"-->
<!--#include file="../Include/Char.jsp" -->
<!--#include file="Admin_IsLogin.jsp" -->
<%
'Define Variable 
dim i
dim rs
dim mGrade,mSql,mFlag,mBgColor
Set rs=Server.createobject("Adodb.RecordSet")
'initialization 
mFlag=true'add

'Display
if request("action")="edit" then 
 'Read
 mSql="Select * From Photo_Album Where F_ID="&Request.QueryString("ModifyID")
 Set rs = conn.Execute(mSql)
 if Not rs.Eof then 
   mAlbumName = rs("F_AlbumName")
   mAddtime = rs("F_Addtime")
   mIPInfo = rs("F_IPInfo")
   mAlbumContent = rs("F_AlbumContent")
   mCategoryID = rs("F_CategoryID")
   mIsCommend = rs("F_IsCommend")
 End if
 mFlag=false
 rs.Close
end if

if Request.ServerVariables("REQUEST_METHOD")="POST" then
  mAlbumName = checkStr(Trim(Request.Form("txtAlbumName")))
  mCategoryID = checkStr(Trim(Request.Form("selCategory")))
  mAlbumContent = checkStr(Trim(Request.Form("txtAlbumContent")))
  mIsCommend = checkStr(Trim(Request.Form("radIsCommend")))

  mSql = "UPDATE Photo_Album SET"
  mSql = mSql+" F_AlbumName='"&mAlbumName&"',"
  mSql = mSql+" F_CategoryID='"&mCategoryID&"',"
  mSql = mSql+" F_AlbumContent='"&mAlbumContent&"',"
  mSql = mSql+" F_IsCommend='"&mIsCommend&"'" 
  mSql = mSql +" WHERE F_ID=" & Request("ModifyID") 
  conn.Execute(mSql)
  Response.redirect "Admin_Album.jsp?action=IsModify&pageno="&Request("pageno")
End if

'Delect Records
if request("action")="Delete" then
  mDeleteID = Request.QueryString("DeleteID")
  
  mSql = "DELETE FROM Photo_Album WHERE F_ID = " & mDeleteID
  conn.execute mSql
  mSql = "SELECT * FROM Photo_AlbumList WHERE F_AlbumID = " & mDeleteID

  
  rs.Open mSql,conn,1,3
  Do While Not rs.Eof 
    rs.delete
    rs.MoveNext
  Loop
  Response.write "<script>location.replace('Admin_Album.jsp?action=IsDelete&pageno="&Request.Querystring("pageno")&"')</script>"
end if
%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="Images/Style.css" rel="stylesheet" type="text/css">
<SCRIPT language="JavaScript">
function jDelete(url)
{
  if((confirm(" 警告:请确定是否删除,删除后不能恢复! "))==true) 
	self.location=url+'&action=Delete';
}
</SCRIPT>
<script language="javascript">
function CheckData(){
  if (document.form1.txtUserName.value=="")
   {
    alert("对不起,用户名不能为空，请输入！");
	document.form1.txtUserName.focus();
	return false;
   }
}
</script>
</head>
<body text="#000000" >

	  <%
      admin_flag=",4|7|0,"
      if instr(session("flag"),admin_flag)=0 or isnull(session("flag"))=true then
         Response.write "<br><br><br><br><b><font color=red>对不起，您没有管理本页面的权限!</font></B>"
		 Response.end
	  end if
      %>
<br>
<table class=tableBorder width="95%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#ebeef6">
  <tr> 
    <th height=21 colspan="8" sytle="line-height:150%">相册管理</th>
  </tr>
  <tr > 
    <td class=forumHeaderBackgroundAlternate width="6%" align="center"><b>ID</b></td>
    <td class=forumHeaderBackgroundAlternate width="23%"><b>相册名称</b></td>
    <td class=forumHeaderBackgroundAlternate align="center"><strong>相册分类</strong></td>
    <td class=forumHeaderBackgroundAlternate width="13%" align="center"><b>拥有者</b></td>
    <td class=forumHeaderBackgroundAlternate width="10%" align="center"><strong>创建时间</strong></td>
    <td class=forumHeaderBackgroundAlternate width="5%" align="center"><b>推荐</b></td>
    <td class=forumHeaderBackgroundAlternate width="6%" align="center"><strong>张数</strong></td>
    <td class=forumHeaderBackgroundAlternate width="15%" align="center"><b>管理</b></td>
  </tr>
  <%  'Photo_ViewAlbumSearch
    pageno=request.querystring("pageno")
    pmcount=20  
    mSql="select * from Photo_ViewAlbumSearch order by F_ID desc"
	rs.open mSql,conn,1,1

	if rs.eof then
	   'response.write "<br><p  align='center'><font color=red><B> 对不起，数据已清空！</B></font></p>"
    else
    rs.pagesize=pmcount
    mpage=rs.pagecount
    if pageno="" then pageno=1
    if  cint(pageno)<1 or cint(pageno)>mpage then  pageno=1
    rs.absolutepage=pageno

 Dim rc,re
 rc=rs.pagesize
 re=1
 do while not rs.eof and rc>0
 mBgColor=Request.Querystring("BgColor")
 if Trim(rs("F_ID"))=Trim(mBgColor) then mColor= "D6DFFF" else mColor= "ffffff"

  m_SQL = "SELECT TOP 1 F_UserID,F_Image FROM Photo_AlbumList WHERE F_AlbumID="&rs("F_ID") & "order by F_Hits DESC"
					  Set rst = conn.Execute(m_SQL)
					  if not rst.Eof then  m_TempImage = rst("F_UserID")&"/"&rst("F_Image") else m_TempImage = "DefaultImage.jpg"
                      rst.close

%>
  <tr bgcolor="<%=mColor%>"   onmouseout="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#EBEEF6'" > 
    <td class=forumRow align="center"><%=rs("F_ID")%></td>
    <td class=forumRow > <a target="_blank" href="../club/photo_album.jsp?ID=<%=rs("F_ID")%>"><img src="../club/upfile/SmallImages/<%=m_TempImage%>" width="91" height="64"  border="0"></a><br>

				<%
				   Response.write "<a target='_blank' title="&rs("F_AlbumName")&" href='../club/photo_album.jsp?ID="&rs("F_ID")&"'>"
				   Response.write rs("F_AlbumName")
				   Response.write "</a>"
				  
				  
				  %>
				  
				  
				   </td>
    <td class=forumRow align="center" ><%=rs("F_CategoryName")%></td>
    <td class=forumRow align="center" ><%=rs("F_UserName")%></td>
    <td align="center" class=forumRow ><%=rs("F_Addtime")%></td>
    <td align="center" class=forumRow >
      <%
			'推荐处理
			if Request("action") = "IsCommend" then
			  mIsCommend = Request("IsCommend")
			  if mIsCommend=1 then mIsCommend = 0 else mIsCommend = 1
			  mSql = "update Photo_Album Set F_IsCommend= "&mIsCommend&" Where F_ID="&Request("ID")
              conn.execute(mSql)
			  Response.redirect "Admin_Album.jsp?pageno="&Request("pageno")
			end if
			Response.Write "<a href='Admin_Album.jsp?action=IsCommend&IsCommend="&rs("F_IsCommend")&"&pageno="&Request("pageno")&"&ID="&rs("F_ID")&"'>"
			if rs("F_IsCommend")=1 then Response.Write "<font color=red>是</font>" Else Response.write "否"
			Response.Write "</a>"
			%>
    </td>
    <td class=forumRow align="center" > <%
						 m_Sql = "Select COUNT(*) From Photo_AlbumList Where F_AlbumID = "&rs("F_ID")
						 Set rst = conn.Execute(m_Sql)
						 Response.write rst(0):rst.close%> </td>
    <td class=forumRow align="center" ><a title="修改记录" href='Admin_Album.jsp?action=edit&ModifyID=<%=rs("F_ID")%>&BgColor=<%=rs("F_ID")%>&pageno=<%=cstr(pageno)%>#anModify'><font color="#666666">[修改]</font></a><a title="请确定是否删除,删除后不能恢复!" href="javascript:jDelete('Admin_Album.jsp?DeleteID=<%=rs("F_ID")%>&pageno=<%=cstr(pageno)%>')"><font color="#666666">[删除]</font></a></td>
  </tr>
  <%
 rs.movenext
 re=re+1
 rc=rc-1
 loop
 end if
%>
  <tr bgcolor="<%=mColor%>"   onmouseout="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#EBEEF6'" > 
    <td class=forumRow  align="center" colspan="8" ><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="38%" height="22"> &nbsp;共 <font color=red><strong> 
            <% = rs.recordcount%>
            </strong></font> 条记录 当前第 <font color=red><strong> 
            <% = Trim(pageno)%>
            </strong></font>页/共 <font color=red><strong> 
            <% = Trim(mpage)%>
            </strong></font>页 </td>
          <td width="62%" align="right"> <%
if pageno="" then pageno=1
if pageno>1 then
   response.write "<a href='Admin_Album.jsp'> <img alt='首页' src='Images/boqb02.gif' border=0 width='15' height='14'></a>"
else
   response.write "<img alt='首页' src='Images/boqb02.gif' border=0 width='15' height='14'>"
end if

if pageno>1 then
   response.write "<a href='Admin_Album.jsp?pageno="&pageno-1&"'><img alt='上一页' src='Images/bob02.gif' border=0 width='15' height='14'></a>"
else
   response.write "<img alt='上一页' src='Images/bob02.gif' border=0 width='15' height='14'>"
end if

add=5'数字分页个数+1
if pageno-int(add/2)<=1 then m=1 else m=pageno-int(add/2)
if m+add>mpage then 
   n=mpage
   if mpage-add<=1 then m=1 else m=mpage-add
else
   n=m+add
end if

for pno=m to n
 if pno=cint(pageno) then
   response.write "&nbsp;<font color=red>"&pno&"</font>"
 else
   response.write "<b>&nbsp;<a href='Admin_Album.jsp?pageno="&pno&"'>"&pno&"</a></b>"
 end if
next
response.write "&nbsp"

if int(pageno) < int(rs.pagecount) then
  response.write "<a href='Admin_Album.jsp?pageno="&pageno+1&"'><img alt='下一页' src='Images/fbob02.gif' border=0 width='15' height='14'></a>"
else 
  response.write "<img alt='下一页' src='Images/fbob02.gif' border=0 width='15' height='14'>"
end if

if int(pageno) < int(rs.pagecount) then
   response.write "<a href='Admin_Album.jsp?pageno="&mpage&"'><img alt='末页' src='Images/fboqb02.gif' border=0 width='15' height='14'></a>"
else
   response.write "<img alt='末页' src='Images/fboqb02.gif' border=0 width='15' height='14'>"
end if
Response.write "&nbsp;&nbsp;"
%> </td>
        </tr>
      </table></td>
  </tr>
</table> 
        
<br>
<%if mFlag=false then%>

            <form name="form1" method="post" action="Admin_Album.jsp?pageno=<%=request("pageno")%>&ModifyID=<%=request("ModifyID")%>" onSubmit="return CheckData()">
<table class=tableBorder  width="95%" border="0" align="center" cellpadding="2" cellspacing="1">
     <tr> 
      <th height=21 colspan="7" sytle="line-height:150%">修改记录</th>
    </tr>
                        <tr> 
                          <td class=forumRow width="12%" height="19">相册名称：</td>
                          <td class=forumRowHighlight width="88%">
						  <input name="txtAlbumName" class="INPUT" type="text"   value="<%=mAlbumName%>" size="21" maxlength="20"></td>
                        </tr>
                        <tr> 
                          <td class=forumRow width="12%" height="19">相册类别：</td>
                          <td class=forumRowHighlight width="88%">
						   <select name="selCategory"  class="SELECT">
                              <%
               mSql="Select * from Photo_Category ORDER BY F_Grade"
			   set rs = conn.Execute(mSql)
			   Do While Not rs.Eof 
			     if Trim(mCategoryID) = Trim(rs("F_ID")) then
     				response.write "<option value=" + cstr(rs("F_ID"))
           			response.write " selected"
       				response.write ">" + rs("F_Value")
                 else
                    response.write "<option value='" & rs("F_ID") &"'>"& rs("F_Value") &"</option>"
                 end if
		        rs.movenext
              loop
			  rs.close
			  %>
                            </select> </td>
                        </tr>
                        <tr> 
                          <td class=forumRow width="12%" height="19">相册推荐：</td>
                          <td class=forumRowHighlight width="88%"> 
						  <input  name="radIsCommend" type="radio" value="1" <%if mIsCommend = true then Response.write "checked"%> >
                            推荐 
                            <input type="radio" name="radIsCommend" value="0" <%if mIsCommend = false then Response.write "checked"%>>
                            不推荐</td>
                        </tr>
                        <tr> 
                          <td class=forumRow>相册介绍： </td>
                          <td class=forumRowHighlight><textarea class="INPUT" name="txtAlbumContent" cols="60" rows="6" ><%=mAlbumContent%></textarea></td>
                        </tr>
                        <tr> 
                          <td class=forumRow>注册时间：</td>
                          <td class=forumRowHighlight><%=mAddtime%></td>
                        </tr>
                        <tr>
                          <td class=forumRow>登陆ＩＰ：</td>
                          <td class=forumRowHighlight><%=mIPInfo%></td>
                        </tr>
                        <tr> 
                          <td class=forumRow height="37" colspan="2"><input type="submit" name="Submit3" value="提交" class="button"> 
        <input type="reSet" name="Submit22" value="重置" class="button"></td>
                        </tr>
                      </table>
            
  <br>
</form>
 <%end if%>
</body>
</html>
<%
 set rs=nothing
 conn.close
 set conn=nothing
%>