Instantly share code, notes, and snippets.

anonymous /buscarclientes
Created Mar 28, 2015

Embed
What would you like to do?
Buscar clientes Tutorial videoclub
unit Ubuscarclientes;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, IBCustomDataSet, IBQuery, StdCtrls, Buttons, ExtCtrls, Grids,
DBGrids, DBCtrls;
type
TFBuscarCliente = class(TForm)
Panel1: TPanel;
DBGrid1: TDBGrid;
RGBus: TRadioGroup;
SBSalir: TSpeedButton;
sbbuscar: TSpeedButton;
sblimpiar: TSpeedButton;
Panel2: TPanel;
Label1: TLabel;
Edit1: TEdit;
DataSource1: TDataSource;
IBQCLIENTEs: TIBQuery;
Panel3: TPanel;
DBNavigator1: TDBNavigator;
DBImage1: TDBImage;
DBText1: TDBText;
Memo1: TMemo;
Label2: TLabel;
procedure SBSalirClick(Sender: TObject);
procedure sblimpiarClick(Sender: TObject);
procedure sbbuscarClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure RGBusClick(Sender: TObject);
procedure DataSource1DataChange(Sender: TObject; Field: TField);
procedure comprobar;
private
{ Private declarations }
public
{ Public declarations }
end;
var
FBuscarCliente: TFBuscarCliente;
implementation
{$R *.dfm}
USes UDM,Funciones;
procedure TFBuscarCliente.comprobar;
//------------------------------------------------------------------------------
//************************************************************[ comprobar ]*****
//------------------------------------------------------------------------------
begin
if FBuscarCliente.Active then
begin
if not (DataSource1.DataSet.State in [dsEdit,dsInsert]) then
begin
if not ((DM.IBDClientes.IsEmpty) or (IBQCLIENTEs.Active=false ))then
begin
if DataSource1.DataSet.FieldByName('NOTAS').Value<>'' then Memo1.Lines.Text:=DataSource1.DataSet.FieldByName('NOTAS').AsString
else Memo1.Lines.Clear;
end;
end;
end;
end;
procedure TFBuscarCliente.DataSource1DataChange(Sender: TObject; Field: TField);
//------------------------------------------------------------------------------
//******************************************************[ Cambia de datos ]*****
//------------------------------------------------------------------------------
begin
comprobar;
end;
procedure TFBuscarCliente.FormActivate(Sender: TObject);
//------------------------------------------------------------------------------
//*************************************************************[ OnActive ]*****
//------------------------------------------------------------------------------
begin
Comprobar;
case RGBus.ItemIndex of
0:Label1.Caption:='Nombre';
1:Label1.Caption:='Código';
end;
end;
procedure TFBuscarCliente.RGBusClick(Sender: TObject);
//------------------------------------------------------------------------------
//**************************************************************[ OnClick ]*****
// Si cambiamos el modo de búsqueda
//------------------------------------------------------------------------------
begin
case RGBus.ItemIndex of
0:Label1.Caption:='Nombre';
1:Label1.Caption:='Código';
end;
end;
procedure TFBuscarCliente.sbbuscarClick(Sender: TObject);
//------------------------------------------------------------------------------
//***********************************************************[ buscar por ]*****
//------------------------------------------------------------------------------
begin
case RGBus.ItemIndex of
0:ActQuery(IBQCLIENTEs,'select * from CLIENTES WHERE CLIENTES.NOMBRE LIKE '+QuotedStr('%'+Edit1.Text+'%'));
1:ActQuery(IBQCLIENTEs,'select * from CLIENTES WHERE CLIENTES.CODIGO LIKE '+QuotedStr('%'+Edit1.Text+'%'));
end;
end;
procedure TFBuscarCliente.sblimpiarClick(Sender: TObject);
begin
Edit1.Text:='';
sbbuscarClick(Sender);
end;
procedure TFBuscarCliente.SBSalirClick(Sender: TObject);
//------------------------------------------------------------------------------
//**************************************************************[ SBSalir ]*****
//------------------------------------------------------------------------------
begin
varSBusqueda:=IntToStr(DataSource1.DataSet.FieldByName('ID').Value);
IBQCLIENTEs.Active:=False;
Edit1.Text:='';
Close;
end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment