<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Cancel1_Grid.aspx.cs" Inherits="ARAP_CancelOrder_Cancel1_Grid" Debug="true" %>
<%@ Register Src="~/Scripts/AWGridRuntime/UserControl/DocumentGridObject.ascx" TagPrefix="include" TagName="GridObject" %>
<%@ Register Src="~/Scripts/AWGridRuntime/UserControl/GridHeader.ascx" TagPrefix="include" TagName="GridHeader" %>


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <include:GridHeader runat="server" ID="GridHeader" />
    <script type="text/javascript" src="../../Scripts/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../Scripts/WebSite.js"></script>
    <script type="text/javascript">
        var id = '<%=Request["id"]%>';
         //打印表体用的SQL
        var sql_print_detail_session_id = "<%=xview["sql_print_detail_session_id"]%>";
    </script>
</head>
<body>
    <form id="main_form">
        <!--列表标题与样式-->
        <style type="text/css">
            <%=xview["aw_column_style"]%>
        </style>
        <!--为控件提供参数与数据-->
        <script type="text/javascript">
            <%=xview["fields_index"]%>
            <%=xview["aw_grid_info"]%>
        </script>
        <!--创建列表控件-->
        <include:GridObject runat="server" ID="GridObject" />
    </form>
<script type="text/javascript">
    obj.setSelectionMode("multi-cell"); //开启单元格多选模式
    obj.setCellEditable(true, _hx_amount);//让本次核销金额列可编辑
    //取消自带的双击事件
    obj.onRowDoubleClicked = function (event, row) {
    }

    //开始验证
    obj.onCellValidating = function (text, col, row) {
        //已审核禁止编辑
        if (parent.$("#verify_user").val() != "")
            return true;
        //返回true代理验证不通过
        if (isNaN(text)) {
            return true;
        }

    }
    //通过验证
    obj.onCellValidated = function (text, col, row) {
        //回写单据单价
        if (col == _hx_amount) {
            var acl_id = aw_myData[row][_acl_id];
            var hx_amount = aw_myData[row][_hx_amount];
            var exchange_rate = parent.document.getElementById("exchange_rate").value;//汇率
            var nat_hx_amount = (hx_amount * exchange_rate).toFixed(2);//本币核销金额
            $.ajax({
                type: "POST",
                contentType: "application/json",
                url: 'Cancel1_Service.asmx/Save',
                data: "{acl_id:'" + acl_id + "',hx_amount:'" + hx_amount + "',nat_hx_amount:'" + nat_hx_amount + "'}",
                dataType: 'json',
                success: function (result) {
                    var r = result.d;
                    if (r == "success") {
                        obj.setCellText(nat_hx_amount, _nat_hx_amount, row);
                        //GetCanceledAmount();//计算未核销金额
                    } else {
                        alert(r);
                        //parent.AlertNO(r);
                    }
                }
            });
        }
    }
    //得到某张收付款单已核销金额
    function GetCanceledAmount() {
        

    }
    window.onload = function () {
        aw_auto_size();
    }
     
    //让grid控件自适应屏幕宽度
    function aw_auto_size() {
        var div_grid = document.getElementById("div_grid");
        var aw_grid = document.getElementById("aw_grid");
        var div_pager = document.getElementById("div_pager");
        var doc_head_height = parent.document.getElementById("doc_head").offsetHeight;
        obj.setSize(div_grid.offsetWidth, div_grid.offsetHeight - 30);
        div_pager.style.width = aw_grid.offsetWidth + 'px';
    }
    //分页条标题信息
    $("#pager_info").html('<%=xview["pager_info"]%>');
</script>
</body>
</html>
