<% userPageRights="{admin}" %>
<!--#include file="check.asp"-->
<!--#include file="../Include/const.asp" -->
<%
dim action
action = lcase(trim(request("types")))
if action = "add" then
n_num = Trim(Request.Form("n_num"))
n_title = Trim(Request.Form("n_title"))
n_time1=Trim(Request.Form("n_time1"))
n_time2 = Trim(Request.Form("n_time2"))
titlepic = Trim(Request.Form("ecoupon"))
	dim rs
	set rs = server.CreateObject("adodb.recordset")
	rs.open "select * from tb_ecoupon ",conn,1,3

		rs.addNew
		rs("n_num") = n_num
		rs("n_title") = n_title
		rs("n_time1") = n_time1
		rs("n_time2") = n_time2
		rs("titlepic") = titlepic
		rs.update
		set rs = nothing
				response.Redirect("ecoupon.asp")
		response.End()

end if
///////////////////////////////////////////////
if action = "dels" then
id=Clng(Request("id"))
set rs = server.CreateObject("adodb.recordset")
conn.Execute = "delete from tb_ecoupon where id="&id
Response.Write("<script language='javascript'>location.assign('ecoupon.asp');</script>")
Response.End()
end if
////////////////////////////////////////////////
if action = "edits" then
id=Request("id")

n_num = Trim(Request.Form("n_num"))
n_title = Trim(Request.Form("n_title"))
n_time1=Trim(Request.Form("n_time1"))
n_time2 = Trim(Request.Form("n_time2"))
titlepic = Trim(Request.Form("ecoupon"))
set rs = server.CreateObject("adodb.recordset")
sql="select * from tb_ecoupon where id = "&id

	rs.open sql,conn,1,3
	if rs.eof then
	  Response.Write("<script language='javascript'>alert('更新失败，原因:"&n_title&"不存在!');location.assign('ecoupon.asp');</script>")
	  Response.End()
	else
		rs("n_num") = n_num
		rs("n_title") = n_title
		rs("n_time1") = n_time1
		rs("n_time2") = n_time2
		rs("titlepic") = titlepic
	  rs.Update
	  	  Response.Write("<script language='javascript'>alert('更新成功，"&n_title&"!');location.assign('ecoupon.asp');</script>")
Response.End()
    end if
