<!--#include file="conn.asp"-->
<!--#include file="inc/cook2.asp"-->
<!--#include file="inc/dimflag.asp"-->
<!--#include file="inc/page.asp"-->
<%
word=trim(request("word"))
anclassid=request("anclassid")
pt=request("pt")
tuij=request("tuij")

canshu1=""
canshu3="word="&word&"&anclassid="&anclassid&"&pt="&pt&"&tuij="&tuij&"&"&canshu1&""
canshu2="page="&page&"&"&canshu3&""

select case action

case "add"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open "select * from com_act",conn,1,3
rs.addnew
rs("CodeNumber")=trim(request("CodeNumber2"))
rs("upamount")=trim(request("upamount2"))
rs("amount")=trim(request("amount2"))
rs("sh")=0
rs.update
rs.close
response.write "<script language=javascript>alert('成功添加！');window.location.href='manage_act.asp';</script>"

response.redirect "manage_act.asp"
response.End


case "inputedit"
attrKey = split(Trim(Request("id")), "$")(0)
index = split(Trim(Request("id")), "$")(1)  
set rs=server.createobject("adodb.recordset")
rs.open "select CodeNumber,amount,upamount from com_act where id="&index&" ",conn,1,3
rs(""&attrKey&"")=Trim(Request("value"))
rs.update
rs.close

Response.Write ""&trim(Request("value"))&""
Response.end() 

case "del"
id=replace(request("id")," ","")
id=split(id,",")
for i=0 to UBound(id)
conn.execute("delete from com_act where id="&id(i))
next
response.Write "<script>location='manage_act.asp'</script>"

case "order"
pi=REQUEST("pi")
pi=REPLACE(pi,", ",",")
SQL5="SELECT * from com_act where id IN ("&pi&")"
SET RS5=SERVER.CREATEOBJECT("ADODB.RECORDSET")
rs5.open sql5,conn,1,3
while not rs5.eof 
RS5("pid")=REQUEST("pid"&RS5("id"))
RS5.UPDATE
RS5.MOVENEXT
wend
response.Write "<script>location='?"&canshu2&"'</script>"

case "sh"
id=replace(request("id")," ","")
id=split(id,",")
for i=0 to UBound(id)
conn.execute("update com_act set sh=0 where id="&id(i))
next
response.Write "<script>location='?"&canshu2&"'</script>"
case "sh2"
id=replace(request("id")," ","")
id=split(id,",")
for i=0 to UBound(id)
conn.execute("update com_act set sh=1 where id="&id(i))
next
response.Write "<script>location='?"&canshu2&"'</script>"

end select
%>
<!--#include file="top.asp"-->
<div id="container">
<div class="top_but">
 <li class="left">&nbsp;</li>
 <li><a href="?action=pageadd"><img src="images/but_1.gif" alt="添加" ></a></li>
 <li><img src="images/but_2.gif" alt="排序"  onclick="form1.action='?action=order&<%=canshu2%>';form1.submit();"></li>
 <li><img src="images/but_3.gif" alt="删除"  onclick="form1.action='?action=del&<%=canshu2%>'; ConfirmDel() "></li>
 <li><a href="?pt=yes"><img src="images/but_13.gif" alt="未审核" ></a></li>
 <li><a href="?tuij=yes"><img src="images/but_14.gif" alt="已审核" ></a></li>
 <li><a href="?tid=<%=tid%>"><img src="images/but_7.gif" alt="全部" ></a></li>
 <li><img src="images/but_8.gif" alt="刷新" onClick="window.location.reload(true);"></li>
 <li><img src="images/but_9.gif" alt="打印" onClick="window.print() "/></li>
<form name="form_search" method="post" action="?<%=canshu1%>">
 <li class="right">
<input name="word" type="text" id="word" class="s_b"><input type="image" name="Submit22" src="images/ss_b.gif" value="搜索" class="s_c" align="absmiddle"></li>
</form>
</div>


