procedure TDeptForm.ApplyButtonClick(Sender: TObject);
begin
// Apply the changes and do not yet commit
Session.ApplyUpdates([DeptDataSet], False);
// Perform some checks and commit or rollback accordingly
if DeptEmpValid then
Session.CommitUpdates([DeptDataSet])
else
Session.Rollback;
end;