end if
////////////////////////////////////////////
Session("lm")="e"
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/Style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #FF0000}
.style2 {color: #0000FF}
-->
</style>
<script language="javascript">
<!--
function insertPic(obj){
	var file = showModalDialog("../include/filesr.asp?lm=e-&path="+obj.name+"/",null,"dialogHeight:600px;dialogWidth:730px;scroll:yes;help:no;status:no;")
		if(typeof(file) != "undefined"){
		obj.value = file;
	}
}
-->
</script>
<script language="JavaScript" src="../js/CheckForm.js"></script>
<SCRIPT language="JavaScript">
function jDelete(url)
{
  if((confirm(" 警告:请确定是否删除,删除后不能恢复! "))==true) 
	self.location=url+'&types=dels';
}
</SCRIPT>
</head>
<body>
<table class=tableBorder width="100%" border=0 align="center" cellpadding=5 cellspacing=1>
  <tbody>
    <tr align="left">
      <th height=21 sytle="line-height:150%">【电子优惠券设置】</th>
    </tr>
    <tr>
      <td  class=forumRow><form name="form1" method="post" action="ecoupon.asp<%if request("id")<>"" then response.write "?types=edits&id="&request("id") else response.write "?types=add" end if%>" onSubmit="return CheckForm(this)">
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="235" height="20" align="center" bgcolor="#6688E3">中文名称</td>
            <td width="243" height="20" align="center" bgcolor="#6688E3">优惠时间</td>
            <td width="230" align="center" bgcolor="#6688E3">图片</td>
            <td width="59" align="center" bgcolor="#6688E3">排序</td>
            </tr>
        </table>
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="235" height="20" align="center" bgcolor="#FFFFFF"><input name="n_title" type="text" id="n_title" value="<%=request("n_title")%>" size="30" maxlength="20" check="^\S" warning="请输入名称">
              </td>
            <td width="242" height="20" align="center" bgcolor="#FFFFFF"><input name="n_time1" type="text" id="n_time1" value="<%=request("n_time1")%>" size="15">
            <input name="n_time2" type="text" id="n_time2" value="<%=request("n_time2")%>" size="15"></td>
            <td width="233" align="center" bgcolor="#FFFFFF"><input name="ecoupon" type="text" id="ecoupon" value="<%= Request("ecoupon") %>" size="20" maxlength="255">
              <input type="button" name="Submit" value="选择&gt;" onClick="javascript:insertPic(this.form.ecoupon);"></td>
            <td width="57" align="center" bgcolor="#FFFFFF"><input name="n_num" type="text" id="n_num" value="<%=request("n_num")%>" size="4" maxlength="20" check="^\S+$" warning="请输入排序数字"></td>
            </tr>
        </table>
        <table width="500"  border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td width="100" height="25" align="center"><input name="action" type="hidden" id="action" value="add"></td>
            <td><input type="submit" name="Submit2" value="提交">
                <input type="reset" name="Submit" value="重置">
            </td>
          </tr>
        </table>
      </form></td>
    </tr>
  </tbody>
</table>
<table width="100%"  border="0" cellpadding="0" cellspacing="0" class="titleBar">
  <tr>
    <td width="8%" height="38">&nbsp;</td>
    <td width="92%">&nbsp;</td>
  </tr>
</table>
<table class="tableBorder" width="100%" border="0" align="center" cellpadding="5" cellspacing="1">
  <tbody>
    <tr align="left">
      <th width="100%" height="21" sytle="line-height:150%">【电子优惠券列表】</th>
    </tr>
  </tbody>
</table>
<table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" class="tableBorder">
  <tr>
    <td width="39" align="center" bgcolor="#7A97E0" sytle="line-height:150%">编号</td>
    <td width="270" height="26" align="center" bgcolor="#7A97E0" sytle="line-height:150%">名称</td>
    <td width="172" height="26" align="center" bgcolor="#7A97E0" sytle="line-height:150%">优惠时间</td>
    <td width="176" align="center" bgcolor="#7A97E0" sytle="line-height:150%">图片</td>
    <td width="70" align="center" bgcolor="#7A97E0" sytle="line-height:150%">排序</td>
    <td width="193" height="26" align="center" bgcolor="#7A97E0" sytle="line-height:150%">操作</td>
  </tr>
</table>
<table width="100%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#6688E3">
<%
set rs=conn.execute("select * from tb_ecoupon order by n_num")
do while not rs.eof
id=rs("id")
%>
  <tr>
    <td width="38" align="center" bgcolor="#D6DFF7"><span class="STYLE2"><%=rs("id")%></span></td>
    <td width="271" height="35" align="center" bgcolor="#D6DFF7"><span class="STYLE2"><%=rs("n_title")%></span></td>
    
    <td width="173" align="center" bgcolor="#D6DFF7"><span class="STYLE2"><%=rs("n_time1")%>到<%=rs("n_time2")%></span></td>
    <td width="174" align="center" bgcolor="#D6DFF7"><span class="STYLE2"><a href="<%=rs("titlepic")%>" target="_blank"><%=rs("titlepic")%></a></span></td>
	<td width="72" align="center" bgcolor="#D6DFF7"><span class="STYLE2"><%=rs("n_num")%></span></td>
    <td width="194" align="center" bgcolor="#D6DFF7"><a href="ecoupon.asp?id=<%=rs("id")%>&n_title=<%=rs("n_title")%>&ecoupon=<%=rs("titlepic")%>&n_time1=<%=rs("n_time1")%>&n_time2=<%=rs("n_time2")%>&n_num=<%=rs("n_num")%>"><img src="Images/41.gif" width="18" height="13" border="0" alt="修改"></a> <a title="请确定是否删除,删除后不能恢复!" href="javascript:jDelete('ecoupon.asp?id=<%=rs("id")%>&n_name=<%=rs("n_title")%>')"><img src="Images/73.gif" width="12" height="12" border="0" alt="删除"></a></td>
  </tr>
  <%
  rs.movenext
  loop%>
</table>
</body>
</html>