unit uSearch3;

interface

uses
  System.SysUtils, System.Classes, FireDAC.Stan.Intf, FireDAC.Stan.Option,
  FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf,
  FireDAC.DApt.Intf, FireDAC.Stan.Async, FireDAC.DApt, Data.DB,
  FireDAC.Comp.DataSet, FireDAC.Comp.Client,uDBConnectionBPL,uSQLQueries,vcl.Dialogs;

type
  TDMSearch = class(TDataModule)
    qSearch: TFDQuery;
    DataSource: TDataSource;
    procedure DataModuleCreate(Sender: TObject);
    procedure DataModuleDestroy(Sender: TObject);
  private

    FDBConnection:TDBConnectionBPL;
    FSQLQueries:TSQLQueries;

    { Private declarations }

  public

  procedure Search(Name:string);
    { Public declarations }
  end;

var
  DMSearch: TDMSearch;

implementation

uses UTreeView;

{%CLASSGROUP 'Vcl.Controls.TControl'}

{$R *.dfm}

procedure TDMSearch.DataModuleCreate(Sender: TObject);



begin
FDBConnection:=TDBConnectionBPL.Create(Self);

//showmessage(FDBConnection.DBConnectionParams);

qSearch.Connection:=FDBConnection.FDConnection;



//TSQLQueries.Create(Self);

end;

procedure TDMSearch.DataModuleDestroy(Sender: TObject);
begin
FreeAndNil(FDBConnection);
FreeAndNil(FSQLQueries);
FreeAndNil(qSearch);

FSQLQueries:=nil;

end;

procedure TDMSearch.Search(Name: string);

begin

if FSQLQueries=nil then FSQLQueries:=TSQLQueries.Create(Self);


qSearch.SQL.Text:=FSQLQueries.Search.Text+'''%'+name+'%''';

//showmessage(FSQLQueries.Search.Text);

//'SELECT name FROM treeview_db.tree where Name like '+'''%'+name+'%''';
//

if qSearch.OpenOrExecute then qSearch.Close;

qSearch.Open();



end;

end.
