摘要: 一个VB计算器,给上学需要应付作业的人用


阅读全文
posted @ 2007-10-19 21:29 Zhuang miao 阅读(677) 评论(0) 编辑
摘要: 带虚拟键盘的登陆页,效果如下 下载地址:精美login页 功能: 1,登录前实现文本框验证 2,点击右侧小键盘图标弹出虚拟键盘 使用jquery相关插件实现以上效果。 阅读全文
posted @ 2011-12-01 22:22 Zhuang miao 阅读(2840) 评论(21) 编辑
摘要: $(document).ready(function() { $("a").modelwindow({ onclosed: function(data) { $("#cb").val(data); }, callbackcontentid: "#Text4" }) })阅读全文
posted @ 2011-11-16 00:19 Zhuang miao 阅读(98) 评论(0) 编辑
Implementing Paging
It is always a good idea to restrict the number of rows returned with a query. Currently, this
implementation returns all the rows in the INVENTORY table. It works well enough now because the
table contains fewer than 100 rows. If this were implemented in a scenario in which the result set
were in the thousands or hundreds of thousands, it would not perform as well.
The IQuery API provides two methods for implementing paging: SetMaxResults() and
SetFirstResult(). The SetMaxResults() method accepts an integer as a parameter that
defines the maximum number of rows that should be returned for the query. This is often
referred to as Top N.
NOTE You don’t need to worry about implementing paging differently between,
for example, Microsoft SQL Server and Oracle. SQL Server uses Top N, whereas
Oracle uses rownum to restrict results. Code it once using NHibernate and it
works without modification whether the database is changed from SQL Server
to Oracle or vice versa.
The SetFirstResult() method also accepts an integer as a parameter. As the name of the method
implies, it sets the first row returned from the database. Therefore, for the first query, the value
should be 0, with future queries being n plus the value sent to the SetMaxResults() method.
NOTE When using IQuery for paging, the first value passed to the
SetFirstResult() should be 0. However, the ICriteria SetFirstResult()
method expects a 1.
The steps required to add paging functionality to the GuitarStore WPF program are as follows:
1. Create a method that accepts both a max result and a first result as parameters and uses
them to return the expected result.
2. Program a method to retrieve the total number of rows on the INVENTORY table.
3. Create and use a PopulateDataGrid() method to populate the DataGrid, rather than using
the Window_Loaded() method.
4. Add paging buttons and logic to the GuitarStore WPF program.
CHAPTER 2: Using HQL
62
The first action taken to implement paging in the GuitarStore WPF program is to create a new
GetPagedInventory() method. This method should accept a max result and a first result as
parameters. Add the code shown in Listing 2-9 to the NHibernateInventory class.
LISTING 2-9: HQL paging method
public IList GetPagedInventory(int MaxResult, int FirstResult)
{
string hqlQuery = “select Builder, Model, Price, Id “ +
“from Inventory order by Builder”;
using (ITransaction transaction = Session.BeginTransaction())
{
IQuery query = Session.CreateQuery(hqlQuery)
.SetMaxResults(MaxResult)
.SetFirstResult(FirstResult);
return query.List();
}
}
Generated SQL (where max=25 and first=0):
select TOP (@p0)
inventory0_.BUILDER as col_0_0_,
inventory0_.MODEL as col_1_0_,
inventory0_.PRICE as col_2_0_,
inventory0_.ID as col_3_0_
from INVENTORY inventory0_
order by inventory0_.BUILDER;
@p0 = 25 [Type: Int32 (0)]
Generated SQL (where max=25 and first=26):
SELECT TOP (@p0)
col_0_0_,
col_1_0_,
col_2_0_,
col_3_0_
FROM (select inventory0_.BUILDER as col_0_0_,
inventory0_.MODEL as col_1_0_,
inventory0_.PRICE as col_2_0_,
inventory0_.ID as col_3_0_,
ROW_NUMBER()
OVER(ORDER BY inventory0_.BUILDER) as __hibernate_sort_row
from INVENTORY inventory0_) as query
WHERE query.__hibernate_sort_row > @p1
ORDER BY query.__hibernate_sort_row;
@p0 = 25 [Type: Int32 (0)],
@p1 = 26 [Type: Int32 (0)]
Note that two generated SQL queries are shown. The first displays the NHibernate-generated SQL
query created when the SetMaxResults() method is 25 and the SetFirstResult() method is
0. When the first result is 0, it generally means that it is the first page being selected. The second
Working with CreateQuery()
63
NHibernate-generated SQL query results from SetMaxResults() being 25 and SetFirstResult()
being 26. The second SQL query returns rows 26 through 50.
When implementing paging, it is common practice to provide information about the current page
and the overall result set to the user. That means the GuitarStore WPF program should populate
a label with information about where the paged result set is in relation to the entire number of
selectable rows on the table — for example, “Records 0 to 25 of 196 displayed.” To do this, add a
GetInventoryCount() method to the NHibernateInventory class that returns the total number of
records on the INVENTORY table. This method is shown in Listing 2-10.
LISTING 2-10: HQL method to retrieve total record count of the INVENTORY table
public int GetInventoryCount()
{
using (ITransaction transaction = Session.BeginTransaction())
{
IQuery query = Session.CreateQuery(“select count(*) from Inventory”);
return Convert.ToInt32(query.UniqueResult());
}
}
Generated SQL:
select count(*) as col_0_0_
from INVENTORY inventory0_
Up until now, the binding of the CreateQuery result set has been performed within the Window_
Loaded() method of the MainWindow.xaml.cs file found in the GuitarStore WPF project. Instead
of the using the Window_Loaded() method, a new method called PopulateDataGrid() is created in
Listing 2-11. This new method is needed to provide paging buttons with a method for triggering the
retrieval of a paged result set.
posted @ 2011-11-14 22:55 Zhuang miao 阅读(32) 评论(0) 编辑
摘要: VIew<%@PageTitle=""Language="C#"MasterPageFile="~/Views/Shared/Site.Master"Inherits="System.Web.Mvc.ViewPage<dynamic>"%><asp:ContentID="Content1"ContentPlaceHolderID="TitleContent"runat="server">EasyUIDemo</as阅读全文
posted @ 2011-11-07 02:45 Zhuang miao 阅读(100) 评论(0) 编辑
摘要: 如果在你的程序里需要输入很多的内容,比如各类单据,如果在进入每一个录入框的时候都能自动把输入法切换到合适的状态将会是一个很酷的特性,相比炫丽的界面而言打字到手抽筋的录入人员们对此会更加感兴趣。在winform中切换输入法是很简单的事情:阅读全文
posted @ 2011-02-20 00:20 Zhuang miao 阅读(1312) 评论(7) 编辑
posted @ 2009-06-20 00:34 Zhuang miao 阅读(1884) 评论(2) 编辑
posted @ 2009-06-17 00:57 Zhuang miao 阅读(1249) 评论(0) 编辑
posted @ 2009-06-16 20:12 Zhuang miao 阅读(1159) 评论(3) 编辑
摘要: Discuz整体架构如下图所示: 横向表示 同一层次中涉及的各个模块(项目) 纵向表示 不同层次之间模块的关系,某些关系是如何在各层次中传递(穿越) Discuz架构上采用了比较流行的三层架构,即表现层,业务逻辑层,数据访问层来进行设计,并结合自己的情况进行了特殊处理。 表现层: 表现层即为上图中蓝色虚线表示,主要包括:Web,Services,UI,Control。各项目主要功能为: UI 定义各种页面基类,提供Ajax访问访问接口。 Control存放Discuz用到的自定义服务器端控件。 Services提供外部访问接口。 Discuz引入了一种模板引擎的机制,来实现表现层的多样化。 主要设计思想为:针对设计人员,提供纯静态页面,并提供了一套约定的语法和标签(具体位置在:templates)。模板制作完成后,要进行模板导入,此时discuz会将静态模板进行解析将其转换成 aspx页面,然后放到aspx/1..n下。如果你打开这下面的文件,会阅读全文
posted @ 2009-06-15 10:28 Zhuang miao 阅读(1129) 评论(0) 编辑