unit uFormPesqFornecedores;

interface

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

type
  TfrmPesqFornecedores = class(TfrmModelodePesquisa)
    DSPesqFornecedores: TDataSource;
    CDSPesqFornecedores: TClientDataSet;
    DSPPesqFornecedores: TDataSetProvider;
    SDSPesqFornecedores: TSQLDataSet;
    CDSPesqFornecedoresID_FORNECEDOR: TIntegerField;
    CDSPesqFornecedoresFORNECEDOR: TStringField;
    CDSPesqFornecedoresFANTASIA: TStringField;
    CDSPesqFornecedoresCPFCNPJ: TStringField;
    procedure FormShow(Sender: TObject);
    procedure edtPesquisaChange(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmPesqFornecedores: TfrmPesqFornecedores;

implementation

uses uDM, uFuncoes;

{$R *.dfm}

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

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

procedure TfrmPesqFornecedores.FormShow(Sender: TObject);
begin
  inherited;
  CDSPesqFornecedores.Open;
end;

end.
