<%if session("user")="" then
response.write "<script language='javascript'>"
response.write "alert('您没还有登录，请登录后再访问本页！');"
response.write"window.close();</SCRIPT>"
response.end
end if
if session("id")="" then 
response.write "<script language='javascript'>"
response.write "alert('您没还有登录，请登录后再访问本页！');"
response.write"window.close()';</SCRIPT>"
response.end
end if%>
<!--#include file="conn/conn.asp"-->
<!--#include file="conn/nosql.asp"-->
<!--#include file="conn/config.asp"-->
<%
act=nosql(request("act"))
jifen1=nosql(request("jifen"))
if act="dh" and isnumeric(jifen1) then
if jifen1<=0 then
response.write "<script language='javascript'>"
response.write "alert('您输入的金额不正确!!!');"
response.write"location.href='/dueihuan.asp'</SCRIPT>"
else
Set rs= Server.CreateObject("ADODB.Recordset") 
rs.open"select * from snsn_user where id="&session("id"),conn,1,3
if rs("jine")>=jifen1/jfen_qian then
rs("jine")=rs("jine")-jifen1/jfen_qian
rs("jifen")=rs("jifen")+jifen1
rs.update
session("jine")=rs("jine")
session("jifen")=rs("jifen")
response.write "<script language=javascript>alert('兑换成功,本页将会关闭！');window.close();window.opener.location.reload();</script>"
else
response.write "<script language='javascript'>"
response.write "alert('您的预存款不足！');"
response.write"location.href='/dueihuan.asp'</SCRIPT>"
end if
end if
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>预存款兑换银两-<%=webname%></title>

<style type="text/css">
<!--
.wenbenkuang {color: #333333;border: 1px solid #cccccc;font-family: "??";font-size: 9pt;}
.go-wenbenkuang {font-family: "??";font-size: 9pt;color: #333333;background-color: #eeeeee;cursor: hand;padding: 1px;height: 19px;border-top: 1px solid #FFFFFF;border-right: 1px solid #a2a2a2;border-bottom: 1px solid #a2a2a2;border-left: 1px solid #FFFFFF;}
.z12 {
	font-size: 12px;
}
.style1 {color: #FF0000}
-->
</style>
</head>

<body onload="javascript:form1.jifen.select()">
<%Set rs= Server.CreateObject("ADODB.Recordset") 
rs.open"select * from snsn_user where id="&session("id"),conn,1,1
%>
<form name="form1" method="post" action="?act=dh">
  <table width="262"  border="0" cellpadding="0" cellspacing="1" bgcolor="cccccc" class="z12">
    <tr align="center" bgcolor="#FFFFFF">
      <td width="260" height="21" bgcolor="efefef">预存款兑换银两</td>
    </tr>
    <tr align="center" bgcolor="#FFFFFF">
      <td height="21">兑换比率：<%=jfen_qian%>/1(银两/预存款)</td>
    </tr>
    <tr align="center" bgcolor="#FFFFFF">
      <td height="21">兑换银两：
        <input name="jifen" type="text" class="wenbenkuang"  style="ime-mode:disabled" onkeypress="return event.keyCode>=48&&event.keyCode<=57"  onkeyup="if(/(^0+)/.test(value))value=value.replace(/^0*/, '');ck1()" size="7" maxlength="8"  onpaste="var s=clipboardData.getData('text'); if(!/\D/.test(s)) value=s.replace(/^0*/,''); return false;" ondragenter="return false">
        [需要预存款：<font color=red id=aa>0</font>元] </td>
    </tr>
    <tr align="center" bgcolor="#FFFFFF">
      <td height="21" bgcolor="#FFFFFF">银两：<span class="style1"><%=rs("jifen")%></span>&nbsp;&nbsp;预存款：<span class="style1"><%=rs("jine")%></span>元</td>
    </tr>
    <tr align="center" bgcolor="#FFFFFF">
      <td height="21"><input name="Submit" type="submit" class="go-wenbenkuang" onClick="return ck()" value="兑换">      
      &nbsp;
      <input name="Submit2" type="button" class="go-wenbenkuang" onClick="window.close()" value="取消"></td>
    </tr>
  </table>
</form>
<script language=javascript>
function ck(){
dhsa=confirm('确定兑换')
if(dhsa)
{if(form1.jifen.value.length==0){
alert("请输入正确兑换金额")
form1.jifen.focus()
return false
}
}else{return false}
}
function ck1(){
aa.innerHTML=form1.jifen.value/<%=jfen_qian%>
}
</script>
</body>
</html>
