<% userPageRights="{member}" %>
<!--#include file="check.asp"-->
<!--#include file="../Include/Char.asp" -->
<!--#include file="../Include/const.asp" -->
<%
dim i
dim rs,rst
dim mTypeName,mGrade,mSql,mFlag,mBgColor,mFolder
mFlag=true

if request("action")="edit" then 
  mSql = "Select * From T_AreaType Where F_ID=" & Request.QueryString("ModifyID")
  Set rs = conn.Execute(mSql)
  mTypeName = rs("F_Value")
  mGrade = rs("F_Grade")
  mFlag=false
end if

if Request.QueryString("action")="Insert" then
  mTypeName = checkStr(Trim(Request.Form("txtTypeName")))
  mCityTypeID = Trim(Request.QueryString("CityTypeID"))
  if Trim(Request.QueryString("grade"))="" then mGrade=1 else mGrade=Cint(Request.QueryString("grade"))
  mSql="Insert into T_AreaType(F_Value,F_Grade,F_CityTypeID)values('"&mTypeName&"',"&mGrade&","&mCityTypeID&")"
  conn.execute(mSql)
  response.redirect "Admin_AgioSmallAreaType.asp?action=IsInsert&pageno=" & Request("pageno") & "&CityTypeID="&Request("CityTypeID")
end if

if request("action")="editsave" then
  mCityTypeID = Request("hidCityTypeID")
  mTypeName = checkStr(Trim(Request.Form("txtTypeName2")))
  mCityTypeID = Trim(Request.QueryString("CityTypeID"))
  mSql="update T_AreaType set F_Value='" & mTypeName &"',F_CityTypeID=" & mCityTypeID &" where F_ID=" & Request.Querystring("ModifyID")
  conn.execute(mSql)
  response.redirect "Admin_AgioSmallAreaType.asp?action=IsModify&pageno="&Request.Querystring("pageno")&"&CityTypeID="&Request.Querystring("CityTypeID")
  flag=false
end if

if request("action")="delete" then
  mSql = "DELETE FROM T_AreaType WHERE F_ID=" &Request.QueryString("DeleteID")
  conn.execute mSql
  Response.write "<script>location.replace('Admin_AgioSmallAreaType.asp?action=IsDelete&pageno="&Request("pageno")&"&CityTypeID="&Request("CityTypeID")&"')</script>"
end if

If Request.QueryString("action")="up" then
   mSql="update T_AreaType set F_Grade=F_Grade-1 where F_Grade="&request.querystring("grade")
   conn.execute(mSql)
   mSql="update T_AreaType set F_Grade=F_Grade+1 where F_Grade="&cint(request.querystring("grade"))-1&" and F_ID<>"&Request.QueryString("SortID")
   conn.execute(mSql)
   mBgColor=Request.QueryString("SortID")
   Response.Redirect "Admin_AgioSmallAreaType.asp?pageno="&Request("pageno")&"&CityTypeID="&Request("CityTypeID")&"&BgColor="&mBgColor
 End if

If Request.QueryString("action")="down" then
   mSql="update T_AreaType set F_Grade=F_Grade+1 where F_Grade="&request.querystring("grade")
   conn.execute(mSql)
   mSql="update T_AreaType set F_Grade=F_Grade-1 where F_Grade="&cint(request.querystring("grade"))+1&" and F_ID<>"&Request.QueryString("SortID")
   conn.execute(mSql)
   mBgColor=Request.QueryString("SortID")
   Response.Redirect "Admin_AgioSmallAreaType.asp?pageno="&Request("pageno")&"&CityTypeID="&Request("CityTypeID")&"&BgColor="&mBgColor
 End if
%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body,td,th {
	font-size: 12px;
}
a:link {
	color: #003366;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #FF00CC;
}
a:hover {
	text-decoration: none;
	color: #00FF00;
}
a:active {
	text-decoration: none;
	color: #FF0000;
}
-->
</style>
<SCRIPT language="JavaScript">
function jDelete(url)
{
  if((confirm(" 警告:请确定是否删除,删除后不能恢复! "))==true) 
	self.location=url+'&action=delete';
}
</SCRIPT>
<script language="javascript">
function CheckData(){
  if (document.form1.txtTypeName.value=="")
   {
    alert("类型不能为空，请输入！");
	document.form1.txtTypeName.focus();
	return false;
   }

   
}

function CheckData2(){
  if (document.form2.txtTypeName2.value=="")
   {
    alert("类型不能为空，请输入！");
	document.form2.txtTypeName2.focus();
	return false;
   }
}
</script>
</head>
<body text="#000000" >
<table width="100%" height="1"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td></td>
  </tr>
