先上代码:前台代码

<!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.ashx?action=upmanager',
data: { id: $("#id").val(), 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('管理员修改成功'); }
else {
LG.showError('修改失败!'); }
}
});
} </script>
</head>
<body>
<a class="l-button" style="width: 80px; float: left; margin-left: 6px;" onclick="beginEdit()">修改行</a>
<a class="l-button" style="width: 80px; float: left; margin-left: 6px;" onclick="deleteRow()">删除选择</a>
<a class="l-button" style="width: 100px; float: left; margin-left: 6px;" onclick="Addadmin()">添加行</a>
<br />
<br />
<div id="grid">
<div id="maingrid">
</div>
</div>
<form id="form2" style="display: none">
</form>
</body>
</html>

后台代码:

using System;
using System.Web;
using Newtonsoft.Json;
using System.Data; public class ManagerData : IHttpHandler
{ public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string action = context.Request.Params["action"]; //获取管理员列表
if (action == "managerlist")
{
DataTable table = new DataTable();
string sql = "select * from A_Admin where 1=1 ";
if (ISDatabase.SelectDatebase() == )
table = DbHelp.DataTableSql(sql);
else
table = DbHelperOleDb.DataTableSql(sql); string ResJsonStr = "{ \"Rows\": ";
if (table.Rows.Count > )
{
Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd";
ResJsonStr = ResJsonStr + JsonConvert.SerializeObject(table, Formatting.Indented, timeConverter) + ", \"Total\": " + table.Rows.Count + " }";
}
context.Response.Write(ResJsonStr);
} //添加管理员
if (action == "addmanager")
{ string UserName = context.Request.Params["UserName"];
string Password = context.Request.Params["Password"];
string StrIP=PubliclClass.getIp();
int result;
string sql = "insert into A_Admin(Name,Password,Loginip) values('" + UserName + "','" + Password + "','" + StrIP + "') ";
if (ISDatabase.SelectDatebase() == )
result = DbHelp.ExecuteSql(sql);
else
result = DbHelperOleDb.ExecuteSql(sql); if (result > )
{
context.Response.Write("{\"success\":true}");
}
else
{
context.Response.Write("{\"success\":false}");
}
} //更新管理员
if (action == "upmanager")
{
string id = context.Request.Params["id"];
string UserName = context.Request.Params["UserName"];
string Password = context.Request.Params["Password"];
string StrIP = PubliclClass.getIp();
int result;
string sql = "update A_Admin set Name='" + UserName + "',Password='" + Password + "',Loginip='" + StrIP + "' where id=" + id + " ";
if (ISDatabase.SelectDatebase() == )
result = DbHelp.ExecuteSql(sql);
else
result = DbHelperOleDb.ExecuteSql(sql); if (result > )
{
context.Response.Write("{\"success\":true}");
}
else
{
context.Response.Write("{\"success\":false}");
}
} //删除管理员
if (action == "delmanager")
{
string id = context.Request.Params["id"];
int result;
string sql = "delete A_Admin where id=" + id + " ";
if (ISDatabase.SelectDatebase() == )
result = DbHelp.ExecuteSql(sql);
else
result = DbHelperOleDb.ExecuteSql(sql); if (result > )
{
context.Response.Write("{\"success\":true}");
}
else
{
context.Response.Write("{\"success\":false}");
}
} } public bool IsReusable
{
get
{
return false;
}
} }

现在网上的前台框架越来越多,大多都基于jQuery的,不得不说jquery的出现给大家带来很多好处。随jquery的前台框架也很多有的简单有的复杂,用了ligerUi的人都会感觉到他们的文档很少,没有帮助文档说明用起来就很费劲。对于初学者还是考虑用easyui吧!比较人家文档很丰富,而且官方例子也很明了。

