| destructor Destroy; override;//析构函数
function Execute : Boolean;//执行查询
procedure ReBuildSQL;//重建SQL语句
property ModifiedSQL : TStrings read FModifiedSQL;
published
{ Published declarations }
property Caption : String read FCaption write SetCaption;//设置标题
property DataSet : TQuery read FDataSet write SetDataSet;//设置数据集
property DefaultMatchType : TDBFilterMatchType read FDefaultMatchType write SetDefaultMatchType
default fdMatchStart;//过滤类型
property Options : TDBOptions read FOptions write SetOptions default
[fdShowCaseSensitive, fdShowNonMatching];//过滤选项
property Fields : TStringList read FFields write SetFieldsList;
end;
定义参数数据变量类
TDBVariable = class //参数数据变量
public
VariableName : String; //变量名
VariableValue : Variant; //变量值
constructor Create(name : String; value : Variant); //构造函数,设置变量名及变量值
end;
构造函数,设置变量名及变量值
constructor TDBVariable.Create(name: String; value : Variant);
begin
//构造函数,设置变量名及变量值
VariableName := name;
VariableValue := value;
end;
常量定义
const
Identifiers = [''''a''''..''''z'''', ''''A''''..''''Z'''', ''''0''''..''''9'''', ''''_'''', ''''#'''', ''''$'''', ''''.'''', ''''"'''', ''''@''''];
procedure Register;//注册组件
注册组件
procedure Register;
//注册组件
begin
RegisterComponents(''''我的数据库组件'''', [TDBFilterDialog]);
end; {of Register}
过滤类型
//过滤的匹配类型:完全匹配、起始处匹配、结束处匹配、任意位置匹配、范围匹配、不匹配
TDBFilterMatchType = (fdMatchExact, fdMatchStart, fdMatchEnd,
fdMatchAny, fdMatchRange, fdMatchNone);
过滤选项
//过滤选项:大小写敏感 显示大小写敏感 显示不匹配记录
TDBOption = (fdCaseSensitive, fdShowCaseSensitive, fdShowNonMatching);
TDBOptions = Set of TDBOption;
设置数据集
procedure TDBFilterDialog.SetDataSet(const Value: TQuery);
begin
//设置数据集
if not ((Value is TQuery) or (Value = nil)) then//如果未指定数据集或指定的数据集不是Tquery,则发出异常
Raise Exception.Create(SDBFilterNonDBError);
//否则
FDataSet := Value;
SQLProp := ''''SQL'''';
if ([csDesigning, csLoading] * ComponentState) = [] then
begin
SetFields;//设置字段
OriginalSQL := TStrings(GetOrdProp(FDataSet, SQLProp));//
end;
end;
设置选项
procedure TDBFilterDialog.SetOptions(const Value: TDBOptions);
begin
//设置选项
FOptions := Value;
end;
设置标题
procedure TDBFilterDialog.SetCaption(const Value: String);
begin
//设置标题
FCaption := Value;
FDialog.Caption := FCaption;
end;
(未完待续)
上一页 [1] [2] |