Created
March 30, 2015 11:40
-
-
Save anonymous/9dc334b3215f17e3b3e7 to your computer and use it in GitHub Desktop.
Buscar alquiler Tutorial videoclub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit ubuscaralquiler; | |
interface | |
uses | |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | |
Dialogs, StdCtrls, DBCtrls, Grids, DBGrids, ExtCtrls, Buttons, DB, | |
IBCustomDataSet, IBQuery; | |
type | |
TFBuscarAlquiler = class(TForm) | |
DataSource1: TDataSource; | |
IBQAlquileres: TIBQuery; | |
Panel1: TPanel; | |
Panel2: TPanel; | |
Panel3: TPanel; | |
SBSalir: TSpeedButton; | |
sbbuscar: TSpeedButton; | |
sblimpiar: TSpeedButton; | |
RGBus: TRadioGroup; | |
Panel5: TPanel; | |
Label1: TLabel; | |
Edit1: TEdit; | |
CheckBox1: TCheckBox; | |
DBGrid1: TDBGrid; | |
DBText1: TDBText; | |
DBText2: TDBText; | |
DBNavigator1: TDBNavigator; | |
Panel4: TPanel; | |
Panel6: TPanel; | |
Label2: TLabel; | |
Edit2: TEdit; | |
DBGrid2: TDBGrid; | |
SBLIMPIARCLIENTE: TSpeedButton; | |
SbPAsar: TSpeedButton; | |
DBText3: TDBText; | |
DsUnidades: TDataSource; | |
DsClientes: TDataSource; | |
Cliente: TLabel; | |
Label3: TLabel; | |
DSBuscliente: TDataSource; | |
IbqUnidades: TIBQuery; | |
IBQclientes: TIBQuery; | |
IBQBuscliente: TIBQuery; | |
DBImage1: TDBImage; | |
procedure SBSalirClick(Sender: TObject); | |
procedure sblimpiarClick(Sender: TObject); | |
procedure sbbuscarClick(Sender: TObject); | |
procedure SBLIMPIARCLIENTEClick(Sender: TObject); | |
procedure SbPAsarClick(Sender: TObject); | |
procedure RGBusClick(Sender: TObject); | |
procedure comprobar; | |
procedure DataSource1DataChange(Sender: TObject; Field: TField); | |
procedure FormActivate(Sender: TObject); | |
procedure Edit2Change(Sender: TObject); | |
private | |
{ Private declarations } | |
public | |
{ Public declarations } | |
end; | |
var | |
FBuscarAlquiler: TFBuscarAlquiler; | |
implementation | |
{$R *.dfm} | |
uses UDM, Funciones; | |
procedure TFBuscarAlquiler.comprobar; | |
//------------------------------------------------------------------------------ | |
//************************************************************[ comprobar ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
if FBuscarAlquiler.Active then | |
begin | |
if not IBQAlquileres.IsEmpty then | |
begin | |
ActQuery(IBQclientes,'Select * from CLIENTES WHERE CLIENTES.CODIGO = '+QuotedStr(IBQAlquileres.FieldByName('CLIENTE').Value)); | |
ActQuery(IbqUnidades,'Select * from UNIDADES WHERE UNIDADES.CODIGO = '+QuotedStr(IBQAlquileres.FieldByName('UNIDAD').Value)); | |
end else | |
begin | |
IBQclientes.Active:=False; | |
IbqUnidades.Active:=False; | |
end; | |
end; | |
end; | |
procedure TFBuscarAlquiler.DataSource1DataChange(Sender: TObject; | |
Field: TField); | |
//------------------------------------------------------------------------------ | |
//************************************************************[ Comprobar ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
comprobar; | |
end; | |
procedure TFBuscarAlquiler.Edit2Change(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*************************************************************[ Onchange ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
ActQuery(IBQBuscliente, 'Select * Form CLIENTES WHERE CLIENTES.NOMBRE LIKE '+QuotedStr('%'+Edit2.Text+'%')); | |
end; | |
procedure TFBuscarAlquiler.FormActivate(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//*************************************************************[ OnActive ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
comprobar; | |
case RGBus.ItemIndex of | |
0:begin | |
Panel1.Enabled=True; | |
Label1.Caption:='Código de sliente'; | |
end; | |
1:begin | |
Panel1.Enabled:=False; | |
Label1.Caption:='Número de alquiler'; | |
end; | |
end; | |
end; | |
procedure TFBuscarAlquiler.RGBusClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**************************************************************[ OnClick ]***** | |
// Si cambiamos el modo de búsqueda | |
//------------------------------------------------------------------------------ | |
begin | |
case RGBus.ItemIndex of | |
0:begin | |
Panel1.Enabled=True; | |
Label1.Caption:='Código de sliente'; | |
end; | |
1:begin | |
Panel1.Enabled:=False; | |
Label1.Caption:='Número de alquiler'; | |
end; | |
end; | |
end; | |
procedure TFBuscarAlquiler.sbbuscarClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//***********************************************************[ buscar por ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
case RGBus.ItemIndex of | |
0:begin | |
if CheckBox1.Checked then ActQuery(IBQAlquileres,'select * from ALQUILER WHERE (ALQUILER.DIA_DEVOLUCION IS NULL) AND (ALQUILER.CLIENTE LIKE '+QuotedStr('%'+Edit1.Text+'%')+')') | |
else ActQuery(IBQAlquileres,'select * from ALQUILER WHERE ALQUILER.CLIENTE LIKE '+QuotedStr('%'+Edit1.Text+'%')); | |
end; | |
1:begin | |
if CheckBox1.Checked then ActQuery(IBQAlquileres,'select * from ALQUILER WHERE (ALQUILER.DIA_DEVOLUCION IS NULL) AND (ALQUILER.REGISTRO LIKE '+QuotedStr('%'+Edit1.Text+'%')+')') | |
else ActQuery(IBQAlquileres,'select * from ALQUILER WHERE ALQUILER.REGISTRO LIKE '+QuotedStr('%'+Edit1.Text+'%')); | |
end; | |
end; | |
comprobar; | |
end; | |
procedure TFBuscarAlquiler.sblimpiarClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**************************************************************[ Limpiar ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
Edit1.Text:=''; | |
sbbuscarClick(Sender); | |
end; | |
procedure TFBuscarAlquiler.SBLIMPIARCLIENTEClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//******************************************************[ Limpiar cliente ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
Edit2.Text:=''; | |
Edit2.SetFocus; | |
end; | |
procedure TFBuscarAlquiler.SbPAsarClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//****************************************************************[ pasar ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
if not IBQBuscliente.IsEmpty then | |
begin | |
edit1.Text:=IBQBuscliente.FieldByName('CODIGO').Value; | |
sbbuscarClick(Sender); | |
end; | |
end; | |
procedure TFBuscarAlquiler.SBSalirClick(Sender: TObject); | |
//------------------------------------------------------------------------------ | |
//**************************************************************[ SBSalir ]***** | |
//------------------------------------------------------------------------------ | |
begin | |
varSBusqueda:=IntToStr(DataSource1.DataSet.FieldByName('ID').Value); | |
IBQUnidades.Active:=False; | |
IBQBuscliente.Active:=False; | |
IBQclientes.Active:=False; | |
IBQAlquileres.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