<!--#include file="User_Const.asp"-->
<%
Dim BwToCpRate,CpToBwRate,ConverRate,BwItemName,CpItemName,BwColumn,CpColumn
BwToCpRate=5
CpToBwRate=5

BwItemName="论坛金钱"
CpItemName="网站点数"
BwColumn=Db.UserWealth'""
CpColumn=Db.UserPoint'""
%>
<html>
<head>
<title><%=BwItemName%>与<%=CpItemName%>互换</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../Skins/User_Style.Css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<br>
<%
Dim Action,rsUser,sqlUser
Dim UserWealth,UserPoint,ConverAmount
Dim ConverType,ConverMsg
Dim sContent,sConPoint,sConRate,sTrueConPoint
Action		= Trim(request("Action"))
ConverAmount= Cl.ChkClng(Request("ConverAmount"))
ConverType	= Cl.ChkClng(request("ConverType"))
if ConverType=1 then
	ConverRate=CpToBwRate
else
	ConverRate=BwToCpRate
end if
Select Case Action
Case "DoConver"
	Call DoConver()
Case Else
	Call Main()
End Select

Sub DoConver()
	if ConverAmount<=0 then User_ShowErr("<br><li>请输入要转换的数量</li>")
	Set rsUser=Server.CreateObject("Adodb.RecordSet")
	sqlUser="Select " & BwColumn & "," & CpColumn & " from " & Db.UserTable & " where " & Db.UserID & "=" & Cl.UserID & ""
	OpenConn_U : rsUser.Open sqlUser,Conn_U,1,3
	if rsUser.bof and rsUser.eof then
		rsUser.close : set rsUser=nothing
		User_ShowErr("<br><li>找不到指定的用户！</li>")
	End if
	if ConverType=1 then
		if ConverAmount>rsUser(1) then
			ConverAmount=rsUser(1)*ConverRate
		else
			ConverAmount=ConverAmount*ConverRate
		end if
		rsUser(0)	= rsUser(0)+ConverAmount
		rsUser(1)	= rsUser(1)-(ConverAmount\ConverRate)
		rsUser.update
		sConPoint		= ConverAmount\ConverRate
		sTrueConPoint	= ConverAmount
		sConRate		= "<font color=#ff0033>"&ConverRate&"</font>:<font color=#0000ff>1</font>"

		ConverMsg		= "成功将 <font color=#0000ff><b>" & sConPoint & "</b></font> 点点数转换为 <font color=#ff0033><b>" & sTrueConPoint & "</b></font> 点论坛金钱！<br>"
	else
		if ConverAmount>rsUser(0) then
			ConverAmount=(rsUser(0)\ConverRate)*ConverRate
		else
			ConverAmount=(ConverAmount\ConverRate)*ConverRate
		end if
		Response.write ConverAmount
		Response.end
		rsUser(0)	= rsUser(0)-ConverAmount
		rsUser(1)	= rsUser(1)+(ConverAmount\ConverRate)
		rsUser.update
		sConPoint		= ConverAmount
		sTrueConPoint	= ConverAmount\ConverRate
		sConRate		= "<font color=#ff0033>1</font>:<font color=#0000ff>"&ConverRate&"</font>"

		ConverMsg		= "成功将 <font color=#0000ff><b>" & sConPoint & "</b></font> 点论坛金钱转换为 <font color=#ff0033><b>" & sTrueConPoint & "</b></font> 点点数！<br>"
	end if
	'Cl.InToDataBase Cl.LogDataBase,"Cl_ConLog","UserID,UserName,Content,ConInName,ConOutName,ConInPoint,ConRate,ConOutPoint,ConTime",""&Cl.UserID&",'"&Cl.User_Info(5)&"','"&ConverMsg&"','"&Cl.User_Info(5)&"','"&Cl.User_Info(5)&"','"&sTrueConPoint&"','"&sConRate&"','" & sConPoint & "','"&Now&"'"
	ConverMsg=ConverMsg & "转换后，你的论坛金钱数量为：<font color=#0000ff><b>" & rsUser(0) & "</b></font>；点数为：<font color=#ff0033><b>" & rsUser(1) & "</b></font>。"
	rsUser.close : set rsUser=nothing
	Response.Write Cl.ShowSuc(ConverMsg)
