<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="mobiledatalist.aspx.cs"
    Inherits="HySoft.BaseCallCenter.Web.telmanage.mobiledatalist" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../scripts/ui/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <script src="../scripts/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/core/base.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/ligerui.min.js" type="text/javascript"></script>
    <link href="../scripts/ui/skins/Tab/css/tab.css" rel="stylesheet" type="text/css" />
    <link href="../scripts/ui/skins/Tab/css/grid.css" rel="stylesheet" type="text/css" />
    <script src="../scripts/ui/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="../scripts/CustomersData.js" type="text/javascript"></script>
    <link href="../scripts/ui/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="../images/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function itemclick(item) {
            alert(item.text);
        }
        var singleClick;
        var gridlist;
        $(function () {
            LoadList();
        });
        function LoadList() {
            gridlist = $("#divDataList").ligerGrid({
                height: '100%',
                checkbox: true,
                columns: [
                { display: '号段', name: '_f_mobilenum', minWidth: 60 },
                { display: '区号', name: '_f_zipcode', minWidth: 60 },
                { display: '城市', name: '_f_citydes', minWidth: 60 },
                { display: '卡类型', name: '_f_carddes'}],
                url: 'ajax/mobiledatalist.ashx?action=getlist&telnum=' + encodeURIComponent(document.getElementById("txtKeywords").value), pageSize: 10, rownumbers: true,
                onSelectRow: function (data, rowindex, rowobj) {
                    singleClick = data._f_mobilenum;
                },
                onDblClickRow: function (data, rowindex, rowobj) {
                    Edit('edit');
                },
                isChecked: function (rowdata) {
                    if (findCheckedCustomer(rowdata._f_mobilenum) == -1)
                        return false;
                    return true;
                },
                onCheckRow: function (checked, data) {
                    if (checked) addCheckedCustomer(data._f_mobilenum);
                    else removeCheckedCustomer(data._f_mobilenum);
                },
                onCheckAllRow: function (checked) {
                    for (var rowid in this.records) {
                        if (checked)
                            addCheckedCustomer(this.records[rowid]['_f_mobilenum']);
                        else
                            removeCheckedCustomer(this.records[rowid]['_f_mobilenum']);
                    }
                }
            });
            gridlist.changePage('first');
            $("#pageloading").hide();
        }

        function formatDateTime(value, rowData, rowIndex) {
            if (value != null) {
                var date = new Date(parseInt(value.replace("/Date(", "").replace(")/", ""), 10));
                var result = date.getFullYear() + "-" + (date.getMonth() + 1 < 10 ? "0"
                    + (date.getMonth() + 1) : date.getMonth() + 1) + "-"
                    + (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " "
                    + (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":"
                    + (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":"
                    + (date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds());
                return result;
            }
            return value;
        }
        function deleteRow() {
            g.deleteSelectedRow();
        }

        var checkedCustomer = [];
        function findCheckedCustomer(_f_mobilenum) {
            for (var i = 0; i < checkedCustomer.length; i++) {
                if (checkedCustomer[i] == _f_mobilenum) return i;
            }
            return -1;
        }
        function addCheckedCustomer(_f_mobilenum) {
            if (findCheckedCustomer(_f_mobilenum) == -1)
                checkedCustomer.push(_f_mobilenum);
        }
        function removeCheckedCustomer(_f_mobilenum) {
            var i = findCheckedCustomer(_f_mobilenum);
            if (i == -1) return;
            checkedCustomer.splice(i, 1);
        }
        function Add(param) {
            $.ligerDialog.open({ url: 'mobiledatalistAddandEdit.aspx?actionFlag=' + param, title: '添加号码归属地', height: 300, width: 530, isResize: true
            });
        }

        function Edit(params) {
            if (singleClick == "" || singleClick == undefined) {
                alert("请选择修改行！");
            } else {
                $.ligerDialog.open({ url: 'mobiledatalistAddandEdit.aspx?actionFlag=' + params + '&singleFlage=' + singleClick, title: '修改号码归属地', height: 300, width: 530, isResize: true
                });
            }
        }

        function DeleteList() {
            if (checkedCustomer.length <= 0) {
                alert("请选择删除行！");
            } else {
                $.ligerDialog.confirm('确定要删除吗?', function (yes) {
                    if (yes) {
                        gridlist = $("#divDataList").ligerGrid({
                            url: 'ajax/mobiledatalist.ashx?action=deletelist&arrid=' + checkedCustomer.join(','), pageSize: 10, rownumbers: true
                        });
                    }
                    LoadList();
                });
            }
        }
        document.onkeydown = function (event) {
            var e = event || window.event || arguments.callee.caller.arguments[0];
            if (e && e.keyCode == 13) {
                LoadList();
            }
        };
    </script>
</head>
<body style="margin: 0px; padding: 0px; overflow: hidden;">
    <form id="form1" runat="server">
    <div class="l-loading" style="display: block" id="pageloading">
    </div>
    <div class="tools_box">
        <div class="tools_bar">
            <a class="tools_btn" href="#" onclick="Add('add');"><span><b class="add">添加</b></span>
            </a><a class="tools_btn" href="#" onclick="Edit('edit');"><span><b class="modify">修改</b></span>
            </a><a class="tools_btn" href="#" onclick="DeleteList();"><span><b class="delete">批量删除</b></span>
            </a>
            <div class="search_box">
                关键字：<asp:TextBox ID="txtKeywords" runat="server" CssClass="txtInput"></asp:TextBox>&nbsp;&nbsp;
                <input id="btnSearch" type="button" value="搜 索" class="btnSearch" onclick="LoadList();" />
            </div>
        </div>
    </div>
    <div id="divDataList">
    </div>
    </form>
</body>
</html>
