CodeCharge Studio | All ASP PHP Perl ColdFusion Java C#.NET VB.NET |
This example shows how to change the value of a control before the Insert and Update operation. In this case, we have a Record form called Tasks which has two hidden fields called LastUpdateDate and LastUpdateUserid. This fields will store the current date and ID of the user who performs the operation.
Function LastUpdateInfo() Tasks.LastUpdateDate.Value = Now() Tasks.LastUpdateUserid.Value = CCGetUserID() End function Function Tasks_BeforeInsert() LastUpdateInfo() End Function Function Tasks_BeforeUpdate() LastUpdateInfo() End Function
function LastUpdateInfo(){ global $Tasks; $Tasks->LastUpdateDate->SetValue(date("m.d.y")); $Tasks->LastUpdateUserid->SetValue(CCGetUserID()); } function Tasks_BeforeInsert() { LastUpdateInfo(); } function Tasks_BeforeUpdate() { LastUpdateInfo(); }
sub LastUpdateInfo(){ $Tasks->{LastUpdateDate}->SetValue(time()); $Tasks->{LastUpdateUserid}->SetValue(CCGetUserID()); } sub Tasks_BeforeInsert() { LastUpdateInfo(); } sub Tasks_BeforeUpdate() { LastUpdateInfo(); }
<!---Tasks_BeforeInsert ---> <CFSET fldLastUpdateDate=Now()> <CFSET fldLastUpdateUserid=Session.UserID>
<!---Tasks_BeforeUpdate ---> <CFSET fldLastUpdateDate=Now()> <CFSET fldLastUpdateUserid=Session.UserID>
class LUI { public void lastUpdateInfo(Page page) { page.getRecord("Tasks").getControl("LastUpdateDate").setValue(new Date()); page.getRecord("Tasks").getControl("LastUpdateUserid").setValue(Utils.getUserId(page)); } }
//Tasks_BeforeInsert new LUI().lastUpdateInfo(e.getPage());
//Tasks_BeforeUpdate new LUI().lastUpdateInfo(e.getPage());
Function LastUpdateInfo() TasksLastUpdateDate.Text = DateTime.Now.ToString() TasksLastUpdateUserid.Value = DBUtility.UserId.ToString() End function
'Tasks_BeforeInsert code LastUpdateInfo()
'Tasks_BeforeUpdate code LastUpdateInfo()
void LastUpdateInfo() { TasksLastUpdateDate.Text = DateTime.Now.ToString(); TasksLastUpdateUserid.Value = DBUtility.UserId.ToString(); }
\\Tasks_BeforeInsert code LastUpdateInfo();
\\Tasks_BeforeUpdate code LastUpdateInfo();