<!--#include file="../ACT.Function.asp"-->
<!--#include file="../../ACT_inc/cls_pageview.asp"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>1</title>
<link href="../Images/css1/css.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.STYLE1 {font-weight: bold}
-->
</style>
</head>
<body>
<%ConnectionDatabase
		dim MaxPerPage,RS,TotalPut,TotalPages,I,CurrentPage,SQL,ComeUrl
		  MaxPerPage=20
			Response.Write"<table width=""98%""  align=""center""   height=""25"" border=""0"" cellspacing=""1"" cellpadding=""2""  class=""table"">"
			Response.Write " <tr class=""bg_tr"">"
			Response.Write"	<td height=""25"" class=""sort""> "
			Response.Write " <strong>操作导航:</strong>&nbsp;<a href=""?"">所有充值卡</a> | <a href=""?status=1"">未使用充值卡</a> | <a href=""?status=2"">已使用充值卡</a> | <a href=""?status=3"">已失效充值卡</a> | <a href=""?status=4"">未失效充值卡</a> | <a href=""?action=Add"">添加充值卡</a> | <a href=""?action=AddMore"">批量生成充值卡</a>"
			Response.Write	" </td>"
			Response.Write " </tr>"
			Response.Write"</TABLE>"
		ComeUrl=Cstr(Request.ServerVariables("HTTP_REFERER"))
		
		Select Case request("Action")
		 Case "Add","Edit"
		  Call Add()
		 Case  "DoAdd"
		  Call DoAdd()
		 Case "AddMore"
		  Call AddMore()
		 Case "DoAddMore"
		  Call DoAddMore()
		 Case "Del"
		  Call Del()
		 Case Else
		  Call CardList()
		End Select
	
	'点卡列表
	Sub CardList()
		%>
<table width="98%" style="MARGIN-TOP: 3px" border="0" align="center" cellspacing="1" cellpadding="2" class="table">
  <tr class="bg_tr">
    <td width="38" height="25" align="center" class="bg_tr"><strong>选中</strong></td>
    <td width="116" height="25" align="center" class="bg_tr"><strong>充值卡号</strong></td>
    <td width="88" height="25" align="center" class="bg_tr"><strong>密码</strong></td>
    <td width="75" align="center" class="bg_tr"><strong>面值</strong></td>
    <td width="82" height="25" align="center" class="bg_tr"><strong>点数</strong></td>
    <td width="100" align="center" class="bg_tr"><strong>过期时间</strong></td>
    <td width="80" height="25" align="center" class="bg_tr"><strong>出售情况</strong></td>
    <td width="80" align="center" class="bg_tr"><strong>使用情况</strong></td>
    <td width="100" height="25" align="center" class="bg_tr"><strong>使用者</strong></td>
    <td width="100" height="25" align="center" class="bg_tr"><strong>充值时间</strong></td>
    <td width="130" align="center" class="bg_tr"><strong>操作</strong></td>
  </tr>
  <%
  CurrentPage	= actcms.ChkNumeric(request("page"))
  Dim Param:Param=" where 1=1"
  Select Case  actcms.ChkNumeric(request("Status"))
   Case 1
     Param=Param & " And IsUsed=0"
   Case 2
     Param=Param & " And IsUsed=1"
   Case 3
     Param=Param & " And datediff('d',EndDate,"&NowString&")>0"
   Case 4
     Param=Param & " And datediff('d',EndDate,"&NowString&")<0"
  End Select
  
  Dim SqlStr:SqlStr="Select ID,CardNum,CardPass,Money,ValidNum,ValidUnit,AddDate,EndDate,UseDate,UserName,IsUsed,IsSale From Card_ACT " & Param & " order by ID desc"
  Set RS=Server.CreateObject("ADODB.RecordSet")
    RS.Open SqlStr,conn,1,1
	If RS.Eof And RS.Bof Then
	 Response.Write "<tr><td colspan=11 align=center height=25 >没有充值卡！</td></tr>"
	Else
                    TotalPut=rs.recordcount
					if (TotalPut mod MaxPerPage)=0 then
						TotalPages = TotalPut \ MaxPerPage
					else
						TotalPages = TotalPut \ MaxPerPage + 1
					end if
					if CurrentPage > TotalPages then CurrentPage=TotalPages
					if CurrentPage < 1 then CurrentPage=1
					rs.move (CurrentPage-1)*MaxPerPage
					SQL = rs.GetRows(MaxPerPage)
					rs.Close:set rs=Nothing
					ShowContent
   End If
