<%@ Control Language="C#" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="Kesion.Config" %>
<%@ Import Namespace="Kesion.Components" %>
<%@ Import Namespace="Kesion.HtmlTags" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Kesion.XML" %>
<script runat="server" type="text/C#">
    public static string path = MyCache.GetCacheConfig(0) + "Plus/Plus.ShareReturn/ShareConfig.config"; //配置文件的绝对路径
    //每天提现额度
    float withdrawdaily = Utils.StrToFloat(XmlObject.ReadXmlReturnNode(Utils.GetMapPath(path), "//shareconfig/withdrawdaily"));
    //余额满多少可以提现     
    float money = Utils.StrToFloat(XmlObject.ReadXmlReturnNode(Utils.GetMapPath(path), "//shareconfig/money"));
    //当前用户收益总额
    float SumReturn = Utils.StrToFloat(DataFactory.GetOnlyValue("SELECT TOP 1 SumReturn FROM KS_ShareReturnDraw WHERE UserID=" + new TemporaryVar().UserID + " ORDER BY ID DESC"));

    protected void Page_Load(object sender, EventArgs e)
    {
        if (KSCMS.S("action").Equals("dosave"))
        {
            WithDrawMoney();
        }
    }

    private void WithDrawMoney()
    {

        #region 添加提现记录
        float withdraw = Utils.StrToFloat(KSCMS.S("BlogName"));
        if (SumReturn >= money)  //满足提现条件
        {
            int i = 0;
            if (!int.TryParse(KSCMS.S("BlogName"),out i))
            {
                Msg.Alert("请输入有效数字!");
            }
            if (withdraw <= 0)
            {
                Msg.Alert("提现金额必须大于0", KSCMS.GetComeUrl());
            }
            if (withdraw > withdrawdaily)
            {
                Msg.Alert("提现金额超出每日提现额度", KSCMS.GetComeUrl());
            }
            if (withdraw > 0 && withdraw <= withdrawdaily)
            {
                if (!DataFactory.Exists("KS_ShareReturnDraw", "UserID=" + new TemporaryVar().UserID + " AND Type=3 AND DATEDIFF(DAY,AddDate,GETDATE())=0") || !DataFactory.Exists("KS_ShareReturnDraw", "UserID=" + new TemporaryVar().UserID + " AND Type=3 AND Status=0"))
                {
                    Hashtable ht = new Hashtable();
                    ht.Add("SumReturn", SumReturn);
                    ht.Add("UserID", new TemporaryVar().UserID);
                    ht.Add("UserName", new TemporaryVar().UserName);
                    ht.Add("Withdraw", withdraw);
                    ht.Add("AddDate", DateTime.Now);
                    ht.Add("Type", 3);
                    ht.Add("Status", 0);
                    ht.Add("Remark", new TemporaryVar().UserName + "提现" + withdraw + "元");
                    CommonData.Insert("KS_ShareReturnDraw", ht);
                    Msg.Alert("提交成功，请等待审核");
                }
            }
        }
        else
        {
            Msg.Alert("余额达到" + money + "才能提现,继续加油吧！");
        }
        #endregion
    }
</script>

<div class="r_tybox t_tybox nomar clearfix">

    <div class="r_title tytitle  pd0">
        <div class="tabs " style="float:left">
            <ul>
                <li><a href="<%=BasicField.GetUserUrl("basic/MyWithdraw")%>">收益详情</a></li>
                <li><a href="<%=BasicField.GetUserUrl("basic/MyWithdrawLog")%>">提现记录</a></li>
                <li class="puton"><a href="<%=BasicField.GetUserUrl("basic/Withdraw")%>">我要提现</a></li>
            </ul>
        </div>  
    </div>
    <div class="top-sort clearfix">
        <div class="top-sort-tab lf">
            <ul>
                <li class="puton"><a href="<%=BasicField.GetUserUrl("basic/Withdraw") %>" class="button">我的提现</a></li>
            </ul>
        </div>
        <div class="top-sort-option rf">
            <a href="javaxcript:;">当前总金额：<%=SumReturn %>元</a>
        </div>
    </div>
    <div>
        <form name="myform" action="{$GetCurrUrl}" method="post" id="myform">
            <input type="hidden" name="action" value="dosave" />
            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
                <tr class="tdbg">
                    <td class="lefttd">提现金额：</td>
                    <td class="tag_left">
                        <input type="text" name="BlogName" id="BlogName" class="textbox" />
                        <span class="tips">Tips:账户收益余额到达<%=money %>元可以提现，每天限额<%=withdrawdaily %>元，当前提现审核后才能进行下次提现！</span>
                    </td>
                </tr>
            </table>
            <div class="cz_btn t-a-center">
                <input type="submit" id="Button1" name="withdraw" class="green-bt bt-w-auto d-inline-block" onclick="return (checkform())" value="提交申请" />
            </div>
        </form>
    </div>
</div>
<script>
     //校验是否为数字
        function isNumber(val) {

            var regPos = /^\d+(\.\d+)?$/; //非负浮点数
            var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
            if (regPos.test(val) || regNeg.test(val)) {
                return true;
            } else {
                return false;
            }
        }
   function checkform()
{
if 
}
</script>
