<!--#include file="../include/Conn.jsp"-->
<!--#include file="Admin_IsLogin.jsp" -->
<%
'Define Variable 
dim i
dim rs,rst
dim mTypeName,mGrade,mSql,mFlag,mBgColor
Set rs=Server.CreateObject("Adodb.RecordSet")
''''''----------------------------------------
'提升排序
if request("action")="add_index" then
  f_ArticleID=request("ArticleID")
 if f_ArticleID="" or IsNumeric(f_ArticleID)=false then
 Call Msgbox("对不起，ID号错误！",1)
 Response.end
 end if
 
 mSql="update t_club set f_index=f_index+1 where f_id="&f_ArticleID
  conn.execute mSql
  response.redirect "admin_club.jsp"
end if

'降低排序
if request("action")="div_index" then
 f_ArticleID=request("ArticleID")
 if f_ArticleID="" or IsNumeric(f_ArticleID)=false then
 Call Msgbox("对不起，ID号错误！",1)
 Response.end
 end if
 
 mSql="update t_club set f_index=f_index-1 where f_id="&f_ArticleID
  conn.execute mSql
  response.redirect "admin_club.jsp"
end if






'initialization 
mFlag=true'add
m_modifyid=Request.QueryString("ModifyID")

'edit
if request("action")="edit" then 
 
  mSql="Select * From T_club Where F_ID="&m_modifyid
  Set rs=Conn.Execute(mSql)
  If not rs.Eof then
    m_name=rs("F_name")
    m_manage_username=rs("F_manage_username")
	m_content=rs("F_content")
	m_area=rs("f_area")	
    rs.Close
  End if
  mFlag=false
end if

'Insert Records
'if request("action")="Insert" then
 ' mSql="Select * From T_FriendLink"
 ' rs.open mSql,conn,1,3
 ' rs.AddNew
'  rs("F_Value")=Trim(Request.Form("txtValue"))
 ' rs("F_Value2")=Trim(Request.Form("txtValue2"))
'  rs("F_Value3")=Trim(Request.Form("selTarget"))
 ' rs.update
'  rs.close
 ' response.redirect "admin_Link.jsp?action=IsInsert&pageno="&Request("pageno")
'end if

'Modify Records
if request("action")="editsave" then
  mSql="Select * From T_club Where F_ID="&m_ModifyID
  rs.open mSql,conn,1,3
  rs("F_name")=Trim(Request.Form("name"))

  new_manage=Trim(Request.Form("manage"))
  old_manage=rs("f_manage_username")
  if old_manage<>new_manage then
  rs("F_manage_username")=new_manage
    '进行修改主席变动修改
       m_Sql = "Update t_club_member Set "
       m_Sql = m_Sql +"F_identity='主席'"
       m_Sql = m_Sql +" Where F_club_ID="&m_ModifyID&" and f_username='"&new_manage&"'"
       conn.Execute(m_Sql)
	   m_Sql = "Update t_club_member Set "
       m_Sql = m_Sql +"F_identity='名誉主席'"
       m_Sql = m_Sql +" Where F_club_ID="&m_ModifyID&" and f_username='"&old_manage&"'"
       conn.Execute(m_Sql)
  end if
  rs("F_content")=Trim(Request.Form("content"))
  rs("F_area")=Trim(Request.Form("area"))
  rs.update
  response.redirect "admin_club.jsp?action=IsModify&pageno="&Request.Querystring("pageno")
  flag=false
end if

