设置默认的匹配类型
procedure TDBFilterDialog.SetDefaultMatchType(const Value: TDBFilterMatchType);
begin
//设置默认的匹配类型
FDefaultMatchType := Value;
if Assigned(FDialog) and not (csDesigning in ComponentState) then
case FDefaultMatchType of
fdMatchNone :
begin
FDialog.grpSearchType.ItemIndex := 0;
FDialog.cbxNonMatching.Checked := true;
end;
fdMatchRange:
FDialog.pgeCriteria.ActivePage := FDialog.tabByRange;
else
FDialog.grpSearchType.ItemIndex := Integer(FDefaultMatchType);
end;
end;
设置字段
procedure TDBFilterDialog.SetFields;
var
i, j, p : Integer;
field, display : String;
begin
//设置字段
FDialog.lstAllFields.Clear;//清除所有字段
if FFields.Count = 0 then
begin
for i := 0 to FDataSet.FieldList.Count - 1 do
if FDataSet.Fields[i].Visible then //定义查询字段
FDialog.lstAllFields.Items.AddObject(FDataSet.Fields[i].DisplayName,FDataSet.FieldList.Fields[i]);
end
else
for j := 0 to FFields.Count - 1 do
begin
p := Pos(';', FFields.Strings[j]);
field := Copy(FFields.Strings[j], 1, p - 1);
if p = Length(FFields.Strings[j]) then
display := field
else
display := Copy(FFields.Strings[j], p 1, Length(FFields.Strings[j]));
for i := 0 to FDataSet.FieldList.Count - 1 do
if FDataSet.FieldList.Fields[i].FieldName = field then
FDialog.lstAllFields.Items.AddObject(display, FDataSet.FieldList.Fields[i]);
end;
if FDialog.lstAllFields.Items.Count > 0 then
begin
FDialog.lstAllFields.ItemIndex := 0;
FDialog.FieldsListBoxClick(nil);//单击字段列表框
end;
end;
设置字段列表
procedure TDBFilterDialog.SetFieldsList(const Value: TStringList);
begin
//设置字段列表
FFields.Assign(Value);
end;
设置SQL
procedure TDBFilterDialog.SetOriginalSQL(const Value: TStrings);
var
i : Integer;
begin
//设置SQL语句
if FOriginalSQL.Text <> Value.Text then
begin
FOriginalSQL.Clear;
FOriginalSQL.AddStrings(Value);
if not (csLoading in ComponentState) then
FFields.Clear;
FDialog.NewSQL;//新建SQL查询
end;
for i := 0 to FOriginalVariables.Count - 1 do
TDBVariable(FOriginalVariables[i]).Free;//定义参数数据变量类
FOriginalVariables.Clear;
if TStrings(GetOrdProp(FDataSet, SQLProp)).Text = '' then
exit;
for i := 0 to TQuery(FDataSet).Params.Count - 1 do
FOriginalVariables.Add(TDBVariable.Create(TQuery(FDataSet).Params[i].Name, TQuery(FDataSet).Params[i].Value)); //定义参数数据变量类
SetFields;//设置字段
end;
恢复SQL
procedure TDBFilterDialog.RestoreSQL;
var
i : Integer;
begin
//恢复SQL语句
// Disable the controls while we are working
FDataSet.DisableControls;
FDataSet.Close;
// clear the existing SQL and variable declarations
// restore the original SQL and variables
SetOrdProp(FDataSet, SQLProp, Integer(FOriginalSQL));
if FDataSet is TDataSet then
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!