%>		
</table>
<table border="0" style="margin-top:20px" width="90%" align=center>
<tr><td><Font color=red><strong>提示：</strong>
已售出或已使用的充值卡，不允许删除，修改等操作。</font>
</td></tr>
</table>
<%End Sub
Sub ShowContent
 Dim InPoint,OutPoint
 %>
 <form name=selform method=post action=?action=Del>
 <%
For i=0 To Ubound(SQL,2)
	%>
  <tr height="25"  onMouseOver=overColor(this) onMouseOut=outColor(this)>
    <td align="center"  ><input type="checkbox" name="id" value="<%=SQL(0,i)%>"></td>
    <td align="center"  ><%=SQL(1,i)%></td>
    <td align="center"  ><%=SQL(2,i)%></td>
    <td align="center"  ><%=SQL(3,i)%>元</td>
    <td align="center"  ><%Response.Write SQL(4,I)
	if SQL(5,I)=1 Then 
	 Response.Write "点" 
	ELSEIf SQL(5,I)=2 Then 
	 Response.Write "天" 
	elseif SQL(5,I)=3 Then
	 response.write "元"
	end if%></td>
    <td align="center"  ><%Response.Write formatdatetime(SQL(7,I),2)%></td>
    <td align="center"  >
	<%
	IF SQL(11,I)=1 Then
	 Response.Write "已售出"
	Else
	 Response.Write "<font color=red>未出售</font>" 
	End If
	%></td>
    <td align="center"  >
	<%
	IF SQL(10,I)=1 Then
	 Response.Write "<font color='#a7a7a7'>已使用</font>"
	Else
	 Response.Write "<font color=red>未使用</font>" 
	End If
	%></td>
    <td align="center"  ><%Response.Write SQL(9,I)%></td>
    <td align="center"  >
	<%if Isdate(Sql(8,i)) then
	   response.write formatdatetime(SQL(8,i),2)
	  end if%></td>
	<td align="center"  >
	<%if SQL(11,I)<>1 and SQL(10,I)<>1 then%>
	<a href="?action=Edit&ID=<%=SQL(0,i)%>">修改</a> <a href="?action=Del&ID=<%=SQL(0,i)%>">删除</a>
	<%end if%>
	</td>
  </tr>
  <%Next
  
  Response.Write "<tr><td height='30' colspan=11  >"
  Response.Write "&nbsp;&nbsp;<input id=""chkAll"" onClick=""CheckAll(this.form)"" type=""checkbox"" value=""checkbox""  name=""chkAll""><label for=""chkAll"">全选&nbsp;&nbsp;</label><input class=act_btn type=""submit"" name=""Submit2"" value="" 删除选中的充值卡 "" onclick=""{if(confirm('此操作不可逆，确定要删除选中的记录吗?')){this.document.selform.submit();return true;}return false;}"">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
  Call ShowPagePara(totalPut, MaxPerPage,"Card_Act.asp?action=Add", True, "条记录", CurrentPage, "status=" & request("status"))
  Response.Write "</td></tr></form>"
