unit UBuscarEmp;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, Vcl.StdCtrls, Vcl.Buttons,
  Vcl.Grids, Vcl.DBGrids, Data.Win.ADODB;

type
  TForm2 = class(TForm)
    txtBus: TEdit;
    Label1: TLabel;
    QBuscar: TADOQuery;
    DSBuscar: TDataSource;
    DBGrid1: TDBGrid;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure txtBusChange(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

uses Udm;


procedure TForm2.txtBusChange(Sender: TObject);
var
   sentencia: string;
begin
   sentencia:= 'SELECT IdEmpleado, trim([Nombres]) & " " & [Apaterno] &" " & [AMaterno] As NombreCom, Curp FROM Empleados ';
   sentencia := sentencia + ' Where (trim([Nombre]) & " " & [Apaterno] &" " & [AMaterno]) like ' + chr(39) + '%' + txtBus.Text +  '%' + chr(39);
  with QBuscar do
   begin
     active:= false;
     sql.Clear;
     sql.Add(sentencia);
     active:= true;
   end;

end;

end.
