在beforePost中写事件
procedure TOperateF.SelQBeforePost(DataSet: TDataSet);
begin
with ExQ do
begin
Close;
Parameters.ParamByName('p_1').Value := Dataset.fieldbyname('Code').Value;
Open;
if (FieldByName('aa').Value > 0) and (DataSet.State in [dsInsert]) then
begin
MessageBox(self.Handle, '该编号已存在!', '编号', MB_ICONWarning + mb_OK);
DataSet.Cancel;
Abort; //关键处
end
else
begin
if DataSet.FieldByName('pwd').OldValue <> DataSet.fieldbyname('pwd').NewValue then
Dataset.FieldByName('pwd').Value :=
Encrypt(DataSet.fieldbyname('pwd').AsString, '0811');
DataSet.FieldByName('onLine').Value := 0;
end;
end;