End Sub

 '删除充值卡
 Sub Del()
  Dim ID:ID=Replace(request("ID"),"Card_Act.asp?action=Add","Card_Act.asp?action=Add")
  Conn.Execute("Delete From Card_ACT Where ID In(" & ID &") and IsSale=0 and IsUsed=0")
  Response.Write "<script>alert('删除成功！');location.href='" & Request.Servervariables("http_referer") & "';</script>"
 End Sub
		
		'批量添加充值卡
		Sub AddMore()
		%>
		<form method='post' action='?' name='myform'>
  <table width='98%' border='0' align='center' cellpadding='2' cellspacing='1' class='table' >
    <tr class="bg_tr"> 
      <td height='22' colspan='2'> <div align='center'><strong>批 量 生 成 充 值 卡</strong></div></td>
    </tr>
    <tr > 
      <td width='40%'><strong>充值卡数量：</strong></td>
      <td width='60%'><input name='Nums' type='text' value='100' size='10' maxlength='10'>
        张</td>
    </tr>
    <tr >
      <td width='40%'><strong>充值卡号码前缀：</strong><br>
        例如：2006,Act2007等固定不变的字母或数字</td>
      <td width='60%'><input name='CardNumPrefix' type='text' id='CardNumPrefix' value='ACT2007' size='10' maxlength='10'></td>
    </tr>
    <tr >
      <td width='40%'><strong>充值卡号码位数：</strong><br>请输入包含前缀字符在内的总位数</td>
      <td width='60%'><input name='CardNumLen' type='text' id='CardNumLen' value='12' size='10' maxlength='10'>
        <font color='#0000FF'>建议设为10-15位</font></td>
    </tr>
    <tr >
      <td width='40%'><strong>充值卡密码位数：</strong></td>
      <td width='60%'><input name='PasswordLen' type='text' id='PasswordLen' value='6' size='10' maxlength='10'>
        <font color='#0000FF'>建议设为6-10位</font></td>
    </tr>
    <tr >
      <td><strong>卡密码构成方式：</strong><br>你可以选择数据或字母的组合</td>
      <td><input type="radio" name="zhtype" value="1" checked>纯数字 <input type="radio" name="zhtype" value="2">数字与字母随机组合 </td>
    </tr>
    <tr >
      <td width='40%'><strong>充值卡面值：</strong><br>
      即购买人需要花费的实际金额</td>
      <td width='60%'><input name='Money' type='text' id='Money' value='50' size='10'>
      元</td>
    </tr>
    <tr > 
      <td width='40%'><strong>充值卡点数、资金或有效期：</strong><br>
        购买人可以得到的点数、资金或有效期      </td>
      <td width='60%'><input name='ValidNum' type='text' id='ValidNum' value='50' size='10' maxlength='10'>
        <select name='ValidUnit' id='ValidUnit'>
          <option value='1' selected>资金</option>
          <option value='2'>积分</option>
        </select></td>
    </tr>
    <tr >
      <td width='40%'><strong>充值截止期限：</strong><br>
      购买人必须在此日期前进行充值，否则自动失效</td>
      <td width='60%' ><input name='EndDate' type='text' id='EndDate' value='<%=now+365%>' size='10' maxlength='10'></td>
    </tr>
    <tr > 
      <td height='40' colspan='2' align='center'><input name='Action' type='hidden' id='Action' value='DoAddMore'> 
        <input  class="ACT_btn" type='submit' name='Submit' value=' 开始生成 ' style='cursor:hand;'> 
        &nbsp; <input class="ACT_btn" name='Cancel' type='button' id='Cancel' value=' 取 消 ' onClick="window.location.href='?'" style='cursor:hand;'></td>
    </tr>
  </table>
