目录结构

先设计数据表结构

DROP SEQUENCE BDLLY_2V.SEQ_CUSTOMER;

CREATE SEQUENCE BDLLY_2V.SEQ_CUSTOMER
START WITH 6
MAXVALUE 999999999999999999999999999
MINVALUE 0
NOCYCLE
NOCACHE
NOORDER; DROP TABLE BDLLY_2V.CUSTOMER CASCADE CONSTRAINTS; CREATE TABLE Customer
(
CustomerId INTEGER,
CompanyName VARCHAR2(50),
ContactName VARCHAR2(50),
ContactTitle VARCHAR2(50),
Address VARCHAR2(50),
City VARCHAR2(30),
Region VARCHAR2(20),
PostalCode VARCHAR2(10),
Country VARCHAR2(50),
Phone VARCHAR2(15)
); Insert into BDLLY_2V.CUSTOMER
(CUSTOMERID, COMPANYNAME, CONTACTNAME, CONTACTTITLE, ADDRESS,
CITY, REGION, POSTALCODE, COUNTRY, PHONE)
Values
(1, ' Apple Inc.', 'Steve P.(aul) Jobs', 'iPhone Change the world', 'America in San Francisco, California',
'San Francisco', 'Buddhism', '', 'America', '');
Insert into BDLLY_2V.CUSTOMER
(CUSTOMERID, COMPANYNAME, CONTACTNAME, CONTACTTITLE, ADDRESS,
CITY, REGION, POSTALCODE, COUNTRY, PHONE)
Values
(2, 'Microsoft Inc.', 'Bill Gates', 'Personal Computer', 'Redmond, Washington America',
'Washington', 'Christianism', '', 'America', '');
Insert into BDLLY_2V.CUSTOMER
(CUSTOMERID, COMPANYNAME, CONTACTNAME, CONTACTTITLE, ADDRESS,
CITY, REGION, POSTALCODE, COUNTRY, PHONE)
Values
(3, 'Google', 'Lawrence Edward Page', 'Google Earth', 'Mountain view, Santa Clara County, California USA',
'County of Santa Clara', 'none', '', 'America', '');
Insert into BDLLY_2V.CUSTOMER
(CUSTOMERID, COMPANYNAME, CONTACTNAME, CONTACTTITLE, ADDRESS,
CITY, REGION, POSTALCODE, COUNTRY, PHONE)
Values
(4, 'Twitter', 'Evan Williams', 'what happening', 'America in San Francisco, California',
'San Francisco', 'none', '', 'America', '');
Insert into BDLLY_2V.CUSTOMER
(CUSTOMERID, COMPANYNAME, CONTACTNAME, CONTACTTITLE, ADDRESS,
CITY, REGION, POSTALCODE, COUNTRY, PHONE)
Values
(5, 'Facebook', 'Mark Elliot Zuckerberg', ' Done is better than perfect.', 'Palo Alto, California, USA',
'alo Alto', 'none', '', 'America', '');

前端jquery

引用

<script src="../../Scripts/jquery-1.8.2.min.js"></script>
<script src="../../Scripts/jquery-pager.js" type="text/javascript"></script>
<link href="../../Scripts/pager.css" rel="stylesheet" type="text/css" /> <script lang="ja" type="text/javascript">
//PageIndex当前页码
//PageCount当前页数
function init(PageIndex, PageCount) {
var receive_url = "/Customer/GetMerchant?PageIndex=" + PageIndex + "&PageCount=" + PageCount;
$.ajax({
type: "GET",
url: receive_url,
cache: "false",
success: function (data) {
data = eval(data);
//循环表格
$("tbody").html("");
var html = "";
for (var i = 0; i < data.length; i++) {
var json = null;
json = data[i];
var customId = json.CustomerId;
var companyName = json.CompanyName;
var contactName = json.ContactName;
var contactTitle = json.ContactTitle;
var address = json.Address;
var city = json.City;
var region = json.Region;
var postalCode = json.PostalCode;
var country = json.Country;
var phone = json.Phone;
html += "<tr><td>" + customId + "</td><td>" + companyName + "</td><td>" + contactName + "</td><td>" + contactTitle + "</td><td>" + address + "</td><td>" + city + "</td><td>" + region + "</td><td>" + postalCode + "</td><td>" + country + "</td><td>" + phone + "</td></tr>";
}
$("tbody").append(html);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("程序异常!");
}
});
}; $(document).ready(function () {
//得到页面数据总数
var result = null;
$.ajax({
type: "POST",
url: "/Customer/GetPageCount",
cache: "false",
async: false,
success: function (data) {
result = eval(data);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("程序异常!");
}
});
initPager(result, 1);
}); //RecordCount[总记录数] PageIndex[当前页码]
function initPager(RecordCount, PageIndex) {
$("#page-bottom").setPager({
RecordCount: RecordCount,
PageIndex: PageIndex,
buttonClick: function (RecordCount, PageIndex) {
initPager(RecordCount, PageIndex);
}
});
//分页同时更新数据源
init(PageIndex, 20);
}; </script>

