<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FeesPastAddBrowse.aspx.cs" Inherits="M_Main.ChargesNew.FeesPastAddBrowse" %>

<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
    <script type="text/javascript" src="../jscript/DateControl.js"></script>
    <script type="text/javascript" src="../jscript/JSClient.js"></script>
    <script type="text/javascript" src="../jscript/ajax.js"></script>
    <script type="text/javascript" src="../jscript/Keydown.js" event="onkeydown" for="document"></script>

    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/jquery.min.js"></script>
    <script src="../jscript/JSClient.js" type="text/javascript"></script>
    <script src="../jscript/jquery.tool.new.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="../Jscript-Ui/jquery-easyui-1.4.4/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../Jscript-Ui/jquery-easyui-1.4.4/themes/icon.css" />
    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/locale/easyui-lang-zh_CN.js"></script>
    <link href="../css/framesearch.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="../Jscript-Ui/JQForm/JQForm.js"></script>
    <script src="../jscript/Dialog.js" type="text/javascript"></script>

    <script src="../jscript/Dialog.js" type="text/javascript"></script>
    <link href="../css/framesearch_old.css" type="text/css" rel="stylesheet" />
    <link href="../css/button.css" rel="stylesheet" />
    <script src="../jscript/DateFormat.js" type="text/javascript"></script>
    <script src="../jscript/format.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Jscript-Ui/JQForm/JQForm.js"></script>
    <script type="text/javascript" src="../jscript/DatePicker/WdatePicker.js"></script>
    <script src="../jscript/pagewalkthrough/jquery.pagewalkthrough.js"></script>
    <link href="../jscript/pagewalkthrough/css/jquery.pagewalkthrough.css" rel="stylesheet" />
    <style type="text/css">
        body {
            margin: 0px;
            margin-top: 0px;
            overflow: hidden;
            font-family: 微软雅黑;
            background-color: #ffffff;
        }

        .Container {
            width: 100%;
            height: auto;
            font-size: 12px;
            font-family: 微软雅黑;
        }

        .ContainerLeft {
            float: left;
            width: 25%;
            overflow-y: auto;
            border-right: 1px solid #cccccc;
        }

        .ContainerRight {
            float: left;
            width: 75%;
            margin-top:-2px;
            margin-right:-1px;
        }

        textarea {
            height: 22px;
            resize: none;
            border: 1px solid #cccccc;
            width: 200px;
        }

    </style>
            