</form>
		<%
		End Sub	
		'添加充值卡
		Sub Add()
		  Dim CardNum,PassWord,IsSale,IsUsed,Money,ValidNum,ValidUnit,EndDate,action1
		  Dim ID:ID=actcms.ChkNumeric(request("ID"))
		  if request("action")="Edit" then
		    Dim RS:Set RS=Server.CreateObject("adodb.recordset")
			rs.open "select * from Card_ACT where ID=" & ID,conn,1,1
			if rs.bof and rs.eof then
			  rs.close:set rs=nothing
			  Call ACTCMS.Alert("参数传递出错！","Card_Act.asp?action=Add")
			  Exit sub
			end if
			CardNum=rs("CardNum")
			PassWord=rs("CardPass")
			Money=rs("money")
			ValidNum=rs("ValidNum")
			ValidUnit=rs("ValidUnit")
			EndDate=rs("EndDate")
			IsSale=rs("IsSale")
			IsUsed=rs("IsUsed")
			action1="Edit"
		  else
		   IsSale=0:IsUsed=0:Money=50:ValidNum=50:ValidUnit=1:EndDate=Now+365
		  end if
		%>
  <table width='98%' border='0' align='center' cellpadding='2' cellspacing='1' class='table' >
		<form method='post' action='?action1=<%=action1%>&id=<%=ID%>' name='myform'>
	<tr  class="bg_tr"> 
      <td height='22' colspan='2' class="bg_tr"> <div align='center'><strong>
	  <%IF request("Action")="Edit" then
	   response.write "修 改 充 值 卡"
	    Else
		Response.Write "添 加 充 值 卡"
	    End If
		%></strong></div></td>
    </tr>
   <tr <%if request("action")="Edit" Then response.write " style='display:none'"%>> 
      <td width='40%'><strong>添加方式：</strong></td>
      <td width='60%'><input name='AddType' type='radio' value='0' checked onClick="trSingle1.style.display='';trSingle2.style.display='';trBatch.style.display='none';"> 单张充值卡&nbsp;&nbsp;&nbsp;&nbsp;<input name='AddType' type='radio' value='1' onClick="trSingle1.style.display='none';trSingle2.style.display='none';trBatch.style.display='';">批量添加充值卡</td>
    </tr>
    <tr  id='trSingle1'>
      <td width='40%'><b>充值卡卡号：</b></td>
      <td><input name='CardNum' type='text' id='CardNum' size='20' value="<%=CardNum%>" maxlength='30'>
        <font color='#0000FF'>建议设为10-""5位</font></td>
    </tr>
    <tr  id='trSingle2'>
      <td width='40%'><b>充值卡密码：</b></td>
      <td><input name='Password' type='text' id='Password' size='20' value="<%=PassWord%>" maxlength='30'>
        <font color='#0000FF'>建议设为6-""0位 </font></td>
    </tr>
    <tr  id='trBatch' style='display:none'>
      <td width='40%'><b>格式文本：</b><br><font color='red'>请按照每行一张卡，每张卡按“卡号＋分隔符＋密码”的格式录入</font><br>
      例：734534759|Actf15f4ag5te（以“|”作为分隔符）</td>
      <td><textarea name='CardList' rows='10' cols='50'></textarea></td>
    </tr>
    <tr >
      <td width='40%'><strong>充值卡面值：</strong><br>
      即购买人需要花费的实际金额</td>
      <td width='60%'><input name='Money' type='text' id='Money' value='<%=Money%>' size='10'>
      元</td>
    </tr>
    <tr > 
      <td width='40%'><strong>充值卡点数、资金或有效期：</strong><br>
        购买人可以得到的点数、资金或有效期      </td>
      <td width='60%'><input name='ValidNum' value="<%=ValidNum%>" type='text' id='ValidNum'  size='10' maxlength='10'>
        <select name='ValidUnit' id='ValidUnit'>
          <option value='1'<%if ValidUnit="1" then response.write " selected"%>>资金</option>
          <option value='2'<%if ValidUnit="2" then response.write " selected"%>>积分</option>
        </select></td>
    </tr>
    <tr >
      <td width='40%'><strong>充值截止期限：</strong><br>
      购买人必须在此日期前进行充值，否则自动失效</td>
      <td width='60%' ><input name='EndDate' type='text' id='EndDate' value='<%=EndDate%>' size='10' maxlength='10'></td>
    </tr>
	<tr >
      <td width='40%'><strong>是否出售：</strong><br>
      添加新充值卡，请选项未出售</td>
      <td width='60%' ><input name='issale' type='radio' id='issale' value='0'<%if issale=0 then response.write " checked"%>>未出售 <input name='issale' type='radio' id='issale' value='1'<%if issale=1 then response.write " checked"%>>已出售</td>
    </tr>
	<tr >
      <td width='40%'><strong>是否使用：</strong><br>
      添加新充值卡，请选项未使用</td>
      <td width='60%' ><input name='isused' type='radio' id='isused' value='0'<%if isused=0 then response.write " checked"%>>未使用 <input name='isused' type='radio' id='isused' value='1'<%if isused=1 then response.write " checked"%>>已使用</td>
    </tr>
    <tr > 
      <td height='40' colspan='2' align='center'><input name='Action' type='hidden' id='Action' value='DoAdd'> 
        <input class="ACT_btn" type='submit' name='Submit' value=' <% if request("action")="Edit" then response.write "确定修改" Else Response.write "开始生成" %> ' style='cursor:hand;'> 
        &nbsp; <input class="ACT_btn"  name='Cancel' type='button' id='Cancel' value=' 取 消 ' onClick="window.location.href='?'" style='cursor:hand;'></td>
    </tr></form>
  </table>

		<%
		End Sub
		
		'开始生成充值卡
		Sub DoAdd()
		 Dim AddType:AddType=request("AddType")
		 Dim CardNum:CardNum=request("CardNum")
		 Dim Password:Password=request("Password")
		 Dim CardList:CardList=request("CardList")
		 Dim Money:Money=actcms.ChkNumeric(request("Money"))
		 Dim ValidNum:ValidNum=actcms.ChkNumeric(request("ValidNum"))
		 Dim ValidUnit:ValidUnit=request("ValidUnit")
		 Dim EndDate:EndDate=request("EndDate")
		 Dim IsUsed:IsUsed=request("IsUsed")
		 Dim ISSale:IsSale=request("IsSale")
		 IF Money=0 Then Call ACTCMS.Alert("充值卡面值，必须大于0","Card_Act.asp?action=Add"):exit sub
		 IF ValidNum=0 Then Call ACTCMS.Alert("充值卡点数，必须大于0","Card_Act.asp?action=Add"):exit sub
		 If Not IsDate(EndDate) Then Call ACTCMS.Alert("充值截止期限格式不正确!","Card_Act.asp?action=Add"):exit sub
          If AddType=0 or request("action1")="Edit" then
		    if CardNum="" then call ACTCMS.Alert("你没有输入充值卡号!","Card_Act.asp?action=Add"):exit sub
			if PassWord=" "then call ACTCMS.Alert("你没有输入充值卡密码","Card_Act.asp?action=Add"):exit sub
			
			   Dim RS:Set RS=Server.CreateObject("adodb.recordset")
			    if request("action1")="Edit" then
				 rs.open "select * from Card_ACT where id=" & actcms.ChkNumeric(request("id")),conn,1,3
				else
					if not conn.execute("select cardnum from Card_ACT where cardnum='" & cardnum & "'").eof then
					  call ACTCMS.Alert("你输入的充值卡号已存在，请重输!","Card_Act.asp?action=Add"):exit sub
					end if
				   rs.open "select * from Card_ACT",conn,1,3
				   rs.addnew
				   rs("AddDate")=now
			   end if
				 rs("cardnum")=CardNum
				 rs("cardpass")=PassWord
				 rs("money")=money
				 rs("ValidNum")=ValidNum
				 rs("ValidUnit")=ValidUnit
				 rs("enddate")=EndDate
				 rs("isused")=isused
				 rs("isSale")=issale
			   rs.update
			   rs.close:set rs=nothing
		  else 
		    if CardList="" then call ACTCMS.Alert("你没有输入充值卡号!","Card_Act.asp?action=Add"):exit sub
			Dim i,j,CardAndPass,CardArr:CardArr=Split(CardList,vbcrlf)
			For I=0 to Ubound(CardArr)
			   CardAndPass=Split(CardArr(I),"|")
			   if not conn.execute("select cardnum from Card_ACT where cardnum='" & CardAndPass(0) & "'").eof then
					 call ACTCMS.Alert("你输入的充值卡号已存在，请重输!","Card_Act.asp?action=Add"):exit sub
			   else
				   Set RS=Server.CreateObject("adodb.recordset")
				   rs.open "select * from Card_ACT",conn,1,3
				   rs.addnew
					 rs("cardnum")=CardAndPass(0)
					 rs("cardpass")=CardAndPass(1)
					 rs("money")=money
					 rs("ValidNum")=ValidNum
					 rs("ValidUnit")=ValidUnit
					 rs("AddDate")=now
					 rs("enddate")=EndDate
					 rs("isused")=isused
					 rs("isSale")=issale
				   rs.update
				   rs.close:set rs=nothing
			  end if
			Next
		  end if
		  if request("action1")="Edit" then
			   response.write "<script>alert('修改充值卡成功！');location.href='?';</script>"
		  else
			   response.write "<script>alert('添加充值卡成功！');location.href='?';</script>"
		  end if
		End Sub
		'批量生成充值卡操作
		Sub DoAddMore()
		 Dim Nums:Nums=actcms.ChkNumeric(request("Nums"))
		 Dim CardNumPrefix:CardNumPrefix=request("CardNumPrefix")
		 Dim CardNumLen:CardNumLen=actcms.ChkNumeric(request("CardNumLen"))
		 Dim PasswordLen:PasswordLen=actcms.ChkNumeric(request("PasswordLen"))
		 Dim zhtype:zhtype=request("zhtype")
		 Dim Money:Money=actcms.ChkNumeric(request("money"))
		 Dim ValidNum:ValidNum=actcms.ChkNumeric(request("ValidNum"))
		 Dim ValidUnit:ValidUnit=request("ValidUnit")
		 Dim EndDate:EndDate=request("EndDate")
		 IF Nums=0 Then Call ACTCMS.Alert("生成充值卡数量，必须大于0","Card_Act.asp?action=Add"):exit sub
		 IF CardNumLen=0 Then Call ACTCMS.Alert("充值卡号码长度，必须大于0","Card_Act.asp?action=Add"):exit sub
		 IF PasswordLen=0 Then Call ACTCMS.Alert("充值卡密码长度，必须大于0","Card_Act.asp?action=Add"):exit sub
		 IF Money=0 Then Call ACTCMS.Alert("充值卡面值，必须大于0","Card_Act.asp?action=Add"):exit sub
		 IF ValidNum=0 Then Call ACTCMS.Alert("充值卡点数，必须大于0","Card_Act.asp?action=Add"):exit sub
		 If Not IsDate(EndDate) Then Call ACTCMS.Alert("充值截止期限格式不正确!","Card_Act.asp?action=Add"):exit sub
		 %>
		 		   <br>
			  <table width='300'  border='0' align='center' cellpadding='2' cellspacing='1' class='table'>
				<tr  class="bg_tr">
				  <td colspan='2' align='center'><strong>本次生成的点卡信息如下：</strong></td>
				</tr>
				<tr >
				  <td width='100'>充值卡数量：</td>
				  <td><%=nums%> 张</td>
				</tr>
				<tr >
				  <td width='100'>充值卡面值：</td>
				  <td><%=money%> 元</td>
				</tr>
				<tr >
				  <td width='100'>
				  <% select case ValidUnit
					case 1:response.write "充值卡点数："
					case 2:response.write "充值卡有效天数："
					case 3:response.write "充值卡金额："
					end select
					%></td>
				  <td>
				  <% response.write ValidNum
				  select case validunit
				   case 1:response.write " 点"
				   case 2:response.write " 天"
				   case 3:response.write " 元"
				  end select
				  %>
			      </td>
				</tr>
				<tr >
				  <td width='100'>充值截止日期：</td>
				  <td><%=enddate%></td>
				</tr>
				