End Sub
	
Sub Main()
	Set rsUser=Server.CreateObject("Adodb.RecordSet")
	sqlUser="Select " & BwColumn & "," & CpColumn & " from " & Db.UserTable & " where " & Db.UserID & "=" & Cl.UserID & ""
	OpenConn_U : rsUser.Open sqlUser,Conn_U,1,3
	if rsUser.bof and rsUser.eof then
		rsUser.close : set rsUser=nothing
		User_ShowErr("<br><li>找不到指定的用户！</li>")
	End if
%>
<FORM name="Form1" action="User_ConverPoint.asp" method="post">
  <table width=400 border=0 align="center" cellpadding=2 cellspacing=1 class="border">
	<%if ConverType=1 then%>
    <TR align=center class="title"> 
      <TD height=22 colSpan=2><font class=en><b><%=CpItemName%>转<%=BwItemName%></b></font></TD>
    </TR>
	<%else%>
    <TR align=center class="title"> 
      <TD height=22 colSpan=2><font class=en><b><%=BwItemName%>转<%=CpItemName%></b></font></TD>
    </TR>
	<%end if%>
    <TR Class="tdbg"> 
      <TD width="150" align="right"><b>用 户 名：</b></TD>
      <TD><%=Cl.User_Info(5)%></TD>
    </TR>
    <TR Class="tdbg"> 
      <TD width="150" align="right"><strong><%=BwItemName%>：</strong></TD>
      <TD><font color="green"><%=rsUser(0)%></font> 点</TD>
    </TR>
    <TR Class="tdbg">
      <TD width="150" align="right"><strong><%=CpItemName%>：</strong></TD>
      <TD><font color="green"><%=rsUser(1)%></font> 点</TD>
    </TR>
    <TR Class="tdbg">
      <TD width="150" align="right"><strong>转换数量：</strong></TD>
      <TD>将<%if ConverType=1 then%>
	  <INPUT name="ConverAmount" id="ConverAmount" value="<%=rsUser(1)%>" size=10 maxLength=10>
      <%=CpItemName%>转成<%=BwItemName%>
	  <%else%>
	  <INPUT name="ConverAmount" id="ConverAmount" value="<%=rsUser(0)%>" size=10 maxLength=10>
      <%=BwItemName%>转成<%=CpItemName%>
	  <%end if%></TD>
    </TR>
    <TR Class="tdbg">
      <TD width="150" align="right"><strong>提&nbsp;&nbsp;&nbsp;&nbsp;示：</strong></TD>
      <TD><%if ConverType=1 then
		response.write "每<b><font color=blue>1</font></b>点点数可转换为<b><font color=red>" & ConverRate & "</font></b>点论坛金钱"
	  else
		response.write "每<b><font color=red>" & ConverRate & "</font></b>点论坛金钱可转换为<b><font color=blue>1</font></b>点点数。"
	  end if
	  %></TD>
    </TR>
    <TR align="center" Class="tdbg">
      <TD height="40" colspan="2">
		<input name="Action" type="hidden" id="Action" value="DoConver">
		<input name="ConverType" type="hidden" id="ConverType" value="<%=ConverType%>"> 
        <input name="Submit" type="submit" id="Submit" value="我要转换"> </TD>
    </TR>
  </TABLE>
</form>
<%
	rsUser.close : set rsUser=nothing
End Sub
%>
<%
'===================================================
' CreateLive CMS Version 3.1
'							Powered by Aspoo.CoM
'===================================================
' Mail: aspoo@126.com, Info@aspoo.cn
' Q  Q: 3315263, 596197794
' Msn : aspoo@126.com, Clw866@hotmail.com
' Web : http://www.aspoo.com, http://www.aspoo.net
' Bbs : http://bbs.aspoo.com, http://bbs.aspoo.net
' Copyright (C) 2005 Aspoo.CoM All Rights Reserved.
'===================================================
%>
