這兒的代碼少了
public enum QueryOperator
{
//等於比較
Equal =
// 不等於
NotEqual =
// Like比較
Like =
}
class Query
{
void Add(string fieldName
string GetSql();
}
QueryPeopleForm : QueryFormBase
OnQueryButtonClick()
{
Query query = new Query();
query
query
QueryAndBind(new PeopleManager()
}
把拼Sql的工作放在Query類中做
到這一步
修改後的代碼
QueryPeopleForm : QueryFormBase
OnQueryButtonClick()
{
InitControls(gridMain);
Query query = new Query();
query
query
QueryAndBind(new PeopleManager()
}
至此
QueryPeopleForm : QueryFormBase
void Initialize()
{
// 指定頁面對應的Manager
Manager = new PeopleManager();
// 綁定控件
InitControls(gridMain
}
void GetQueryInfo(Query query)
{
//獲得查詢條件
query
query
}
QueryFormBase:
private IManager manager = null;
public IManager Manager
{
get { return manager; }
set { manager = value; }
}
void InitControls(GridView grid
{
this
this
queryButton
}
void QueryButton_Click(object sender
{
Query query = new Query();
GetQueryInfo(Query);
QueryAndBind(manager
}
總的代碼可以從附件中下載
應該說基類的設計相對復雜
而基類頁的設計其實是有技巧的
從設計上來講
[
From:http://tw.wingwit.com/Article/program/net/201311/15133.html