'Delect Records
if request("action")="delete" then
  m_DeleteID=Request.QueryString("DeleteID")
  '删除记录及相应文件
   
   mSql = "select f_photo,f_id FROM t_club WHERE F_ID=" &m_DeleteID
   Set rs_del=conn.execute(mSql)
   '删除图片文件
   del_id=rs_del("f_id")
   strUploadFiles=rs_del("f_photo")
	     if strUploadFiles<>"" then
				Set fso = CreateObject("Scripting.FileSystemObject")				
					if fso.FileExists(server.MapPath("../member/" & strUploadfiles)) then
						fso.DeleteFile(server.MapPath("../member/" & strUploadfiles))
					end if				
				Set fso = nothing
			end if
	'删除文件夹
			strUploadFiles=del_id
			  if strUploadFiles<>"" then
				Set fso = CreateObject("Scripting.FileSystemObject")				
				    if fso.FolderExists(server.MapPath("../member/ClubImages/" & strUploadfiles)) then
						fso.DeleteFolder(server.MapPath("../member/ClubImages/" & strUploadfiles))
				      end if				
				Set fso = nothing
			end if
   rs_del.close
   set rs_del=nothing
   
  mSql = "DELETE FROM t_club WHERE F_ID=" &m_DeleteID  '删除俱乐部
  conn.execute mSql
  mSql = "DELETE FROM t_club_member WHERE F_club_ID=" &m_DeleteID  '删除俱乐部下会员
  conn.execute mSql
    mSql = "DELETE FROM t_club_photo WHERE F_club_ID=" &m_DeleteID  '删除俱乐部下照片
  conn.execute mSql
    mSql = "DELETE FROM t_club_photobook WHERE F_club_ID=" &m_DeleteID  '删除俱乐部下照片评论
  conn.execute mSql
   mSql = "DELETE FROM t_club_book WHERE F_club_ID=" &m_DeleteID  '删除俱乐部留言
  conn.execute mSql
   mSql = "DELETE FROM t_club_board WHERE F_club_ID=" &m_DeleteID  '删除俱乐部公告
  conn.execute mSql
    mSql = "DELETE FROM t_club_meet WHERE F_club_ID=" &m_DeleteID  '删除俱乐部活动
  conn.execute mSql 
    mSql = "DELETE FROM T_club_meetmember WHERE F_club_ID=" &m_DeleteID  '删除俱乐部参加活动会员表
  conn.execute mSql
    mSql = "DELETE FROM t_club_meetbook WHERE F_club_ID=" &m_DeleteID  '删除俱乐部活动咨询留言表
  conn.execute mSql
  Response.write "<script>location.replace('admin_club.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.SignUpForm.name.value=="")
   {
    alert("俱乐部名称不能为空，请输入！");
	document.SignUpForm.name.focus();
	return false;
   }
  if (document.SignUpForm.content.value=="")
   {
    alert("介绍不能为空，请输入！");
	document.SignUpForm.content.focus();
	return false;
   }

}
</script>
</head>
<body text="#000000" >

<%
	admin_flag=",4|4|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">
  <tr > 
    <th height="22" colspan="8"> 俱乐部列表</span></th>
  </tr>
  <tr > 
    <td width="5%" align="center" class=forumHeaderBackgroundAlternate><strong>次序</strong></td>
    <td width="8%" align="center" class=forumHeaderBackgroundAlternate><strong>排序设置</strong></td>
    <td class=forumHeaderBackgroundAlternate width="19%"><b>俱乐部名称</b></td>
    <td width="9%" class=forumHeaderBackgroundAlternate><b>当前主席</b></td>
    <td width="25%" align="center" class=forumHeaderBackgroundAlternate> <div align="center"><strong>用户|活动|照片|留言(数量)</strong></div></td>
    <td width="9%" align="center" class=forumHeaderBackgroundAlternate><b>注册时间</b></td>
    <td width="5%" align="center" class=forumHeaderBackgroundAlternate><b>点击</b></td>
    <td width="20%" align="center" class=forumHeaderBackgroundAlternate><b>管理</b></td>
  </tr>
  <%  
	Set rs=Server.createobject("Adodb.RecordSet")
    pageno=request.querystring("pageno")
    pmcount=16  
    mSql="select * from t_club order by f_regtime 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"
%>
  <tr  > 
    <td width="5%" align="center"  class=forumRow><%=rs("F_index")%></td>
    <td width="8%" align="center"  class=forumRow><a href="admin_club.jsp?action=add_index&ArticleID=<%=rs("f_id")%>">[+]</a> 
      <a href="admin_club.jsp?action=div_index&ArticleID=<%=rs("f_id")%>">[-]</a></td>
    <td class=forumRow width="19%" ><a href="../member/club_viewsub.jsp?id=<%=rs("F_id")%>" target="_blank"><%=rs("F_name")%></a> </td>
    <td class=forumRow > &nbsp;<%=rs("F_manage_username")%></td>
    <td class=forumRow >&nbsp;&nbsp;&nbsp;[<font color="#FF0000"><%=rs("F_usercount")%></font>]&nbsp;|&nbsp;[<font color="#FF0000"><%=rs("F_clubactive")%></font>]&nbsp;|&nbsp;[<font color="#FF0000"><%=rs("F_clubphoto")%></font>]&nbsp;|&nbsp;[<font color="#FF0000"><%=rs("F_clubbook")%></font>]</td>
    <td class=forumRow width="9%" align="center" ><%=rs("F_regtime")%> </td>
    <td class=forumRow width="5%" align="center" ><%=rs("F_Hit")%></td>
    <td class=forumRow width="20%" align="center" ><a title="修改记录" href='admin_club.jsp?action=edit&ModifyID=<%=rs("F_ID")%>&BgColor=<%=rs("F_ID")%>&pageno=<%=cstr(pageno)%>'><font color="#666666">[修改]</font></a><a title="请确定是否删除,删除后不能恢复!" href="javascript:jDelete('admin_club.jsp?DeleteID=<%=rs("F_ID")%>&pageno=<%=cstr(pageno)%>')"><font color="#666666">[删除]</font></a> 
      <a href='admin_clublogin.jsp?ModifyID=<%=rs("F_ID")%>&BgColor=<%=rs("F_ID")%>&pageno=<%=cstr(pageno)%>' title="以该俱乐部主席身份进入前台修改" target="_blank">[前台修改]</a> 
    </td>
  </tr>
  <%
 rs.movenext
 re=re+1
 rc=rc-1
 loop
 end if
