先上代码:前台代码
<!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="../js/LG.js" type="text/javascript"></script> <script type="text/javascript"> var manager, g; var detailWin; $(function () { g = manager = $("#maingrid").ligerGrid({ //title : 'gg', columns: [ { display: 'ID编号', name: 'id', width: 50, type: 'int', frozen: true }, { display: '名字', name: 'Name', width: 100, editor: { type: 'text'} }, { display: '密码', name: 'PassWord', width: 260, type: 'text', editor: { type: 'text'} }, { display: '登录IP', name: 'Loginip', 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: "ManagerData.ashx?action=managerlist", 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()); //创建表单结构 $("#form2").ligerForm({ inputWidth: 170, labelWidth: 90, space: 40, validate: true, fields: [ { name: "id", newline: true, type: "hidden" }, { display: "用户名称", name: "UserName", newline: true, type: "text", validate: { required: true, minlength: 2} }, { display: "密 码", name: "Password1", newline: true, type: "text", validate: { required: true, minlength: 6} }, { display: "重复密码", name: "Password2", newline: true, type: "text", validate: { required: true, minlength: 6} } ] }); }); function Addadmin() { $('input[name="id"]').val(""); $('input[name="UserName"]').val(""); $('input[name="Password1"]').val(""); $('input[name="Password2"]').val(""); detailWin = $.ligerDialog.open({ height: 200, target: $("#form2"), width: null, height: 'auto', //showMax: true, //showToggle: true, //showMin: true, //isResize: true, modal: false, title: "新增", buttons: [ { text: '确定', onclick: function () { addNewRow(); detailWin.hide(); manager.loadData() } }, { text: '取消', onclick: function () { detailWin.hide(); } } ] }); } function beginEdit() { $('input[name="id"]').val(""); $('input[name="UserName"]').val(""); $('input[name="Password1"]').val(""); $('input[name="Password2"]').val(""); var row = manager.getSelectedRow(); if (!row) { alert('请选择行'); return; } detailWin = $.ligerDialog.open({ height: 200, target: $("#form2"), width: null, height: 'auto', modal: false, title: "新增", buttons: [ { text: '确定', onclick: function () { UpdateRow(); detailWin.hide(); manager.loadData() } }, { text: '取消', onclick: function () { detailWin.hide(); } } ] }); $('input[name="id"]').val(row.id); $('input[name="UserName"]').val(row.Name); $('input[name="Password1"]').val(row.Password); $('input[name="Password2"]').val(row.Password); } function deleteRow() { var row = manager.getSelectedRow(); if (!row) { alert('请选择行'); return; } $.Ajax({ type: "get", url: 'ManagerData.ashx?action=delmanager', 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('删除管理员成功'); } else { LG.showError('删除失败!'); } } }); } function addNewRow() { if (liger.get("UserName").getValue() == "") { LG.tip('用户名不能为空?'); return; } if (liger.get("Password1").getValue() != liger.get("Password2").getValue()) { LG.tip('两次输入的密码不相等?'); return; } $.ajax({ type: "get", url: 'ManagerData.ashx?action=addmanager', data: { UserName: liger.get("UserName").getValue(), Password: liger.get("Password1").getValue() }, 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 UpdateRow() { if ($("#id").val() == "") { LG.tip('编辑信息可能丢失?'); return; } if (liger.get("UserName").getValue() == "") { LG.tip('用户名不能为空?'); return; } if (liger.get("Password1").getValue() != liger.get("Password2").getValue()) { LG.tip('两次输入的密码不相等?'); return; } $.ajax({ type: "get", url: 'ManagerData.
新闻热点
疑难解答