First commit 14/02/1999
This commit is contained in:
109
TDlgBuscar.cpp
Normal file
109
TDlgBuscar.cpp
Normal file
@ -0,0 +1,109 @@
|
||||
//---------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "TDlgBuscar.h"
|
||||
//---------------------------------------------------------------------
|
||||
#pragma link "Grids"
|
||||
#pragma resource "*.dfm"
|
||||
TDlgBuscar *DlgBuscar;
|
||||
//---------------------------------------------------------------------
|
||||
__fastcall TDlgBuscar::TDlgBuscar(TComponent* AOwner)
|
||||
: TForm(AOwner)
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
bool __fastcall TDlgBuscar::Buscar(int Tipo, TTable *Sender)
|
||||
{
|
||||
switch( Tipo )
|
||||
{
|
||||
case PRIOR:
|
||||
if ( TbBusquedas -> FindPrior() == true )
|
||||
{
|
||||
try{
|
||||
Sender -> GotoCurrent( TbBusquedas );
|
||||
}catch(...){/*nothing*/}
|
||||
return true;
|
||||
} else
|
||||
MessageBox( 0, "Coincidencia no hayada", "<EFBFBD> Buscar Anterior !", MB_OK );
|
||||
break;
|
||||
case NEW:
|
||||
ShowModal();
|
||||
if ( ModalResult == mrOk )
|
||||
{
|
||||
try{
|
||||
Sender -> GotoCurrent( TbBusquedas );
|
||||
}catch(...){/*nothing*/}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case NEXT:
|
||||
if ( TbBusquedas -> FindNext() == true )
|
||||
{
|
||||
try{
|
||||
Sender -> GotoCurrent( TbBusquedas );
|
||||
}catch(...){/*nothing*/}
|
||||
return true;
|
||||
} else
|
||||
MessageBox( 0, "Coincidencia no hayada", "<EFBFBD> Buscar Siguiente !", MB_OK );
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//---------------------------------------------------------------------
|
||||
void __fastcall TDlgBuscar::ComboBox1Change(TObject *Sender)
|
||||
{
|
||||
// Make the field we're locating in the leftmost field.
|
||||
TbBusquedas->FieldByName(ComboBox1->Text)->Index = 0;
|
||||
|
||||
TbBusquedas->IndexName = "";
|
||||
|
||||
|
||||
Edit1->SetFocus();
|
||||
Edit1->Text = "";
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TDlgBuscar::Edit1Change(TObject *Sender)
|
||||
{
|
||||
AnsiString BuscarEsto;
|
||||
BuscarEsto = Edit1->Text;
|
||||
|
||||
{ // Some non-indexed field.
|
||||
AnsiString BuscarCota;
|
||||
BuscarCota = BuscarEsto + "Z";
|
||||
|
||||
TbBusquedas->FilterOptions = TbBusquedas->FilterOptions << foCaseInsensitive;
|
||||
|
||||
TbBusquedas->Filter = "( ([" + ComboBox1->Text + "] >= '" + BuscarEsto + "') AND [" + ComboBox1->Text + "] < '" + BuscarCota + "')" + ( Filter.IsEmpty()?AnsiString(""):AnsiString(" AND " + Filter));
|
||||
TbBusquedas->Filtered = true;
|
||||
// else
|
||||
// TbBusquedas->Filtered = false;
|
||||
}
|
||||
|
||||
TbBusquedas->Refresh();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TDlgBuscar::DBGrid1DblClick(TObject *Sender)
|
||||
{
|
||||
ModalResult = mrOk;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TDlgBuscar::TbBusquedasAfterOpen(TDataSet *DataSet)
|
||||
{
|
||||
// Rellenamos el combo de "campos donde buscar", con TODOS los campos
|
||||
// de la base de datos...
|
||||
TbBusquedas -> GetFieldNames( ComboBox1 -> Items );
|
||||
|
||||
TbBusquedas->FilterOptions = TbBusquedas->FilterOptions << foCaseInsensitive;
|
||||
TbBusquedas->Filter = Filter;
|
||||
TbBusquedas->Filtered = true;
|
||||
|
||||
if ( !DefaultField.IsEmpty() )
|
||||
{
|
||||
TbBusquedas->FieldByName(DefaultField)->Index = 0;
|
||||
ComboBox1->ItemIndex = ComboBox1->Items->IndexOf( DefaultField );
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
Reference in New Issue
Block a user