我有一个搜索屏幕,列出了所有客户。用户可以编辑几个字段(电话号码,地址等)。
在保存该“特定”记录(仅限已更改的记录)时,我想更新ModifiedBy
和ModifiedOn
字段。我怎么能在代码中这样做?
我正在尝试在搜索屏幕的_Saving
事件中处理此问题,但如何获取更改的行?
答案 0 :(得分:2)
进入表格的实体设计器,然后单击“编写代码”旁边的箭头。您需要修改两种方法_Updating
和_Inserting
。与此类似:
<强> C#:强>
partial void TableName_Updating(TableName entity)
{
entity.ModifiedBy = this.Application.User.FullName;
entity.ModifiedOn = DateTime.Now;
}
partial void TableName_Inserting(TableName entity)
{
entity.ModifiedBy = this.Application.User.FullName;
entity.ModifiedOn = DateTime.Now;
}
<强> VB.NET:强>
Private Partial Sub TableName_Updating(entity As TableName)
entity.ModifiedBy = Me.Application.User.FullName
entity.ModifiedOn = DateTime.Now
End Sub
Private Partial Sub TableName_Inserting(entity As TableName)
entity.ModifiedBy = Me.Application.User.FullName
entity.ModifiedOn = DateTime.Now
End Sub