</head>
<body>
    <form id="frmForm" runat="server">

        <div id="walkthrough-content" style="display: none;">
            <div id="walkthrough-1">
                <h3>这里是应收调账-往期应收调账操作介绍<br />
                    点击下一步继续教程</h3>
            </div>

            <div id="walkthrough-2">
                在这里点击新增进行新增应收
            </div>

            <div id="walkthrough-3">
                点击新增费用
            </div>
        </div>

        <input type="hidden" name="CostGeneType" id="CostGeneType" runat="server" />

        <input type="hidden" name="FeesRow" id="FeesRow" runat="server" />
        <input type="hidden" name="OperatorType" id="OperatorType" runat="server" />
        <input id="CommID" style="width: 16px; height: 22px" type="hidden" size="1" value="-1" name="CommID"
            runat="server" />
        <input id="hidID" type="hidden" size="2" name="hidID" runat="server" />
        <input id="OrganCode" type="hidden" size="2" name="OrganCode" runat="server" />
        <input id="OrganName" type="hidden" size="2" name="OrganName" runat="server" />
        <input id="InPopedom" type="hidden" name="InPopedom" runat="server" />
        <div id="SearchDlg" class="easyui-dialog" title="筛选条件" data-options="iconCls:'icon-search',closed: true,modal:true"
            style="width: 600px; height: 270px;">
            <table class="DialogTable" width="100%">
               <%-- <tr>
                    <td class="TdTitle">管理项目
                    </td>
                    <td class="TdContentSearch" colspan="3">
                        <input type="text" class="easyui-searchbox" searcher="SelComm" data-options="required:true"
                            id="CommName" name="CommName" runat="server" />
                    </td>
                </tr>--%>
                <tr>
                    <td class="TdTitle">客户名称</td>
                    <td class="TdContentSearch">
                        <input class="easyui-searchbox" id="CustName" maxlength="50" name="CustName" data-options="editable:false" searcher="SelCust" runat="server" dd="dd" />
                        <input type="hidden" name="CustID" id="CustID" runat="server" />
                    </td>
                    <td class="TdTitle">可选房号</td>
                    <td class="TdContentSearch">
                        <select id="SelectRoomID" class="easyui-combobox" data-options="editable:false,panelHeight: 'auto'" name="SelectRoomID" onchange="javascript:SelectRoomID_OnChange();" runat="server">
                            <option selected></option>
                        </select></td>
                </tr>
                <tr>
                    <td class="TdTitle">房屋编号</td>
                    <td class="TdContentSearch">
                        <input class="easyui-searchbox" data-options="editable:false" id="RoomSign" name="RoomSign" searcher="SelRoom" runat="server" data-dd="ddd" />

                        <input type="hidden" name="RoomID" id="RoomID" runat="server" /></td>
                    <td class="TdTitle">车位编号 </td>
                    <td class="TdContentSearch">
                        <select id="HandID" class="easyui-combobox" data-options="editable:false,panelHeight: 'auto'" name="HandID" runat="server">
                            <option selected></option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td class="TdTitle">费用项目</td>
                    <td class="TdContentSearch">
                        <input class="easyui-searchbox" id="CostName" data-options="editable:false" maxlength="50" name="CostName" searcher="SelCost" runat="server" dd="dd" />
                        <input type="hidden" name="CostID" id="CostID" runat="server" /></td>
                    <td class="TdTitle"></td>
                    <td class="TdContentSearch"></td>
                </tr>
                <tr>
                    <td class="TdTitle">应收时间从</td>
                    <td class="TdContentSearch">
                        <input id="EditBeginDate" class="Wdate"
                            onclick="WdatePicker()" type="text" maxlength="50" name="EditBeginDate"
                            runat="server"></td>
                    <td class="TdTitle">到</td>
                    <td class="TdContentSearch">
                        <input id="EditEndDate" class="Wdate"
                            onclick="WdatePicker()" type="text" maxlength="50" name="EditEndDate"
                            runat="server"></td>
                </tr>
                <tr>
                    <td class="TdTitle">操作时间从</td>
                    <td class="TdContentSearch">
                        <input id="OptBeginDate" class="Wdate"
                            onclick="WdatePicker()" type="text" maxlength="50" name="OptBeginDate"
                            runat="server"></td>
                    <td class="TdTitle">到</td>
                    <td class="TdContentSearch">
                        <input id="OptEndDate" class="Wdate"
                            onclick="WdatePicker()" type="text" maxlength="50" name="OptEndDate"
                            runat="server"></td>
                </tr>
                <tr>
                    <td colspan="4" style="text-align: center">
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="LoadList();">确定筛选</a>
                        <%-- <input type="button" class="button" value="查询" id="btnSearch" name="btnSearch" />
                        &nbsp;&nbsp;
                         <input type="button" class="button" value="新增" id="btnSave" name="btnSave" runat="server" />--%>
                    </td>
                </tr>
            </table>

        </div>
        <div class="Container">
            <div id="ContainerLeft" class="ContainerLeft" style="height: 500px;">
                <div id="TableContainerTree">
                </div>
            </div>
            <div id="ContainerRight" class="ContainerRight" style="height: 500px;">
                <div style="width: 100%; background-color: #cccccc" id="TableContainer">
                </div>
            </div>
        </div>

        <script src="../jscript/CloseAjaxCache.js" type="text/javascript"></script>
        <script type="text/javascript">

            var column;
            column = [[
                {
                    field: 'text', title: '项目列表', align: 'left', sortable: true, formatter: function (value, row, index) {
                        var str = "<a class=\"HrefStyle\" href=\"#\">" + row.text + "</a>";
                        return str;
                    }
                },
                {
                    field: 'InPopedom', title: '小区ID', align: 'left', formatter: function (value, row, index) {
                        var str = row.attributes.InPopedom;
                        if (str == 0) str = '';
                        return str;
                    }
                }
            ]];

            var IsCollapseAll = false;
            var toolbar = [
                {
                    text: '展开/折叠',
                    iconCls: 'icon-redo',
                    handler: function () {
                        if (IsCollapseAll == true) {
                            $('#TableContainerTree').treegrid('expandAll');
                            IsCollapseAll = false;
                        }
                        else {
                            $('#TableContainerTree').treegrid('collapseAll');
                            IsCollapseAll = true;
                        }
                    }
                }
            ];

            function LoadListTree() {
                $("#TableContainerTree").treegrid({
                    url: '/HM/M_Main/HC/DataGetControl.aspx?Method=DataGet&Class=Organ&Command=GetOrganTreeGridList&' + $('#frmForm').serialize(),
                    treeField: 'text',
                    idField: 'id',
                    method: "get",
                    nowrap: false,
                    pageSize: top.ListPageSize,
                    pageList: top.ListPageList,
                    columns: column,
                    fitColumns: true,
                    singleSelect: true,
                    remoteSort: false,
                    pagination: false,
                    rownumbers: true,
                    IsCustomHead: false,
                    cascadeCheck: true,
                    width: "100%",
                    toolbar: toolbar,
                    border: false,
                    sortOrder: "asc",
                    cascadeCheck: true,
                    onClickRow: function (node) {
                        //$("#OrganCode").val(node.attributes.OrganCode);
                        if (parseInt(node.attributes.InPopedom) > 0) {
                            $("#CommID").val(node.attributes.InPopedom);
                            $("#OrganName").val(node.text);
                        } else {
                            $("#CommID").val('');
                            $("#OrganName").val('');
                        }
                        LoadList();
                    }
                });
            }
            LoadListTree();


            function InitFunction() {
                var h = $(window).height();
                $("#ContainerLeft").css("height", h + "px");
                $("#ContainerRight").css("height", h + "px");
                $("#TableContainer").css("height", h + "px");
            }
            InitFunction();

            //指定列求和
            function compute(colName) {
                var rows = $('#TableContainer').datagrid('getRows');
                var total = 0;
                for (var i = 0; i < rows.length; i++) {
                    total += parseFloat(rows[i][colName]);
                }
                return ToDecimal(total, 2);
            }

            function SelComm() {
                $('.easyui-dialog').parent().appendTo($("form:first"));
                HDialog.Open('1000', '600', '../DialogNew/SelComm.aspx', '管理项目选择', false, function callback(_Data) {
                    if (_Data != '') {
                        var arrRet = JSON.parse(_Data);
                        $("#CommID").val(arrRet.id);
                        $("#CommName").searchbox("setValue", arrRet.name);
                    }
                });
            }

            function SelCost() {
                var varReturn;

                var vCommID = $('#CommID').val();

                if (vCommID == "-1") {
                    HDialog.Info("请选择管理项目,此项不能为空!");
                    return;
                }

                var w = $(window).width();
                var h = $(window).height();

                HDialog.Open(w, h, "../dialogNew/MultiCorpCommCostDlg.aspx" + "?CommID=" + vCommID, '收费项目选择', false, function callback(_Data) {


                    if (_Data != "") {//**获得返回 刷新
                        var varObjects = _Data.split("\t");

                        $('#CostID').val(varObjects[0]);
                        $('#CostName').searchbox('setValue', varObjects[1]);


                        return true;
                    }
                });

                return false;
            }

            function SelCust() {

                var vCommID = $('#CommID').val();

                if (vCommID == "-1") {
                    HDialog.Info("请选择管理项目,此项不能为空!");
                    return;
                }

                $('#CustName').searchbox("setValue", '');
                $('#CustID').val('');
                $('#RoomSign').searchbox("setValue", '');
                $('#RoomID').val('');
                $('#SelectRoomID').combobox({ data: [], valueField: 'RoomID', textField: 'RoomText' });

                var w = $(window).width();
                var h = $(window).height();

                var conent = "../DialogNew/CustDlg.aspx" + "?CommID=" + vCommID;

                HDialog.Open(w, h, conent, '客户选择', false, function callback(_Data) {
                    var data = JSON.parse(_Data);
                    $('#CustName').searchbox("setValue", data.CustName);
                    $('#CustID').val(data.CustID);


                    $.tool.DataGet('Choose', 'CustRoomSigns', "CustID=" + data.CustID,
                        function Init() {
                        },
                        function callback(_Data) {

                            varObjects = eval("(" + _Data.replace(/\\/g, "/") + ")"); //转换为json对象
                            if (varObjects.length > 0) {

                                var RoomData = [];
                                for (var i = 0; i < varObjects.length; i++) {

                                    var vIsDelLive = varObjects[i].IsDelLive;
                                    var strTmp = "";

                                    if (vIsDelLive == 1) {
                                        strTmp = "(历史)";
                                    }
                                    var RoomID = varObjects[i].RoomID;
                                    var RoomSign = varObjects[i].RoomSign;
                                    var Buildarea = varObjects[i].BuildArea;

                                    var RoomText = RoomSign + "(" + Buildarea + ")" + strTmp;

                                    RoomData.push({ "RoomText": RoomText, "RoomID": RoomID + "|" + Buildarea });

                                }
                                $('#SelectRoomID').combobox({
                                    data: RoomData,
                                    valueField: 'RoomID',
                                    textField: 'RoomText',
                                    onChange: function (n, o) {


                                        var data = $('#SelectRoomID').combobox('getData');
                                        if (data.length > 0) {
                                            for (var i = 0; i < data.length; i++) {
                                                if (n == data[i].RoomID) {

                                                    $('#RoomSign').searchbox('setValue', data[i].RoomText);
                                                    $('#RoomID').val(data[i].RoomID.split('|')[0]);
                                                    var buildArea = data[i].RoomID.split("|")[1];
                                                    $('#BuildArea').val(buildArea);
                                                    $('#CalcArea').val(buildArea);

                                                    break;
                                                }
                                            }
                                        }
                                    }
                                });
                            }
                        },
                        function completeCallback() {
                        },
                        function errorCallback() {
                        });

                });
            }
            function SelRoom() {
                var vCommID = $('#CommID').val();

                if (vCommID == "-1") {
                    HDialog.Info("请选择管理项目,此项不能为空!");
                    return;
                }

                $('#CustName').searchbox("setValue", '');
                $('#CustID').val('');
                $('#RoomSign').searchbox("setValue", '');
                $('#RoomID').val('');
                $('#SelectRoomID').combobox({ data: [], valueField: 'RoomID', textField: 'RoomText' });

                var conent = "../DialogNew/RoomDlg.aspx" + "?CommID=" + vCommID;

                var w = $(window).width();
                var h = $(window).height();

                HDialog.Open(w, h, conent, '房屋选择', false, function callback(_Data) {
                    var data = JSON.parse(_Data);
                    $('#RoomSign').searchbox("setValue", data.RoomSign);
                    $('#CustName').searchbox("setValue", data.CustName);
                    $('#CustID').val(data.CustID);
                    $('#RoomID').val(data.RoomID);

                    $('#BuildArea').val(data.BuildArea);
                    $('#CalcArea').val(data.BuildArea);
                });

            }


            var toolbar = [

                {
                    id: 'btn_add',
                    text: '新增',
                    iconCls: 'icon-add',
                    handler: function () {
                        var conent = "../ChargesNew/FeesPastManage.aspx";

                        HDialog.Open('900', '450', conent, '新增费用', false, function callback(_Data) {

                            if (_Data != "") {
                                HDialog.Info(_Data);
                                LoadFeesList();
                            }

                        });
                    }
                }, '-',
                {
                    text: '筛选',
                    iconCls: 'icon-search',
                    handler: function () {

                        $('#SearchDlg').parent().appendTo($("form:first"))
                        $('#SearchDlg').dialog('open');

                    }
                }
            ];



            var frozenColumns = [[
                { field: 'CommName', title: '管理项目', width: 100, align: 'left', sortable: true },
                { field: 'CustName', title: '客户名称', width: 100, align: 'left', sortable: true },
                { field: 'RoomSign', title: '房屋编号', width: 180, align: 'left', sortable: true },
                { field: 'HandID', title: '车位编号', width: 180, align: 'left', sortable: true },
            ]];

            var column = [[

                { field: 'FeesID', title: '', width: 100, align: 'left', sortable: true, hidden: true },

                { field: 'CostSNum', title: '费用序号', width: 80, align: 'left', sortable: true },
                { field: 'CostName', title: '费用名称', width: 100, align: 'left', sortable: true },
                {
                    field: 'FeeDueYearMonth', title: '费用日期', width: 100, align: 'left', sortable: true
                },
                {
                    field: 'AccountsDueDate', title: '应收日期', width: 100, align: 'left', sortable: true, formatter: function (value, row, index) {

                        var str = formatDate(row.AccountsDueDate, "yyyy-MM-dd");
                        return str;
                    }
                },
                {
                    field: 'FeesStateDate', title: '开始日期', width: 100, align: 'left', sortable: true, formatter: function (value, row, index) {

                        var str = formatDate(row.FeesStateDate, "yyyy-MM-dd");
                        return str;
                    }
                },
                {
                    field: 'FeesEndDate', title: '结束日期', width: 100, align: 'left', sortable: true, formatter: function (value, row, index) {

                        var str = formatDate(row.FeesEndDate, "yyyy-MM-dd");
                        return str;
                    }
                },
                { field: 'DueAmount', title: '应收金额', width: 100, align: 'left', sortable: true },
                { field: 'PaidAmount', title: '实收金额', width: 100, align: 'left', sortable: true },
                { field: 'PrecAmount', title: '预交冲抵', width: 100, align: 'left', sortable: true },
                { field: 'WaivAmount', title: '减免冲销', width: 100, align: 'left', sortable: true },
                { field: 'RefundAmount', title: '退款金额', width: 100, align: 'left', sortable: true },
                { field: 'DebtsAmount', title: '欠收金额', width: 100, align: 'left', sortable: true },
                { field: 'ChangeDate', title: '操作日期', width: 150, align: 'left', sortable: true },
                { field: 'UserName', title: '操作人', width: 100, align: 'left', sortable: true }


            ]];

            function InitTableHeight() {
                var h = $(window).height();

                $("#TableContainer").css("height", h + 'px');

                $('#HandID').combobox({
                    width: 148
                });


                $('#SelectRoomID').combobox({
                    width: 148
                });



            }
            InitTableHeight();

            //重写DataGrid,支持更改页脚样式
            var myview = $.extend({}, $.fn.datagrid.defaults.view, {
                renderFooter: function (target, container, frozen) {
                    var opts = $.data(target, 'datagrid').options;
                    var rows = $.data(target, 'datagrid').footer || [];
                    var fields = $(target).datagrid('getColumnFields', frozen);
                    var table = ['<table class="datagrid-ftable" cellspacing="0" cellpadding="0" border="0"><tbody>'];

                    for (var i = 0; i < rows.length; i++) {
                        var styleValue = opts.rowStyler ? opts.rowStyler.call(target, i, rows[i]) : '';
                        var style = styleValue ? 'style="' + styleValue + '"' : '';
                        table.push('<tr class="datagrid-row" datagrid-row-index="' + i + '"' + style + '>');
                        table.push(this.renderRow.call(this, target, fields, frozen, i, rows[i]));
                        table.push('</tr>');
                    }
                    table.push('</tbody></table>');
                    $(container).html(table.join(''));
                }
            });



            function LoadFeesList() {

                $("#TableContainer").datagrid({
                    url: '/HM/M_Main/HC/DataGetControl.aspx?Method=DataGet&Class=FeesPast&Command=ListAdd' + '&' + $('#frmForm').serialize(),
                    method: "get",
                    nowrap: false,
                    pageSize: top.ListPageSize,
                    pageList: top.ListPageList,
                    columns: column,
                    frozenColumns: frozenColumns,
                    fitColumns: false,
                    remoteSort: false,
                    singleSelect: true,
                    width: "100%",
                    sortOrder: "asc",
                    singleSelect: true,
                    toolbar: toolbar,
                    selectOnCheck: false,
                    checkOnSelect: false,
                    pagination: true,
                    rownumbers: true,
                    border: false,
                    width: "100%",
                    showFooter: true,
                    view: myview,
                    sortOrder: "asc",
                    onDblClickRow: function (rowIndex, rowData) {

                    },
                    rowStyler: function (index, row) {
                        if (row.FeesID == 'footer') {
                            return 'background-color:#F4F4F4;border:none;'; // return inline style
                        }

                    },
                    onLoadSuccess: function (data) {

                        //加载页脚
                        $('#TableContainer').datagrid('reloadFooter', [
                            {
                                FeesID: 'footer',
                                CustName: "<span style='color:red'>累计合计</span>",
                                DueAmount: "<span style='color:red'>0</span>",
                                PaidAmount: "<span style='color:red'>0</span>",
                                PrecAmount: "<span style='color:red'>0</span>",
                                WaivAmount: "<span style='color:red'>0</span>",
                                RefundAmount: "<span style='color:red'>0</span>",
                                DebtsAmount: "<span style='color:red'>0</span>"
                            }
                        ]);

                        var vCommID = $('#CommID').val();

                        if (vCommID != '') {
                            $.tool.DataPostNoLoading('FeesPast', "ListAddSum", $('#frmForm').serialize(),
                                function Init() {
                                    //加载页脚
                                    $('#TableContainer').datagrid('reloadFooter', [
                                        {
                                            FeesID: 'footer',
                                            CustName: "<span style='color:red'>累计合计</span>",
                                            DueAmount: "<span style='color:red'>0</span>",
                                            PaidAmount: "<span style='color:red'>0</span>",
                                            PrecAmount: "<span style='color:red'>0</span>",
                                            WaivAmount: "<span style='color:red'>0</span>",
                                            RefundAmount: "<span style='color:red'>0</span>",
                                            DebtsAmount: "<span style='color:red'>0</span>"
                                        }
                                    ]);
                                },
                                function callback(_Data) {

                                    var Data = eval("(" + _Data + ")"); //转换为json对象
                                    var obj = Data.rows[0];
                                    //加载页脚
                                    $('#TableContainer').datagrid('reloadFooter', [
                                        {
                                            FeesID: 'footer',
                                            CustName: "<span style='color:red'>累计合计</span>",
                                            DueAmount: "<span style='color:red'>" + obj.DueAmount + "</span>",
                                            PaidAmount: "<span style='color:red'>" + obj.PaidAmount + "</span>",
                                            PrecAmount: "<span style='color:red'>" + obj.PrecAmount + "</span>",
                                            WaivAmount: "<span style='color:red'>" + obj.WaivAmount + "</span>",
                                            RefundAmount: "<span style='color:red'>" + obj.RefundAmount + "</span>",
                                            DebtsAmount: "<span style='color:red'>" + obj.DebtsAmount + "</span>"

                                        }
                                    ]);
                                },
                                function completeCallback() {

                                },
                                function errorCallback() {
                                    //加载页脚
                                    $('#TableContainer').datagrid('reloadFooter', [
                                        {
                                            FeesID: 'footer',
                                            CustName: "<span style='color:red'>累计合计</span>",
                                            DueAmount: "<span style='color:red'>0</span>",
                                            PaidAmount: "<span style='color:red'>0</span>",
                                            PrecAmount: "<span style='color:red'>0</span>",
                                            WaivAmount: "<span style='color:red'>0</span>",
                                            RefundAmount: "<span style='color:red'>0</span>",
                                            DebtsAmount: "<span style='color:red'>0</span>"

                                        }
                                    ]);
                                });
                        }
                    }
                });
                $('#SearchDlg').dialog('close');
            }

            function FeesIsOperator(row) {

                var IsSplit = "false:false";
                var IsDel = "false:false";
                var IsUpdate = "false:false";

                var iCostGeneType = parseInt($('#CostGeneType').val());
                var strSysCostSign = row.SysCostSign;
                var strDueAmount = row.DueAmount;
                var strDebtsAmount = row.DebtsAmount;
                var strAccountFlag = row.AccountFlag;
                var strCostName = row.CostName;

                var strIsBank = row.IsBank;
                var strIsFreeze = row.IsFreeze;
                var strIsProperty = row.IsProperty;
                var strIsPrec = row.IsPrec;
                var strMeterSign = row.MeterSign;



                var iIncidentID = ToDecimal(row.IncidentID, 0);
                var iLeaseContID = ToDecimal(row.LeaseContID, 0);
                var iContID = ToDecimal(row.ContID, 0);


                if ((ToDecimal(strDueAmount, 2) == ToDecimal(strDebtsAmount, 2))
                    && ((iCostGeneType != 0 && ToDecimal(strAccountFlag, 0) == 100)
                        || (iCostGeneType == 0)
                    )
                    && (ToDecimal(strIsBank, 0) == 0)
                    && (ToDecimal(strIsFreeze, 0) == 0)
                    && (ToDecimal(strIsProperty, 0) == 0)
                    && (ToDecimal(strIsPrec, 0) == 0)
                ) {

                    if (strMeterSign == "") {
                        IsUpdate = "true:true"
                        IsDel = "true:true";
                        IsSplit = "true:true";
                    }
                    else {
                        IsUpdate = "false:抄表类费用不允许修改";
                        IsDel = "false:抄表类费用不允许删除";
                        IsSplit = "false:抄表类费用不允许拆分";
                    }

                }
                else {

                    IsUpdate = "true";
                    IsDel = "true";
                    IsSplit = "true";
                    if (ToDecimal(strIsBank, 0) != 0) {
                        IsUpdate = "false:费用已托收不允许修改";
                        IsDel = "false:费用已托收不允许删除";
                        IsSplit = "false:费用已托收不允许拆分";
                    }
                    if (ToDecimal(strIsFreeze, 0) != 0) {
                        IsUpdate = "false:费用已冻结不允许修改";
                        IsDel = "false:费用已冻结不允许删除";
                        IsSplit = "false:费用已冻结不允许拆分";
                    }
                    if (ToDecimal(strIsProperty, 0) != 0) {
                        IsUpdate = "false:费用已垫付不允许修改";
                        IsDel = "false:费用已垫付不允许删除";
                        IsSplit = "false:费用已垫付不允许拆分";
                    }
                    if (ToDecimal(strIsPrec, 0) != 0) {
                        IsUpdate = "false:费用已预收不允许修改";
                        IsDel = "false:费用已预收不允许删除";
                        IsSplit = "false:费用已预收不允许拆分";
                    }
                }

                if ((ToDecimal(strDueAmount, 2) == ToDecimal(strDebtsAmount, 2))
                    && (ToDecimal(strIsBank, 0) == 0)
                    && (ToDecimal(strIsFreeze, 0) == 0)
                    && (ToDecimal(strIsProperty, 0) == 0)
                    && (ToDecimal(strIsPrec, 0) == 0)
                    && (strMeterSign == "")
                ) {
                    IsSplit = "true:true";
                }
                else {

                    IsUpdate = "true:true";
                    IsDel = "true:true";
                    IsSplit = "true:true";

                    if (ToDecimal(strIsBank, 0) != 0) {
                        IsUpdate = "false:费用已托收不允许修改";
                        IsDel = "false:费用已托收不允许删除";
                        IsSplit = "false:费用已托收不允许拆分";
                    }
                    if (ToDecimal(strIsFreeze, 0) != 0) {
                        IsUpdate = "false:费用已冻结不允许修改";
                        IsDel = "false:费用已冻结不允许删除";
                        IsSplit = "false:费用已冻结不允许拆分";
                    }
                    if (ToDecimal(strIsProperty, 0) != 0) {
                        IsUpdate = "false:费用已垫付不允许修改";
                        IsDel = "false:费用已垫付不允许删除";
                        IsSplit = "false:费用已垫付不允许拆分";
                    }
                    if (ToDecimal(strIsPrec, 0) != 0) {
                        IsUpdate = "false:费用已预收不允许修改";
                        IsDel = "false:费用已预收不允许删除";
                        IsSplit = "false:费用已预收不允许拆分";
                    }
                }

                if (strSysCostSign == "B0005" && strCostName != "补交") {

                    IsUpdate = "false:产权税费不允许修改";
                    IsDel = "false:产权税费不允许删除";
                    IsSplit = "false:产权税费不允许拆分";
                }
                if ((iIncidentID > 0 || iLeaseContID > 0 || iContID > 0) && (iCostGeneType != 0)) {
                    if (iIncidentID > 0) {
                        IsUpdate = "false:特约服务类费用不允许修改";
                        IsDel = "false:特约服务类费用不允许删除";
                        IsSplit = "false:特约服务类费用不允许拆分";
                    }
                    else {
                        IsUpdate = "false:合同费用不允许修改";
                        IsDel = "false:合同费用不允许删除";
                        IsSplit = "false:合同费用不允许拆分";
                    }
                }

                //0 修改，1删除，2修改
                return IsUpdate + "|" + IsDel + "|" + IsSplit;
            }
            function FeesOperator(rowData, type) {

                var FeesRow = JSON.stringify(rowData);

                $('#FeesRow').val(FeesRow);
                $('#OperatorType').val(type);

                var cotent = "";
                var Title = "";
                var width = 900;
                var height = 450;
                switch (type) {

                    case "update":
                        Title = "修改费用";
                        conent = "../ChargesNew/FeesPastManage.aspx?OPType=Edit&FeesID=" + rowData.FeesID + "&CostGeneType=" + $('#CostGeneType').val();
                        break;
                    case "delete":
                        Title = "删除费用";
                        width = 600;
                        height = 250;
                        conent = "../DialogNew/FeesAmendDelDlg.aspx?FeesID=" + rowData.FeesID;
                        break;
                    //case "split":
                    //  Title = "拆分费用";
                    //  conent = "../ChargesNew/FeesSplitManage.aspx?OPType=Edit&FeesID=" + rowData.FeesID + "&CostGeneType=" + $('#CostGeneType').val();
                    //  break;

                }
                HDialog.Open(width, height, conent, Title, false, function callback(_Data) {
                    if (_Data != "") {
                        HDialog.Info(_Data);
                        LoadFeesList();
                    }
                });

                LoadFeesList();
            }

            function LoadList() {
                //var vCommID = $('#CommID').val();

                //if (vCommID == "-1") {
                //    HDialog.Info("请选择管理项目,此项不能为空!");
                //    return;
                //}
                LoadFeesList();
            }

            LoadFeesList();


            function GetShow() {
                $('body').pagewalkthrough({
                    name: 'introduction',
                    steps: [{
                        popup: {
                            content: '#walkthrough-1',
                            type: 'modal'
                        }
                    }, {
                        wrapper: '#btn_add',
                        popup: {
                            content: '#walkthrough-2',
                            type: 'tooltip',
                            position: 'bottom'
                        },
                        onLeave: function () {
                            var conent = "../ChargesNew/FeesPastManage.aspx?is_show=1";
                            HDialog.Open('900', '450', conent, '新增费用', false, function callback(_Data) {
                                $('body').pagewalkthrough('close');
                            });
                        }
                    }
                    ],
                    buttons: {
                        jpwNext: {
                            i18n: "下一步 &rarr;"
                        },
                        jpwFinish: {
                            i18n: "下一步 &rarr;"
                        },
                        jpwPrevious: {
                            i18n: "&larr; 上一步"
                        },
                        jpwClose: {
                            i18n: "关闭",
                        }
                    }
                });
                $('body').pagewalkthrough('show');
            }


        </script>


    </form>
</body>
</html>
