<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<html>
<head>
<title>酒店分类名称管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #FFFFFF;
}
-->
</style>
<link href="style/global.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #FF0000}
.style2 {color: #CCCCCC}
.style3 {color: #FFFFFF;
	font-weight: bold;
}
-->
</style>
<script language="javascript">
function check(obj){
	if(obj.Title.value==""){
		alert("名称不能为空!");
		obj.Title.focus();
		obj.Title.select();
		return false;
	}
	return true;
}
function goto(frm)
{
	var gourl ="?";
	gourl += "page=" + (frm.page.value);
     var hid=parseInt(frm.hid.value);
	 if(parseInt(frm.page.value)>hid||frm.page.value<=0){
	 alert("错误！请确定你输入的数字在1-"+hid+"之间");
	 return false;
	 }
	window.location.href(gourl);
}
function ConfirmDel()
{
   if(confirm("确认删除？，并且不能恢复！确定要删除此信息吗？"))
     return true;
   else
     return false;
	 
}
</script>
</head>

<body>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><iframe src="right_top.htm" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" height="30" width="100%"></iframe></td>
  </tr>
</table>
<%
dim act,table
table="t_hotel_catalog"
act=trim(request.QueryString("act"))
if isempty(act) or act="" then
	call InnerKeys_List
elseif(act="add") then
	call InnerKeys_Add
elseif(act="addok") then
	call InnerKeys_AddOk
elseif(act="mod") then
	call InnerKeys_Mod
elseif(act="modok") then
	call InnerKeys_ModOk
end if
%>
<%
Sub InnerKeys_Add
%>
<FORM method="POST" name="form1" action="?act=addok" style="margin:0 0 0 0;" onSubmit="return check(this)">
  <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
<TR bgcolor="#FF9900">
  <TD height="24" colspan="2"><div align="center" class="style3">添加酒店分类</div></TD>
  </TR>
<TR bgcolor="#F5F5F5">
  <TD width="46%"><div align="right">名称：</div></TD>
  <TD width="54%"><input name="Title" type="text" id="Title" size="35"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>&nbsp;	  </TD>
  <TD align=right><div align="left"> 
    <input type=submit name=b1 value="提 交">&nbsp;&nbsp;
    <input type=reset name=b2 value="重 填">       
    </div></TD>
</TR>
</TABLE>
</FORM>
<%
end Sub
Sub InnerKeys_AddOk
	dim title,url
	title=replace(request.Form("Title"),"'","")
	set rs=server.createobject("adodb.recordset")
	rs.open "select top 1 * from "&table&" where Title='"&title&"'",conn,3,3
	if not rs.eof then
		response.Write("<script>alert(""该名称已存在!"");history.back();</script>")
		response.End()
	else		
		rs.addnew
		rs("Title")=title		
		rs.update	
		response.Write("添加酒店分类名称成功~!")
		response.Write("<br><a href=?>返回</a>")
	end if
	rs.close
	set rs=nothing
end Sub
Sub InnerKeys_ModOk
	dim id,title,url
	id=Clng(request.QueryString("id"))
	title=replace(request.Form("Title"),"'","")
	set rs=server.createobject("adodb.recordset")
	rs.open "select top 1 * from "&table&" where id="&id,conn,3,3
	if not rs.eof then		
		rs("Title")=title		
		rs.update	
		response.Write("修改酒店分类名称成功~!")
		response.Write("<br><a href=""?"">返回</a>")
	end if
	rs.close
	set rs=nothing
end Sub
Sub InnerKeys_Mod
	dim id,rs
	id=Clng(request.QueryString("id"))
	set rs=conn.execute("select * from "&table&" where id="&id)
	if not rs.eof then
%>
<FORM method="POST" name="form1" action="?act=modok&id=<%=id%>" style="margin:0 0 0 0;" onSubmit="return check(this)">
  <TABLE width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#666666">
<TR bgcolor="#FF9900">
  <TD height="24" colspan="2"><div align="center" class="style3">修改线路分类</div></TD>
  </TR>
<TR bgcolor="#F5F5F5">
  <TD width="46%"><div align="right">名称：</div></TD>
  <TD width="54%"><input name="Title" type="text" id="Title" size="35" value="<%=rs("Title")%>"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>&nbsp;	  </TD>
  <TD align=right><div align="left"> 
    <input type=submit name=b1 value="提 交">&nbsp;&nbsp;
    <input type=reset name=b2 value="重 填">       
    </div></TD>
</TR>
</TABLE>
</FORM>
<%
	end if
	rs.close
	set rs=nothing
end Sub
Sub InnerKeys_List
	dim BeginTime,i,currentpage,allrec,totalpage,n,p
	BeginTime=Timer
	const recpage=20
	if not isempty(request("page")) and request("page")<>"" then 
		currentpage=Clng(request("page"))
	else
		currentpage=1
	end if
%>
<div align="center" class="thead"><a href="?act=add">添加新分类--&gt;</a></div>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#999999">
  <tr bgcolor="#FF9900">
    <td height="22" colspan="6"><div align="center"><span class="style3">◆ 管理酒店分类 ◆</span></div></td>
  </tr>
  <tr bgcolor="#EEEEEE">
    <td width="15%" height="22"><div align="center">id</div></td>
    <td width="57%"><div align="center">名称</div></td>
    <td width="14%"><div align="center">修改</div></td>
    <td width="14%"><div align="center">删除</div></td>
  </tr>
  <%
  		set rs=server.createobject("adodb.recordset")
  		rs.open "select count(*) AS co from "&table,conn,3,1
		allrec=rs(0)
		totalpage=int((allrec+recpage-1)/recpage)
		rs.close
		set rs=nothing
		set rs=server.createobject("adodb.recordset")
		sql="select top "&recpage&" id,Title from "&table&" where id <=(select min(id) from (select top "&(recpage*(currentpage-1)+1)&" id from "&table&" order by id desc) as t) order by id desc "
		rs.open sql,conn,3,1		
		do while not rs.eof		
	%>
  <tr>
    <td height="20" bgcolor="#FFFFFF"><div align="center"><%=rs(0)%></div></td>    
    <td bgcolor="#FFFFFF"><div align="center"><%=rs(1)%></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><a href="?act=mod&id=<%=rs(0)%>">修改</a></div></td>
    <td bgcolor="#FFFFFF"><div align="center"><a href="dele.asp?id=<%=rs(0)%>&table=<%=table%>" onClick="return ConfirmDel()">删除</a></div></td>
  </tr>
  
  <%
    		rs.movenext
	  loop
	  rs.close
	  set rs=nothing
  %>
  <tr>
    <td height="22" colspan="6" bgcolor="#FFFFFF">
	<div align="center">
	<form name="form1" method="post" action="" style="margin:0 0 0 0">
	<%
	n=currentpage+1
	p=currentpage-1
	if p>0then
		response.write("["&"<a href='?page="&cstr(p)&"'>上一页</a>]&nbsp;&nbsp;&nbsp;")
	else response.write("上一页&nbsp;&nbsp;&nbsp;")
	end if 
	if (n-1)*recpage>=allrec then 
		response.write("下一页" )
	else
		response.Write("["&"<a href='?page="&cstr(n)&"'>下一页</a>]")
	end if
	response.write("&nbsp;共"&allrec&"条&nbsp;")
	response.Write("&nbsp;共"&totalpage&"页&nbsp;")
	response.Write("&nbsp;第"&currentpage&"页&nbsp;")
	%>
          <input type="hidden" name="hid" value="<%=totalpage%>">
&nbsp;&nbsp;跳至
          <input name="page" type="text" size="5" onChange="goto(this.form)" style="border:1px solid #000000;height:18px ">
          页
          <input type="button" name="Button22" value="Go->" style="font-size:12px ;border:1px solid #000000;height:18px ">
        </form></div></td>
  </tr>
</table>
<%=CStr(FormatNumber((Timer-BeginTime)*1000,2))& "毫秒"%>
<%end Sub%>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="40"><div align="center"></div></td>
  </tr>
</table>
</body>
</html>
<%
call connclose()
%>