起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 1066|回复: 0

如何控制,当某个字段等于特定值得时候不可以删除?

[复制链接]
发表于 2005-8-16 10:08:57 | 显示全部楼层 |阅读模式
unit YWXX2;

interface

uses
  Business.System, Business.Model, Business.Data, Business.Forms;

type
  TYWXX2 = class(TInfo)
    DataSetBZSJJ1: TSQLDataSet;
    procedure DataSetBZSJJ1BeforeDelete(DataSet: TDataSet);
  private
    {private declarations}
    procedure DoDeleteError(DataSet: TAbstractDataSet; E: EDatabaseError;
      var Action: TDataAction);
  public
    {public declarations}
  end;

implementation


procedure TYWXX2.DataSetBZSJJ1BeforeDelete(DataSet: TDataSet);
begin
  if not DataSet.Fields[0].IsNull then
  begin
    DataSet.ReadOnly := True;
    DataSet.OnDeleteError := DoDeleteError;
  end;
end;

procedure TYWXX2.DoDeleteError(DataSet: TAbstractDataSet; E: EDatabaseError;
    var Action: TDataAction);
begin
  (DataSet as TDataSet).ReadOnly := False;
  E.Message := '不能删除';
end;

end.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2024-12-22 19:15 , Processed in 0.041493 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表