<!--#include file="../include/Conn.jsp"-->
<!--#include file="../Include/Char.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")

'initialization 
mFlag=true'add


'edit
if request("action")="edit" then 
  mSql="Select * From info_ad Where F_ID="&Request.QueryString("ModifyID")
  Set rs=Conn.Execute(mSql)
  If not rs.Eof then
    mname=rs("F_name")
    mtext=rs("F_text")
	mlink=rs("F_link")
	mtel=rs("F_tel")
	mfax=rs("f_fax")
	mpostcode=rs("f_postcode")
	maddress=rs("f_address")
	memail=rs("f_email")
	mweb=rs("f_web")
	mcity=rs("f_city")
	mbigclassid=rs("f_bigclassid")
	msmallclassid=rs("f_smallclassid")
  rs.Close
  End if
  mFlag=false
end if

'Insert Records
if request("action")="Insert" then
 ' response.write request("langmu2")
 ' response.end
  mSql="Select * From info_ad where f_name='"&Trim(Request.Form("info_name"))&"'"
  rs.open mSql,conn,3,3
  if not rs.eof then
   response.write "<script>alert('您输入的分类信息名称已经重复，请重新输入！');history.back();</Script>"
	Response.end
  end if
  rs.AddNew
  rs("F_name")=Trim(Request.Form("info_name"))
  rs("F_bigclassid")=Trim(Request.Form("langmu"))
  rs("F_smallclassid")=Trim(Request.Form("langmu2"))  
  rs("f_tel")=Trim(Request.Form("info_tel"))
  rs("f_image")=application("newsuploadpic")
  'rs("F_area")=Trim(Request.Form("selBigCategory"))
  rs("F_city")=Trim(Request.Form("TypeID"))
  rs("F_link")=Trim(Request.Form("info_link"))
  rs("F_address")=Trim(Request.Form("info_address"))
  rs("F_fax")=Trim(Request.Form("info_fax"))
  rs("F_postcode")=Trim(Request.Form("info_post"))
   
  rs("F_email")=Trim(Request.Form("info_email"))
  rs("F_web")=Trim(Request.Form("info_http"))  
  rs("F_text")=(checkStr(Request.Form("txtContent")))
  rs("F_regtime")=now()
  
  rs.update
 application("newsuploadpic")=""
  rs.close
  response.redirect "admin_ad.jsp?action=IsInsert"
end if

'Modify Records
if request("action")="editsave" then
  mSql="Select * From info_ad Where F_ID="&Request.QueryString("ModifyID")
  rs.open mSql,conn,1,3
 rs("F_name")=Trim(Request.Form("info_name"))
  rs("F_bigclassid")=Trim(Request.Form("langmu"))
  rs("F_smallclassid")=Trim(Request.Form("langmu2"))  
  rs("f_tel")=Trim(Request.Form("info_tel"))
   if application("newsuploadpic")<>"" then
  rs("f_image")=application("newsuploadpic")
  end if
  'rs("F_area")=Trim(Request.Form("selBigCategory"))
  rs("F_city")=Trim(Request.Form("TypeID"))
  rs("F_link")=Trim(Request.Form("info_link"))
  rs("F_address")=Trim(Request.Form("info_address"))
  rs("F_fax")=Trim(Request.Form("info_fax"))
  rs("F_postcode")=Trim(Request.Form("info_post"))
   
  rs("F_email")=Trim(Request.Form("info_email"))
  rs("F_web")=Trim(Request.Form("info_http"))  
  rs("F_text")=(checkStr(Request.Form("txtContent")))
  rs.update
  application("newsuploadpic")=""
    Response.write "<script>alert('修改成功！');location.replace('admin_ad.jsp?action=IsModify&pageno="&Request.Querystring("pageno")&"')</script>"
  flag=false
end if

'Delect Records 删除
if request("action")="delete" then
  msql="select * from info_ad WHERE F_ID=" &Request.QueryString("DeleteID")
  rs.open mSql,conn,1,3
  if not rs.eof then
  'm_delimage=rs("f_image")
         '   if rs("f_image") <>"" then
	        '  delfname=server.mappath("..\Editor\UploadFile") & "\"&m_delimage  '删除文件
         '     set TestFileObject=Server.Createobject("Scripting.FileSystemObject")
         '     if  TestFileObject.FileExists(delfname) then
          '     set NewFile=TestFileObject.getfile(delfname)
        '       Newfile.delete
	     '     end if
		'	end if
		'删除评论
		 delSql="delete from info_adcomment Where f_adid="&rs("f_id")
         Conn.Execute(delSql)		
  rs.delete
  rs.update
  end if
  
  Response.write "<script>location.replace('admin_ad.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">