hibernate.cfg.xml

<?xml version="1.0" encoding="utf-8"?>
<!--
This template was written to work with NHibernate.Test.
Copy the template to your NHibernate.Test project folder and rename it in hibernate.cfg.xml and change it
for your own use before compile tests in VisualStudio.
-->
<!-- This is the System.Data.OracleClient.dll provider for Oracle from MS -->
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" >
<session-factory name="NHibernateUI">
<property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
<property name="connection.connection_string">
User ID=bdlly_2v;Password=gmgl;Data Source=glxt
</property>
<property name="show_sql">false</property>
<property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<!--添加下面这行代码,除此之外,其它都不用改动,当然,你也可以修改上面的数据库链接字符串-->
<mapping assembly="NHibernate.Domain"/>
</session-factory>
</hibernate-configuration>

Entity:

namespace NHibernate.Domain
{

    public class Customer
{
public virtual int CustomerId { get; set; }
public virtual string CompanyName { get; set; }
public virtual string ContactName { get; set; }
public virtual string ContactTitle { get; set; }
public virtual string Address { get; set; }
public virtual string City { get; set; }
public virtual string Region { get; set; }
public virtual string PostalCode { get; set; }
public virtual string Country { get; set; }
public virtual string Phone { get; set; }
}

Mapping:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Domain" namespace="NHibernate.Domain">
<class name="NHibernate.Domain.Customer,NHibernate.Domain" table="Customer">
<id name="CustomerId" column="CustomerId" type="int" unsaved-value="0">
<generator class= "sequence">
<param name= "sequence">SEQ_CUSTOMER</param>
</generator>
</id>
<property name="CompanyName" column="CompanyName" type="string" />
<property name="ContactName" column="ContactName" type="string" />
<property name="ContactTitle" column="ContactTitle" type="string" />
<property name="Address" column="Address" type="string" />
<property name="City" column="City" type="string" />
<property name="Region" column="Region" type="string" />
<property name="PostalCode" column="PostalCode" type="string" />
<property name="Country" column="Country" type="string" />
<property name="Phone" column="Phone" type="string" /> </class>
</hibernate-mapping>

NHibernate.DataPortal:

namespace NHibernate.DataPortal
{
public class CustomerOperator
{
private NHibernateHelper nhibernateHelper = new NHibernateHelper(); protected ISession Session { get; set; } /// <summary>
/// 打开Session
/// </summary>
public CustomerOperator()
{
this.Session = nhibernateHelper.GetSession();
}
/// <summary>
/// 构造session
/// </summary>
/// <param name="session"></param>
public CustomerOperator(ISession session)
{
this.Session = session;
} /// <summary>
/// 查询客户并返回所有的信息
/// </summary>
/// <returns></returns>
public IList<Customer> GetCunstomers(int pageIndex, int pageCount)
{
IList<Customer> list = (IList<Customer>)Session.CreateQuery("FROM Customer")
.SetFirstResult(pageCount * (pageIndex - ) + )
.SetMaxResults(pageCount)
.List<Customer>();
return list;
}
/// <summary>
/// 查询记录数
/// </summary>
/// <returns></returns>
public Single GetCount()
{
IQuery q = Session.CreateQuery(@"SELECT t FROM Customer t");
return Convert.ToSingle(q.List().Count);
} }
}

Controllers:

namespace NHibernateUI.Controllers
{
public class CustomerController : Controller
{
//
// GET: /Customer/ public ActionResult Merchant()
{
return View();
}
/// <summary>
/// 初始化数据
/// </summary>
/// <returns></returns>
public ActionResult GetMerchant()
{
//请求当前页码和当前页数
int pageIndex = Convert.ToInt32(Request.Params.Get("PageIndex"));
int pageCount = Convert.ToInt32(Request.Params.Get("PageCount")); CustomerOperator oper = new CustomerOperator();
IList<Customer> list = oper.GetCunstomers(pageIndex,pageCount); return Json(list, JsonRequestBehavior.AllowGet);
} public ActionResult GetPageCount()
{
CustomerOperator oper=new CustomerOperator();
Single s = oper.GetCount();
return Json(s, JsonRequestBehavior.AllowGet);
} }
}

jquery+NHibernate3.3.3+MVC的分页效果的更多相关文章

  1. 分享5种风格的 jQuery 分页效果【附代码】

    jPaginate 是一款非常精致的分页插件,提供了五种不同风格的分页效果,支持鼠标悬停翻页,快速分页功能.这款插件还提供了丰富的配置选项,你可以根据需要进行设置. 效果演示      源码下载 各个 ...