LigerUI一个前台框架增、删、改asp.net代码的实现的更多相关文章

  1. LigerUI一个前台框架增、删、改asp.net代码

    LigerUI一个前台框架增.删.改asp.net代码的实现   先上代码:前台代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tran ...

  2. django ajax增 删 改 查

    具于django ajax实现增 删 改 查功能 代码示例: 代码: urls.py from django.conf.urls import url from django.contrib impo ...

  3. iOS FMDB的使用(增,删,改,查,sqlite存取图片)

    iOS FMDB的使用(增,删,改,查,sqlite存取图片) 在上一篇博客我对sqlite的基本使用进行了详细介绍... 但是在实际开发中原生使用的频率是很少的... 这篇博客我将会较全面的介绍FM ...

  4. iOS sqlite3 的基本使用(增 删 改 查)

    iOS sqlite3 的基本使用(增 删 改 查) 这篇博客不会讲述太多sql语言,目的重在实现sqlite3的一些基本操作. 例:增 删 改 查 如果想了解更多的sql语言可以利用强大的互联网. ...

  5. ADO.NET 增 删 改 查

    ADO.NET:(数据访问技术)就是将C#和MSSQL连接起来的一个纽带 可以通过ADO.NET将内存中的临时数据写入到数据库中 也可以将数据库中的数据提取到内存中供程序调用 ADO.NET所有数据访 ...

  6. 第18课-数据库开发及ado.net 连接数据库.增.删.改向表中插入数据并且返回自动编号.SQLDataReade读取数据

    第18课-数据库开发及ado.net 连接数据库.增.删.改向表中插入数据并且返回自动编号.SQLDataReade读取数据 ADO.NET 为什么要学习? 我们要搭建一个平台(Web/Winform ...

  7. C# ADO.NET (sql语句连接方式)(增,删,改)

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  8. 好用的SQL TVP~~独家赠送[增-删-改-查]的例子

    以前总是追求新东西,发现基础才是最重要的,今年主要的目标是精通SQL查询和SQL性能优化.  本系列主要是针对T-SQL的总结. [T-SQL基础]01.单表查询-几道sql查询题 [T-SQL基础] ...

  9. MVC EF 增 删 改 查

    using System;using System.Collections.Generic;using System.Linq;using System.Web;//using System.Data ...

随机推荐

  1. 前端学PHP之基础语法

    × 目录 [1]代码标识 [2]注释 [3]输出 [4]计算表达式 [5]大小写 [6]空白符 前面的话 PHP是一种创建动态交互性站点的强有力的服务器端脚本语言.PHP能够包含文本.HTML.CSS ...

  2. java中父类与子类, 不同的两个类中的因为构造函数由于递归调用导致栈溢出问题

    /* 对于类中对成员变量的初始化和代码块中的代码全部都挪到了构造函数中, 并且是按照java源文件的初始化顺序依次对成员变量进行初始化的,而原构造函数中的代码则移到了构造函数的最后执行 */ impo ...

  3. Prim算法(一)之 C语言详解

    本章介绍普里姆算法.和以往一样,本文会先对普里姆算法的理论论知识进行介绍,然后给出C语言的实现.后续再分别给出C++和Java版本的实现. 目录 1. 普里姆算法介绍 2. 普里姆算法图解 3. 普里 ...

  4. 自制jQuery标签插件

    在项目中需要一个添加标签的小插件,查看了一些已有插件后,发现很现成的高级插件,也有比较简单的插件.最后还是决定自己来写,这样能控制代码,以后与其他插件结合使用的时候能更好的把控.初步在IE6 7 8, ...

  5. 【深入BFC】 关于CSS中float布局,清除浮动,和margin合并的原理解析,解开你心中的那些困惑!

    BFC的通俗理解: Block Formatting Context(块级格式化上下文)是W3C CSS 2.1 规范中的一个概念,它决定了元素如何对其内容进行定位,以及与其他元素的关系和相互作用. ...

  6. [SDK2.2]Windows Azure Cloud Service (35) 使用VS2013发布Azure Cloud Service

    <Windows Azure Platform 系列文章目录> 好久没有更新BLOG了,今天我们继续Windows Azure相关的内容. 笔者最近把Visual Studio升级到了20 ...

  7. JAVA 设计模式 外观模式

    用途 外观模式 (Facade) 为子系统中的一组接口提供一个一致的界面,此模式定义了一个高层接口,这个接口使得这一子系统更加容易使用. 外观模式是一种结构型模式. 结构

  8. 通过自定义相册来介绍photo library的使用

    因为我在模仿美图秀秀的功能,在使用相册时候,UIImagePickerController本来就是一个UINavigationController的子类,所以没有办法使用push,所以做了一个自定义的 ...

  9. .NET的EF框架中:在应用程序配置文件中找不到名为“”的连接字符串问题

    今天在使用EF Code First框架时,当把模型都定义好了,想通过程序包管理控制台利用enable-migrations –force来生成数据库表的时候报错了,如下: 找不到连接字符串,但是我仔 ...

  10. 原生JS 获取浏览器、窗口、元素等尺寸的方法及注意事项

    一.通过浏览器获得屏幕的尺寸 screen.width screen.height screen.availHeight //获取去除状态栏后的屏幕高度 screen.availWidth //获取去 ...