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

<!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/json2.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/ui/js/plugins/ligerLayout.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerTree.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerMenu.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 src="../scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
        var menu;
        var singleClick;
        $(function () {
            InitMenu();
            InitList();
        });
        function InitMenu() {
            menu = $.ligerMenu({ top: 100, left: 100, width: 120, items:
            [
            { text: '增加', click: itemclick, icon: 'add' },
            { text: '修改', click: itemclick, icon: 'modify' },
            { line: true },
            { text: '删除', click: itemclick, icon: 'delete' }
            ]
            });
        }
        function itemclick(item, i) {
            switch (i) {
                case 0:
                    Add();
                    break;
                case 1:
                    ModifyEdit();
                    break;
                case 2:
                    Delete();
                    break;
                default:
                    break;
            }
        }
        function InitList() {
            var sql = GetSql();
            try {
                gridlist = $("#divDataList").ligerGrid({
                    checkbox: true,
                    height: '99%',
                    columns: [
                { display: 'ID', name: '_f_paramid', width: '1%', hide: 'ID' },
                { display: '参数名称', name: '_f_paramcode', align: 'left', width: '20%' },
                { display: '参数内容', name: '_f_paramvalue', width: '40%' },
                { display: '备注', name: '_f_paramdes',width: '34%'  }
                ],
                    onContextmenu: function (node, e) {
                        try {
                            actionRow = node;
                            //gridlist.select(node);
                            menu.show({ top: e.pageY, left: e.pageX });
                        }
                        catch (e) {
                            alert(e.Message);
                        }
                        return false;
                    },
                    url: 'ajax/sysconfigmanage.ashx?action=getlist' + sql, pageSize: 50, pageSizeOptions: [10, 20, 50, 100], rownumbers: true,
                    onSelectRow: function (data, rowindex, rowobj) {
                        singleClick = data._f_paramid;
                    },
                    onDblClickRow: function (data, rowindex, rowobj) {
                        ModifyEdit();
                    }
                });
            }
            catch (e) {
                alert(e.Message);
            }
            gridlist.changePage('first');
            $("#pageloading").hide();
        }
        function GetSql() {
            var sql = "";
            if (document.getElementById("txtF_ParamValue").value != "") {
                sql += "&value=" + escape(document.getElementById("txtF_ParamValue").value);
            }
            if (document.getElementById("txtF_ParamCode").value != "") {
                sql += "&code=" + document.getElementById("txtF_ParamCode").value;
            }
            return sql;
        }
        function Add() {
            $.ligerDialog.open({ url: 'sysconfigedit.aspx?getPuction=Add', title: '添加参数信息', height: 370, width: 700, isResize: true
            });
        }
        function ModifyEdit() {
            if (singleClick == "" || singleClick == undefined) {
                alert("请选择修改行！");
            } else {
                $.ligerDialog.open({ url: 'sysconfigedit.aspx?getPuction=Edit' + '&singleFlage=' + singleClick, title: '修改参数信息', height: 370, width: 700, isResize: true
                });
            }
        }
        function Delete() {
            try {
                //获取选择的行
                var rows = gridlist.getSelectedRows();
                if (rows.length > 0) {
                    $.ligerDialog.confirm('确定要批量删除选择的记录吗？', function (yes) {
                        if (yes) {
                            try {
                                var arr = new Array();
                                var i = 0;
                                for (var i = 0; i < rows.length; i++) {
                                    arr[i] = rows[i]._f_paramid;
                                }
                                $.post("ajax/sysconfigmanage.ashx?action=delete&arrid=" + arr.toString(), function (data) {
                                    if (data == "success") {
                                        $.ligerDialog.success('删除成功');
                                        InitList();
                                    }
                                    else {
                                        $.ligerDialog.error('删除失败');
                                    }
                                });
                            }
                            catch (e) {
                                alert(e.Message);
                            }
                        }
                        else {
                        }
                    });
                }
                else {
                    $.ligerDialog.error('没有选择要删除的参数');
                }
            }
            catch (e) {
                $.ligerDialog.error(e.Message);
            }
        }
        document.onkeydown = function (event) {
            var e = event || window.event || arguments.callee.caller.arguments[0];
            if (e && e.keyCode == 13) {
                InitList();
            }
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="tools_box">
        <div class="tools_bar">
            <a class="tools_btn" href="#" onclick="Add();">
                <span><b class="add">添加</b></span>
            </a>
            <a class="tools_btn" href="#" onclick="ModifyEdit();">
                <span><b class="modify">修改</b></span>
            </a>
            <a class="tools_btn" href="#" onclick="Delete();"><span>
                    <b class="delete">批量删除</b></span> </a>
            <div class="search_box">
                参数名称：<asp:TextBox ID="txtF_ParamCode" runat="server" CssClass="txtInput"></asp:TextBox>&nbsp;&nbsp;
                参数内容：<asp:TextBox ID="txtF_ParamValue" runat="server"  CssClass="txtInput" ></asp:TextBox>&nbsp;&nbsp;
                <input id="btnSearch" type="button" value="搜 索" class="btnSearch" onclick="InitList();" />
            </div>
        </div>
    </div>
    <div id="layout1">
      <div position="center" title="参数列表">
            <div id="divDataList">
            </div>
        </div>
    </div>
    </form>
</body>
</html>
