GENQ3.PAS
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:3k
- unit GenQ3;
- interface
- uses
- Windows, Messages, SysUtils,
- Classes, Graphics, Controls,
- Forms, Dialogs, Gen_Q,DBClient;
- type
- TGenQ3 = class(Tcomponent)
- private
- { Private declarations }
- FV_AppServName: TCustomRemoteServer; //设置连接的应用服务器名;
- FV_ProviderName: string; // 设置连接查询的表接口;
- FV_TableName: string; //设置查询的表名
- FV_fieldsstrings: Tstrings;
- procedure setfieldsstrings(value: Tstrings);
- function copyLelf(aStringsFrom: Tstrings; var aStringsTo: Tstrings): boolean;
- function copyRight(aStringsFrom: Tstrings; var aStringsTo: Tstrings): boolean;
- public
- V_filtervalue: string; //存储过滤条件
- constructor Create(AOwner: TComponent); override;
- destructor destroy; override;
- function execute: boolean;
- { Public declarations }
- published
- property v_AppServName: TCustomRemoteServer read FV_AppServName write FV_AppServName;
- property v_ProviderName: string read FV_ProviderName write FV_ProviderName;
- property v_TableName: string read FV_TableName write FV_TableName;
- property v_fieldsstrings: Tstrings read FV_fieldsstrings write setfieldsstrings;
- { Published declarations }
- end;
- procedure Register;
- implementation
- procedure Register;
- begin
- RegisterComponents('Unleash', [TGenQ3]);
- end;
- function TGenQ3.copyLelf(aStringsFrom: Tstrings; var aStringsTo: Tstrings): boolean;
- var
- i: integer;
- begin
- result := true;
- for i := 0 to aStringsFrom.Count - 1 do
- begin
- if pos(';', aStringsFrom[i]) <= 1 then
- begin
- result := false;
- exit;
- end;
- aStringsTo.Add(copy(aStringsFrom[i], 1, pos(';', aStringsFrom[i]) - 1));
- end;
- end;
- function TGenQ3.copyRight(aStringsFrom: TStrings; var aStringsTo: TStrings): Boolean;
- var
- i: integer;
- begin
- result := true;
- for i := 0 to aStringsFrom.Count - 1 do
- begin
- if length(aStringsFrom[i]) - pos(';', aStringsFrom[i]) <= 0 then
- begin
- result := false;
- exit;
- end;
- aStringsTo.add(copy(aStringsFrom[i], pos(';', aStringsFrom[i]) + 1, length(aStringsFrom[i]) - pos(';', aStringsFrom[i])));
- end;
- end;
- procedure TGenQ3.setfieldsstrings(value: Tstrings);
- begin
- if Assigned(value) then
- Fv_fieldsstrings.Assign(value);
- end;
- constructor TGenQ3.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- FV_fieldsstrings := Tstringlist.Create;
- end;
- destructor TGenQ3.Destroy;
- begin
- FV_fieldsstrings.Free;
- inherited Destroy;
- end;
- function TGenQ3.Execute: Boolean;
- var
- F_Query: TF_Query;
- begin
- result := false;
- F_Query := TF_Query.Create(application);
- F_Query.AppServName := Fv_AppServName;
- F_Query.ProviderName := FV_ProviderName;
- F_Query.TableName := FV_TableName;
- if copyLelf(FV_fieldsstrings, F_Query.fields) = false then
- begin
- showmessage('V_fieldsstrings属性设置有错');
- exit;
- end;
- if copyRight(FV_fieldsstrings, F_Query.fieldsAlias) = false then
- begin
- showmessage('V_fieldsstrings属性设置有错');
- exit;
- end;
- F_Query.Position := poScreenCenter;
- F_Query.AutoSize := true;
- try
- F_Query.ShowModal;
- result := F_Query.Conf ;
- V_filtervalue := F_Query.filtervalue;
- finally
- F_Query.Free;
- end;
- end;
- initialization
- registerclass(TF_Query);
- end.