Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit LotePesquisa.Fornecedores;
- interface
- uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
- Vcl.Controls,Forms,Dialogs,DB,
- FireDAC.Stan.Intf, FireDAC.Stan.Option,
- FireDAC.Stan.Error,FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def, FireDAC.Stan.Pool,
- FireDAC.Stan.Async, FireDAC.Phys,FireDAC.Phys.FB, FireDAC.Phys.FBDef, FireDAC.VCLUI.Wait, FireDAC.Comp.Client;
- type ILotePesquisaFornecedor = Interface
- ['{09ED3C04-3CD8-418D-B2CD-C1E07DA04EFB}']
- Procedure AddConnection(aConnection: TFDconnection);
- Procedure Conect;
- Function ReturnTable: TFDquery;
- Procedure Pesquisa(aDescricaoForn,aCnpj: string);
- End;
- type TLotePesquisaFornecedor = Class(TInterfacedObject,ILotePesquisaFornecedor )
- private
- {Private declaration}
- var LoteFornTable: TFDquery;
- Function Asql: String;
- Procedure Pesquisa(aDescricaoForn,aCnpj: string);
- Var Connectionserver: TFDConnection;
- Procedure AddConnection(aConnection: TFDconnection);
- Procedure Conect;
- Function ReturnTable: TFDquery;
- protected
- {Protected declaration}
- public
- {Public declaration declaration}
- Function NewILotePesquisaFornecedor: ILotePesquisaFornecedor;
- constructor Create; (*Metodos do Constructor*)
- destructor Destroy; override;
- published
- {Protected declaration}
- end;
- {$IFDEF RTL230_UP}
- [ComponentPlatformsAttribute(pidWin32 or pidWin64)]
- {$ENDIF RTL230_UP}
- type TBeforeChabgeRecord = procedure of object;
- type TLotePesquisaForn = class(TComponent)
- private
- FConexao: TFDConnection;
- LoteForn: ILotePesquisaFornecedor;
- FBeforeChangeRecord: TBeforeChabgeRecord;
- procedure setConexao(const Value: TFDConnection);
- function GetTableFornecedor: TFDquery;
- function GetConnect: TObject;
- function GetBeforeChangeRecord: TNotifyEvent;
- procedure SetBeforeChangeRecord(const Value: TNotifyEvent);
- {Private declaration}
- protected
- {Protected declaration}
- public
- {Public declaration declaration}
- Procedure AfterConstruction; Override;
- Procedure BeforeDestruction; Override;
- constructor Create(AOwner: TComponent); override;
- Destructor Destroy; override;
- published
- {Protected declaration}
- property Conexao: TFDConnection read FConexao write setConexao;
- property TableFornecedor: TFDquery read GetTableFornecedor;
- property ConnecttoTable: TObject read GetConnect;
- Procedure Pesquisar(aDescrField,aCnpjField: string);
- property BeforeChangeRecord: TBeforeChabgeRecord read FBeforeChangeRecord write FBeforeChangeRecord;
- Procedure BeforeChangeRecordEvent();
- Procedure BeforeScroll(Dataset: TDataset);
- procedure register;
- end;
- implementation
- { TLotePesquisaForn }
- uses Lote.FrmPesquisaFornecedores;
- procedure TLotePesquisaForn.AfterConstruction;
- begin
- inherited AfterConstruction;
- end;
- procedure TLotePesquisaForn.BeforeChangeRecordEvent;
- begin
- if Assigned(FBeforeChangeRecord) then
- FBeforeChangeRecord();
- end;
- procedure TLotePesquisaForn.BeforeDestruction;
- begin
- inherited BeforeDestruction;
- FrmLotePesquisaFornecedor.Close;
- FrmLotePesquisaFornecedor.DisposeOf;
- end;
- procedure TLotePesquisaForn.BeforeScroll(Dataset: TDataset);
- begin
- BeforeChangeRecordEvent;
- end;
- constructor TLotePesquisaForn.Create(AOwner: TComponent);
- begin
- inherited create( AOwner );
- LoteForn:= TLotePesquisaFornecedor.Create;
- end;
- destructor TLotePesquisaForn.Destroy;
- begin
- inherited;
- end;
- function TLotePesquisaForn.GetBeforeChangeRecord: TNotifyEvent;
- begin
- end;
- function TLotePesquisaForn.GetConnect: TObject;
- begin
- LoteForn.Conect;
- FrmLotePesquisaFornecedor:= TFrmLotePesquisaFornecedor.create(Application);
- FrmLotePesquisaFornecedor.DsLoteForn.DataSet := LoteForn.ReturnTable;
- FrmLotePesquisaFornecedor.showModal;
- end;
- function TLotePesquisaForn.GetTableFornecedor: TFDquery;
- begin
- Result:= LoteForn.ReturnTable;
- Result.BeforeScroll:= Self.BeforeScroll;
- end;
- procedure TLotePesquisaForn.Pesquisar(aDescrField, aCnpjField: string);
- begin
- LoteForn.Pesquisa(aDescrField,aCnpjField);
- end;
- procedure TLotePesquisaForn.register;
- begin
- RegisterComponents('Leopard',[TLotePesquisaForn]);
- end;
- procedure TLotePesquisaForn.SetBeforeChangeRecord(const Value: TNotifyEvent);
- begin
- end;
- procedure TLotePesquisaForn.setConexao(const Value: TFDConnection);
- begin
- FConexao := Value;
- LoteForn.AddConnection(FConexao);
- end;
- { TLotePesquisaFornecedor }
- procedure TLotePesquisaFornecedor.AddConnection(aConnection: TFDconnection);
- begin
- self.Connectionserver:= aConnection;
- end;
- function TLotePesquisaFornecedor.Asql: String;
- begin
- Result:= ' select ID, DATA, HORA, USUARIO, NOMERAZAO, FANTASIAAPELIDO, CNPJ, IE, IM, SUFRAMA, LOGADOURO, NUMERO, COMPLEMENTO, '+
- ' BAIRRO, MUNICIPIO, ESTADO, UF, PAIS, CEP, TELEFONE, FAX, CELULAR, REPRESCOMERCIAL, EMAIL, WEBSITE, SIT, '+
- ' CATEGORIA, OBS, IBGE_CODUF, IBGE_CODMUNI, IBGE_CODPAIS, IBGE_PAISISO3, FUNDACAO '+
- ' from CAD_FORNECEDOR ';
- end;
- procedure TLotePesquisaFornecedor.Conect;
- begin
- LoteFornTable := TFDquery.Create(Nil);
- LoteFornTable.Connection := Connectionserver;
- LoteFornTable.SQL.Text := Asql;
- LoteFornTable.Open();
- end;
- constructor TLotePesquisaFornecedor.Create;
- begin
- end;
- destructor TLotePesquisaFornecedor.Destroy;
- begin
- inherited;
- end;
- function TLotePesquisaFornecedor.NewILotePesquisaFornecedor: ILotePesquisaFornecedor;
- begin
- Result:= TLotePesquisaFornecedor.Create;
- end;
- procedure TLotePesquisaFornecedor.Pesquisa(aDescricaoForn, aCnpj: string);
- begin
- LoteFornTable.Filtered:= False;
- LoteFornTable.Filter := 'Upper (NOMERAZAO) Like' + quotedStr(Ansiuppercase('%'+aDescricaoForn+'%'));
- LoteFornTable.Filtered:= True;
- end;
- function TLotePesquisaFornecedor.ReturnTable: TFDquery;
- begin
- Result:= LoteFornTable;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement