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

<!DOCTYPE html>

<html>
<head runat="server">
    <title></title>
    <script type="text/javascript" src="../jscript/jquery-1.11.3.min.js"></script>
    <script src="../jscript/jquery.tool.new.js" type="text/javascript"></script>
    <script src="../jscript/Dialog.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" />
</head>
<body>
    <form id="frmForm" runat="server">
        <div style="width: 100%; background-color: #cccccc;" id="TableContainer">
        </div>
        <div id="SearchDlg" class="easyui-dialog" title="筛选条件" data-options="iconCls:'icon-search',closed: true,modal:true"
            style="width: 500px; height: 200px; padding: 10px;">
            <table style="width: 100%; font-size: 12px; font-family: 微软雅黑;">
                <tr>
                    <td class="TdTitle">账套名称</td>
                    <td class="TdContent" colspan="3">
                        <input id="CompanyName" name="CompanyName" maxlength="50" style="width: 90%; "  />                       
                    </td>
                </tr>
                <tr>
                    <td  colspan="4" align="center">
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="LoadList();">确定筛选</a>
                    </td>
                </tr>
            </table>
        </div>
        <div id="SearchDlg1" class="easyui-dialog" title="数据发放" data-options="iconCls:'icon-search',closed: true,modal:true"
            style="width: 500px; height: 200px; padding: 10px;">
            <input id="SDState" type="hidden"  name="SDState" value="0" runat="server" />
            <table style="width: 100%; font-size: 12px; font-family: 微软雅黑;">
                <tr>
                    <td>选择项目</td>
                    <td class="TdSearch" colspan="3">
                        <input class="easyui-searchbox" id="CommNames" name="CommNames" searcher="SelComm" style="width: 90%;" data-options="editable:false" runat="server" />
                        <input id="CommIDs" type="hidden"  name="CommIDs" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td><br /></td>
                </tr>
                <tr>
                    <td  colspan="4" align="center">
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="Grant()">确定发放</a>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>
<script type="text/javascript">
    var column = [[
        { field: 'IID', title: 'IID', width: 50, align: 'left', sortable: true, hidden: true },
        {
            field: 'UFCorpID', title: '账套ID', width: 200, align: 'left', sortable: true, formatter: function (value, row, index) {
                var str = "<a class=\"HrefStyle\"  href='#' onclick=\"ViewDetail('修改设置','update'," + row.IID + ");\">" + row.UFCorpID + "</a>";
                return str;
            }
        },
        { field: 'CompanyCode', title: '账套编码', width: 100, align: 'left', sortable: true },
        { field: 'CompanyName', title: '账套名称', width: 100, align: 'left', sortable: true },
        { field: 'TaxNo', title: '税号', width: 100, align: 'left', sortable: true },
        { field: 'TaxBody', title: '纳税主体', width: 100, align: 'left', sortable: true }
    ]];

    //发放
    function Grant() {
        $.tool.DataPostNoLoading('UFJDAccountCorp', 'Grant', 'CommIDs=' + $("#CommIDs").val(),
            function Init() {
            },
            function callback(result) {
                if (result == 'true') {
                    HDialog.Info("数据发送成功！");
                    if ($("#SDState").val() == '1') {
                        $("#SearchDlg1").dialog("close");
                        $("#SDState").val('0');
                    }
                } else {
                    HDialog.Info("数据发送失败！");
                    if ($("#SDState").val() == '1') {
                        $("#SearchDlg1").dialog("close");
                        $("#SDState").val('0');
                    }
                }
            },
            function completeCallback() {
            },
            function errorCallback() {
            }
        );
    }

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

    var toolbar = [
        {
            text: '新增',
            iconCls: 'icon-add',
            handler: function () {
                ViewDetail("账套设置", 'add', 0);
            }
        }, '-',
        {
            text: '删除',
            iconCls: 'icon-cancel',
            handler: function () {
                var row = $("#TableContainer").datagrid("getSelected");
                if (row != undefined && row != null) {
                    DelRecord(row.IID);
                }
            }
        }, '-',
        {
            text: '筛选',
            iconCls: 'icon-filter',
            handler: function () {
                $('#SearchDlg').parent().appendTo($("form:first"))
                $('#SearchDlg').dialog('open');
            }
        }, '-',
        {
            text: 'Excel导入',
            iconCls: 'icon-page_white_excel',
            handler: function () {
                HDialog.Open(770, 400, '../UFJDVoucherCorp/UFJDAccountExcelInput.aspx', '批量导入信息', false, function callback(_Data) {
                    if (_Data == "true") {
                        LoadList();
                    }
                });
            }
        }, '-',
        {
            text: '数据发放',
            iconCls: 'icon-edit',
            handler: function () {
                $('#SearchDlg1').parent().appendTo($("form:first"))
                $('#SearchDlg1').dialog('open');
                $('#SDState').val('1');
            }
        }
    ];

    LoadList();

    function DelRecord(Id) {
        HDialog.Prompt('是否删除该项', function () {
            $.tool.DataGet('UFJDAccountCorp', 'delete', 'IID=' + Id,
                function Init() {
                },
                function callback(_Data) {

                    var varObjects = _Data.split("|");

                    if (varObjects[0] == "true") {
                        HDialog.Info(varObjects[1]);
                    }
                    else { HDialog.Info('删除失败,' + varObjects[1]); }
                    LoadList();
                },
                function completeCallback() {
                },
                function errorCallback() {
                });
        });
    }

    function LoadList() {
        $("#TableContainer").datagrid({
            url: '/HM/M_Main/HC/DataGetControl.aspx?Method=DataGet&Class=UFJDAccountCorp&Command=List&' + $("#frmForm").serialize(),
            method: "get",
            nowrap: false,
            pageSize: top.ListPageSize,
            pageList: top.ListPageList,
            columns: column,
            fitColumns: true,
            singleSelect: true,
            border: false,
            pagination: true,
            width: "100%",
            toolbar: toolbar,
            sortOrder: "asc",
            remoteSort: false,
            onLoadSuccess: function (data) {

            }
        });
        $("#SearchDlg").dialog("close");
    }

    function SelComm() {
        if ($('#CommID').val() != '' && $('#IsCorp').val() == '') {
            return;
        }
        else {
            var w = $(window).width() * 0.7;
            HDialog.Open(w, 500, '../DialogNew/SelComm.aspx?IsCheck=1', "选择项目", false, function callback(_Data) {
                var arrRet = JSON.parse(_Data);
                $("#CommIDs").val(arrRet.id);
                $("#CommNames").searchbox("setText", arrRet.name);
            });
        }
    }

    function ViewDetail(title, OpType, ID) {

        HDialog.Open('800', '300', '../UFJDVoucherCorp/UFJDAccountManage.aspx?IID=' + ID + '&OpType=' + OpType, title, true, function callback(_Data) {
            //if (_Data == "true") {
            LoadList();
            //}

        });
    }
</script>