First commit 27/10/2000
This commit is contained in:
953
Agenda.cpp
Normal file
953
Agenda.cpp
Normal file
@ -0,0 +1,953 @@
|
||||
//---------------------------------------------------------------------------
|
||||
#include <vcl.h>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "Agenda.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "DlgQueImprimir.h"
|
||||
|
||||
#define Digito(Num, Dig) ( (Num-( (Num/(int)pow10(Dig)) * (int)pow10(Dig) )) / ( Dig==1 ? 1 : (int)pow10(Dig-1) ) )
|
||||
|
||||
// Comprobamos que la CC sea correcta
|
||||
bool CorrectaCC( int Banco, int Oficina, int DC, AnsiString NumCuenta )
|
||||
{
|
||||
int Suma1, Suma2, R1, R2;
|
||||
bool dev;
|
||||
char *NumCC;
|
||||
|
||||
dev = false;
|
||||
if ( NumCuenta.Length() == 10 )
|
||||
{
|
||||
NumCC = NumCuenta.c_str();
|
||||
Suma1 = Digito(Oficina, 1)* 6 +
|
||||
Digito(Oficina, 2)* 3 +
|
||||
Digito(Oficina, 3)* 7 +
|
||||
Digito(Oficina, 4)* 9 +
|
||||
Digito(Banco, 1)*10 +
|
||||
Digito(Banco, 2)* 5 +
|
||||
Digito(Banco, 3)* 8 +
|
||||
Digito(Banco, 4)* 4 ;
|
||||
Suma2 = (NumCC[9]-'0')*6 +
|
||||
(NumCC[8]-'0')*3 +
|
||||
(NumCC[7]-'0')*7 +
|
||||
(NumCC[6]-'0')*9 +
|
||||
(NumCC[5]-'0')*10 +
|
||||
(NumCC[4]-'0')*5 +
|
||||
(NumCC[3]-'0')*8 +
|
||||
(NumCC[2]-'0')*4 +
|
||||
(NumCC[1]-'0')*2 +
|
||||
(NumCC[0]-'0')*1 ;
|
||||
|
||||
R1 = 11-(Suma1%11); if ( R1==11 ) R1 = 0; if ( R1==10 ) R1 = 1;
|
||||
R2 = 11-(Suma2%11); if ( R2==11 ) R2 = 0; if ( R2==10 ) R2 = 1;
|
||||
|
||||
if ( Digito(DC,2)== R1 && Digito(DC,1)== R2 )
|
||||
dev = true;
|
||||
}
|
||||
return dev;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
#pragma package(smart_init)
|
||||
#pragma link "ElastFrm"
|
||||
#pragma link "ElastFrm"
|
||||
#pragma resource "*.dfm"
|
||||
TListadoClientes *ListadoClientes;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall TListadoClientes::TListadoClientes(TComponent* Owner)
|
||||
: TForm(Owner)
|
||||
{
|
||||
DB_Path = "datos\\";
|
||||
|
||||
Session1->Active = true;
|
||||
// Cargamos el DB_Path...
|
||||
{
|
||||
FILE *iFileHandle;
|
||||
int iFileLength;
|
||||
|
||||
char pszBuffer[180];
|
||||
if ( (iFileHandle = fopen( "Path.cfg", "r" )) != NULL )
|
||||
{
|
||||
fgets( pszBuffer, 180, iFileHandle );
|
||||
DB_Path = pszBuffer;
|
||||
fclose( iFileHandle );
|
||||
try {
|
||||
Image1->Picture->LoadFromFile( "logo.bmp" );
|
||||
} catch(...) {
|
||||
Image1->Visible = false;
|
||||
}
|
||||
} else {
|
||||
ShowMessage( "TRABAJANDO EN MODO PRIVADO" );
|
||||
}
|
||||
}
|
||||
|
||||
InfoBar->SimpleText = "Inicializando programa..." ;
|
||||
|
||||
MinFecha->Date = TDateTime::CurrentDate();
|
||||
MaxFecha->Date = TDateTime::CurrentDate();
|
||||
|
||||
OnDataChanged = false;
|
||||
SelIndex->ItemIndex = 0;
|
||||
|
||||
if ( FileExists( DB_Path + "correos\\poblacion.db" ) )
|
||||
{
|
||||
DBcorreos = true;
|
||||
TbCorreos->ReadOnly = true;
|
||||
TbCorreos->TableType = ttParadox;
|
||||
TbCorreos->TableName = DB_Path + "correos\\poblacion.db";
|
||||
TbCorreos->Active = true;
|
||||
} else {
|
||||
DBcorreos = false;
|
||||
}
|
||||
|
||||
|
||||
TbCarpetas->TableName = DB_Path + "carpetas.DB";
|
||||
TbLlamadas->TableName = DB_Path + "llamadas.DB";
|
||||
TbListado->TableName = DB_Path + "personas.DB";
|
||||
TbNotas->TableName = DB_Path + "misnotas.DB";
|
||||
TbListado->Active = true;
|
||||
TbLlamadas->Active = true;
|
||||
TbCarpetas->Active = true;
|
||||
TbNotas->Active = true;
|
||||
|
||||
InfoBar->SimpleText = "www.infdj.com" ;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TListadoClientes::TbCarpetasBeforeOpen(TDataSet *DataSet)
|
||||
{
|
||||
if ( !FileExists( TbCarpetas->TableName ) )
|
||||
{
|
||||
InfoBar->SimpleText= "Creando carpetas..." ;
|
||||
TbCarpetas -> TableType = ttParadox;
|
||||
|
||||
TbCarpetas -> FieldDefs -> Clear();
|
||||
|
||||
/********************\
|
||||
|* Datos B<>sicos *|
|
||||
\********************/
|
||||
TbCarpetas -> FieldDefs -> Add("IDcarpeta", ftAutoInc, 0, false );
|
||||
TbCarpetas -> FieldDefs -> Add("carpeta", ftString, 15, false );
|
||||
|
||||
TbCarpetas -> IndexDefs-> Clear();
|
||||
|
||||
// Creamos la base...
|
||||
TbCarpetas -> CreateTable();
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::TbListadoBeforeOpen(TDataSet *DataSet)
|
||||
{
|
||||
if ( !FileExists( TbListado->TableName ) )
|
||||
{
|
||||
InfoBar->SimpleText= "Creando personas..." ;
|
||||
TbListado -> TableType = ttParadox;
|
||||
|
||||
TbListado -> FieldDefs -> Clear();
|
||||
|
||||
/********************\
|
||||
|* Datos B<>sicos *|
|
||||
\********************/
|
||||
TbListado -> FieldDefs -> Add("CodCliente1", ftAutoInc, 0, false );
|
||||
TbListado -> FieldDefs -> Add("CodCliente2", ftString, 15, false );
|
||||
|
||||
TbListado -> FieldDefs -> Add("FAlta", ftDateTime, 0, false );
|
||||
TbListado -> FieldDefs -> Add("FModif", ftDateTime, 0, false );
|
||||
|
||||
TbListado -> FieldDefs -> Add("Empresa", ftString, 30, false );
|
||||
TbListado -> FieldDefs -> Add("Actividad", ftString, 25, false );
|
||||
TbListado -> FieldDefs -> Add("Nombre", ftString, 15, false );
|
||||
TbListado -> FieldDefs -> Add("Apellidos", ftString, 30, false );
|
||||
TbListado -> FieldDefs -> Add("Dni Nif Pasaporte", ftSmallint, 0, false );
|
||||
TbListado -> FieldDefs -> Add("DocumentoDNP", ftString, 20, false );
|
||||
|
||||
TbListado -> FieldDefs -> Add("Telefono 1", ftString, 15, false );
|
||||
TbListado -> FieldDefs -> Add("Telefono 2", ftString, 15, false );
|
||||
TbListado -> FieldDefs -> Add("Telefono 3", ftString, 15, false );
|
||||
TbListado -> FieldDefs -> Add("Telefono 4", ftString, 15, false );
|
||||
TbListado -> FieldDefs -> Add("e-Mail", ftString, 30, false );
|
||||
TbListado -> FieldDefs -> Add("url", ftString, 50, false );
|
||||
TbListado -> FieldDefs -> Add("Calle", ftString, 25, false );
|
||||
TbListado -> FieldDefs -> Add("Calle2", ftString, 25, false );
|
||||
TbListado -> FieldDefs -> Add("Num", ftString, 4, false );
|
||||
TbListado -> FieldDefs -> Add("Piso", ftString, 2, false );
|
||||
TbListado -> FieldDefs -> Add("Letra", ftString, 2, false );
|
||||
TbListado -> FieldDefs -> Add("Poblaci<EFBFBD>n", ftString, 20, false );
|
||||
TbListado -> FieldDefs -> Add("Provincia", ftString, 15, false );
|
||||
TbListado -> FieldDefs -> Add("CP", ftInteger, 0, false );
|
||||
|
||||
TbListado -> FieldDefs -> Add("Deposito", ftCurrency, 0, false );
|
||||
TbListado -> FieldDefs -> Add("Credito", ftCurrency, 0, false );
|
||||
TbListado -> FieldDefs -> Add("TiempoH", ftInteger, 0, false );
|
||||
TbListado -> FieldDefs -> Add("TiempoM", ftInteger, 0, false );
|
||||
|
||||
/************************\
|
||||
|* Domiciliaci<63>n Bancaria *|
|
||||
\************************/
|
||||
|
||||
TbListado -> FieldDefs -> Add("Titular de la cuenta", ftString, 30, false );
|
||||
TbListado -> FieldDefs -> Add("Nif del Titular", ftString, 15, false );
|
||||
TbListado -> FieldDefs -> Add("Entidad Bancaria", ftString, 30, false );
|
||||
TbListado -> FieldDefs -> Add("Banco_Calle", ftString, 20, false );
|
||||
TbListado -> FieldDefs -> Add("Banco_Num", ftString, 4, false );
|
||||
TbListado -> FieldDefs -> Add("Banco_Poblaci<EFBFBD>n", ftString, 20, false );
|
||||
TbListado -> FieldDefs -> Add("Banco_Provincia", ftString, 15, false );
|
||||
TbListado -> FieldDefs -> Add("Banco_CP", ftInteger, 0, false );
|
||||
|
||||
TbListado -> FieldDefs -> Add("Banco_Entidad", ftSmallint, 0, false );
|
||||
TbListado -> FieldDefs -> Add("Banco_Sucursal", ftSmallint, 0, false );
|
||||
TbListado -> FieldDefs -> Add("Banco_DC", ftSmallint, 0, false );
|
||||
TbListado -> FieldDefs -> Add("Banco_NumCuenta", ftString, 10, false );
|
||||
|
||||
/************************\
|
||||
|* Informaci<63>n Extra *|
|
||||
\************************/
|
||||
|
||||
TbListado -> FieldDefs -> Add("Estado Civil", ftSmallint, 0, false );
|
||||
TbListado -> FieldDefs -> Add("Fecha de Nacimiento", ftDate, 0, false );
|
||||
TbListado -> FieldDefs -> Add("Profesi<EFBFBD>n", ftString, 15, false );
|
||||
TbListado -> FieldDefs -> Add("A<EFBFBD>os en la empresa",ftSmallint, 0, false );
|
||||
TbListado -> FieldDefs -> Add("Personas en la familia", ftSmallint, 0, false );
|
||||
TbListado -> FieldDefs -> Add("Estudios", ftSmallint, 0, false );
|
||||
TbListado -> FieldDefs -> Add("Tipo vivienda", ftSmallint, 0, false );
|
||||
TbListado -> FieldDefs -> Add("A<EFBFBD>os vivienda", ftSmallint, 0, false );
|
||||
TbListado -> FieldDefs -> Add("Extras1", ftString, 15, false );
|
||||
TbListado -> FieldDefs -> Add("Extras2", ftString, 15, false );
|
||||
TbListado -> FieldDefs -> Add("Extras3", ftString, 15, false );
|
||||
TbListado -> FieldDefs -> Add("Extras4", ftString, 15, false );
|
||||
TbListado -> FieldDefs -> Add("Notas", ftMemo, 200, false );
|
||||
|
||||
|
||||
TbListado -> FieldDefs -> Add("Imagen", ftString, 80, false );
|
||||
|
||||
TbListado -> FieldDefs -> Add("Proveedor", ftInteger, 0, false );
|
||||
TbListado -> FieldDefs -> Add("Empleado", ftInteger, 0, false );
|
||||
TbListado -> FieldDefs -> Add("Cliente", ftInteger, 0, false );
|
||||
TbListado -> FieldDefs -> Add("Amigo", ftInteger, 0, false );
|
||||
|
||||
TbListado -> FieldDefs -> Add("IDcarpeta", ftInteger, 0, false );
|
||||
|
||||
TbListado -> IndexDefs-> Clear();
|
||||
|
||||
TIndexOptions MyIndexOptions;
|
||||
MyIndexOptions << ixPrimary << ixUnique;
|
||||
TbListado->IndexDefs->Add("Primary", "CodCliente1", MyIndexOptions);
|
||||
|
||||
TbListado->IndexDefs->Add("Nombre", "Nombre", TIndexOptions() << ixCaseInsensitive);
|
||||
TbListado->IndexDefs->Add("Apellidos", "Apellidos", TIndexOptions() << ixCaseInsensitive);
|
||||
TbListado->IndexDefs->Add("Empresa", "Empresa", TIndexOptions() << ixCaseInsensitive);
|
||||
TbListado->IndexDefs->Add("Actividad", "Actividad", TIndexOptions() << ixCaseInsensitive);
|
||||
TbListado->IndexDefs->Add("Telefono 1", "Telefono 1", TIndexOptions() << ixCaseInsensitive);
|
||||
TbListado->IndexDefs->Add("Telefono 2", "Telefono 2", TIndexOptions() << ixCaseInsensitive);
|
||||
// Creamos la base...
|
||||
TbListado -> CreateTable();
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::TbLlamadasBeforeOpen(TDataSet *DataSet)
|
||||
{
|
||||
if ( !FileExists( TbLlamadas->TableName ) )
|
||||
{
|
||||
InfoBar->SimpleText= "Creando control de llamadas..." ;
|
||||
TbLlamadas -> TableType = ttParadox;
|
||||
|
||||
TbLlamadas -> FieldDefs -> Clear();
|
||||
|
||||
/********************\
|
||||
|* Datos B<>sicos *|
|
||||
\********************/
|
||||
TbLlamadas -> FieldDefs -> Add("IDllamada", ftAutoInc, 0, false );
|
||||
TbLlamadas -> FieldDefs -> Add("IDcliente", ftInteger, 0, false );
|
||||
TbLlamadas -> FieldDefs -> Add("fecha", ftDate, 0, false );
|
||||
TbLlamadas -> FieldDefs -> Add("hora", ftTime, 0, false );
|
||||
TbLlamadas -> FieldDefs -> Add("asunto", ftString, 30, false );
|
||||
TbLlamadas -> FieldDefs -> Add("notas", ftMemo, 160, false );
|
||||
|
||||
TbLlamadas -> IndexDefs-> Clear();
|
||||
|
||||
TbLlamadas->IndexDefs->Add("Primary", "IDllamada", TIndexOptions() << ixPrimary << ixUnique);
|
||||
TbLlamadas->IndexDefs->Add("EnlaceCliente", "IDcliente", TIndexOptions() << ixCaseInsensitive);
|
||||
|
||||
// Creamos la base...
|
||||
TbLlamadas -> CreateTable();
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TListadoClientes::FiltrarCategoriasClick(TObject *Sender)
|
||||
{
|
||||
FiltraCriterios();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TListadoClientes::FiltrarCarpetasClick(TObject *Sender)
|
||||
{
|
||||
FiltraCriterios();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TListadoClientes::FiltraCriterios(void)
|
||||
{
|
||||
AnsiString CadenaFiltro;
|
||||
|
||||
TbListado->FilterOptions = TbListado->FilterOptions << foCaseInsensitive;
|
||||
|
||||
if ( FiltrarCarpetas->Checked && !TbCarpetas->FieldByName( "IDcarpeta" )->AsString.IsEmpty() )
|
||||
CadenaFiltro = "( [IDcarpeta] = '" + TbCarpetas->FieldByName( "IDcarpeta" )->AsString + "') ";
|
||||
|
||||
switch( FiltrarCategorias->ItemIndex )
|
||||
{
|
||||
// Proveedores
|
||||
case 0:
|
||||
if ( FiltrarCarpetas->Checked ) CadenaFiltro += " AND ";
|
||||
CadenaFiltro += "[Proveedor] >= 1";
|
||||
break;
|
||||
// Empleados
|
||||
case 1:
|
||||
if ( FiltrarCarpetas->Checked ) CadenaFiltro += " AND ";
|
||||
CadenaFiltro += "[Empleado] >= 1";
|
||||
break;
|
||||
// Clientes
|
||||
case 2:
|
||||
if ( FiltrarCarpetas->Checked ) CadenaFiltro += " AND ";
|
||||
CadenaFiltro += "[Cliente] >= 1";
|
||||
break;
|
||||
// Amigos
|
||||
case 3:
|
||||
if ( FiltrarCarpetas->Checked ) CadenaFiltro += " AND ";
|
||||
CadenaFiltro += "[Amigo] >= 1";
|
||||
break;
|
||||
}
|
||||
|
||||
if ( CadenaFiltro.IsEmpty() )
|
||||
{
|
||||
TbListado->Filtered = false;
|
||||
} else {
|
||||
TbListado->Filter = CadenaFiltro;
|
||||
TbListado->Filtered = true;
|
||||
}
|
||||
|
||||
// AlfabetoChange(0);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TListadoClientes::BitBtn1Click(TObject *Sender)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TListadoClientes::AlfabetoChange(TObject *Sender)
|
||||
{
|
||||
// Posici<63>n dentro de la lista...
|
||||
switch ( Alfabeto->TabIndex )
|
||||
{
|
||||
case 0:
|
||||
if ( ! ( TbListado->Locate( "Nombre", "a", TLocateOptions() << loCaseInsensitive << loPartialKey ) ) )
|
||||
TbListado->Locate( "Nombre", "b", TLocateOptions() << loCaseInsensitive << loPartialKey ) ;
|
||||
break;
|
||||
case 1:
|
||||
if ( ! ( TbListado->Locate( "Nombre", "c", TLocateOptions() << loCaseInsensitive << loPartialKey ) ) )
|
||||
TbListado->Locate( "Nombre", "d", TLocateOptions() << loCaseInsensitive << loPartialKey ) ;
|
||||
break;
|
||||
case 2:
|
||||
if ( ! ( TbListado->Locate( "Nombre", "e", TLocateOptions() << loCaseInsensitive << loPartialKey ) ) )
|
||||
TbListado->Locate( "Nombre", "f", TLocateOptions() << loCaseInsensitive << loPartialKey ) ;
|
||||
break;
|
||||
case 3:
|
||||
if ( ! ( TbListado->Locate( "Nombre", "g", TLocateOptions() << loCaseInsensitive << loPartialKey ) ) )
|
||||
TbListado->Locate( "Nombre", "h", TLocateOptions() << loCaseInsensitive << loPartialKey ) ;
|
||||
break;
|
||||
case 4:
|
||||
if ( ! ( TbListado->Locate( "Nombre", "i", TLocateOptions() << loCaseInsensitive << loPartialKey ) ) )
|
||||
if ( ! ( TbListado->Locate( "Nombre", "j", TLocateOptions() << loCaseInsensitive << loPartialKey ) ) )
|
||||
TbListado->Locate( "Nombre", "k", TLocateOptions() << loCaseInsensitive << loPartialKey ) ;
|
||||
break;
|
||||
case 5:
|
||||
if ( ! ( TbListado->Locate( "Nombre", "l", TLocateOptions() << loCaseInsensitive << loPartialKey ) ) )
|
||||
TbListado->Locate( "Nombre", "m", TLocateOptions() << loCaseInsensitive << loPartialKey ) ;
|
||||
break;
|
||||
case 6:
|
||||
if ( ! ( TbListado->Locate( "Nombre", "n", TLocateOptions() << loCaseInsensitive << loPartialKey ) ) )
|
||||
TbListado->Locate( "Nombre", "o", TLocateOptions() << loCaseInsensitive << loPartialKey ) ;
|
||||
break;
|
||||
case 7:
|
||||
if ( ! ( TbListado->Locate( "Nombre", "p", TLocateOptions() << loCaseInsensitive << loPartialKey ) ) )
|
||||
if ( ! ( TbListado->Locate( "Nombre", "q", TLocateOptions() << loCaseInsensitive << loPartialKey ) ) )
|
||||
TbListado->Locate( "Nombre", "r", TLocateOptions() << loCaseInsensitive << loPartialKey ) ;
|
||||
break;
|
||||
case 8:
|
||||
TbListado->Locate( "Nombre", "s", TLocateOptions() << loCaseInsensitive << loPartialKey );
|
||||
break;
|
||||
case 9:
|
||||
if ( ! ( TbListado->Locate( "Nombre", "t", TLocateOptions() << loCaseInsensitive << loPartialKey ) ) )
|
||||
TbListado->Locate( "Nombre", "u", TLocateOptions() << loCaseInsensitive << loPartialKey ) ;
|
||||
break;
|
||||
case 10:
|
||||
if ( ! ( TbListado->Locate( "Nombre", "v", TLocateOptions() << loCaseInsensitive << loPartialKey ) ) )
|
||||
TbListado->Locate( "Nombre", "w", TLocateOptions() << loCaseInsensitive << loPartialKey ) ;
|
||||
break;
|
||||
case 11:
|
||||
if ( ! ( TbListado->Locate( "Nombre", "x", TLocateOptions() << loCaseInsensitive << loPartialKey ) ) )
|
||||
if ( ! ( TbListado->Locate( "Nombre", "y", TLocateOptions() << loCaseInsensitive << loPartialKey ) ) )
|
||||
TbListado->Locate( "Nombre", "z", TLocateOptions() << loCaseInsensitive << loPartialKey ) ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
void __fastcall TListadoClientes::DsCarpetasDataChange(TObject *Sender,
|
||||
TField *Field)
|
||||
{
|
||||
if ( !( TbCarpetas->State == dsEdit || TbCarpetas->State == dsInsert) )
|
||||
FiltraCriterios();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TListadoClientes::DsListadoDataChange(TObject *Sender,
|
||||
TField *Field)
|
||||
{
|
||||
OnDataChanged = true;
|
||||
|
||||
if ( TbListado->State == dsEdit || TbListado->State == dsInsert )
|
||||
return;
|
||||
|
||||
// Cargamos la imagen
|
||||
|
||||
AnsiString PathToImage = DB_Path + "pictures\\"+ TbListado->FieldByName( "Imagen" )->AsString;
|
||||
SetCurrentDir( ExtractFilePath( Application->ExeName ) );
|
||||
try {
|
||||
Foto->Picture->LoadFromFile( PathToImage );
|
||||
} catch(...) {
|
||||
try {
|
||||
Foto->Picture->LoadFromFile( DB_Path + "pictures\\iError.bmp" );
|
||||
} catch(...) {
|
||||
// nothing
|
||||
};
|
||||
};
|
||||
|
||||
if ( CorrectaCC( TbListado->FieldByName("Banco_Entidad")->AsInteger,
|
||||
TbListado->FieldByName("Banco_Sucursal")->AsInteger,
|
||||
TbListado->FieldByName("Banco_DC")->AsInteger,
|
||||
TbListado->FieldByName("Banco_NumCuenta")->AsString )
|
||||
)
|
||||
{
|
||||
DBEdit28->Color = clWindow;
|
||||
DBEdit29->Color = clWindow;
|
||||
DBEdit30->Color = clWindow;
|
||||
DBEdit31->Color = clWindow;
|
||||
}else{
|
||||
DBEdit28->Color = clRed;
|
||||
DBEdit29->Color = clRed;
|
||||
DBEdit30->Color = clRed;
|
||||
DBEdit31->Color = clRed;
|
||||
}
|
||||
|
||||
CheckBox1->Checked = TbListado->FieldByName( "Proveedor" ) ->AsInteger;
|
||||
CheckBox3->Checked = TbListado->FieldByName( "Empleado" ) ->AsInteger;
|
||||
CheckBox2->Checked = TbListado->FieldByName( "Cliente" ) ->AsInteger;
|
||||
CheckBox4->Checked = TbListado->FieldByName( "Amigo" ) ->AsInteger;
|
||||
|
||||
OnDataChanged = false;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TListadoClientes::FotoDblClick(TObject *Sender)
|
||||
{
|
||||
OpenPictureDialog1->InitialDir = DB_Path + "pictures\\";
|
||||
if (OpenPictureDialog1->Execute())
|
||||
{
|
||||
TbListado -> Edit();
|
||||
TbListado -> FieldByName( "Imagen" ) -> AsString = ExtractFileName(OpenPictureDialog1->FileName);
|
||||
TbListado -> Post();
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::SpeedButton6Click(TObject *Sender)
|
||||
{
|
||||
ShowMessage( "No se puede validar la cuenta bancaria\nListado de bancos no accesible..." );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::SpeedButton5Click(TObject *Sender)
|
||||
{
|
||||
InfoBar->SimpleText = "Localizando C<>digo Postal..." ;
|
||||
|
||||
if ( !DBcorreos )
|
||||
{
|
||||
ShowMessage( "No se puede validar el c<>digo postal.\nBase Postal no disponible..." );
|
||||
} else {
|
||||
if ( TbCorreos->Locate( "CODIGO", TbListado->FieldByName("CP")->AsString, TLocateOptions() << loCaseInsensitive ) )
|
||||
{
|
||||
AnsiString Provincias[] = { "###desconocido###",
|
||||
"Alava",
|
||||
"Albacete",
|
||||
"Alicante",
|
||||
"Almeria",
|
||||
"Avila",
|
||||
"Badajoz",
|
||||
"Illes Balears",
|
||||
"Barcelona",
|
||||
"Burgos",
|
||||
"Caceres",
|
||||
"Cadiz",
|
||||
"Castellon de la Plana",
|
||||
"Ciudad Real",
|
||||
"Cordoba",
|
||||
"Coru<EFBFBD>a, A",
|
||||
"Cuenca",
|
||||
"Girona",
|
||||
"Granada",
|
||||
"Guadalajara",
|
||||
"Guippuzcoa",
|
||||
"Huelva",
|
||||
"Huesca",
|
||||
"Jaen",
|
||||
"Leon",
|
||||
"Lleida",
|
||||
"Rioja, La",
|
||||
"Lugo",
|
||||
"Madrid",
|
||||
"Malaga",
|
||||
"Murcia",
|
||||
"Navarra",
|
||||
"Ourense",
|
||||
"Asturias",
|
||||
"Palencia",
|
||||
"Palmas, Las",
|
||||
"Pontevedra",
|
||||
"Salamanca",
|
||||
"Santa Cruz de Tenerife",
|
||||
"Cantabria",
|
||||
"Segovia",
|
||||
"Sevilla",
|
||||
"Soria",
|
||||
"Tarragona",
|
||||
"Teruel",
|
||||
"Toledo",
|
||||
"Valencia",
|
||||
"Valladolid",
|
||||
"Vizcaya",
|
||||
"Vizcaya",
|
||||
"Zamora",
|
||||
"Zaragoza",
|
||||
"Ceuta",
|
||||
"Melilla" };
|
||||
|
||||
|
||||
|
||||
TbListado->Edit();
|
||||
TbListado->FieldByName("Poblaci<EFBFBD>n")->AsString = TbCorreos->FieldByName("Descripcion")->AsString;
|
||||
|
||||
if ( TbCorreos->FieldByName("ID_Provincia")->AsInteger <= 50 &&
|
||||
TbCorreos->FieldByName("ID_Provincia")->AsInteger > 0
|
||||
)
|
||||
TbListado->FieldByName("Provincia")->AsString = Provincias[TbCorreos->FieldByName("ID_Provincia")->AsInteger];
|
||||
TbListado->Post();
|
||||
}
|
||||
}
|
||||
|
||||
InfoBar->SimpleText = "www.infdj.com";
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::SpeedButton1Click(TObject *Sender)
|
||||
{
|
||||
InfoBar->SimpleText = "Inicializando marcador Telef<65>nico" ;
|
||||
// Marcar tel<65>fono 1...
|
||||
PageControl1->ActivePage = TabSheet2;
|
||||
PageControl2->ActivePage = TabSheet6;
|
||||
TbLlamadas->Insert();
|
||||
InfoBar->SimpleText = "www.infdj.com" ;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::SpeedButton2Click(TObject *Sender)
|
||||
{
|
||||
InfoBar->SimpleText = "Inicializando marcador Telef<65>nico" ;
|
||||
// Marcar tel<65>fono 2
|
||||
PageControl1->ActivePage = TabSheet2;
|
||||
PageControl2->ActivePage = TabSheet6;
|
||||
TbLlamadas->Insert();
|
||||
InfoBar->SimpleText = "www.infdj.com" ;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::SpeedButton4Click(TObject *Sender)
|
||||
{
|
||||
InfoBar->SimpleText = "Enganchando con el Explorador" ;
|
||||
|
||||
char zFileName[80], zParams[80], zDir[80];
|
||||
AnsiString URL = "http://" + TbListado->FieldByName("url")->AsString;
|
||||
ShellExecute(Application->MainForm->Handle, 0, StrPCopy(zFileName, URL),
|
||||
StrPCopy(zParams, ""), StrPCopy(zDir, ""), SW_SHOWNOACTIVATE > 32);
|
||||
/*
|
||||
URL1->URL = TbListado->FieldByName("url")->AsString;
|
||||
URL1->URLType = utHttp;
|
||||
URL1->Execute();
|
||||
*/
|
||||
// Abrir i-explorer con esta p<>gina
|
||||
InfoBar->SimpleText = "www.infdj.com" ;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::SpeedButton3Click(TObject *Sender)
|
||||
{
|
||||
InfoBar->SimpleText = "Preparando nuevo correo..." ;
|
||||
|
||||
char zFileName[80], zParams[80], zDir[80];
|
||||
AnsiString URL = "mailto:" + TbListado->FieldByName("e-Mail")->AsString;
|
||||
ShellExecute(Application->MainForm->Handle, 0, StrPCopy(zFileName, URL),
|
||||
StrPCopy(zParams, ""), StrPCopy(zDir, ""), SW_SHOWNOACTIVATE > 32);
|
||||
|
||||
/*
|
||||
URL1->URL = TbListado->FieldByName("e-Mail")->AsString;
|
||||
URL1->URLType = utMailto;
|
||||
URL1->Execute();
|
||||
*/
|
||||
// Abrir outlook express con este correo...
|
||||
InfoBar->SimpleText = "www.infdj.com" ;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::SpeedButton8Click(TObject *Sender)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::SpeedButton7Click(TObject *Sender)
|
||||
{
|
||||
if ( PageControl1->ActivePage == TabSheet7 )
|
||||
{
|
||||
PageControl1->ActivePage = TabSheet7;
|
||||
PageControl3->ActivePage = TabSheet9;
|
||||
DBEdit32->SetFocus();
|
||||
TbNotas->Insert();
|
||||
} else {
|
||||
PageControl1->ActivePage = TabSheet2;
|
||||
PageControl2->ActivePage = TabSheet3;
|
||||
DBEdit1->SetFocus();
|
||||
TbListado->Insert();
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::SpeedButton11Click(TObject *Sender)
|
||||
{
|
||||
TDlgImprimir *DlgImp;
|
||||
DlgImp = new TDlgImprimir(this);
|
||||
DlgImp->ShowModal();
|
||||
delete DlgImp;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::BuscarFichaClick(TObject *Sender)
|
||||
{
|
||||
PageControl1->ActivePage = TabSheet7;
|
||||
PageControl3->ActivePage = TabSheet9;
|
||||
DBEdit32->SetFocus();
|
||||
TbNotas->Insert();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::SpeedButton9Click(TObject *Sender)
|
||||
{
|
||||
if ( PageControl1->ActivePage == TabSheet7 )
|
||||
{
|
||||
TbNotas -> Delete();
|
||||
} else {
|
||||
if ( PageControl2->ActivePage == TabSheet6 )
|
||||
TbLlamadas -> Delete();
|
||||
else
|
||||
TbListado -> Delete();
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::TbListadoBeforeDelete(TDataSet *DataSet)
|
||||
{
|
||||
if ( MessageDlg( "<EFBFBD>Esta seguro que desea eliminar el REGISTRO actual?", mtWarning, TMsgDlgButtons() << mbNo << mbYes, 0 ) == mrNo )
|
||||
Abort();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::SelIndexChange(TObject *Sender)
|
||||
{
|
||||
TbListado->IndexFieldNames = SelIndex->Items->Strings[SelIndex->ItemIndex];
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::BuscadorKeyUp(TObject *Sender, WORD &Key,
|
||||
TShiftState Shift)
|
||||
{
|
||||
TbListado->Locate( SelIndex->Items->Strings[SelIndex->ItemIndex], Buscador->Text, TLocateOptions() << loCaseInsensitive << loPartialKey );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::TbLlamadasNewRecord(TDataSet *DataSet)
|
||||
{
|
||||
TbLlamadas->FieldByName( "fecha" )->AsDateTime = TDateTime::CurrentDate();
|
||||
TbLlamadas->FieldByName( "hora" )->AsDateTime = TDateTime::CurrentTime();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::FormClose(TObject *Sender,
|
||||
TCloseAction &Action)
|
||||
{
|
||||
if ( TbListado->State == dsEdit || TbListado->State == dsInsert )
|
||||
TbListado->Post();
|
||||
if ( TbLlamadas->State == dsEdit || TbLlamadas->State == dsInsert )
|
||||
TbLlamadas->Post();
|
||||
if ( TbCarpetas->State == dsEdit || TbCarpetas->State == dsInsert )
|
||||
TbCarpetas->Post();
|
||||
if ( TbNotas->State == dsEdit || TbNotas->State == dsInsert )
|
||||
TbNotas->Post();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::MinFechaChange(TObject *Sender)
|
||||
{
|
||||
FiltraLlamadas();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TListadoClientes::FiltraLlamadas( void )
|
||||
{
|
||||
if ( FiltroLlamadas->Checked )
|
||||
{
|
||||
TbLlamadas->FilterOptions = TbLlamadas->FilterOptions << foCaseInsensitive;
|
||||
TbLlamadas->Filter = "([fecha] >= '" + MinFecha->Date + "' AND [fecha] <= '" + MaxFecha->Date +"')";
|
||||
TbLlamadas->Filtered = true;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TListadoClientes::FiltroLlamadasClick(TObject *Sender)
|
||||
{
|
||||
if ( FiltroLlamadas->Checked )
|
||||
{
|
||||
FiltraLlamadas();
|
||||
} else {
|
||||
TbLlamadas->Filtered = false;
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TListadoClientes::DBText1DblClick(TObject *Sender)
|
||||
{
|
||||
PageControl1->ActivePage = TabSheet2;
|
||||
PageControl2->ActivePage = TabSheet3;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::TbListadoNewRecord(TDataSet *DataSet)
|
||||
{
|
||||
TbListado->FieldByName( "FAlta" ) -> AsDateTime = TDateTime::CurrentDateTime();
|
||||
TbListado->FieldByName( "Proveedor" ) -> AsInteger = 0;
|
||||
TbListado->FieldByName( "Empleado" ) -> AsInteger = 0;
|
||||
TbListado->FieldByName( "Cliente" ) -> AsInteger = 1;
|
||||
TbListado->FieldByName( "Amigo" ) -> AsInteger = 0;
|
||||
|
||||
CheckBox1->Checked = false;
|
||||
CheckBox3->Checked = false;
|
||||
CheckBox2->Checked = true;
|
||||
CheckBox4->Checked = false;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::SpeedButton10Click(TObject *Sender)
|
||||
{
|
||||
// Traemos esta ficha a la carpeta seleccionada...
|
||||
TbListado->Edit();
|
||||
try {
|
||||
TbListado->FieldByName( "IDcarpeta" )->AsInteger = TbCarpetas->FieldByName( "IDcarpeta" )->AsInteger;
|
||||
TbListado->Post();
|
||||
}catch (...) {
|
||||
ShowMessage( "No hay carpetas disponibles o se<73>aladas.\nPruebe a seleccionar o crear una nueva...");
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TListadoClientes::CheckBox1Click(TObject *Sender)
|
||||
{
|
||||
try {
|
||||
if ( OnDataChanged ) return;
|
||||
TbListado->Edit();
|
||||
TbListado->FieldByName( "Proveedor" ) ->AsInteger = (int)( CheckBox1->Checked );
|
||||
TbListado->Post();
|
||||
} catch(...) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TListadoClientes::CheckBox3Click(TObject *Sender)
|
||||
{
|
||||
try {
|
||||
if ( OnDataChanged ) return;
|
||||
TbListado->Edit();
|
||||
TbListado->FieldByName( "Empleado" ) ->AsInteger = (int)( CheckBox3->Checked );
|
||||
TbListado->Post();
|
||||
} catch(...) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TListadoClientes::CheckBox2Click(TObject *Sender)
|
||||
{
|
||||
try {
|
||||
if ( OnDataChanged ) return;
|
||||
TbListado->Edit();
|
||||
TbListado->FieldByName( "Cliente" ) ->AsInteger = (int)( CheckBox2->Checked );
|
||||
TbListado->Post();
|
||||
} catch(...) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TListadoClientes::CheckBox4Click(TObject *Sender)
|
||||
{
|
||||
try {
|
||||
if ( OnDataChanged ) return;
|
||||
TbListado->Edit();
|
||||
TbListado->FieldByName( "Amigo" ) ->AsInteger = (int)( CheckBox4->Checked );
|
||||
TbListado->Post();
|
||||
} catch(...) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::TbNotasBeforeOpen(TDataSet *DataSet)
|
||||
{
|
||||
if ( !FileExists( TbNotas->TableName ) )
|
||||
{
|
||||
InfoBar->SimpleText= "Creando << mis notas >>..." ;
|
||||
TbNotas -> TableType = ttParadox;
|
||||
|
||||
TbNotas -> FieldDefs -> Clear();
|
||||
|
||||
/********************\
|
||||
|* Datos B<>sicos *|
|
||||
\********************/
|
||||
TbNotas -> FieldDefs -> Add("IDnota", ftAutoInc, 0, false );
|
||||
TbNotas -> FieldDefs -> Add("fecha", ftDate, 0, false );
|
||||
TbNotas -> FieldDefs -> Add("hora", ftTime, 0, false );
|
||||
TbNotas -> FieldDefs -> Add("asunto", ftString, 30, false );
|
||||
TbNotas -> FieldDefs -> Add("notas", ftMemo, 160, false );
|
||||
|
||||
TbNotas -> IndexDefs-> Clear();
|
||||
|
||||
TbNotas->IndexDefs->Add("Primary", "IDnota", TIndexOptions() << ixPrimary << ixUnique);
|
||||
|
||||
// Creamos la base...
|
||||
TbNotas -> CreateTable();
|
||||
}
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::TbNotasNewRecord(TDataSet *DataSet)
|
||||
{
|
||||
TbNotas->FieldByName( "fecha" )->AsDateTime = TDateTime::CurrentDate();
|
||||
TbNotas->FieldByName( "hora" )->AsDateTime = TDateTime::CurrentTime();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::DBMemo3DblClick(TObject *Sender)
|
||||
{
|
||||
PageControl1->ActivePage = TabSheet7;
|
||||
PageControl3->ActivePage = TabSheet9;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::PageControl1Change(TObject *Sender)
|
||||
{
|
||||
if ( PageControl1->ActivePage == TabSheet7 )
|
||||
{
|
||||
DBNavigator1->DataSource = DsNotas;
|
||||
} else {
|
||||
DBNavigator1->DataSource = DsListado;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::DBEdit32KeyUp(TObject *Sender, WORD &Key,
|
||||
TShiftState Shift)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
TbNotas->Post();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::TbNotasBeforeDelete(TDataSet *DataSet)
|
||||
{
|
||||
if ( MessageDlg( "<EFBFBD>Confirma que desea eliminar la ANOTACION actual?", mtWarning, TMsgDlgButtons() << mbNo << mbYes, 0 ) == mrNo )
|
||||
Abort();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::NextField(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
TDBEdit *Siguiente[] = { DBEdit1, DBEdit2, DBEdit3, DBEdit4, DBEdit5,
|
||||
DBEdit6, DBEdit7, DBEdit17, DBEdit18, DBEdit8,
|
||||
DBEdit9, DBEdit10, DBEdit11, DBEdit12, DBEdit13,
|
||||
DBEdit19, DBEdit14, DBEdit15, DBEdit16, DBEdit1 };
|
||||
|
||||
for ( int i=0; i < 20; i++ )
|
||||
{
|
||||
if ( Sender == Siguiente[i] )
|
||||
{
|
||||
if ( TbListado->State == dsEdit || TbListado->State == dsInsert )
|
||||
TbListado->Post();
|
||||
Siguiente[i+1]->SetFocus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::NextField2(TObject *Sender, char &Key)
|
||||
{
|
||||
if ( Key == VK_RETURN )
|
||||
{
|
||||
TDBEdit *Siguiente[] = { DBEdit20, DBEdit21, DBEdit22, DBEdit23, DBEdit24,
|
||||
DBEdit25, DBEdit26, DBEdit27, DBEdit28, DBEdit29,
|
||||
DBEdit30, DBEdit31, DBEdit20 };
|
||||
|
||||
for ( int i=0; i < 12; i++ )
|
||||
{
|
||||
if ( Sender == Siguiente[i] )
|
||||
{
|
||||
if ( TbListado->State == dsEdit || TbListado->State == dsInsert )
|
||||
TbListado->Post();
|
||||
Siguiente[i+1]->SetFocus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void __fastcall TListadoClientes::TbListadoBeforePost(TDataSet *DataSet)
|
||||
{
|
||||
TbListado->FieldByName( "FModif" ) -> AsDateTime = TDateTime::CurrentDateTime();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
void __fastcall TListadoClientes::DBMemo1Exit(TObject *Sender)
|
||||
{
|
||||
if ( TbLlamadas->State == dsEdit || TbLlamadas->State == dsInsert )
|
||||
TbLlamadas->Post();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
||||
void __fastcall TListadoClientes::TbLlamadasBeforeDelete(TDataSet *DataSet)
|
||||
{
|
||||
if ( MessageDlg( "<EFBFBD>Esta seguro que desea eliminar la LLAMADA actual?", mtWarning, TMsgDlgButtons() << mbNo << mbYes, 0 ) == mrNo )
|
||||
Abort();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
Reference in New Issue
Block a user