</table>
<TABLE width=100% height=100% border=1 align="center" cellPadding=0 
cellSpacing=0 borderColor=#7c96b8 borderColorDark=#ffffff>
  <TBODY>
    <TR> 
      <TD width="100%" align=center valign="top">
<table width="100%" border="0" cellspacing="1" cellpadding="1" align="center">
          <tr style="cursor:hand" onMouseOut="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#EBEEF6'"  bgcolor="#dde1ec" align="center"> 
            <td width="2%" height="11"><b><font color="#333333">ID</font></b></td>
            <td width="2%" height="11"><b><font color="#333333">新序</font></b></td>
            <td width="4%"><b><a href="Admin_AgioBigAreaType.asp"><font color="#0066FF">二级类别[返回]</font></a></b></td>
            <td width="3%"><b><font color="#333333">排序</font></b></td>
            <td width="6%" height="11"><b><font color="#333333">管理</font></b></td>
          </tr>
        </table>
        <table width="100%" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#ebeef6">
          <%  
	Set rs=Server.createobject("Adodb.RecordSet")
    pageno=request.querystring("pageno")
    pmcount=16  
    mSql="Select * From T_AreaType Where F_CityTypeID="&Request("CityTypeID")&" order by F_Grade"
	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
 i=0
 do while not rs.eof and rc>0
 i=i+1
 mBgColor=Request.Querystring("BgColor")
 if Trim(rs("F_ID"))=Trim(mBgColor) then mColor= "D6DFFF" else mColor= "ffffff"
%>
          <tr bgcolor="<%=mColor%>" style="cursor:hand"  onmouseout="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#EBEEF6'" > 
            <td width="2%" height="2" align="center" ><%=rs("F_ID")%></td>
            <td width="2%" height="2" align="center" ><%=i+(Pageno-1)*pmcount%> </td>
            <td width="4%" > <%response.write rs("F_Value")%> </td>
            <td width="3%" align="center" > <%
	 if i+(Pageno-1)*pmcount=1 then 
	    Response.write "拉上"
	  else
		Response.write "<a href='Admin_AgioSmallAreaType.asp?pageno="&Request("pageno")&"&action=up&SortID="&rs("F_ID")&"&CityTypeID="&Request("CityTypeID")&"&grade="&i+(Pageno-1)*pmcount&"'>拉上</a>"
      end if
	  Response.write "&nbsp;|&nbsp;"

	  if i+(Pageno-1)*pmcount=rs.recordcount then 
	    response.write "拉下"
	  else
		response.write "<a href='Admin_AgioSmallAreaType.asp?pageno="&Request("pageno")&"&action=down&SortID="&rs("F_ID")&"&CityTypeID="&Request("CityTypeID")&"&grade="&i+(Pageno-1)*pmcount&"'>拉下</a>"
      end if
	%> </td>
            <td width="6%" height="2" align="center" > <a href='Admin_AgioSmallAreaType.asp?pageno=<%=mPage%>&CityTypeID=<%=Request("CityTypeID")%>'><font color="#666666">添加</font></a> 
              | <a href='Admin_AgioSmallAreaType.asp?action=edit&ModifyID=<%=rs("F_ID")%>&BgColor=<%=rs("F_ID")%>&CityTypeID=<%=Request("CityTypeID")%>&pageno=<%=cstr(pageno)%>'><font color="#666666">修改</font></a> 
              | <a href="javascript:jDelete('Admin_AgioSmallAreaType.asp?DeleteID=<%=rs("F_ID")%>&CityTypeID=<%=Request("CityTypeID")%>&pageno=<%=cstr(pageno)%>')"><font color="#666666">删除</font></a> 
            </td>
          </tr>
          <%
 rs.movenext
 re=re+1
 rc=rc-1
 loop
 end if
%>
        </table> 
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="f2f2f2">
          <tr> 
            <td width="35%" 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="65%" align="right"> 
<%
if pageno>1 then
   response.write "<a href='Admin_AgioSmallAreaType.asp?CityTypeID="&Request("CityTypeID")&"'> <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_AgioSmallAreaType.asp?pageno="&pageno-1&"&CityTypeID="&Request("CityTypeID")&"'><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_AgioSmallAreaType.asp?pageno="&pno&"&CityTypeID="&Request("CityTypeID")&"'>"&pno&"</a></b>"
 end if
next
response.write "&nbsp"

