扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
class FormBase class BizFormBase :FormBase class ViewFormBase : BizFormBase class EditFormBase : BizFormBase class QueryFormBase : FormBase |
QueryPeopleForm OnQueryButtonClick() { string peopleName = txtPeopleName.Text; string peopleAge = txtPeopleAge.Text; string sql; sql = string.Format(“Name Like‘%{0}%’and Age = {1}, PeopleName, peopleAge); PeopleManager manager = new PeopleManager(); this.gridMain.DataSource = manager.GetDataTable(sql); this.gridMain.DataBind(); } |
QueryPeopleForm : QueryFormBase OnQueryButtonClick() { string peopleName = txtPeopleName.Text; string peopleAge = txtPeopleAge.Text; sql = string.Format(“Name Like‘%{0}%’and Age = {1}, PeopleName, peopleAge); QueryAndBind(new PeopleManager(), sql); } |
public enum QueryOperator { //等于比较。 Equal = 0, // 不等于 NotEqual = 1, // Like比较 Like = 6 } class Query { void Add(string fieldName, string value, QueryOperator oper); string GetSql(); } QueryPeopleForm : QueryFormBase OnQueryButtonClick() { Query query = new Query(); query.Add(“Name”, txtPeopleName.Text, QueryOperator.Like); query.Add(“Age”, txtPeopleAge.Text, QueryOperator.Equal); QueryAndBind(new PeopleManager(), query.GetSql()); } |
QueryPeopleForm : QueryFormBase OnQueryButtonClick() { InitControls(gridMain); Query query = new Query(); query.Add(“Name”, txtPeopleName.Text, QueryOperator.Like); query.Add(“Age”, txtPeopleAge.Text, QueryOperator.Equal); QueryAndBind(new PeopleManager(), query.GetSql()); } |
QueryPeopleForm : QueryFormBase void Initialize() { // 指定页面对应的Manager Manager = new PeopleManager(); // 绑定控件 InitControls(gridMain, btnQuery); } void GetQueryInfo(Query query) { //获得查询条件 query.Add(“Name”, txtPeopleName.Text, QueryOperator.Like); query.Add(“Age”, txtPeopleAge.Text, QueryOperator.Equal); } QueryFormBase: private IManager manager = null; public IManager Manager { get { return manager; } set { manager = value; } } void InitControls(GridView grid, Button queryButton) { this.defaultGrid = grid; this.queryButton = queryButton; queryButton.Click += new EventHandler(QueryButton_Click); } void QueryButton_Click(object sender, EventArgs e) { Query query = new Query(); GetQueryInfo(Query); QueryAndBind(manager, query.GetSql()); } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者