{ =============================================================================== Copyright (©) 2001. Rodax Software. =============================================================================== Los contenidos de este fichero son propiedad de Rodax Software titular del copyright. Este fichero sólo podrá ser copiado, distribuido y utilizado, en su totalidad o en parte, con el permiso escrito de Rodax Software, o de acuerdo con los términos y condiciones establecidas en el acuerdo/contrato bajo el que se suministra. ----------------------------------------------------------------------------- Web: www.rodax-software.com =============================================================================== Fecha primera versión: 01-10-2001 Versión actual: 1.0.0 Fecha versión actual: 01-10-2001 =============================================================================== Modificaciones: Fecha Comentarios --------------------------------------------------------------------------- =============================================================================== } unit BuscarCliente; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, RdxFrameClientes, RdxBotones, ExtCtrls, StdCtrls, RdxCampos, RdxTitulos, RdxPaneles, RdxBarras, RdxFrame; type TfrBuscarCliente = class(TRdxFrameClientes) RdxCabecera1: TRdxCabecera; Codigo: TRdxEdit; Label1: TLabel; Label2: TLabel; NIFCIF: TRdxEdit; Label8: TLabel; Nombre: TRdxEdit; RdxBarraInferior1: TRdxBarraInferior; bBuscar: TRdxBoton; bCerrar: TRdxBoton; procedure bCerrarClick(Sender: TObject); procedure bBuscarClick(Sender: TObject); private procedure RecogerDatos; protected procedure BuscarCliente; override; function CloseFrame : boolean; override; public constructor Create (AOwner : TComponent); override; end; var frBuscarCliente: TfrBuscarCliente; implementation {$R *.DFM} uses Tipos, DB, Mensajes, StrFunc, Configuracion, Literales; var Campos : String; Valores : Variant; Contador : Integer; constructor TfrBuscarCliente.Create (AOwner : TComponent); begin if not (AOwner is TRdxFrameClientes) then exit; inherited Create(AOwner); Entidad := entCliente; ConfigurarFrame(Self, Self.Entidad); Contador := -1; Campos := ''; Valores := VarArrayOf([null, null, null]); TablaClientes := (AOwner as TRdxFrameClientes).TablaClientes; with TablaClientes do begin Codigo.MaxLength := FieldByName('CODIGO').Size; NIFCIF.MaxLength := FieldByName('NIFCIF').Size; Nombre.MaxLength := FieldByName('NOMBRE').Size; end; end; procedure TfrBuscarCliente.bCerrarClick(Sender: TObject); begin inherited; CloseFrame; end; procedure TfrBuscarCliente.BuscarCliente; var Respuesta : integer; Resultado : Boolean; begin if Contador <> -1 then begin TablaClientes.DisableControls; if Contador = 0 then Resultado := TablaClientes.LocateNext(Campos, Valores[Contador], [loCaseInsensitive, loPartialKey]) else Resultado := TablaClientes.LocateNext(Campos, Valores, [loCaseInsensitive, loPartialKey]); if (Resultado = false) then begin Respuesta := VerMensajePregunta(msgIrInicio); case Respuesta of IDYES: TablaClientes.First; end; end; TablaClientes.EnableControls; end; end; procedure TfrBuscarCliente.RecogerDatos; begin Campos := ''; Contador := -1; if not EsCadenaVacia(Codigo.Text) then begin Contador := Contador + 1; Campos := Campos + 'CODIGO'; Valores[Contador] := Trim(Codigo.Text); end; if not EsCadenaVacia(NIFCIF.Text) then begin Contador := Contador + 1; if Contador > 0 then Campos := Campos + ';'; Campos := Campos + 'NIFCIF'; Valores[Contador] := Trim(NIFCIF.Text); end; if not EsCadenaVacia(Nombre.Text) then begin Contador := Contador + 1; if Contador > 0 then Campos := Campos + ';'; Campos := Campos + 'NOMBRE'; Valores[Contador] := Trim(Nombre.Text); end; end; procedure TfrBuscarCliente.bBuscarClick(Sender: TObject); begin RecogerDatos; if Contador <> -1 then BuscarCliente else VerMensaje(msgNoParametros); end; function TfrBuscarCliente.CloseFrame: boolean; begin FCodigoCliente := TablaClientes.FieldByName('CODIGO').AsString; Result := inherited CloseFrame; end; end.