<%@ Page Title="记账_借贷" Language="C#" MasterPageFile="~/Master/officeMaster.master" AutoEventWireup="true" EnableEventValidation="false" CodeFile="Record_ Loan.aspx.cs" Inherits="A_Record_Record__Loan" %>
<%@ Register Src="~/Ucontrol/UcAccount.ascx" TagName="Account" TagPrefix="ucl" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <script src="../My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        function CheckEmpty() {
            var loanType = $("#<%=ddlLoanType.ClientID %>")[0];//借贷类型
            var loanMoney = $("#<%=txtLoanMoney.ClientID %>")[0]; //借贷金额
            var accountTypeId = $('#<%= uclAccount.FindControl("ddlAccountType").ClientID %>')[0]; //账户类型ID
            var cashAccount = $('#<%= uclAccount.FindControl("ddlCashAccount").ClientID %>')[0]; //现金账户
            var creditCard = $('#<%= uclAccount.FindControl("ddlCreditCard").ClientID %>')[0]; //信用卡
            var savingsCard = $('#<%= uclAccount.FindControl("ddlSavingsCard").ClientID %>')[0]; //储蓄卡
            var onlinePay = $('#<%= uclAccount.FindControl("ddlOnlinePay").ClientID %>')[0]; //网上支付
            var loanTime = $("#<%=txtLoanDateTime.ClientID %>")[0]; //借贷日期
            var repaymentDateTime = $("#<%=txtRepaymentDateTime.ClientID %>")[0]; //还款日（1-借入，2-借出需要）
            var Interest = $("#<%=txtInterest.ClientID %>")[0];//利息（3-收款，4-还款）
            if (loanMoney.value == '') {
                alert('金额不能为空！');
                loanMoney.focus();
                return false;
            }
            if (accountTypeId.value == '0') {
                alert('账户类型不能为空！');
                return false;
            }
            if (accountTypeId.value == '1') {//现金账户
                if (cashAccount.value == '0') {
                    alert('现金账户不能为空！');
                    return false;
                }
            }
            else if (accountTypeId.value == '2') {//信用卡
                if (creditCard.value == '0') {
                    alert('信用卡不能为空！');
                    return false;
                }
            }
            else if (accountTypeId.value == '3') {//储蓄卡
                if (savingsCard.value == '0') {
                    alert('储蓄卡不能为空！');
                    return false;
                }
            }
            else if (accountTypeId.value == '4') {//网上支付
                if (onlinePay.value == '0') {
                    alert('网上支付不能为空！');
                    return false;
                }
            }
            if (loanTime.value == '') {
                alert('时间不能为空');
                loanTime.focus();
                return false;
            }
            if (loanType.value == '1' || loanType.value == '2') {//（1-借入，2-借出）
                if(repaymentDateTime.value==''){
                    alert('还款日不能为空！');
                    repaymentDateTime.focus();
                    return false;
                }
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <%--    <table class="usertableborder" cellspacing="1" cellpadding="3" width="100%" align="center"
        border="0">
        <tr>
            <th>
                借贷
            </th>
        </tr>
    </table>--%>
     <div style="font-size: 15px;">
        <asp:Button ID="btnExpenditure" runat="server" Text="支 出" Style="
            width: 80px; height: 30px;" OnClick="btnExpenditure_Click" />
        <asp:Button ID="btnIncome" runat="server" Text="收 入" Style="width: 80px; height: 30px;"
            OnClick="btnIncome_Click" />
        <asp:Button ID="btnTransfer" runat="server" Text="转 账" Style="width: 80px; height: 30px;"
            OnClick="btnTransfer_Click" />
        <asp:Button ID="btnLoan" runat="server" Text="借 贷" Style="font-weight: bold;width: 80px; height: 30px;"
            OnClick="btnLoan_Click" />
    </div>
    <br />
    <table class="usertableborder" cellspacing="1" cellpadding="3" width="100%" align="center">
        <tr>
            <td width="48%" class="alignright">
                类型：
            </td>
            <td>
                <asp:DropDownList ID="ddlLoanType" runat="server" AutoPostBack="True" 
                    onselectedindexchanged="ddlLoanType_SelectedIndexChanged">
                    <asp:ListItem Text="借入" Value="1"></asp:ListItem>
                    <asp:ListItem Text="借出" Value="2"></asp:ListItem>
                    <asp:ListItem Text="收款" Value="3"></asp:ListItem>
                    <asp:ListItem Text="还款" Value="4"></asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="alignright">
                金额：
            </td>
            <td>
                <asp:TextBox ID="txtLoanMoney" runat="server" Width="140"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="alignright">
               <span id="spanSellerTdName" runat="server">债权人：</span>
            </td>
            <td>
                <asp:DropDownList ID="ddlLoanAccount" runat="server">
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="alignright">
                <span id="spanAccountTdName" runat="server">借入账户：</span>
            </td>
            <td>
                <ucl:Account ID="uclAccount" runat="server" OpenAjaxUrl="../Ajax/Ajax_CreditCard.aspx" OpenSavingsCardAjaxUrl="../Ajax/Ajax_SavingsCard.aspx" />
            </td>
        </tr>
        <tr>
            <td class="alignright">
                时间：
            </td>
            <td>
                <asp:TextBox ID="txtLoanDateTime" runat="server" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
                    Width="140"></asp:TextBox>
            </td>
        </tr>
        <tr id="trRepaymentDateTime" runat="server">
            <td class="alignright">
            还款日：
            </td>
            <td><asp:TextBox ID="txtRepaymentDateTime" runat="server" onfocus="WdatePicker()" Width="140"></asp:TextBox></td>
        </tr>
        <tr id="trInterst" runat="server">
            <td class="alignright">其中利息为：</td>
            <td><asp:TextBox ID="txtInterest" runat="server" Width="140">0</asp:TextBox></td>
        </tr>
        <tr id="trReplaymentInfo" runat="server">
            <td class="alignright">还款提醒：</td>
            <td>
                 <asp:DropDownList ID="ddlReplaymentInfoWay" runat="server">
                    <asp:ListItem Text="无需提醒" Value="1"></asp:ListItem>
                    <asp:ListItem Text="当天提醒" Value="2"></asp:ListItem>
                    <asp:ListItem Text="提前三天提醒" Value="3"></asp:ListItem>
                 </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <td class="alignright">备注：</td>
            <td><asp:TextBox ID="txtLoanRemarks" runat="server" TextMode="MultiLine" Height="50" Width="300"></asp:TextBox></td>
        </tr>
        <tr>
            <td align="center" colspan="2">
                <asp:Button ID="btnSubmit" runat="server" Text="提 交" Width="72" BackColor="#CCCCCC" 
                    OnClientClick="return CheckEmpty();" onclick="btnSubmit_Click"/>&nbsp;&nbsp;
                <asp:Button ID="btnCancel" runat="server" Text="返 回" Width="72" BackColor="#CCCCCC"  onclick="btnCancel_Click"/>
            </td>
        </tr>
    </table>
</asp:Content>

