<%@ page language="C#" autoeventwireup="true" inherits="Admin_Magiclantern_Magiclanternlist, App_Web_wmf01ttc" %>

<!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 runat="server">
    <title>管理员管理</title>
    <link href="../ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="../ligerUI/json2.js" type="text/javascript"></script>
    <script src="../ligerUI/js/core/base.js" type="text/javascript"></script>
    <script src="../ligerUI/js/plugins/ligerForm.js" type="text/javascript"></script>
    <script src="../ligerUI/js/plugins/ligerDrag.js" type="text/javascript"></script>
    <script src="../ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
    <script src="../ligerUI/js/plugins/ligerTextBox.js" type="text/javascript"></script>
    <script src="../ligerUI/js/plugins/ligerCheckBox.js" type="text/javascript"></script>
    <script src="../ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>
    <script src="../ligerUI/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="../ligerUI/js/plugins/ligerDateEditor.js" type="text/javascript"></script>
    <script src="../ligerUI/js/plugins/ligerSpinner.js" type="text/javascript"></script>
    <script src="../ligerUI/js/plugins/ligerResizable.js" type="text/javascript"></script>
    <script src="../ligerUI/js/plugins/ligerButton.js" type="text/javascript"></script>
    <script src="../js/LG.js" type="text/javascript"></script>
    <script type="text/javascript">
        var manager, g;
        var detailWin;
        var gridManager;

        $(function () {
            $(window).width($(document).width() - 20);

            g = manager = $("#maingrid").ligerGrid({
                //title : 'gg',
                columns: [
                { display: 'ID编号', name: 'id', width: 50, type: 'int', frozen: true },
                { display: '幻灯名', name: 'MagicName', width: 100, editor: { type: 'text'} },
                { display: '幻灯地址', name: 'MagicUrl', width: 260, type: 'text', editor: { type: 'text'} },
                { display: '幻灯图片', name: 'MagicImage', width: 260, type: 'text', editor: { type: 'text'} },
                { display: '添加时间', name: 'AddTime', type: 'text', width: 100, editor: { type: 'text'} }
                ],
                //                onSelectRow: function (data, rowindex, rowobj) {
                //                    $("#Name").html(data.Name);
                //                    $("#Password").html(data.Password);
                //                },

                dataAction: 'local',
                pageSize: 10,
                pageSizeOptions: [10, 20, 30],
                url: "MagiclanternData.ashx?action=Magiclanternlist",
                isScroll: false,
                //checkbox: true,
                rownumbers: true,
                width: '100%',
                heightDiff: -1,
                onRClickToSelect: true,
                onContextmenu: function (parm, e) {
                    actionCustomerID = parm.data.id;
                    menu.show({ top: e.pageY, left: e.pageX });
                    return false;
                }
            });

            $("#maingrid").width($("#maingrid").width() - 16);

            $("#grid").height(document.documentElement.clientHeight - $(".toolbar").height());



            $("#searchbtn").ligerButton({
                click: function () {
                    manager.options.data = $.extend(true, {}, manager);
                    manager.loadData(f_getWhere());
                }
            });

        });


        $("#searchbtn").click(function () {
                manager.options.data = $.extend(true, {}, manager);
                manager.loadData(f_getWhere());
            });
   


    function f_getWhere() {
        if (!grid) return null;
        var clause = function (rowdata, rowindex) {
            var key = $("#sName").val();
            return rowdata.MagicName.indexOf(key) > -1;
        };
        return clause;
    }




        function deleteRow() {
            var row = manager.getSelectedRow();
            if (!row) { LG.showSuccess('请选择行'); return; }
            $.ajax({
                type: "get",
                url: 'MagiclanternData.ashx?action=delMagiclantern',
                data: { id: row.id },
                cache: false,
                async: false,
                success: function (result) {
                    var obj_result = eval('(' + result + ')');   //返回信息 {'success':true}
                    if (obj_result.success == true) {
                        LG.showSuccess('删除幻灯成功');
                        manager.loadData();
                    }
                    else {
                        LG.showError('删除失败！');
                        manager.loadData();

                    }
                }
            });

        }


        function addNewRow() {
            window.location.href = "MagiclanternForm.aspx";

        }
        function UpdateRow() {
            var row = manager.getSelectedRow();
            if (!row) { LG.showSuccess('请选择行'); return; }
            window.location.href = "MagiclanternForm.aspx?uid="+row.id; ;
        }


    </script>
</head>
<body style="text-align:center;margin:10px;">
    <div class="l-panel-search">
    <a class="l-button" style="width: 100px; float: left; margin-left: 6px;" onclick="addNewRow()">添加行</a>
    <a class="l-button" style="width: 80px; float: left; margin-left: 6px;" onclick="UpdateRow()">修改行</a> 
    <a class="l-button" style="width: 80px; float: left; margin-left: 6px;" onclick="deleteRow()">删除选择</a>

    <div class="l-panel-search-item">
       幻灯名：
    </div>
    <div class="l-panel-search-item">
        <input type="text" id="sName" />
    </div>
    <div class="l-panel-search-item">
        <div id="searchbtn" style="width:80px;">搜索</div>
    </div>
</div>
    <div id="grid">
        <div id="maingrid">
        </div>
    </div>
    <form id="form2" style="display: none">
    </form>
</body>
</html>