<%
if word<>"" then
sql= "select * from com_act where link_namecn like'%"&word&"%' order by pid asc,id desc"
elseif pt<>"" then
sql= "select * from com_act where sh=0 order by pid asc,id desc"
elseif tuij<>"" then
sql= "select * from com_act where sh=1 order by pid asc,id desc"
elseif anclassid<>"" then
sql= "select * from com_act where anclassid="&anclassid&" order by pid asc,id desc"
else
sql= "select * from com_act order by pid asc,id desc"
end if
set rs=server.createobject("adodb.recordset")                     
rs.open sql,conn,1,1                     
if rs.eof and rs.bof then                     
response.write conn_eof
else 
page1("18")
i=1	
set CodeNumber=rs("CodeNumber")
set amount=rs("amount")
set upamount=rs("upamount")
set link_pid=rs("pid")
set link_sh=rs("sh")
set id=rs("id")
set link_date=rs("date")
%>
<%if word<>"" then%><div class="tablesearch">您搜索的关键字是：<font color=#ff6600><%=word%></font>，共搜索到 <%=rs.recordcount%> 条信息。 </div><%end if%>
<form name="form1" id="form1" method="post" action="?<%=canshu2%>">
<div class="tableAll titlebgcolor">
<ul>
 <li style="width:30px"><input name="chkall" type="checkbox" id="chkall" value="select" onClick="CheckAll(this.form);" ></li>
 <li style="width:220px">优惠活动（点击修改）</li>
 <li style="width:100px">超过金额</li>
 <li style="width:100px">立减金额</li>
 <li style="width:80px">显示</li>
 <li style="width:50px">排序</li>
 </ul>
</div>
<%
do while not rs.eof and i<=rs.pagesize
%>
<div class="tableAll trbgcolor">
<ul>
 <li style="width:30px"><input type="checkbox" name="ID"  value="<%=id%>"></li>
 <li style="width:220px"><span id="CodeNumber$<%= id %>" class="edit"><%=CodeNumber%></span></li>
 <li style="width:100px"><span id="upamount$<%= id %>" class="edit"><%=upamount%></span></li>
  <li style="width:100px"><span id="amount$<%= id %>" class="edit"><%=amount%></span></li>
 <li style="width:80px"><%if link_sh=1 then%><a href="?action=sh&id=<%=id%>&<%=canshu2%>" title="点击更改显示状态"><font color=green>√</font></a>
 <%else%><a href="?action=sh2&id=<%=id%>&<%=canshu2%>" title="点击更改显示状态"><font color=#999999>×</font></a><%end if%></li>

 <li style="width:50px"><input name="pid<%=id%>" type="text" id="pid<%=id%>" value="<%=link_pid%>" size="2"> 
        <input name="pi" type="hidden" id="pi" value="<%=id%>"></li>
 </ul>
</div>

<%i=i+1
rs.movenext
loop
%>

</form>

<div id="divStayTop" class="bottom titlebgcolor">
<%call page2(5,""&canshu3&"&")%>
</div>
<%
end if
rs.close
set rs=nothing
%>
<%
select case action
case "pageadd" 
%>
<div class="tableAll titlebgcolor">
<ul>
 <li style="width:30px">&nbsp;</li>
 <li style="width:700px;">添加</li>
</ul>
</div>

<form name="myform" method="post" action="?action=add" >
<div class="tableAll trbgcolor">
 <li style="width:30px">&nbsp;</li>
 <li><font color="#990000">
<script>
  function   check()   
  {     
  var   upnum=document.getElementById("upamount2").value; 
   var   num=document.getElementById("amount2").value; 
	var strP=/^\d+$/;
	if(!strP.test(upnum)) { 
	alert("抱歉,请输入正确整数金额！"); 
	document.getElementById("amount2").value=0;
/*	return false;*/
	} 
	if(!strP.test(num)) { 
	alert("抱歉,请输入正确整数金额！"); 
	document.getElementById("amount2").value=0;
/*	return false;*/
	}  
	} 
   </script>
优惠活动： <input name="CodeNumber2" type="text" id="CodeNumber2" size="30" value=<%=pass%> > 
设定超过金额： <input name="upamount2" type="text" id="upamount2" value="200"  onChange='check()' size="8"> &nbsp;
立减金额： <input name="amount2" type="text" id="amount2" value="0"  onChange='check()' size="8"> （整数）&nbsp;
              <input class="button" type="submit" name="Submit3" value="添加" >
 </font></li>
</div>
</form>

<%
end select
%>
</div>
<script language="JavaScript" type="text/JavaScript" src="js/jquery.latest.js"></script> 
<!--#include file="footer.asp"-->