unit uFormPesqLotes;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uFormModelodePesquisa, StdCtrls, Buttons, Grids, DBGrids, daEdit,
  ExtCtrls, FMTBcd, DB, DBClient, Provider, SqlExpr;

type
  TfrmPesqLotes = class(TfrmModelodePesquisa)
    SDSPesqLotes: TSQLDataSet;
    DSPPesqLotes: TDataSetProvider;
    CDSPesqLotes: TClientDataSet;
    DSPesqLotes: TDataSource;
    CDSPesqLotesID: TIntegerField;
    CDSPesqLotesID_LOTE: TIntegerField;
    CDSPesqLotesDESCRICAO: TStringField;
    CDSPesqLotesFLAG: TSmallintField;
    procedure FormShow(Sender: TObject);
    procedure edtPesquisaChange(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmPesqLotes: TfrmPesqLotes;

implementation

uses uDM;

{$R *.dfm}

procedure TfrmPesqLotes.edtPesquisaChange(Sender: TObject);
begin
  inherited;
  if Length(edtPesquisa.Text) = 1 then

  if edtPesquisa.Text[1] in ['A'..'Z'] then
  begin
    CDSPesqLotes.IndexFieldNames := 'DESCRICAO';
  end
  ELSE
  IF edtPesquisa.Text[1] in ['0'..'9'] then
  begin
    CDSPesqLotes.IndexFieldNames := 'ID_LOTE';
  end;
  CDSPesqLotes.FindNearest([edtPesquisa.Text]);
end;

procedure TfrmPesqLotes.FormShow(Sender: TObject);
begin
  inherited;
  CDSPesqLotes.Open;
end;

end.