%>
  <tr  > 
    <td class=forumRow align="center" colspan="10"><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>1 then
   response.write "<a href='admin_club.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_club.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_club.jsp?pageno="&pno&"'>"&pno&"</a></b>"
 end if
next
response.write "&nbsp"

if int(pageno) < int(rs.pagecount) then
  response.write "<a href='admin_club.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_club.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> 
        <%if mFlag=true then'add%>
<%else%>
<br>
<TABLE cellSpacing=1 cellPadding=5 width=95% align=center 
            bgColor=#ececec border=0>
  <FORM name=SignUpForm action="admin_club.jsp?pageno=<%=request("pageno")%>&action=editsave&ModifyID=<%=request("ModifyID")%>" method=post  onSubmit="return CheckData()">
    <TBODY>
      <TR bgColor=#e5f6ff> 
        <TD colSpan=3>　修改俱乐部（<font color="#FF0000">*</font>为必填项）</TD>
      </TR>
      <TR bgColor=#ffffff> 
        <TD align=right width=96>俱乐部名称：</TD>
        <TD width="430" colSpan=2><INPUT name=name id="name" value="<%=m_name%>" size=35 
                  autocomplete="off"> <FONT color=#ff0000><B>*</B></FONT></TD>
      </TR>
      <TR bgColor=#ffffff>
        <TD align=right>俱乐部主席：</TD>
        <TD colSpan=2><select name="manage" id="manage">
            <%
		 c_Sql="Select f_username From T_club_member Where f_ischeck=1 and F_club_ID="&m_modifyid
          Set rs_cn=Conn.Execute(c_Sql)  
		  do while not rs_cn.eof
		%>
            <option value="<%=rs_cn("f_username")%>"<% if m_manage_username=rs_cn("f_username") then %>selected<% end if %>><%=rs_cn("f_username")%></option>
            <%
		rs_cn.movenext
		loop
		rs_cn.close
		set rs_cn=nothing
		%>
          </select>
          <font color="#FF0000">（修改俱乐部主席后，会将原来的主席降为&quot;名誉主席&quot;）</font></TD>
      </TR>
    <INPUT type=hidden 
              name=personal_URL>
    <TR bgColor=#ffffff> 
      <TD align=right width=96>俱乐部介绍：</TD>
      <TD colSpan=2><textarea name="content" cols="50" rows="8" id="content"><%=m_content%></textarea> 
        <FONT color=#ff0000><B>*</B><FONT 
                  color=#000000>(限800字)</FONT></FONT></TD>
    </TR>
    <TR bgColor=#ffffff> 
      <TD align=right>所在区域：</TD>
      <TD colSpan=2><font class=cha2><font class=cha2> 
        <select 
      name=area id="area" style="BACKGROUND-COLOR: #ffffff; WIDTH: 170px">
          <option value=<%=m_area%>><%=m_area%></option>
          <option value="龙山县">龙山县</option>
		              <option value="来凤县">来凤县</option>
                      
		
                      
        </font></font></TD>
    </TR>
    <TR align="center" bgColor=#e5f6ff> 
      <TD colSpan=3> <input type="hidden" name="filepath" value="<%=filepath%>"> 
        <INPUT type=submit value="确 定" name=submit> <INPUT type=reset value="取 消" name=reset> 
      </TD>
    </TR>
  </FORM>
</TABLE>
            <%end if%>

</body>
</html>
<%
 rs.close
 set rs=nothing
 conn.close
 set conn=nothing
%>
