BLL层_DataBinder对象以及_DataBinder.Rows[0].EndEdit方法详解
BLL层_DataBinder对象以及_DataBinder.Rows[0].EndEdit方法详解开发框架基础资料(单表资料)界面,在保存数据前会调用_DataBinder.Rows[0].EndEdit方法更新DataTable的缓存数据。
流程:用户点【保存】按钮 --> 调用BLL.Update方法 --> 调用_DataBinder.Rows[0].EndEdit方法。

_DataBinder对象
_DataBinder对象是个DataTable,用户点击【查看】或【编辑】按钮时创建的DataTable对象,里面只有一条记录,用于缓存当前编辑记录的临时数据。
DoBindingSummaryEditor方法
创建_DataBinder对象后,会调用DoBindingSummaryEditor方法绑定当前界面所有文本编辑框的数据源。
DoBindingEditorPanel方法
框架提供 DoBindingEditorPanel 方法,自动绑定编辑区域的数据源,编辑区域通常使用Panel组件容器。
绑定规则(文本编辑框命名规则):txt+字段名,或者chk+字段名。
统一命名后,打循环遍历当前Panel内所有txtXXX的组件,自动绑定数据源。
C# Code:
for (int i = 0; i <= editorPanel.Controls.Count - 1; i++)
{
if (editorPanel.Controls[i] is BaseEdit)
{
BaseEdit edit = editorPanel.Controls[i] as BaseEdit;
if (edit.Name.Substring(0, 3) == "txt")
{
fieldName = edit.Name.Substring(3, edit.Name.Length - 3);
DataBinder.BindingTextEditBase(edit, dataSource, fieldName);
}
}
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
{
if (editorPanel.Controls[i] is BaseEdit)
{
BaseEdit edit = editorPanel.Controls[i] as BaseEdit;
if (edit.Name.Substring(0, 3) == "txt")
{
fieldName = edit.Name.Substring(3, edit.Name.Length - 3);
DataBinder.BindingTextEditBase(edit, dataSource, fieldName);
}
}
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
详细解释:
数据编辑页面的文本编辑框数据源是绑定_DataBinder对象的,一个文本编辑框绑定一个字段的数据,用户录入资料后,会自动写入_DataBinder对象对应的字段里面。使用_DataBinder.Rows[0].EndEdit方法是告诉DataTable对象已修改完成,同时将当前焦点所在的文本编辑框的数据写入到DataTable对象。
参考:DataRow.EndEdit方法元数据:
C# Code:
//
// 摘要:
// Ends the edit occurring on the row.
//
// 异常:
// T:System.Data.InRowChangingEventException:
// The method was called inside the System.Data.DataTable.RowChanging event.
//
// T:System.Data.ConstraintException:
// The edit broke a constraint.
//
// T:System.Data.ReadOnlyException:
// The row belongs to the table and the edit tried to change the value of a read-only
// column.
//
// T:System.Data.NoNullAllowedException:
// The edit tried to put a null value into a column where System.Data.DataColumn.AllowDBNull
// is false.
[EditorBrowsable(EditorBrowsableState.Advanced)]
public void EndEdit();
//来源:C/S框架网 | www.csframework.com | QQ:23404761
// 摘要:
// Ends the edit occurring on the row.
//
// 异常:
// T:System.Data.InRowChangingEventException:
// The method was called inside the System.Data.DataTable.RowChanging event.
//
// T:System.Data.ConstraintException:
// The edit broke a constraint.
//
// T:System.Data.ReadOnlyException:
// The row belongs to the table and the edit tried to change the value of a read-only
// column.
//
// T:System.Data.NoNullAllowedException:
// The edit tried to put a null value into a column where System.Data.DataColumn.AllowDBNull
// is false.
[EditorBrowsable(EditorBrowsableState.Advanced)]
public void EndEdit();
//来源:C/S框架网 | www.csframework.com | QQ:23404761
参考文档:
bllBaseDataDict.CreateDataBinder方法详解及性能优化
数据字典窗体bllBaseDataDict类详解|开发教程
数据字典窗体BLL、DAL继承关系图|开发教程
CSFramework C#代码生成器生成窗体界面UI,BLL,DAL,Model,WCF接口层源代码
支持主从表BLL单独提交明细表优化UpdateDetailKey方法|C/S框架网
使用bllBaseDataDict类提交业务单据(主从表)的明细表实例|C/S框架网
数据字典BLL不依赖WCF连接策略实现三层架构的直连模式(ADO-Direct)
数据字典BLL.CreateDataBinder方法实现新增记录给主键赋值
bllBaseBusiness.cs优化DataBinder及DataBindRow属性
你的框架中是把WCF放在BLL和DAL之间?
ClassGenerator V2.01 生成的BLL源码
CS系统快速开发框架 - 生成BLL和DAL
C#.Net C/S结构开发框架中BLL层的作用
表单上实现增删改查,除了生成的BLL,DAL和ORM表,还需要处理什么?
C#.Net快速开发框架 - ORM ,BLL,DAL三者关系
WinFramework轻量级开发框架 | 主从表窗体开发指南|详细二次开发|C/S开发框架
bllBaseDataDict.CreateDataBinder方法详解及性能优化
数据字典窗体bllBaseDataDict类详解|开发教程
数据字典窗体BLL、DAL继承关系图|开发教程
CSFramework C#代码生成器生成窗体界面UI,BLL,DAL,Model,WCF接口层源代码
支持主从表BLL单独提交明细表优化UpdateDetailKey方法|C/S框架网
使用bllBaseDataDict类提交业务单据(主从表)的明细表实例|C/S框架网
数据字典BLL不依赖WCF连接策略实现三层架构的直连模式(ADO-Direct)
数据字典BLL.CreateDataBinder方法实现新增记录给主键赋值
bllBaseBusiness.cs优化DataBinder及DataBindRow属性
你的框架中是把WCF放在BLL和DAL之间?
ClassGenerator V2.01 生成的BLL源码
CS系统快速开发框架 - 生成BLL和DAL
C#.Net C/S结构开发框架中BLL层的作用
表单上实现增删改查,除了生成的BLL,DAL和ORM表,还需要处理什么?
C#.Net快速开发框架 - ORM ,BLL,DAL三者关系
WinFramework轻量级开发框架 | 主从表窗体开发指南|详细二次开发|C/S开发框架
其它资料:
什么是C/S结构? | C/S框架核心组成部分 | C/S框架-WebService部署图 | C/S框架-权限管理 | C/S结构系统框架 - 5.1旗舰版介绍 | C/S结构系统框架 - 功能介绍 | C/S结构系统框架 - 产品列表 | C/S结构系统框架 - 应用展示(图) | 三层体系架构详解 | C/S架构轻量级快速开发框架 | C/S框架网客户案例 | WebApi快速开发框架 | C/S框架代码生成器 | 用户授权注册软件系统 | 版本自动升级软件 | 数据库底层应用框架 | CSFramework.CMS内容管理系统 |
什么是C/S结构? | C/S框架核心组成部分 | C/S框架-WebService部署图 | C/S框架-权限管理 | C/S结构系统框架 - 5.1旗舰版介绍 | C/S结构系统框架 - 功能介绍 | C/S结构系统框架 - 产品列表 | C/S结构系统框架 - 应用展示(图) | 三层体系架构详解 | C/S架构轻量级快速开发框架 | C/S框架网客户案例 | WebApi快速开发框架 | C/S框架代码生成器 | 用户授权注册软件系统 | 版本自动升级软件 | 数据库底层应用框架 | CSFramework.CMS内容管理系统 |
在线客服