<%
set rs1=server.createobject("adodb.recordset")
sql = "select * from info_SmallClass order by f_ID asc"
rs1.open sql,conn,1,1
%>
<script language = "JavaScript">
var lmcount;
lm=new Array();
<%count=0
do while not rs1.eof
%>
lm[<%=count%>]=new Array('<%= trim(rs1("f_value"))%>','<%= trim(rs1("f_bigclassid"))%>','<%= trim(rs1("f_id"))%>');
<%
count=count+1
rs1.movenext
loop
rs1.close
%>
lmcount=<%=count%>;
function changelangmu1(langmu1){
document.form1.langmu2.length=1; 
var langmu1=langmu1;
var i;
for (i=0;i<lmcount; i++){
if (lm[i][1]==langmu1){ 
document.form1.langmu2.options[document.form1.langmu2.length]=new Option(lm[i][0], lm[i][2]);
}        
}
}    
</script>
<SCRIPT language="JavaScript">
function jDelete(url)
{
  if((confirm(" 警告:请确定是否删除,删除后不能恢复! "))==true) 
	self.location=url+'&action=delete';
}
</SCRIPT>
<script language="javascript">
function CheckData(){
  if (document.form1.info_name.value=="")
   {
    alert("名称不能为空，请输入！");
	document.form1.info_name.focus();
	return false;
   }
     if (document.form1.langmu.value=="")
   {
    alert("请选择大类！");
	document.form1.langmu.focus();
	return false;
   }
   
        if (document.form1.langmu2.value=="")
   {
    alert("请选择小类！");
	document.form1.langmu2.focus();
	return false;
   }
  if (document.form1.info_tel.value=="")
   {
    alert("联系电话不能为空，请输入！");
	document.form1.info_tel.focus();
	return false;
   }   

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

<%
	admin_flag=",6|3|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 width="95%" border="0" align="center" cellpadding="0">
  <form name="form_txt" method="post" action="admin_ad.jsp"><tr>
      <td>搜索： 
        <input name="txtword" type="text" id="txtword">
        <select name="txtclass" id="txtclass">
          <option value="">选择类型</option>
		    <% 
				classsql="select * from info_adClass"
	  'classsql="select f_id,f_value from mall_shopcategory order by f_index desc"
	  Set rsclass=Conn.Execute(classSql)
	  do while not rsclass.eof 
	  %>
      <option value="<%=rsclass("f_id")%>"><%=rsclass("f_value")%></option>
	  <%
	  rsclass.movenext 
	  loop
	  rsclass.close
	  set rsclass=nothing
	  %>
        </select> 
        <input type="submit" name="Submit" value="搜索"> </td>
  </tr></form>
</table>

<table class=tableBorder width="95%" border="0" align="center" cellpadding="2" cellspacing="1">
  <tr > 
    <th height="22" colspan="6"> 分类信息列表</span></th>
  </tr>
  <tr > 
    <td width="6%" align="center" class=forumHeaderBackgroundAlternate><b>ID</b></td>
    <td class=forumHeaderBackgroundAlternate width="27%"><b>标题</b></td>
    <td width="10%" class=forumHeaderBackgroundAlternate><strong>所在区域</strong></td>
    <td width="20%" class=forumHeaderBackgroundAlternate><b>发布时间|有效时间</b></td>
    <td width="16%" align="center" class=forumHeaderBackgroundAlternate><b>所属分类</b></td>
    <td width="21%" align="center" class=forumHeaderBackgroundAlternate><b>管理</b></td>
  </tr>
  <%  
	Set rs=Server.createobject("Adodb.RecordSet")
    pageno=request("pageno")
    pmcount=16  
	m_txtword=trim(request("txtword"))
	m_txtclass=trim(request("txtclass"))
	
    mSql="select * from info_ad where 1=1"
	if m_txtword<>"" then
	msql=msql&" and ( f_title like '%"&m_txtword&"%')"
	end if
	if m_txtclass<>"" then
	msql=msql&" and F_adclassid="&m_txtclass
	end if
	msql=msql&" 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  class=forumRow width="6%" align="center"><%=rs("F_ID")%></td>
    <td class=forumRow width="27%" ><a target="_blank" href="../info/ShowInfo.jsp?ID=<%=rs("F_id")%>"><%=rs("F_title")%></a> </td>
    <td class=forumRow > <%  
	mSql="Select F_ID,F_Value From T_areaType where F_CityTypeID=22 and f_id="&rs("f_area")
	Set rst = conn.Execute(mSql)
	if not rst.eof then
	%> <%=rst("F_value")%> <%
	end if
	rst.close
	set rst=nothing
	%> </td>
    <td class=forumRow ><%=datevalue(rs("F_regtime"))%>|<%=rs("F_update")%></td>
    <td align="center" class=forumRow > <%
	  classsql="select f_value from info_adclass where f_id="&rs("F_adclassid")
	  Set rsclass=Conn.Execute(classSql)
	  if not rsclass.eof then
	  %> <%=rsclass("f_value")%> <%
	  end if
	  rsclass.close
	  set rsclass=nothing
	  %> </td>
    <td class=forumRow width="21%" align="center" ><a title="添加记录" href='../info/write_info.jsp'><font color="#666666">[添加]</font></a><a title="请确定是否删除,删除后不能恢复!" href="javascript:jDelete('admin_ad.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  > 
    <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>1 then
   response.write "<a href='admin_ad.jsp?txtclass="&m_txtclass&"&txtword="&m_txtword&"'> <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_ad.jsp?txtclass="&m_txtclass&"&txtword="&m_txtword&"&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_ad.jsp?txtclass="&m_txtclass&"&txtword="&m_txtword&"&pageno="&pno&"'>"&pno&"</a></b>"
 end if
next
response.write "&nbsp"

if int(pageno) < int(rs.pagecount) then
  response.write "<a href='admin_ad.jsp?txtclass="&m_txtclass&"&txtword="&m_txtword&"&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_ad.jsp?txtclass="&m_txtclass&"&txtword="&m_txtword&"&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> 
</body>
</html>
<%
 rs.close
 set rs=nothing
 conn.close
 set conn=nothing
%>
