<%@ 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" %>
<script runat="server" type="text/C#">
    int recordcount, pagecount;
    int CurrPage = new BasicField().GetCurrPage;
    int PageSize = 10;
     public static int forward = 0;
    public static int browse = 0;
    //当前用户收益总额
    float SumReturn =Utils.StrToFloat(DataFactory.GetOnlyValue("SELECT sum(returnmoney)  FROM KS_ShareReturnDraw WHERE UserID=" + new TemporaryVar().UserID + " and status=1 and type!=3"));
    string param = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        param = " WHERE UserID=" + new TemporaryVar().UserID + " AND Type!=3";
        if (!IsPostBack)
        {
            forward = Utils.StrToInt(DataFactoryUser.GetOnlyValue("select count(1) from KS_ShareReturnDraw" + param + " AND Type=1"));
            browse = Utils.StrToInt(DataFactoryUser.GetOnlyValue("select count(1) from KS_ShareReturnDraw" + param + " AND Type=2"));
        }
    }
</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/ShareMain")%>">分享收益</a></li>
                <li class="puton"><a href="<%=BasicField.GetUserUrl("basic/MyWithdraw")%>">收益详情</a></li>
                <li><a href="<%=BasicField.GetUserUrl("basic/MyWithdrawLog")%>">提现记录</a></li>
               
            </ul>
        </div>
    </div>
    <div class="top-sort clearfix">
        <div class="top-sort-tab lf">
            <ul>
               
            </ul>
        </div>
        <div class="top-sort-option rf">
            <a href="javaxcript:;">当前总金额：<%=Kesion.APPCode.Public.ReturnShopPrice(SumReturn) %>元</a>
            <a href='<%=BasicField.GetUserUrl("basic/MyWithdraw") %>'>所有记录（<%=forward+browse %>）</a>
            <a href='<%=BasicField.GetUserUrl("basic/MyWithdraw","Type-1") %>'>转发记录（<%=forward %>）</a>
            <a href='<%=BasicField.GetUserUrl("basic/MyWithdraw","Type-2") %>'>浏览记录（<%=browse %>）</a>
        </div>
    </div>

    <table id="tablist" width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
        <tr align="center" class="title">
            <td align="center">用户</td>
            <td align="center">收益类型</td>
            <td align="center">收益金额</td>
            <td align="center">时间</td>
            <td align="center" width="300">备注</td>
        </tr>
        <%
            if (Utils.StrToInt(KSCMS.S("Type")) > 0)
            {
                param += " AND Type=" + Utils.StrToInt(KSCMS.S("Type"));
            }
            using (DataTable dt = DataFactoryUser.GetPage("*", "[KS_ShareReturnDraw]" + param, "id", "order by id desc", CurrPage, PageSize, out recordcount, out pagecount))
            {
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
        %>
        <tr>
            <td align="center"><%=dr["UserName"].ToString() %> </td>
            <td align="center" style="text-align: center"><%=dr["Type"].ToString() == "1" ? "转发收益" : dr["Type"].ToString() == "2" ? "浏览收益" : "" %> </td>
            <td align="center"><%=Kesion.APPCode.Public.ReturnShopPrice(dr["ReturnMoney"].ToString()) %></td>
            <td align="center"><%=Utils.FormatHumanizedTime(Convert.ToDateTime(dr["AddDate"].ToString())) %></td>
            <td align="center"><%=dr["Remark"].ToString() %></td>

        </tr>
        <%
                    }
                }
                else
                {
                    KSCMS.W(@" <tr class=""tdbg "">
                <td class=""splittd"" style=""border:0px;"" colspan=""10"">
                  <div class=""empty"">没有收益记录！<div>
                  <style>.cz_btn{display:none;}</style>
                </td>
           </tr> ");
                }
            }

        %>
    </table>

    <div class="fy_box">
        <%
            #region 分页
            string PageStr = "[KS:PageStr1]";
            BasicField.ReplaceFilterPage(ref PageStr, CurrPage, PageSize, pagecount, recordcount);
            KSCMS.W(PageStr);
            #endregion
        %>
    </div>

</div>
<script>
    var url = location.href.replace(location.origin, '');
    $('.top-sort-option').find('a').each(function () {
        var href = $(this).attr('href');
        if (href == url) {
            $(this).addClass('on');
        }
    });

</script>

