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

<!DOCTYPE html>


<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>CarBrowse</title>
    <script type="text/javascript" src="../Jscript-Ui/jquery-easyui-1.4.4/jquery.min.js"></script>
    <script src="../jscript/jquery.tool.js" type="text/javascript"></script>
    <script src="../jscript/Authority.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>
    <script src="../jscript/PersonDictionaryCanNull.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Jscript-Ui/JQForm/JQForm.js"></script>
    <script src="../jscript/Dialog.js" type="text/javascript"></script>
    <script src="../jscript/CloseAjaxCache.js" type="text/javascript"></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>
        <input id="CustID" type="hidden" name="CustID" runat="server" />
        <input id="RoomID" type="hidden" name="RoomID" runat="server" />
        <div id="SearchDlg" class="easyui-dialog" title="筛选条件" data-options="iconCls:'icon-search',closed: true,modal:true"
            style="width: 600px; height: 200px; padding: 10px;">
            <table style="width: 100%; font-size: 12px; font-family: 微软雅黑;">
                <tr>
                    <td>车牌号码</td>
                    <td>
                        <input id="CarNum" style="width: 136px" size="17" name="CarNum" maxlength="50" />
                    </td>
                    <td>客户名称</td>
                    <td>
                        <input id="CustName" style="width: 136px" size="17" name="CustName" placeholder="双击选择" readonly="readonly" autocomplete="off" maxlength="50" />
                    </td>
                </tr>
                <tr>
                    <td>车主</td>
                    <td>
                        <input id="Owner" style="width: 136px" size="17" name="Owner" maxlength="50" />
                    </td>
                    <td>房屋编号</td>
                    <td>
                        <input type="text" style="width: 136px" size="17" id="RoomSign" name="RoomSign" placeholder="双击选择" autocomplete="off" readonly="readonly" runat="server" />
                    </td>
                </tr>
                <tr><td>&nbsp;</td></tr>
                <tr>
                    <td colspan="4" align="center">
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="LoadList();">确定筛选</a>
                        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-filter'" onclick="btnDel();">清空筛选</a>
                    </td>

                </tr>

            </table>
        </div>
    </form>
</body>
</html>
<script language="javascript" type="text/javascript">

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

    $(function () {
        InitTableHeight();
        LoadList();
    });

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

    var column = [[
        { field: 'CarID', title: 'CarID', width: '5%', align: 'left', sortable: true, hidden: true },
        {
            field: 'CarNum', title: '车牌号码', width: '10%', align: 'left', sortable: true, formatter: function (value, row, index) {
                var str = "<a class=\"HrefStyle\"  href='#' onclick=\"ViewDetail('修改车辆信息','update', '" + row.CarID + "' );\">" + row.CarNum + "</a>";
                return str;
            }
        },
        { field: 'Brand', title: '车辆品牌', width: '10%', align: 'left', sortable: true },
        { field: 'Owner', title: '车主姓名', width: '10%', align: 'left', sortable: true },
        { field: 'Category', title: '车辆类别', width: '10%', align: 'left', sortable: true },
        { field: 'Color', title: '车辆颜色', width: '10%', align: 'left', sortable: true },
        { field: 'Displacement', title: '排量', width: '10%', align: 'left', sortable: true },
        { field: 'CustName', title: '客户名称', width: '10%', align: 'left', sortable: true },
        { field: 'RoomSign', title: '房间名称', width: '15%', align: 'left', sortable: true },
        { field: 'ParkName', title: '车位名称', width: '10%', align: 'left', sortable: true },
        {
            field: '删除', title: '删除', width: '5%', align: 'left', sortable: true,
            formatter: function (value, row, index) {
                var str = "";
                if (row.ParkName != "") {
                    str = "";
                } else {
                    str = "<a class=\"HrefStyle\"  href='#' onclick=\"DelRecord('" + row.CarID + "');\">删 除</a>";
                }
                return str;
            }
        }
    ]];

    var toolbar = [
        {
            text: '新增',
            iconCls: 'icon-add',
            handler: function () {
                ViewDetail("新增车辆信息", 'add', "");
            }
        }, '-',
        {
            text: '车辆批量导入',
            iconCls: 'icon-page_white_excel',
            handler: function () {
                ViewReport("车辆批量导入");
            }
        }, '-',
        {
            text: '筛选',
            iconCls: 'icon-search',
            handler: function () {
                $('#SearchDlg').parent().appendTo($("form:first"))
                $('#SearchDlg').dialog('open');

            }
        }
    ];

    function LoadList() {
        $("#TableContainer").datagrid({
            url: '/HM/M_Main/HC/DataPostControl.aspx',
            method: "post",
            title: '',
            nowrap: false,
            pageSize: top.ListPageSize,
            pageList: top.ListPageList,
            columns: column,
            remoteSort: false,
            fitColumns: true,
            rownumbers: true,
            singleSelect: true,
            pagination: true,
            width: "100%",
            border: false,
            toolbar: toolbar,
            sortOrder: "asc",
            onBeforeLoad: function (param) {
                param = $.JQForm.GetParam("Car", "search", "TableContainer", param);
            }
        });
        $("#SearchDlg").dialog("close");
    }


    function DelRecord(Id) {
        $.messager.confirm('确定', '是否删除该项', function (r) {
            if (r) {
                $.tool.DataGet('Car', 'delete', 'CarID=' + Id,
                    function Init() {
                    },
                    function callback(_Data) {

                        if (_Data == "1") {
                            HDialog.Info('删除成功');
                        }
                        else if (_Data == "-2") {
                            HDialog.Info('删除失败,已绑定车位，不能删除');
                        }
                        else { HDialog.Info('删除失败'); }
                        LoadList();

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


    function ViewDetail(title, OpType, ID) {
        HDialog.Open(800, 300, '../CarparkNew/CarManage.aspx?CarID=' + ID + '&OpType=' + OpType, title, false, function callback(_Data) {
            //if (_Data == "true") {
            //    LoadList();
            //}
            LoadList();
        });
    }

    //导入
    function ViewReport(title) {
        HDialog.Open(770, 270, '../CarparkNew/CarBrowseExcel.aspx', title, true, function callback(_Data) {
            if (_Data == "true") {
                LoadList();
            }
        });
    }

    $('#CustName').dblclick(function (e) {
        var conent = "../DialogNew/CustDlg.aspx";
        HDialog.Open('1000', '600', conent, '客户选择', false, function callback(_Data) {
            var data = JSON.parse(_Data);
            $('#CustName').val(data.CustName);
            $('#RoomSign').val('');
            $('#RoomID').val('');
            $("#CustID").val(data.CustID);
        });
    })

    $('#RoomSign').dblclick(function (e) {
        var conent = "../DialogNew/RoomDlg.aspx";
        HDialog.Open('1000', '600', conent, '房屋选择', false, function callback(_Data) {
            var data = JSON.parse(_Data);
            $('#RoomSign').val(data.RoomSign);
            $('#CustName').val('');
            $('#CustID').val('');
            $('#RoomID').val(data.RoomID);
        });
    })

    function btnDel() {
        $('#RoomSign').val('');
        $('#RoomID').val('');
        $('#CustName').val('');
        $('#CustID').val('');
        $('#Owner').val('');
        $('#CarNum').val('');
    }

</script>


