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, JvExDBGrids, JvDBGrid;

type
  TFBuscarEmp = class(TForm)
    txtBus: TEdit;
    Label1: TLabel;
    QBuscar: TADOQuery;
    DSBuscar: TDataSource;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    JvDBGrid1: TJvDBGrid;
    procedure txtBusChange(Sender: TObject);
    procedure FormActivate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FBuscarEmp: TFBuscarEmp;

implementation

{$R *.dfm}

uses Udm;

procedure TFBuscarEmp.FormActivate(Sender: TObject);
begin
txtBus.SetFocus
end;

procedure TFBuscarEmp.txtBusChange(Sender: TObject);
var
   sentencia: string;
begin
   sentencia:= 'SELECT NumEmp, trim([Nombres]) & " " & [Apaterno] &" " & [AMaterno] As NombreCom, Curp, IdEmpleado FROM Empleados ';
   sentencia := sentencia + ' Where (NumEmp like ' + chr(39) + '%' + txtBus.Text +  '%' + chr(39) + ') or  ((trim([Nombres]) & " " & [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.