  2. 5种风格的 jQuery 分页效果【附代码】

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...

  3. 基于jquery 的分页插件,前端实现假分页效果

    上次分享了一款jquery插件,现在依旧分享这个插件,不过上一次分享主要是用于regular框件,且每一页数据都是从后端获取过来的,这一次的分享主要是讲一次性获取完数据 然后手动进行分页.此需求基本上 ...

  4. jquery自定义插件实现分页效果

    这节介绍如何自定义jquery插件,实现分页效果,话不多说,先看看实现的效果: 分页插件 实现的代码如下: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTM ...

  5. 使用Jquery做分页效果

    之前写过一个PHP 的分页效果,但是今天小伙伴和我说了一个不适用后台单纯用前段的JS来写分页,整理了一下,代码如下: html: <div id="containet"> ...

  6. MVC快速分页

    .NET手记-ASP.NET MVC快速分页的实现   对于Web应用,展示List是很常见的需求,随之而来的常见的分页组件.jQuery有现成的分页组件,网上也有着大量的第三方分页组件,都能够快速实 ...

  7. MVC自定义分页

    MVC自定义分页 之前我发表了一篇MVC无刷新分页的文章,里面用的是MvcPager控件,但是那个受那个控件限制,传值只能用PagedList,各方面都受到了限制,自由度不够高,现在还是做MVC无刷新 ...

  8. 基于存储过程的MVC开源分页控件--LYB.NET.SPPager

    摘要 现在基于ASP.NET MVC的分页控件我想大家都不陌生了,百度一下一大箩筐.其中有不少精品,陕北吴旗娃杨涛大哥做的分页控件MVCPager(http://www.webdiyer.com/)算 ...

  9. JQuery对ASP.NET MVC数据进行更新删除

    以前学习ASP.NET MVC时,学习与应用,操作过数据显示,添加,编辑,更新和删除等功能. 很多方法是相通的,看自己是怎样来进行方便,快捷,高效率. 今天Insus.NET写的练习,是直接对绑定在T ...

随机推荐

  1. IOS开发中针对UIImageView的几种常用手势

    // //  ViewController.m //  05-手势 // //  Created by wanghy on 15/9/21. //  Copyright (c) 2015年 wangh ...

  2. O-C相关05:方法的封装.

    前言:在 OC 中进行封装, 就是实现设置实例变量和获取实例变量数据的方法, 常常称为 setter 方法和 getter 方法. 或称为 get set 读写器. 1,setter 方法 sette ...

  3. ipod nano 无法添加mp4视频 电影失败解决方法

    我的是nano7. 导入mp4各种错误, 同步资料库 无效等等方法都没用. 后来发现当中 多个mp4,少年pi.mp4竟然导入成功, 怀疑是mp4格式不符合nano 于是:(测试后成功) 先拉到资料库 ...

  4. VIM 及正则表达式

    VIM及正则表达式 一.查找/Search + 统计 1.统计某个关键字 方法是:%s:keyword:&:gn. 其中,keyword是要搜索的关键字,&表示前面匹配的字符串,n表示 ...

  5. ZeroBrane Lua脚本编辑器代码自动补全

    简介         ZeroBrane Studio是一款支持代码提示.语法高亮.远程调试.代码分析.调试等功能的轻量级Lua IDE工具.可以去官网studio.zerobrane.com进行下载 ...

  6. WebConfig加密解密

    加密:aspnet_regiis -pef appSettings "G:\FlyMusicNew\Web"解密:aspnet_regiis -pdf appSettings &q ...

  7. Linux系统的启动流程以及做个小小的Linux

    内核的作用     进程管理:进程间切换     内存管理:内存空间分割为内核空间和用户空间     IO管理:对底层硬件的使用必须由内来实现,不能由用户空间进程来实现     文件系统管理     ...

  8. Makefile隐含规则和用到的默认变量

    如果要使用隐含规则生成你需要的目标,你所需要做的就是不要写出这个目标的规则.那么,make会试图去自动推导产生这个目标的规则和命令,如果make可以自动推导生成这个目标的规则和命令,那么这个行为就是隐 ...

  9. /etc/rc.local ; /etc/init.d ;/etc/profile;/etc/bashrc;~/.bash_profile;~/.bashrc;~/.bash_logout

    1. /etc/rc.local 这是使用者自订开机启动程序,把需要开机自动运行的程序写在这个脚本里. 把脚本程序写在/etc/rc.d/init.d/目录下也可以  在完成 run level 3 ...

  10. easy ui tabs 顶部绑定事件

    $(function(){     $('#tb').tabs('bindclick', function(index, title){     }); }); $.extend($.fn.tabs. ...