<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/Session.asp" -->
<!-- #include file="inc/function.asp" -->
<!-- #include file="inc/checkrole.asp" -->
<%
'''''''''''''''''''''''''''''''''''''''''''''''
call checkPrevilege(Session("Name"),"p21")
'''''''''''''''''''''''''''''''''''''''''''''''
%>
<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;
}
.h_table{}
.h_table .tr{ height:30px;}
.h_table .tr .d1{ float:left; width:35%; line-height:30px;}
.h_table .tr .d2{ float:left; width:10%; line-height:30px;}
.h_table .tr .d3{ float:left; width:10%; line-height:30px;}
.h_table .tr .d4{ float:left; width:15%; line-height:30px;}
.h_table .tr .d5{ float:left; width:15%; line-height:30px;}
.h_table .tr .d6{ float:left; width:15%; line-height:30px;}
-->
</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 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_ticket"
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="14%" align="right">分类：</TD>
  <TD width="86%">
  <select name="ClassId" id="ClassId">
  <%=getSourceOption(0,"t_ticket_catalog")%>
  </select>
  <a href="ticket_catalog.asp">分类管理？ </a></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>景点门票名称：</TD>
  <TD align=left><input name="Title" type="text" id="Title" size="35"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>图片：</TD>
  <TD align=left><input name="Photo" type="text" id="Photo" value="/images/nopic.jpg" size="30">
    <input type="button" name="Button" value="上传->" onClick="javascript:document.form1.Photo.value=window.showModalDialog('upimg.htm','','dialogHeight:130px;dialogWidth:410px;help:no;status:no;scroll:no')"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>原价：</TD>
  <TD align=left><input name="Price1" type="text" id="Price1" value="0" size="6">
    优惠价：
      <input name="Price2" type="text" id="Price2" value="0" size="6"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>详细介绍：</TD>
  <TD align=left><textarea name="Content" style="display:none;" id="Content"></textarea>
    <IFRAME ID="eWebEditor2" src="webedits/ewebeditor.htm?id=Content&style=coolblue" frameborder="0" scrolling="no" width="98%" height="350"></IFRAME></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,Photo,Price1,Price2,Content,ClassId
	ClassId=Cint(request.Form("ClassId"))
	Photo=request.Form("Photo")
	title=replace(request.Form("Title"),"'","")
	Price1=Clng(request.Form("Price1"))
	Price2=Clng(request.Form("Price2"))
	Content=request.Form("Content")	
	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("ClassId")=ClassId
		rs("Title")=title	
		rs("Photo")=Photo
		rs("Price1")=Price1
		rs("Price2")=Price2
		rs("Content")=Content		
		rs.update			
	end if
	rs.close
	set rs=nothing
	
	response.Write("<p align=""center"">添加旅游景点门票成功~!")
		response.Write("<br><a href=?>返回</a></p>")
end Sub
Sub InnerKeys_ModOk	
	dim id,title,Photo,Price1,Price2,Content,ClassId
	id=Clng(request.QueryString("id"))
	ClassId=Cint(request.Form("ClassId"))
	Photo=request.Form("Photo")
	title=replace(request.Form("Title"),"'","")
	Price1=Clng(request.Form("Price1"))
	Price2=Clng(request.Form("Price2"))
	Content=request.Form("Content")	
	set rs=server.createobject("adodb.recordset")
	rs.open "select top 1 * from "&table&" where id="&id,conn,3,3
	rs("ClassId")=ClassId
	rs("Title")=title	
	rs("Photo")=Photo
	rs("Price1")=Price1
	rs("Price2")=Price2
	rs("Content")=Content
	rs.update			
	rs.close
	set rs=nothing
	
	response.Write("<p align=""center"">修改旅游景点门票成功~!")
		response.Write("<br><a href=?>返回</a></p>")
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 align="right">分类：</TD>
  <TD>
    <select name="ClassId" id="ClassId">
      <%=getSourceOption(Clng(rs("ClassId")),"t_ticket_catalog")%>
      </select>
    <a href="ticket_catalog.asp">分类管理？ </a></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD width="14%" align=right>景点门票名称：</TD>
  <TD width="86%" align=left><input name="Title" type="text" id="Title" value="<%=rs("Title")%>" size="35"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>图片：</TD>
  <TD align=left><input name="Photo" type="text" id="Photo" value="<%=rs("Photo")%>" size="30">
    <input type="button" name="Button" value="上传->" onClick="javascript:document.form1.Photo.value=window.showModalDialog('upimg.htm','','dialogHeight:130px;dialogWidth:410px;help:no;status:no;scroll:no')"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>原价：</TD>
  <TD align=left><input name="Price1" type="text" id="Price1" value="<%=rs("Price1")%>" size="6">
    优惠价：
      <input name="Price2" type="text" id="Price2" value="<%=rs("Price2")%>" size="6"></TD>
</TR>
<TR bgcolor="#F5F5F5">
  <TD align=right>详细介绍：</TD>
  <TD align=left>
    <textarea name="Content" style="display:none;" id="Content"><%=rs("Content")%></textarea>
    <IFRAME ID="eWebEditor1" src="webedits/ewebeditor.htm?id=Content&style=coolblue" frameborder="0" scrolling="no" width="98%" height="350"></IFRAME>
    </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,key
	BeginTime=Timer
	const recpage=20
	if not isempty(request("page")) and request("page")<>"" then 
		currentpage=Clng(request("page"))
	else
		currentpage=1
	end if
	key=request.QueryString("key")
%>
<script type="text/javascript">
function goto(frm)
{
	var gourl ="?key=<%=key%>&";
	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);
}
</script>
<div style="line-height:24px; text-align:left; padding-left:10px;">
  <form name="form2" method="get" action="?">
    <a href="?act=add"><strong>添加新旅游景点门票</strong>--&gt;</a>
    关键字：
    <input type="text" name="key" id="key" value="<%=key%>">
    <input type="submit" name="button" id="button" value="查询">
  </form>
</div>
<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#eeeeee">
  <tr bgcolor="#FF9900">
    <td height="22" colspan="8"><div align="center"><span class="style3">◆ 旅游景点门票管理 ◆</span></div></td>
  </tr>
  <tr bgcolor="#EEEEEE">
    <td width="3%" height="22"><div align="center">id</div></td>
    <td width="12%" align="center">图片</td>
    <td width="57%"><div align="center">名称</div></td>
    <td width="12%" align="center">价格</td>
    <td width="8%"><div align="center">修改</div></td>
    <td width="8%"><div align="center">删除</div></td>
  </tr>
  <%
		sql="select count(*) AS co from "&table&" where 1=1"
		if(key<>"") then
			sql=sql&" and Title like '%"&key&"%'"
		end if
		set rs=server.createobject("adodb.recordset")
		rs.open sql,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,Price1,Price2,Photo from "&table&" where id <=(select min(id) from (select top "&(recpage*(currentpage-1)+1)&" id from "&table&" where 1=1"
		if(key<>"") then
			sql=sql&" and Title like '%"&key&"%'"
		end if
		sql=sql&" order by id desc) as t)"
		if(key<>"") then
			sql=sql&" and Title like '%"&key&"%'"
		end if
		sql=sql&" 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 align="center" bgcolor="#FFFFFF"><img src="<%=rs(4)%>" width="112" height="89" alt=" "></td>    
    <td bgcolor="#FFFFFF"><div align="left">&nbsp;<%=rs(1)%></div></td>
    <td align="center" bgcolor="#FFFFFF"><%=rs(2)%>~<%=rs(3)%></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="8" 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>
<%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()
%>