1159 lines
43 KiB
C++
1159 lines
43 KiB
C++
#include <alloc.h>
|
||
#include <conio.h>
|
||
#include <string.h>
|
||
#include <stdlib.h>
|
||
|
||
#include "d:\program\src_dos\libs\bdatos\bdatos.hh"
|
||
#include "mail_.h"
|
||
|
||
#define NLINEAS_REF 18
|
||
|
||
BDatos BMailings; // Base de datos de Mailingserencias
|
||
MAILINGS SMailings; // Estructura de referencias
|
||
MAILINGS BHtmp; // Estructura de referencias
|
||
|
||
#define COD1 15
|
||
#define COD2 15
|
||
#define COD3 15
|
||
|
||
//123456789-123456789-12345
|
||
char Codigo3[15][25+1] = { " ( sin codigo ) ",
|
||
"InfoMundo. Jos‚ David (c)",
|
||
"Linea 2 Codigo 3 ",
|
||
"Linea 3 Codigo 3 ",
|
||
"Linea 4 Codigo 3 ",
|
||
"Linea 5 Codigo 3 ",
|
||
"Linea 6 Codigo 3 ",
|
||
"Linea 7 Codigo 3 ",
|
||
"Linea 8 Codigo 3 ",
|
||
"Linea 9 Codigo 3 ",
|
||
"Linea 0 Codigo 3 ",
|
||
"Linea a Codigo 3 ",
|
||
"Linea b Codigo 3 ",
|
||
"Linea c Codigo 3 ",
|
||
"Linea d Codigo 3 " };
|
||
|
||
char Codigo2[15][25+1] = { " ( sin codigo ) ",
|
||
"para un miembro de ",
|
||
"Linea 2 Codigo 2 ",
|
||
"Linea 3 Codigo 2 ",
|
||
"Linea 4 Codigo 2 ",
|
||
"Linea 5 Codigo 2 ",
|
||
"Linea 6 Codigo 2 ",
|
||
"Linea 7 Codigo 2 ",
|
||
"Linea 8 Codigo 2 ",
|
||
"Linea 9 Codigo 2 ",
|
||
"Linea 0 Codigo 2 ",
|
||
"Linea a Codigo 2 ",
|
||
"Linea b Codigo 2 ",
|
||
"Linea c Codigo 2 ",
|
||
"Linea d Codigo 2 " };
|
||
|
||
char Codigo1[15][25+1] = { " ( sin codigo ) ",
|
||
"Programa Realizado por y ",
|
||
"Linea 2 Codigo 1 ",
|
||
"Linea 3 Codigo 1 ",
|
||
"Linea 4 Codigo 1 ",
|
||
"Linea 5 Codigo 1 ",
|
||
"Linea 6 Codigo 1 ",
|
||
"Linea 7 Codigo 1 ",
|
||
"Linea 8 Codigo 1 ",
|
||
"Linea 9 Codigo 1 ",
|
||
"Linea 0 Codigo 1 ",
|
||
"Linea a Codigo 1 ",
|
||
"Linea b Codigo 1 ",
|
||
"Linea c Codigo 1 ",
|
||
"Linea d Codigo 1 " };
|
||
|
||
int OrdenMailings;
|
||
|
||
extern CONFIG Config;
|
||
|
||
void RastreaFicheroGastosi(void);
|
||
|
||
void Error( int code );
|
||
void MuestraDatosMailings( void );
|
||
|
||
void DibujaPantallaMatch(void);
|
||
|
||
void Imprimir( void );
|
||
|
||
int ComparaRegistrosPrecio( const void *A, const void *B );
|
||
|
||
void EditItemMailings( char columna );
|
||
void MailingsNuevoRegistro( MAILINGS *MSMailings );
|
||
void MuestraMailings( char columna, char como );
|
||
void ObtenCoordenadasMailings( char columna, int *X0, int *Y0, int *X1, int *Y1 );
|
||
void OrdenaMailings(void);
|
||
|
||
void ObtenCoordenadasMatchPr( char Row, int *X0, int *Y0, int *X1, int *Y1 );
|
||
void MatchDrawMailings( char Row, MAILINGS MMailings, char como );
|
||
void BuscaMailings( char TipoBusqueda, char *CurrRow, long *CurrMailings );
|
||
int Match_Mailings( MAILINGS A, MAILINGS B );
|
||
void EditMatchMailings( char Row, MAILINGS * MMailings );
|
||
int ObtenMatchMailings( void/*MAILINGS *MMailings*/ );
|
||
|
||
|
||
|
||
void ImprimeMailingserencias( char como );
|
||
void ImprimeCabeceraMailings( char como, FILE *file_out );
|
||
void DibujaPantallaArticulos( void );
|
||
|
||
|
||
// ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
|
||
// Ű Parte principal del m˘dulo Ű
|
||
// ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
|
||
|
||
char CurrRow; // Linea sobre la que estamos
|
||
long CurrMailings; // Producto sobre el que estamos posicionados a golpes
|
||
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* InfoProducto *|
|
||
|* *|
|
||
|* Descripci˘n: *|
|
||
|* Controla la introduccion de datos y muestreo asi como todo *|
|
||
|* el interfaz de usuario... *|
|
||
|* *|
|
||
|* Entradas: (ninguna) *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void Mailings(void)
|
||
{
|
||
struct Boton_Texto BT[6];
|
||
BDatos BDummy;
|
||
|
||
BT[0].x = 1; BT[0].y = 1; strcpy( BT[0].Texto, " &Salir "); BT[0].ID_T1 = 0; BT[0].ID_T2 = 31;
|
||
BT[1].x = 20; BT[1].y = 1; strcpy( BT[1].Texto, " &Insertar "); BT[1].ID_T1 = 0; BT[1].ID_T2 = 23;
|
||
|
||
BT[2].x = 33; BT[2].y = 1; strcpy( BT[2].Texto, " &Borrar ."); BT[2].ID_T1 = 0; BT[2].ID_T2 = 48;
|
||
BT[3].x = 47; BT[3].y = 1; strcpy( BT[3].Texto, " &Ordenar"); BT[3].ID_T1 = 0; BT[3].ID_T2 = 24;
|
||
|
||
BT[4].x = 58; BT[4].y = 1; strcpy( BT[4].Texto, " b&Uscar"); BT[4].ID_T1 = 0; BT[4].ID_T2 = 22;
|
||
BT[5].x = 72; BT[5].y = 1; strcpy( BT[5].Texto, " im&Pr. "); BT[5].ID_T1 = 0; BT[5].ID_T2 = 25;
|
||
|
||
char ok = 0;
|
||
int BPush, key;
|
||
|
||
char oldCol;
|
||
char CurrCol; // Columna sobre la que estamos
|
||
|
||
_setcursortype( _NOCURSOR );
|
||
DibujaPantallaArticulos();
|
||
/*
|
||
if ( BDummy.AbrirReg( "dummy.dbf", sizeof( MAILINGS ) ) == ERROR )
|
||
Error(0x01);
|
||
*/
|
||
|
||
if ( BMailings.AbrirReg( "mailings.dbf", sizeof( MAILINGS ) ) == ERROR )
|
||
Error(0x01);
|
||
/*
|
||
for ( CurrMailings=0; CurrMailings < BDummy.Registros(); CurrMailings++)
|
||
{
|
||
BDummy.LeeReg( (void *)&SMailings, CurrMailings );
|
||
BMailings.InsReg( (void *)&SMailings, BMailings.Registros(), ARRIBA );
|
||
}
|
||
|
||
BDummy.CerrarReg();
|
||
*/
|
||
// Si no hay registros, creamos uno almenos.
|
||
if ( BMailings.Registros() == 0 )
|
||
{
|
||
MailingsNuevoRegistro( &SMailings );
|
||
if ( BMailings.InsReg( (void *)&SMailings, BMailings.Registros(), ARRIBA ) == ERROR )
|
||
Error(0x02);
|
||
/*
|
||
for ( long i = 0; i < 1000; i++ )
|
||
{
|
||
SMailings.Codigo = 1000 - i;
|
||
sprintf( SMailings.Nombre, "%03d-%03d-%03d-%03d", i, i, i, i );
|
||
if ( BMailings.InsReg( (void *)&SMailings, BMailings.Registros(), ARRIBA ) == ERROR )
|
||
Error(0x02);
|
||
}
|
||
*/
|
||
}
|
||
|
||
CurrMailings = 0; CurrRow = 0;
|
||
|
||
if ( BMailings.LeeReg( (void *)&SMailings, 0 ) == ERROR )
|
||
Error(0x03);
|
||
MuestraDatosMailings( );
|
||
|
||
CurrCol = 0; oldCol = -1;
|
||
|
||
do {
|
||
if ( CurrCol != oldCol )
|
||
{
|
||
oldCol = CurrCol;
|
||
}
|
||
|
||
MuestraMailings( CurrCol, INTENSO );
|
||
BPush = Funcion_Botones(STD_BY, 6, BT);
|
||
MuestraMailings( CurrCol, NORMAL );
|
||
|
||
switch ( BPush )
|
||
{
|
||
case 0: // No se pulso ningun BOTON
|
||
while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER
|
||
break;
|
||
case -2: // Hay una tecla normal en BUFFER
|
||
if ( ( key = getch() ) != 13 && key != 27 )
|
||
ungetch( key );
|
||
EditItemMailings( CurrCol );
|
||
_setcursortype( _NOCURSOR );
|
||
if ( BMailings.EscribeReg( (void *)&SMailings, (CurrRow + CurrMailings) ) == ERROR )
|
||
Error(0x04);
|
||
while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER
|
||
MuestraMailings( CurrCol, NORMAL );
|
||
CurrCol++; if ( CurrCol > 10 ) CurrCol = 0;
|
||
break;
|
||
case -1: // Hay una tecla especial en BUFFER
|
||
switch( getch() )
|
||
{
|
||
// Flecha Izquierda
|
||
case 75:
|
||
case 15:
|
||
CurrCol--; if ( CurrCol < 0 ) CurrCol = 10;
|
||
break;
|
||
// Flecha Derecha
|
||
case 77:
|
||
case 9:
|
||
CurrCol++; if ( CurrCol > 10 ) CurrCol = 0;
|
||
break;
|
||
// Flecha Arriba
|
||
case 72:
|
||
if ( CurrMailings > 0 )
|
||
CurrMailings--;
|
||
if ( BMailings.LeeReg( (void *)&SMailings, (CurrMailings + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
MuestraDatosMailings( );
|
||
break;
|
||
// Flecha Abajo
|
||
case 80:
|
||
if ( ( CurrRow + CurrMailings ) < BMailings.Registros() - 1 )
|
||
CurrMailings ++;
|
||
if ( BMailings.LeeReg( (void *)&SMailings, (CurrMailings + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
MuestraDatosMailings( );
|
||
break;
|
||
// Inicio
|
||
case 71:
|
||
CurrMailings = 0;
|
||
if ( BMailings.LeeReg( (void *)&SMailings, (CurrMailings + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosMailings( );
|
||
break;
|
||
// Fin
|
||
case 79:
|
||
CurrMailings = BMailings.Registros()-1;
|
||
if ( BMailings.LeeReg( (void *)&SMailings, (CurrMailings + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosMailings( );
|
||
|
||
break;
|
||
// AvanceR pido
|
||
case 81:
|
||
CurrMailings += NLINEAS_REF;
|
||
|
||
while ( (CurrMailings + CurrRow) >= BMailings.Registros() ) CurrMailings--;
|
||
|
||
if ( BMailings.LeeReg( (void *)&SMailings, (CurrMailings + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosMailings( );
|
||
|
||
break;
|
||
// Retroceso R pido
|
||
case 73:
|
||
CurrMailings -= NLINEAS_REF;
|
||
if ( CurrMailings < 0 ) CurrMailings = 0;
|
||
|
||
while( ( CurrRow + CurrMailings ) >= BMailings.Registros() && CurrMailings > 0 ) CurrMailings++;
|
||
|
||
if ( BMailings.LeeReg( (void *)&SMailings, (CurrMailings + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosMailings( );
|
||
break;
|
||
|
||
// Gastos por proveedor
|
||
case 82:
|
||
BuscaMailings( ATRAS, &CurrRow, &CurrMailings );
|
||
break;
|
||
|
||
// Gastos por proveedor
|
||
case 83:
|
||
BuscaMailings( ADELANTE, &CurrRow, &CurrMailings );
|
||
break;
|
||
|
||
}
|
||
while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER
|
||
break;
|
||
// Imprimir Lista de socios
|
||
case 6:
|
||
Imprimir();
|
||
DibujaPantallaArticulos();
|
||
if ( BMailings.LeeReg( (void *)&SMailings, CurrRow + CurrMailings ) == ERROR )
|
||
Error(0x03);
|
||
MuestraDatosMailings( );
|
||
break;
|
||
// Menu Principal
|
||
case 1:
|
||
ok = 1;
|
||
break;
|
||
// Eliminar
|
||
case 3:
|
||
while( kbhit() ) getch();
|
||
if ( Optar( 1, "ATENCION", "Eliminar un Registro", "confirme eliminacion", NULL ) )
|
||
{
|
||
if ( BMailings.DelReg( CurrMailings + CurrRow ) == ERROR )
|
||
Error(0x04);
|
||
if ( BMailings.Registros() == 0 )
|
||
{
|
||
MailingsNuevoRegistro( &SMailings );
|
||
if ( BMailings.InsReg( (void *)&SMailings, BMailings.Registros(), ARRIBA ) == ERROR )
|
||
Error(0x02);
|
||
CurrRow = 0;
|
||
}
|
||
|
||
CurrMailings--; if ( CurrMailings < 0 ) CurrMailings = 0;
|
||
|
||
if ( BMailings.LeeReg( (void *)&SMailings, (CurrMailings + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosMailings( );
|
||
}
|
||
break;
|
||
// Insertar
|
||
case 2:
|
||
MailingsNuevoRegistro( &SMailings );
|
||
CurrRow = 0; CurrMailings = BMailings.Registros();
|
||
if ( BMailings.InsReg( (void *)&SMailings, (CurrMailings + CurrRow), ARRIBA ) == ERROR )
|
||
Error(0x02);
|
||
|
||
if ( BMailings.LeeReg( (void *)&SMailings, (CurrMailings + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosMailings( );
|
||
|
||
break;
|
||
|
||
// Ordenar
|
||
case 4:
|
||
OrdenaMailings();
|
||
CurrMailings = 0; CurrRow = 0;
|
||
|
||
if ( BMailings.LeeReg( (void *)&SMailings, 0 ) == ERROR )
|
||
Error(0x03);
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosMailings( );
|
||
|
||
CurrCol = 0;
|
||
|
||
break;
|
||
// Gastos por proveedor
|
||
case 5:
|
||
BuscaMailings( NUEVA_BUSQUEDA, &CurrRow, &CurrMailings );
|
||
break;
|
||
default:
|
||
while( kbhit() ) getch();
|
||
break;
|
||
}
|
||
|
||
} while( !ok );
|
||
|
||
BMailings.CerrarReg();
|
||
|
||
}
|
||
|
||
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* MuestraDatosMailings *|
|
||
|* *|
|
||
|* Descripci˘n: *|
|
||
|* Dado un registro, se muestran sucesivamente este y todos *|
|
||
|* los que hay por debajo de ‚l, hasta que se agote la base *|
|
||
|* o no quepan mas en la pantalla. *|
|
||
|* *|
|
||
|* Entradas: Registro por el que comenzar *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void MuestraDatosMailings( void )
|
||
{
|
||
int campo;
|
||
// Por cada linea hay 12 campos, ehhh!!!
|
||
for ( campo=0; campo < 11; campo++ )
|
||
MuestraMailings( campo, NORMAL );
|
||
|
||
gotoxy( 70, 24 ); printf( "%8ld", CurrMailings + CurrRow );
|
||
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* MuestraMailings *|
|
||
|* *|
|
||
|* Descripci˘n: *|
|
||
|* Reescribe el campo dado, segŁn la fila, y la intensidad *|
|
||
|* *|
|
||
|* Entradas: *|
|
||
|* columna campo ha mostar *|
|
||
|* linea linea en la que nos encontramos *|
|
||
|* como intensidad del texto (NORMAL/INTENSO) *|
|
||
|* *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void MuestraMailings( char columna, char como )
|
||
{
|
||
char buffer[80];
|
||
char buffer1[80];
|
||
|
||
int X0, Y0, X1, Y1;
|
||
|
||
ObtenCoordenadasMailings( columna, &X0, &Y0, &X1, &Y1 );
|
||
|
||
switch( columna )
|
||
{
|
||
// Codigo
|
||
case 0:
|
||
sprintf ( buffer, " %9ld", SMailings.Codigo );
|
||
break;
|
||
// NIF
|
||
case 1:
|
||
sprintf ( buffer, "%-15s", SMailings.NIF );
|
||
break;
|
||
// Nombre
|
||
case 2:
|
||
sprintf ( buffer, "%-45s", SMailings.Nombre );
|
||
break;
|
||
// Direccion
|
||
case 3:
|
||
sprintf ( buffer, "%-33s", SMailings.Direccion );
|
||
break;
|
||
// Piso
|
||
case 4:
|
||
sprintf ( buffer, "%-4s", SMailings.Piso );
|
||
break;
|
||
// Localidad
|
||
case 5:
|
||
sprintf ( buffer, "%-25s", SMailings.Localidad );
|
||
break;
|
||
// Provincia
|
||
case 6:
|
||
sprintf ( buffer, "%-15s", SMailings.Provincia );
|
||
break;
|
||
// Cod. Postal
|
||
case 7:
|
||
formatea_u_long( SMailings.CodPostal, buffer1 );
|
||
sprintf ( buffer, "%6s", buffer1 );
|
||
break;
|
||
// Cod 1
|
||
case 8:
|
||
sprintf ( buffer, "%25s", Codigo1[ SMailings.Cod1 ] );
|
||
break;
|
||
// Cod 2
|
||
case 9:
|
||
sprintf ( buffer, "%25s", Codigo2[ SMailings.Cod2 ] );
|
||
break;
|
||
// Cod 3
|
||
case 10:
|
||
sprintf ( buffer, "%25s", Codigo3[ SMailings.Cod3 ] );
|
||
break;
|
||
}
|
||
|
||
textbackground( ( como == NORMAL ) ? Config.TxtBgN : Config.TxtBgI );
|
||
strnset( buffer1, 32, X1 );
|
||
|
||
textcolor( ( como == NORMAL ) ? Config.TxtFgN : Config.TxtFgI );
|
||
gotoxy( X0, Y0 );
|
||
cprintf( "%s", buffer );
|
||
|
||
}
|
||
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* EditItemMailings *|
|
||
|* *|
|
||
|* Descripci˘n: *|
|
||
|* Se encarga de editar y validar el campo. *|
|
||
|* *|
|
||
|* Entradas: *|
|
||
|* columna campo ha editar *|
|
||
|* linea linea en la que nos encontramos *|
|
||
|* *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void EditItemMailings( char columna )
|
||
{
|
||
char buffer[80];
|
||
|
||
int X0, Y0, X1, Y1;
|
||
|
||
ObtenCoordenadasMailings( columna, &X0, &Y0, &X1, &Y1 );
|
||
|
||
switch( columna )
|
||
{
|
||
// Codigo
|
||
case 0:
|
||
sprintf ( buffer, "%ld", SMailings.Codigo );
|
||
if ( !( InputCadenaG( buffer, 1, 9, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
SMailings.Codigo = atol ( buffer );
|
||
break;
|
||
// NIF
|
||
case 1:
|
||
strcpy ( buffer, SMailings.NIF );
|
||
if ( !( InputCadenaG( buffer, 0, 10, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SMailings.NIF, buffer );
|
||
break;
|
||
// Nombre
|
||
case 2:
|
||
strcpy ( buffer, SMailings.Nombre );
|
||
if ( !( InputCadenaG( buffer, 0, 37, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SMailings.Nombre, buffer );
|
||
break;
|
||
// Direccion
|
||
case 3:
|
||
strcpy ( buffer, SMailings.Direccion );
|
||
if ( !( InputCadenaG( buffer, 0, 33, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy( SMailings.Direccion, buffer );
|
||
break;
|
||
// Piso
|
||
case 4:
|
||
strcpy ( buffer, SMailings.Piso );
|
||
if ( !( InputCadenaG( buffer, 0, 4, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SMailings.Piso, buffer );
|
||
break;
|
||
// Localidad
|
||
case 5:
|
||
strcpy ( buffer, SMailings.Localidad );
|
||
if ( !( InputCadenaG( buffer, 0, 25, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SMailings.Localidad, buffer );
|
||
break;
|
||
// Provincia
|
||
case 6:
|
||
strcpy ( buffer, SMailings.Provincia );
|
||
if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SMailings.Provincia, buffer );
|
||
break;
|
||
// Cod. Postal
|
||
case 7:
|
||
sprintf ( buffer, "%ld", SMailings.CodPostal );
|
||
if ( !( InputCadenaG( buffer, 1, 5, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
SMailings.CodPostal = atol( buffer );
|
||
break;
|
||
// Cod. 1
|
||
case 8:
|
||
SMailings.Cod1 = ( (SMailings.Cod1++) % COD1 );
|
||
break;
|
||
// Cod. 2
|
||
case 9:
|
||
SMailings.Cod2 = ( (SMailings.Cod2++) % COD2 );
|
||
break;
|
||
// Cod. 3
|
||
case 10:
|
||
SMailings.Cod3 = ( (SMailings.Cod3++) % COD3 );
|
||
break;
|
||
}
|
||
while( kbhit() ) getch();
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* ObtenCoordenadasMailings *|
|
||
|* *|
|
||
|* Descripci˘n: *|
|
||
|* Obtiene las coordenadas de acotacion para el campo pedido *|
|
||
|* *|
|
||
|* Entradas: *|
|
||
|* columna campo del que obtener las coordenadas *|
|
||
|* linea linea en la que nos encontramos *|
|
||
|* X0 Y0 X1 Y1 Punteros para devolver las coordenadas *|
|
||
|* *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void ObtenCoordenadasMailings( char columna, int *X0, int *Y0, int *X1, int *Y1 )
|
||
{
|
||
|
||
// Calculamos la Y0, Y1 para la linea dada ( SOLO columna < 6 )
|
||
|
||
switch( columna )
|
||
{
|
||
case 0:
|
||
*X0 = 23; *X1 = 10;
|
||
*Y0 = *Y1 = 5;
|
||
break;
|
||
case 1:
|
||
*X0 = 59; *X1 = 15;
|
||
*Y0 = *Y1 = 5;
|
||
break;
|
||
case 2:
|
||
*X0 = 11; *X1 = 45;
|
||
*Y0 = *Y1 = 7;
|
||
break;
|
||
case 3:
|
||
*X0 = 15; *X1 = 33;
|
||
*Y0 = *Y1 =10;
|
||
break;
|
||
case 4:
|
||
*X0 = 62; *X1 = 4;
|
||
*Y0 = *Y1 =10;
|
||
break;
|
||
case 5:
|
||
*X0 = 15; *X1 = 25;
|
||
*Y0 = *Y1 =13;
|
||
break;
|
||
case 6:
|
||
*X0 = 57; *X1 = 15;
|
||
*Y0 = *Y1 = 13;
|
||
break;
|
||
case 7:
|
||
*X0 = 17; *X1 = 6;
|
||
*Y0 = *Y1 = 16;
|
||
break;
|
||
case 8:
|
||
*X0 = 13; *X1 = 2;
|
||
*Y0 = *Y1 = 21;
|
||
break;
|
||
case 9:
|
||
*X0 = 54; *X1 = 2;
|
||
*Y0 = *Y1 = 21;
|
||
break;
|
||
case 10:
|
||
*X0 = 50; *X1 = 2;
|
||
*Y0 = *Y1 = 23;
|
||
break;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* MailingsNuevoRegistro *|
|
||
|* *|
|
||
|* Descripci˘n: *|
|
||
|* Limpia el buffer, para un nuevo registro. *|
|
||
|* *|
|
||
|* Entradas: (ninguna) *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void MailingsNuevoRegistro( MAILINGS *NSMailings )
|
||
{
|
||
|
||
NSMailings -> Codigo = 0;
|
||
NSMailings -> NIF[0] = '\0';
|
||
|
||
NSMailings -> Nombre[0] = '\0';
|
||
|
||
NSMailings -> Direccion[0] = '\0';
|
||
NSMailings -> Piso[0] = '\0';
|
||
|
||
NSMailings -> Localidad[0] = '\0';
|
||
NSMailings -> Provincia[0] = '\0';
|
||
|
||
NSMailings -> CodPostal = 0 ;
|
||
|
||
NSMailings -> Cod1 = 0 ;
|
||
NSMailings -> Cod2 = 0 ;
|
||
NSMailings -> Cod3 = 0 ;
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
// ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
|
||
// Ű Parte secundaria del m˘dulo Ű
|
||
// Ű Ű
|
||
// Ű Secci˘n de Busqueda de refecencias Ű
|
||
// ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* MuestraImpresionesRed *|
|
||
|* *|
|
||
|* Descripci˘n: *|
|
||
|* Muestra un cuadro con las distintas opciones de impresi˘n *|
|
||
|* *|
|
||
|* Entradas:(ninguna) *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* ImprimeMailingserencias *|
|
||
|* *|
|
||
|* Descripci˘n: *|
|
||
|* Imprime todas las referencias segŁn se le indique *|
|
||
|* *|
|
||
|* Entradas: *|
|
||
|* Como imprimir las referencias *|
|
||
|* *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void Imprimir( void )
|
||
{
|
||
long i, old_reg;
|
||
FILE *file_out;
|
||
char buffer[80], dev;
|
||
static MAILINGS MMailings;
|
||
|
||
|
||
old_reg = BMailings.RegActual();
|
||
|
||
MailingsNuevoRegistro( &SMailings );
|
||
if ( ObtenMatchMailings( /*&MMailings*/ ) != OK )
|
||
return;
|
||
MMailings = SMailings;
|
||
|
||
if ( !Config.Printer )
|
||
{
|
||
if ( ( file_out = fopen( Config.PrintTo, "w" ) ) == NULL )
|
||
return;
|
||
} else
|
||
|
||
file_out = stdprn;
|
||
|
||
for ( i=0; i<BMailings.Registros(); i+=2 )
|
||
{
|
||
while ( ( dev = BMailings.LeeReg( (void *)&SMailings, i ) ) == OK && !Match_Mailings( SMailings, MMailings ) ) i++;
|
||
if ( dev != OK ) break;
|
||
while ( ( dev = BMailings.LeeReg( (void *)&BHtmp, i+1 ) ) == OK && !Match_Mailings( BHtmp, MMailings ) ) i++;
|
||
if ( dev != OK )
|
||
MailingsNuevoRegistro( &BHtmp );
|
||
|
||
fprintf( stdprn, "\n\r" );
|
||
fprintf( stdprn, " " );
|
||
fprintf( stdprn, "\n\r" );
|
||
sprintf( buffer, "%s", SMailings.Nombre );
|
||
fprintf( stdprn, "%-37s ", buffer );
|
||
sprintf( buffer, "%s", BHtmp.Nombre );
|
||
fprintf( stdprn, "%-37s", buffer );
|
||
|
||
fprintf( stdprn, "\n\r" );
|
||
|
||
sprintf( buffer, "%s %s", SMailings.Direccion, SMailings.Piso );
|
||
buffer[38] = '\0';
|
||
fprintf( stdprn, "%-37s ", buffer );
|
||
sprintf( buffer, "%s %s", BHtmp.Direccion, BHtmp.Piso );
|
||
buffer[38] = '\0';
|
||
fprintf( stdprn, "%-37s", buffer );
|
||
|
||
fprintf( stdprn, "\n\r" );
|
||
sprintf( buffer, "%-25s", SMailings.Localidad );
|
||
fprintf( stdprn, "%5ld %25s ", SMailings.CodPostal, buffer );
|
||
sprintf( buffer, "%-25s", BHtmp.Localidad );
|
||
fprintf( stdprn, "%5ld %25s", BHtmp.CodPostal, buffer );
|
||
|
||
|
||
fprintf( stdprn, "\n\r" );
|
||
|
||
sprintf( buffer, "%s ", SMailings.Provincia );
|
||
fprintf( stdprn, "%-37s ", buffer );
|
||
sprintf( buffer, "%s ", BHtmp.Provincia );
|
||
fprintf( stdprn, "%-37s", buffer );
|
||
|
||
fprintf( stdprn, "\n\r" );
|
||
|
||
|
||
if ( kbhit() )
|
||
{
|
||
getch();
|
||
if ( Optar( 1, "Desea Cancelar la impresion", "el trabajo aun no ha concluido", NULL ) )
|
||
{
|
||
BMailings.LeeReg( (void *)&SMailings, old_reg );
|
||
return ;
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
|
||
fputc( 19, file_out );
|
||
|
||
if ( !Config.Printer )
|
||
fclose( file_out );
|
||
|
||
BMailings.LeeReg( (void *)&SMailings, old_reg );
|
||
|
||
}
|
||
|
||
void ImprimeCabeceraMailings( char como, FILE *file_out )
|
||
{
|
||
switch( como )
|
||
{
|
||
// Listado R pido
|
||
case 1:
|
||
fprintf( file_out, "C˘digo Proveedor Cant.Unt P.Costo P.Venta Combinado\n\r" );
|
||
break;
|
||
// Listado Completo
|
||
case 2:
|
||
fprintf( file_out, "C˘digo Proveedor Cant.Unt P.Costo P.Venta Cod. Combinado\n\r" );
|
||
break;
|
||
// C˘digos de barra
|
||
case 3:
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
void DibujaPantallaArticulos(void)
|
||
{
|
||
textcolor( WHITE );
|
||
// 145678 123456789-123456789-123 12345 345.789 123.123.123 123456789-123456789-
|
||
|
||
textbackground( BLACK );
|
||
cprintf( "\r ");
|
||
cprintf( " ");
|
||
cprintf( "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄż");
|
||
cprintf( "ł ł");
|
||
cprintf( "ł Codigo de Cliente: Nif/Cif: ł");
|
||
cprintf( "ł ł");
|
||
cprintf( "ł Nombre: ł");
|
||
cprintf( "ł ł");
|
||
cprintf( "ł ł");
|
||
cprintf( "ł Direcci˘n: ł");
|
||
cprintf( "ł ł");
|
||
cprintf( "ł ł");
|
||
cprintf( "ł Localidad: Provincia: ł");
|
||
cprintf( "ł ł");
|
||
cprintf( "ł ł");
|
||
cprintf( "ł Cod. Postal: ł");
|
||
cprintf( "ł ł");
|
||
cprintf( "ł ł");
|
||
cprintf( "ł ł");
|
||
cprintf( "ĂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´");
|
||
cprintf( "ł C. Ramo: C. Competencia: ł");
|
||
cprintf( "ł ł");
|
||
cprintf( "ł C˘digos de los motivos de la perdida venta: ł");
|
||
cprintf( "ŔÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ĂÄŮ");
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
int ComparaRegistrosPrecio( const void *A, const void *B )
|
||
{
|
||
char dev;
|
||
|
||
// Tipos de ordenaciones posibles
|
||
switch( OrdenMailings )
|
||
{
|
||
// Por Precio
|
||
case 3:
|
||
dev = strcmpi( ( ((MAILINGS *)A) -> Direccion ), ( ((MAILINGS *)B) -> Direccion ) );
|
||
break;
|
||
// Por Precio
|
||
case 2:
|
||
dev = strcmpi( ( ((MAILINGS *)A) -> Nombre ), ( ((MAILINGS *)B) -> Nombre ) );
|
||
return dev;
|
||
case 1:
|
||
if ( ( ((MAILINGS *)A) -> Codigo ) < ( ((MAILINGS *)B) -> Codigo ) ) return -1;
|
||
if ( ( ((MAILINGS *)A) -> Codigo ) > ( ((MAILINGS *)B) -> Codigo ) ) return 1;
|
||
|
||
/*
|
||
if ( ( ((MAILINGS *)A) -> Cod1 ) < ( ((MAILINGS *)B) -> Cod1 ) ) return -1;
|
||
if ( ( ((MAILINGS *)A) -> Cod1 ) > ( ((MAILINGS *)B) -> Cod1 ) ) return 1;
|
||
|
||
if ( ( ((MAILINGS *)A) -> Cod2 ) < ( ((MAILINGS *)B) -> Cod3 ) ) return -1;
|
||
if ( ( ((MAILINGS *)A) -> Cod2 ) > ( ((MAILINGS *)B) -> Cod3 ) ) return 1;
|
||
|
||
if ( ( ((MAILINGS *)A) -> Cod3 ) < ( ((MAILINGS *)B) -> Cod3 ) ) return -1;
|
||
if ( ( ((MAILINGS *)A) -> Cod3 ) > ( ((MAILINGS *)B) -> Cod3 ) ) return 1;
|
||
*/
|
||
return 0;
|
||
}
|
||
return 0;
|
||
}
|
||
|
||
|
||
void OrdenaMailings(void)
|
||
{
|
||
/*
|
||
BDatos BMailings; // Base de datos de Mailingserencias
|
||
MAILINGS SMailings; // Estructura de referencias
|
||
|
||
int OrdenMailings;
|
||
*/
|
||
struct Boton_Texto BT[4];
|
||
int devolver;
|
||
|
||
BT[0].x = 32; BT[0].y = 9; strcpy( BT[0].Texto, " C&˘digo "); BT[0].ID_T1 = 0; BT[0].ID_T2 = 24;
|
||
BT[1].x = 32; BT[1].y = 11; strcpy( BT[1].Texto, " &Nombre "); BT[1].ID_T1 = 0; BT[1].ID_T2 = 49;
|
||
BT[2].x = 32; BT[2].y = 13; strcpy( BT[2].Texto, " &Direccion "); BT[2].ID_T1 = 0; BT[2].ID_T2 = 32;
|
||
BT[3].x = 32; BT[3].y = 15; strcpy( BT[3].Texto, " &Cancelar operacion"); BT[3].ID_T1 = 0; BT[3].ID_T2 = 46;
|
||
|
||
Optar( ENCUADRE, "Elija orden a seguir", NULL );
|
||
|
||
while( ( devolver = Funcion_Botones(STD_BY, 4, BT) ) < 1 || devolver > 4 ) while ( kbhit() ) getch();
|
||
|
||
if ( devolver != 4 )
|
||
{
|
||
OrdenMailings = devolver;
|
||
BMailings.SortReg( ComparaRegistrosPrecio );
|
||
}
|
||
|
||
Optar( ENCUADRE, NULL );
|
||
|
||
}
|
||
|
||
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* BuscaMailings *|
|
||
|* *|
|
||
|* Descripci˘n: *|
|
||
|* Busca una referencia por su n§ o descripcion *|
|
||
|* *|
|
||
|* Entradas: *|
|
||
|* ATRAS Busca otra coincidencia hacia atras *|
|
||
|* NUEVA_BUSQUEDA Inicia una nueva busqueda *|
|
||
|* ADELANTE Busca otra coincidencia hacia delante *|
|
||
|* *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void BuscaMailings( char TipoBusqueda, char *CurrRow, long *CurrMailings )
|
||
{
|
||
static MAILINGS MMailings;
|
||
char enc; long i;
|
||
|
||
|
||
switch ( TipoBusqueda )
|
||
{
|
||
case NUEVA_BUSQUEDA:
|
||
MailingsNuevoRegistro( &SMailings );
|
||
if ( ObtenMatchMailings( /*&MMailings*/ ) != OK )
|
||
return;
|
||
MMailings = SMailings;
|
||
i = 0;
|
||
break;
|
||
case ATRAS:
|
||
case ADELANTE:
|
||
i = ( *CurrRow + *CurrMailings )+TipoBusqueda;
|
||
if ( i < 0 || i >= BMailings.Registros() ) return;
|
||
break;
|
||
}
|
||
|
||
Optar( ENCUADRE, "Comando: Buscar", "Ahora se inica", "la busqueda elegida", NULL );
|
||
enc = 0;
|
||
while ( i < BMailings.Registros() && !enc )
|
||
{
|
||
if ( BMailings.LeeReg( (void *)&SMailings, i ) == ERROR )
|
||
Error( 0x03 );
|
||
if ( Match_Mailings( SMailings, MMailings ) )
|
||
enc = 1;
|
||
else
|
||
i++;
|
||
}
|
||
|
||
Optar( ENCUADRE, NULL );
|
||
|
||
if ( enc )
|
||
{
|
||
*CurrRow = 0; *CurrMailings = i;
|
||
if ( BMailings.LeeReg( (void *)&SMailings, i ) == ERROR )
|
||
Error( 0x03 );
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosMailings( );
|
||
} else
|
||
switch( TipoBusqueda )
|
||
{
|
||
case NUEVA_BUSQUEDA:
|
||
Optar( 0, "Comando: Buscar", "No se encontr˘", "ninguna coincidencia", NULL );
|
||
break;
|
||
case ATRAS:
|
||
case ADELANTE:
|
||
Optar( 0, "Comando: Buscar", "No se encontr˘", "ninguna coincidencia", NULL );
|
||
break;
|
||
}
|
||
|
||
DibujaPantallaArticulos();
|
||
|
||
if ( BMailings.LeeReg( (void *)&SMailings, (*CurrRow + *CurrMailings) ) == ERROR )
|
||
Error( 0x03 );
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosMailings( );
|
||
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* Match_Mailings *|
|
||
|* *|
|
||
|* Descripci˘n: *|
|
||
|* Compara dos registros y devuelve la posible coincidencia *|
|
||
|* *|
|
||
|* Entradas: *|
|
||
|* Registros a comparar *|
|
||
|* *|
|
||
|* Salidas: *|
|
||
|* Resultado de la comparaci˘n *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
int Match_Mailings( MAILINGS A, MAILINGS B )
|
||
{
|
||
int enc = 1;
|
||
|
||
if ( B.NIF != '\0' )
|
||
enc = ( strncmpi( A.NIF, B.NIF, strlen( B.NIF ) ) == 0 );
|
||
|
||
if ( B.Codigo != 0 )
|
||
enc = B.Codigo == A.Codigo;
|
||
if ( B.Nombre[0] != '\0' )
|
||
enc = ( strncmpi( A.Nombre, B.Nombre, strlen( B.Nombre ) ) == 0 );
|
||
if ( B.Localidad[0] != '\0' )
|
||
enc = ( strncmpi( A.Localidad, B.Localidad, strlen( B.Localidad ) ) == 0 );
|
||
if ( B.Provincia[0] != '\0' )
|
||
enc = ( strncmpi( A.Provincia, B.Provincia, strlen( B.Provincia ) ) == 0 );
|
||
if ( B.CodPostal != 0 )
|
||
enc = A.CodPostal == B.CodPostal;
|
||
if ( B.Cod1 != 0 )
|
||
enc = A.Cod1 == B.Cod1;
|
||
if ( B.Cod2 != 0 )
|
||
enc = A.Cod2 == B.Cod2;
|
||
if ( B.Cod3 != 0 )
|
||
enc = A.Cod3 == B.Cod3;
|
||
|
||
return enc;
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* ObtenMatchMailings *|
|
||
|* *|
|
||
|* Descripci˘n: *|
|
||
|* Obtine los patrones de busqueda necesarios *|
|
||
|* *|
|
||
|* Entradas: *|
|
||
|* Estructura donde guardar el patron de busqueda *|
|
||
|* *|
|
||
|* Salidas: *|
|
||
|* OK La entrada es correcta *|
|
||
|* ERROR El usuario interrumpio la busqueda *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
int ObtenMatchMailings( /*MAILINGS *MMailings*/void )
|
||
{
|
||
struct Boton_Texto BT[6];
|
||
|
||
BT[0].x = 65; BT[0].y = 20; strcpy( BT[0].Texto, " acep&Tar "); BT[0].ID_T1 = 00; BT[0].ID_T2 = 20;
|
||
BT[1].x = 65; BT[1].y = 22; strcpy( BT[1].Texto, " &Cancelar"); BT[1].ID_T1 = 00; BT[1].ID_T2 = 46;
|
||
|
||
char Row, ok;
|
||
int BPush, key, DEV;
|
||
|
||
DibujaPantallaArticulos();
|
||
|
||
ok = 0; Row = 0;
|
||
|
||
do
|
||
{
|
||
MuestraMailings( Row, INTENSO );
|
||
BPush = Funcion_Botones(STD_BY, 2, BT);
|
||
MuestraMailings( Row, NORMAL );
|
||
|
||
switch ( BPush )
|
||
{
|
||
case 0: // No se pulso ningun BOTON
|
||
while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER
|
||
case -2:
|
||
if ( ( key = getch() ) != 13 && key != 27 )
|
||
ungetch( key );
|
||
EditItemMailings( Row );
|
||
break;
|
||
case -1:
|
||
switch ( getch() )
|
||
{
|
||
// Flecha Izquierda
|
||
case 75:
|
||
case 15:
|
||
// Flecha Arriba
|
||
case 72:
|
||
Row--; if ( Row < 0 ) Row = 11;
|
||
break;
|
||
// Flecha Derecha
|
||
case 77:
|
||
case 9:
|
||
// Flecha Abajo
|
||
case 80:
|
||
Row++; if ( Row > 11 ) Row = 0;
|
||
break;
|
||
}
|
||
break;
|
||
case 1:
|
||
DEV = OK; ok = 1;
|
||
break;
|
||
case 2:
|
||
DEV = ERROR; ok = 1;
|
||
break;
|
||
}
|
||
|
||
} while ( !ok );
|
||
|
||
return DEV;
|
||
|
||
}
|
||
|
||
|
||
|
||
void Error( int code )
|
||
{
|
||
|
||
printf( "\nSe produjo un codigo de error %d, subcodigo no disponible \n\r", code );
|
||
switch( code )
|
||
{
|
||
case 0:
|
||
printf( "\n Error incocumentado " );
|
||
break;
|
||
case 1:
|
||
printf( "\n Error abriendo " );
|
||
break;
|
||
case 2:
|
||
printf( "\n Error insertando " );
|
||
break;
|
||
case 3:
|
||
printf( "\n Error leyendo " );
|
||
break;
|
||
case 4:
|
||
printf( "\n Error escribiendo " );
|
||
break;
|
||
case 5:
|
||
printf( "\n Error borrando " );
|
||
break;
|
||
};
|
||
|
||
exit(code);
|
||
}
|
||
|
||
|