<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PostIncome.aspx.cs" Inherits="MTCUN.Finance.PostIncome"
    Title="增加收支-财务" %>

<%@ Import Namespace="MTCUN" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link id="linkStyle" runat="server" href="../Themes/Blue/css.css" rel="stylesheet"
        type="text/css" />

        <script type="text/javascript">
        function NoDataTips() {
            var _billItems = document.getElementById("BillItems");
            if (_billItems.innerText.trim() == "") {
                _billItems.innerHTML = "<span style='color:red'>*</span>请增加收支项目，可增加多个项目。";
            }
        }
    </script>
</head>
<body onload="NoDataTips()">
    <form id="form1" runat="server">
        <div class="divpanel">
            <table class="table" cellspacing="0">
                <tr>
                    <th colspan="2">增加新的账目
                    </th>
                </tr>
                <tr>
                    <td>入帐日期：
                    </td>
                    <td class="required">
                        <asp:TextBox ID="tbxAccountDate" runat="server"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>校区：
                    </td>
                    <td class="required">
                        <asp:DropDownList ID="ddlSchool" runat="server" DataTextField="SchoolName" DataValueField="SchoolID">
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td>收支项目：
                    </td>
                    <td>
                        <div class="striking_head">
                            类型：<asp:DropDownList ID="ddlIncome" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlIncome_SelectedIndexChanged">
                                <asp:ListItem Value="-1">选择</asp:ListItem>
                                <asp:ListItem Value="0">支出</asp:ListItem>
                                <asp:ListItem Value="1">收入</asp:ListItem>
                            </asp:DropDownList>
                            &nbsp;账目分类：<asp:DropDownList ID="ddlIncomeClass" runat="server" DataTextField="IncomeClassName"
                                DataValueField="IncomeClassID">
                            </asp:DropDownList>
                            金额：<%= swq.CurrentCurrencySymbol%><asp:TextBox ID="tbxPrice" runat="server" Width="55px"></asp:TextBox>
                            &nbsp;资金账户：<asp:DropDownList ID="ddlAccount" runat="server" DataTextField="AccountName"
                                DataValueField="AccountID">
                            </asp:DropDownList>
                            备注：<asp:TextBox ID="tbxRemark" runat="server" Width="134px"></asp:TextBox>
                            &nbsp;<label class="lab_button striking_btnc">
                                <asp:Button ID="btnAdd" runat="server" Text="增加" OnClick="btnAdd_Click" /></label>
                        </div>

                        <div class="striking_content">
                            <div style="width: 60%" id="BillItems">
                                <asp:GridView ID="GridView1" runat="server" CssClass="smallgridview" AutoGenerateColumns="False"
                                    DataKeyNames="Index" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowEditing="GridView1_RowEditing"
                                    OnRowUpdating="GridView1_RowUpdating" OnRowDeleting="GridView1_RowDeleting">
                                    <Columns>
                                        <asp:TemplateField HeaderText="类型">
                                            <ItemTemplate>
                                                <%# (int)Eval("Income") == 0 ? "支出" : "收入" %>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="账目">
                                            <ItemTemplate>
                                                <asp:Label ID="labIncomeClassName" runat="server" Text='<%# Eval("IncomeClassName") %>'></asp:Label>
                                            </ItemTemplate>
                                            <EditItemTemplate>
                                                <asp:DropDownList ID="ddlIncomeClass" runat="server" DataTextField="IncomeClassName"
                                                    DataValueField="IncomeClassID" DataSource='<%# swq.Cache.GetIncomeClass((int)Eval("Income")) %>'
                                                    SelectedValue='<%# Eval("IncomeClassID") %>'>
                                                </asp:DropDownList>
                                            </EditItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="金额">
                                            <ItemTemplate>
                                                <asp:Label ID="labPrice" runat="server" Text='<%# Eval("Price","{0:c2}") %>'></asp:Label>
                                            </ItemTemplate>
                                            <EditItemTemplate>
                                                <asp:TextBox ID="tbxPrice" runat="server" Text='<%# Eval("Price") %>' Width="60"></asp:TextBox>
                                            </EditItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="帐户">
                                            <ItemTemplate>
                                                <asp:Label ID="labAccountName" runat="server" Text='<%# Eval("AccountName") %>'></asp:Label>
                                            </ItemTemplate>
                                            <EditItemTemplate>
                                                <asp:DropDownList ID="ddlAccount" runat="server" DataTextField="AccountName" DataValueField="AccountID"
                                                    DataSource='<%# swq.Cache.GetAccount() %>' SelectedValue='<%# Eval("AccountID") %>'>
                                                </asp:DropDownList>
                                            </EditItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="备注">
                                            <ItemTemplate>
                                                <asp:Label ID="labRemark" runat="server" Text='<%# Eval("Remark") %>'></asp:Label>
                                            </ItemTemplate>
                                            <EditItemTemplate>
                                                <asp:TextBox ID="tbxRemark" runat="server" Text='<%# Eval("Remark") %>'></asp:TextBox>
                                            </EditItemTemplate>
                                        </asp:TemplateField>
                                        <%--<asp:CommandField HeaderText="编辑" EditText="编辑" CancelText="取消" UpdateText="更新" ShowEditButton="true" />--%>
                                        <asp:TemplateField HeaderText="编辑">
                                            <ItemTemplate>
                                                <div class="lab_button_sub" id="divEdit" runat="server">
                                                    <asp:LinkButton ID="lbnEdit" runat="server" Text="编辑" CommandName="Edit"></asp:LinkButton>
                                                </div>
                                            </ItemTemplate>
                                            <EditItemTemplate>
                                                <div class="lab_button_sub">
                                                    <asp:LinkButton ID="lbnUpdate" runat="server" Text="更新" CommandName="Update"></asp:LinkButton>
                                                </div>
                                                <div class="lab_button_sub">
                                                    <asp:LinkButton ID="lbnCancel" runat="server" Text="取消" CommandName="Cancel"></asp:LinkButton>
                                                </div>
                                            </EditItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="删除">
                                            <ItemTemplate>
                                                <div class="lab_button_sub" id="divDelete" runat="server">
                                                    <asp:LinkButton ID="lbnDelete" runat="server" Text="删除" CommandName="Delete"></asp:LinkButton>
                                                </div>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                            </div>

                        </div>
                    </td>
                </tr>

                <tr>
                    <td>&nbsp;
                    </td>
                    <td>
                        <label class="lab_button">
                            <asp:Button ID="btnSave" runat="server" Text="保存" OnClick="btnSave_Click" />
                        </label>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>&nbsp;
                    </td>
                </tr>
            </table>
        </div>
        <div class="backpanel">
            <label class="lab_button" id="__mt_labBack" runat="server">
                <input id="Button1" causesvalidation="false" type="button" runat="server" onclick="back(this)"
                    value="返回" />
            </label>
        </div>
    </form>
</body>
</html>