</table>
			<br>
			<table width='300' border='0' align='center' cellpadding='2' cellspacing='1' class="table">
		  <tr align='center' class="bg_tr">
			<td  width=150 height='22'><strong> 卡 号 </strong></td>
			<td  width=150 height='22'><strong> 密 码 </strong></td>
		  </tr>
		 <%
		 Dim n,currcard,CurrCardPass
		 For N=1 To Nums
		   CurrCard=ACTCMS.MakeRandom(CardNumLen-len(CardNumPrefix))
		   CurrCard=CardNumPrefix & CurrCard
		   If ZhType=2 then
		     CurrCardPass=ACTCMS.GetRandomize(PasswordLen)
		   Else
		     CurrCardPass=ACTCMS.MakeRandom(PasswordLen)
		   End If
		   Do While not Conn.execute("select CardNum From Card_ACT Where CardNum='" & CurrCard & "'").eof 
			   CurrCard=ACTCMS.MakeRandom(CardNumLen-len(CardNumPrefix))
			   CurrCard=CardNumPrefix & CurrCard
		   loop
		   
		   response.write "<tr align='center' >" & vbcrlf
		   response.write "<td height='22'>" & CurrCard & "</td>" & vbcrlf
		   response.write "<td>" & CurrCardPass & "</td>" & vbcrlf
		   response.write "</tr>" & vbcrlf
		   Dim RS:Set RS=Server.CreateObject("adodb.recordset")
		   rs.open "select * from Card_ACT",conn,1,3
		   rs.addnew
		     rs("cardnum")=CurrCard
			 rs("cardpass")=CurrCardPass
			 rs("money")=money
			 rs("ValidNum")=ValidNum
			 rs("ValidUnit")=ValidUnit
			 rs("AddDate")=now
			 rs("enddate")=EndDate
			 rs("isused")=0
			 rs("isSale")=0
		   rs.update
		   rs.close:set rs=nothing
		   %>
		   
		   <%
		 Next
		 		   response.write "</table>"

		End SUb	
	Public Function ShowPagePara(totalnumber, MaxPerPage, FileName, ShowAllPages, strUnit, CurrentPage, ParamterStr)
		  Dim N, I, PageStr
				Const Btn_First = "第一页"'样式定义
				Const Btn_Prev = "上一页" 
				Const Btn_Next = "下一页" 
				Const Btn_Last = "最后一页" 
				  PageStr = ""
					If totalnumber Mod MaxPerPage = 0 Then
						N = totalnumber \ MaxPerPage
					Else
						N = totalnumber \ MaxPerPage + 1
					End If
				If N > 1 Then
					PageStr = PageStr & ("页次：<font color=red>" & CurrentPage & "</font>/" & N & "页 共有:" & totalnumber & strUnit & " 每页:" & MaxPerPage & strUnit & " ")
					If CurrentPage < 2 Then
						PageStr = PageStr & Btn_First & " " & Btn_Prev & " "
					Else
						PageStr = PageStr & ("<a href=" & FileName & "?page=1" & "&" & ParamterStr & ">" & Btn_First & "</a> <a href=" & FileName & "?page=" & CurrentPage - 1 & "&" & ParamterStr & ">" & Btn_Prev & "</a> ")
					End If
					
					If N - CurrentPage < 1 Then
						PageStr = PageStr & " " & Btn_Next & " " & Btn_Last & " "
					Else
						PageStr = PageStr & (" <a href=" & FileName & "?page=" & (CurrentPage + 1) & "&" & ParamterStr & ">" & Btn_Next & "</a> <a href=" & FileName & "?page=" & N & "&" & ParamterStr & ">" & Btn_Last & "</a> ")
					End If
					If ShowAllPages = True Then
						PageStr = PageStr & ("GO:<select  onChange='location.href=this.value;' style='width:55;' name='select'>")
				   For I = 1 To N
					 If Cint(CurrentPage) = I Then
						PageStr = PageStr & ("<option value=" & FileName & "?page=" & I & "&" & ParamterStr & " selected>NO." & I & "</option>")
					 Else
						 PageStr = PageStr & ("<option value=" & FileName & "?page=" & I & "&" & ParamterStr & ">NO." & I & "</option>")
					 End If
				   Next
				  PageStr = PageStr & "</select>"
				  End If
			 End If
			 ShowPagePara = PageStr
			 response.write ShowPagePara
	End Function
%> 
<script language="javascript">

function CheckAll(form)
		  {  
		 for (var i=0;i<form.elements.length;i++)  
			{  
			   var e = selform.elements[i];  
			   if (e.name != 'chkAll'&&e.type=="checkbox")  
			   e.checked = selform.chkAll.checked;  
		   }  
	  }function overColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="tdbg1"
		Obj.bgColor="";
	}
	
}
function outColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="tdbg";
		Obj.bgColor="";
	}
}
</script>