<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Repayments.aspx.cs" Inherits="WAP2P.Web.PC.Test.Repayments" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <style type="text/css">
        input, select{padding:6px 20px; margin:3px;}
        table{border-collapse:collapse; }
        th,td{padding:3px 5px; white-space:nowrap;}
        #result{padding:5px 10px;}
    </style>    
</head>
<body>
<div>    
    <form action="" id="form1" method="post">
        <div>借款金额：<input type="number" name="amount" required="required" /> 借款时间：<input type="number" name="date" required="required" /><ruson:EnumSelect runat="server" ID="dateUnit" TypeName="WAP2P.Sys.BorrowType+LoanTimeUnit,WAP2P.Sys"></ruson:EnumSelect> 年化率：<input type="number" name="yearRate" required="required" /> 结算日：<input type="number" name="day" /></div>
        <div>投标日期：<input type="datetime" name="bidAt" required="required" /> 还款方式 <ruson:Select runat="server" ID="repayType"></ruson:Select> 费用年化率<input type="text" value="0" name="feeRate" /> 计息周期 <ruson:EnumSelect runat="server" ID="interestStartType" TypeName="WAP2P.Sys.BorrowType+InterestStartTypeEnum,WAP2P.Sys"></ruson:EnumSelect> 计息周期计算方式 <ruson:EnumSelect runat="server" ID="interestType" TypeName="WAP2P.Sys.BorrowType+InterestTypeEnum,WAP2P.Sys"></ruson:EnumSelect></div>
        <div><input type="submit" value="确定" style="display:block; width:100%; margin-top:6px;" /></div>
    </form>
    <div id="result"></div>
    <ruson:Repater runat="server" ID="rptReceives" Visible="false"  ItemType="WAP2P.BorrowLoan.Receive">
        <HeaderTemplate>
            <table border="1">
                <tr>
                    <th>期数</th>
                    <th>还款本金</th>
                    <th>还款利息</th>
                    <th>费用</th>
                    <th>还款总额</th>
                    <th>最后还款时间</th>
                </tr>
        </HeaderTemplate>
        <ItemTemplate>
            <tr>
                <td><%# Item.Period %></td>
                <td><%# Item.ShouldRepayPrincipal.ToMoneyString() %></td>
                <td><%# Item.ShouldRepayInterest.ToMoneyString() %></td>
                <td><%# Item.ShouldRepayFee.ToMoneyString() %></td>
                <td><%# (Item.ShouldRepayPrincipal + Item.ShouldRepayInterest + Item.ShouldRepayFee).ToMoneyString() %></td>
                <td><%# Item.ShouldRepayAt.ToDateTimeString() %></td>
            </tr>
        </ItemTemplate>
        <FooterTemplate>
            <tr>
                <td>合计</td>
                <td><% =list.Sum(o => o.ShouldRepayPrincipal).ToMoneyString() %></td>
                <td><% =list.Sum(o => o.ShouldRepayInterest).ToMoneyString() %></td>
                <td><% =list.Sum(o => o.ShouldRepayFee).ToMoneyString() %></td>
                <td><% =list.Sum(o => o.ShouldRepayPrincipal + o.ShouldRepayInterest + o.ShouldRepayFee).ToMoneyString() %></td>
                <td>共 <% =list.Count %> 期</td>
            </tr>
            </table>
        </FooterTemplate>
    </ruson:Repater>
</div>
<script src="../Res/core/Scripts/jquery.js"></script>
<script>
    $('#form1').submit(function () {        
        $.ajax({
            url: location.href,
            data: $('#form1').serialize(),
            beforeSend: function() {
                $('#result').empty();
            },
            success: function (res) {
                $('#result').html(res);
            }
        });
        return false;
    });
</script>
</body>
</html>