if int(pageno) < int(rs.pagecount) then
  response.write "<a href='Admin_AgioSmallAreaType.asp?pageno="&pageno+1&"&CityTypeID="&Request("CityTypeID")&"'><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_AgioSmallAreaType.asp?pageno="&mpage&"&CityTypeID="&Request("CityTypeID")&"'><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>
        <%if mFlag=true then'add%>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="18" align="center" bgcolor="f2f2f2"><strong><font color=red>
        <%
		  if Request.QueryString("action")="IsInsert" then response.write "提示：记录添加成功！" 
		  if Request.QueryString("action")="IsDelete" then response.write "提示：记录删除成功！" 
		  if Request.QueryString("action")="IsModify" then response.write "提示：记录修改成功！" 
  		  if Trim(Request.QueryString("action"))="" then response.write "提示：当前为添加状态！" 
		%>
              </font></strong></td>
          </tr>
        </table> 
        <strong><font color=red> </font></strong> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" height="54">
          <tr> 
            <form name="form1" method="post" action="Admin_AgioSmallAreaType.asp?pageno=<%=mpage%>&action=Insert&CityTypeID=<%=Request("CityTypeID")%>&grade=<%=rs.recordcount+1%>" onSubmit="return CheckData()">
              <td valign="top"> <table width="100%" height="67" border="0" cellpadding="1" cellspacing="0">
                  <tr background="Images/mmTo.gif"> 
                    <td height="6" colspan="2" background="Images/mmTo.gif"> <span style="CURSOR: hand; FILTER: dropshadow(color=#FFFFFF, offx=1, offy=1, positive=1);  WIDTH: 100%">功能：添加记录</span></td>
                  </tr>
                  <tr> 
                    <td width="14%" align="center" bgcolor="fcfcfc">类别名称： </td>
                    <td width="86%" valign="top" bgcolor="fcfcfc"><input class="text" name="txtTypeName" type="text"  value="" size="30" maxlength="20"></td>
                  </tr>
                  <tr> 
                    <td width="14%" valign="top" bgcolor="fcfcfc">&nbsp;</td>
                    <td height="33" colspan="2" bgcolor="fcfcfc"> <input type="submit" value="提交信息" name="B3" class="button"> 
                      <input type="reset" value="从新来过" name="B3" class="button"> 
                    </td>
                  </tr>
                </table></td>
            </form>
          </tr>
        </table>
        <%else%>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr> 
            <td height="18" align="center" bgcolor="f2f2f2"><strong><font color=red> 
       <%
		  if Request.QueryString("action")="IsInsert" then response.write "提示：记录添加成功！" 
		  if Request.QueryString("action")="IsDelete" then response.write "提示：记录删除成功！" 
		  if Request.QueryString("action")="IsModify" then response.write "提示：记录修改成功！" 
		  if Trim(Request.QueryString("action"))="edit" then response.write "提示：当前为修改状态！" 
	   %>
              </font></strong></td>
          </tr>
        </table>
        <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" height="54">
          <tr> 
            <form name="form2" method="post" action="Admin_AgioSmallAreaType.asp?pageno=<%=request("pageno")%>&CityTypeID=<%=Request("CityTypeID")%>&action=editsave&ModifyID=<%=request("ModifyID")%>" onSubmit="return CheckData2()">
              <td> <table width="100%" height="67" border="0" cellpadding="1" cellspacing="0">
                  <tr background="Images/mmTo.gif"> 
                    <td height="6" colspan="2" background="Images/mmTo.gif"> <span style="CURSOR: hand; FILTER: dropshadow(color=#FFFFFF, offx=1, offy=1, positive=1);  WIDTH: 100%">功能：修改记录</span></td>
                  </tr>
                  <tr> 
                    <td width="14%" align="center" valign="top" bgcolor="fcfcfc">类别名称： 
                    </td>
                    <td width="86%" valign="top" bgcolor="fcfcfc"><input class="text" name="txtTypeName2" type="text"  value="<% = mTypeName %>" size="30" maxlength="20"> 
                      <input name="hidCityTypeID" type="hidden" value="<%=Request("CityTypeID")%>"></td>
                  </tr>
                  <tr> 
                    <td width="14%" valign="top" bgcolor="fcfcfc">&nbsp;</td>
                    <td height="33" colspan="2" bgcolor="fcfcfc"> <input type="submit" value="提交信息" name="B32" class="button"> 
                      <input type="reset" value="从新来过" name="B32" class="button"> 
                    </td>
                  </tr>
                </table></td>
            </form>
          </tr>
        </table>
        <%end if%>
      </TD>
    </TR>
  </TBODY>
</TABLE>
</body>
</html>