/// <reference path="jquery-1.10.2.min.js" />


var pageindex = 1;
var pagesize = 10;
var pagecount = 0;

function QueryId_btn() {
    var dataid = $.trim($("#Data_Id").val());
    $("#datalist ul").not(":eq(0)").remove();
    $.post("/ajax/Admin_DateBase.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": 10, "dataid": dataid }, function (data) {
        var data = eval('(' + data + ')');
        pagecount = data.pagecount;
        $("#datalist").html("").append(data.pagelist);
        layui.use(['laypage', 'layer'], function () {
            var nums = pagesize; //每页出现的数据量
            var laypage = layui.laypage
            , layer = layui.layer;
            laypage.render({
                elem: 'pager'
               , count: pagecount //总页数
               , groups: 1
                , jump: function (obj) {
                    pageindex = obj.curr;//获取到当前页
                    $.post("/ajax/Admin_DateBase.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": 10, "dataid": dataid }, function (data) {
                        var data = eval('(' + data + ')');
                        pagecount = data.pagecount;
                        $("#datalist").html("").append(data.pagelist);
                    });

                }
            });
        });
    })
}



function QueryName_btn() {
    var dataname = $.trim($("#Data_Name").val());
    $("#datalist ul").not(":eq(0)").remove();
    $.post("/ajax/Admin_DateBase.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": 11, "dataname": dataname }, function (data) {
        var data = eval('(' + data + ')');
        pagecount = data.pagecount;
        $("#datalist").html("").append(data.pagelist);
        layui.use(['laypage', 'layer'], function () {
            var nums = pagesize; //每页出现的数据量
            var laypage = layui.laypage
            , layer = layui.layer;
            laypage.render({
                elem: 'pager'
               , count: pagecount //总页数
               , groups: 1
                , jump: function (obj) {
                    pageindex = obj.curr;//获取到当前页
                    $.post("/ajax/Admin_DateBase.ashx", { "pageindex": pageindex, "pagesize": pagesize, "type": 11, "dataname": dataname }, function (data) {
                        var data = eval('(' + data + ')');
                        pagecount = data.pagecount;
                        $("#datalist").html("").append(data.pagelist);
                    });

                }
            });
        });
    })
}




function datadel_btn() {
    var datadelid = $.trim($("#data_del_id").val());
    if (!confirm("确定要删除吗？") == true) {

        return true;

    } else {
    $.post("/ajax/Admin_DateBase.ashx", { "type": "del", "datadelid": datadelid }, function (data) {
        if (data == "ok") {
            alert("删除成功");
            window.location.href = "./Admin_DataList.aspx";
        } else {
            alert("删除失败");
        }


    });
    }

}
