<%@ Page Title="" Language="C#" MasterPageFile="~/StockOut/Site1.Master" AutoEventWireup="true" CodeBehind="CutStockOutNoticeFreight.aspx.cs" Inherits="GxHub.Wms.Abroad.Web.StockOut.CutStockOutNoticeFreight" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <yee:PageTitle ID="ptTitle" runat="server">
    </yee:PageTitle>
    <div style="text-align:right"><a href="StockOutNoticeList.aspx">返回列表</a></div>
    <yee:MessageBox ID="msg" runat="server">
    </yee:MessageBox>
    <div class="print" id="print">
        <asp:Repeater ID="rptList" runat="server" OnItemDataBound="rptList_ItemDataBound">
            <HeaderTemplate>
                <table cellpadding="0" cellspacing="0" class="table">
                    <tr>
                        <td rowspan="2" class="tbheader" style="width:150px"><%=GetText("流水号") %></td> 
                        <td rowspan="2" class="tbheader" style="width:150px"><%=GetText("重量") %>（KG）</td>
                        <td rowspan="2" class="tbheader" style="width:150px"><%=GetText("体积") %>(m³)</td> 
                        <td colspan="2" class="tbheader"><%=GetText("国际运费") %></td>
                        <td colspan="2" class="tbheader"><%=GetText("海外运费") %></td> 

                    </tr>
                    <tr>
                        <td class="tbheader" style="width: 50px;"><%=GetText("系统计算") %></td>
                        <td class="tbheader" style="width: 50px;"><%=GetText("实际支付") %></td>
                        <td class="tbheader" style="width: 50px;"><%=GetText("系统计算") %></td>
                        <td class="tbheader" style="width: 50px;"><%=GetText("实际支付") %></td>
                    </tr>
            </HeaderTemplate>

            <ItemTemplate>
                <tr class="tbrow">
                   <td class="tbpost">
                        <asp:Literal runat="server" ID="litSerialNo" Text='<%#Eval("SerialNo") %>'></asp:Literal>
                      
                        <asp:HiddenField runat="server" ID="hfNoticeId" Value='<%#Eval("NoticeId") %>' />
                    </td>
                    <td class="tbpost">
                        <asp:Literal runat="server" ID="litWeight" Text='<%#Eval("Weight") %>'></asp:Literal>
                    </td> 
                    
                    <td class="tbpost">
                        <asp:Literal ID="litAbroadVolume" runat="server" Text='<%#Eval("Volume") %>'></asp:Literal>
                    </td>
                
                    <td class="tbpost">
                        <asp:Literal runat="server" ID="litCN2TH"  ></asp:Literal>
                    </td>
                    <td class="tbpost"> 
                        <input id="txtCN2TH" runat="server" class="CN2TH" onkeyup="cn2thKeyUp()" />
                    </td>
                    <td class="tbpost">
                        <asp:Literal runat="server" ID="litTN2TH" ></asp:Literal>
                    </td>
                    <td class="tbpost"> 
                        <input id="txtTH2TH" runat="server" class="TH2TH" onkeyup="th2thKeyUp()" />
                    </td>
                    
                </tr>

            </ItemTemplate>
            
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
        <asp:HiddenField ID="hfWarehouseId" runat="server" ClientIDMode="Static" />
        <asp:HiddenField ID="hfIsNewCustomer" runat="server" ClientIDMode="Static" />
        <asp:HiddenField ID="hfInterFreight" runat="server" ClientIDMode="Static" />
        <div class="query">
            <table cellpadding="0" cellspacing="0" border="0" class="table">
                <tr>
                    <td class="tbpostheader">
                        <%=GetText("客户名称") %>：
                    </td>
                    <td class="tbpost">
                         <asp:Literal ID="litCustomerName" runat="server" ></asp:Literal>
                    </td>
                </tr>
                <tr>
                    <td class="tbpostheader">
                        <%=GetText("客户代号") %>：
                    </td>
                    <td class="tbpost">
                        <asp:Literal ID="litCustomerCode" runat="server" ></asp:Literal> 
                    </td>
                </tr>

                <tr>
                    <td class="tbpostheader">
                        <%=GetText("国际运费合计") %>：
                    </td>
                    <td class="tbpost"> 
                        <asp:Label ID="labTotalCN2THAmount" runat="server" ClientIDMode="Static"></asp:Label>
                        <asp:HiddenField ID="hfTotalCN2THAmount" runat="server" ClientIDMode="Static" />
                    </td>
                </tr>
                 <tr>
                    <td class="tbpostheader">
                        <%=GetText("海外运费合计") %>：
                    </td>
                    <td class="tbpost"> 
                        <asp:Label ID="labTotalTH2THAmount" runat="server" ClientIDMode="Static"></asp:Label>
                         <asp:HiddenField ID="hfTotalTH2THAmount" runat="server" ClientIDMode="Static" />
                    </td>
                </tr>
                
                 <tr>
                    <td class="tbpostheader">
                        <%=GetText("总合计") %>：
                    </td>
                    <td class="tbpost"> 
                       <asp:Label ID="labTotalAmount" runat="server" ClientIDMode="Static" Text="0"></asp:Label>
                       <asp:HiddenField ID="hfTotalAmount" runat="server" ClientIDMode="Static" />
                    </td>
                </tr>

                <tr>
                    <td class="tbpostheader">
                        <%=GetText("币种") %>：
                    </td>
                    <td class="tbpost">
                        <asp:Literal ID="litCurrencyCode" runat="server" ></asp:Literal>
                        <asp:HiddenField ID="hfCurrencyCode" runat="server"  ClientIDMode="Static"/>
                    </td>
                </tr>
                <tr>
                    <td class="tbpostheader">
                        <%=GetText("备注") %>：
                    </td>
                    <td class="tbpost">
                        <asp:TextBox ID="txtRemark" runat="server" MaxLength="255" TextMode="MultiLine"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="tbfooter" >
                         </td>
                    <td class="tbfooter" >
                        <asp:Button ID="btSave" runat="server" CssClass="button" Text="扣费并生成收据单" OnClick="btSave_Click" /></td>
                </tr>
            </table>
        </div>
    </div>
    <script type="text/javascript">

        $(function () {
            cn2thKeyUp();
            th2thKeyUp();
          
        });
         
        function cn2thKeyUp() {
            var amount = 0;
            $(".CN2TH").each(function () {
                var ss = $(this).val();
                amount += (parseFloat($(this).val()));

            });
            var interFreight = parseFloat($("#hfInterFreight").val());

            var wareId = $("#hfWarehouseId").val();
            var total = amount;
            if (wareId == 6) {
                var isNew = $("#hfWarehouseId").val();
                if (amount < interFreight) {
                    total = interFreight;
                }
            }
            $("#labTotalCN2THAmount").text(formatFloat(total));
            $("#hfTotalCN2THAmount").val(formatFloat(total));
            sumFunction();

        }
        function th2thKeyUp() {
            var amount = 0;
            $(".TH2TH").each(function () {
                var ss = $(this).val();
                amount += (parseFloat($(this).val()));

            });
            $("#labTotalTH2THAmount").text(formatFloat(amount));
            $("#hfTotalTH2THAmount").val(formatFloat(amount));
            sumFunction();

        }
       

        function sumFunction() {
            var cn2th = parseFloat($("#labTotalCN2THAmount").text());
            var th2th = parseFloat($("#labTotalTH2THAmount").text());
         
            var total = cn2th  + th2th;


            $("#labTotalAmount").text(formatFloat(total));
            $("#hfTotalAmount").val(formatFloat(total));
        }

        function formatFloat(amount) {
            var currency = $("#hfCurrencyCode").val();
            var newAmount;
            if (currency == "IDR" || currency == "VND") {
                newAmount = amount.toFixed(0);
            }
            else {
                newAmount = amount.toFixed(2);
            }
            return newAmount;
        }
    </script>
</asp:Content>
