1610 lines
62 KiB
C++
1610 lines
62 KiB
C++
#include <alloc.h>
|
||
#include <conio.h>
|
||
#include <string.h>
|
||
#include <stdlib.h>
|
||
|
||
#include "d:\program\src_dos\libs\bdatos\bdatos.hh"
|
||
#include "zorr.h"
|
||
|
||
#define NLINEAS_REF 11
|
||
#define NLINEAS_REFs 6
|
||
|
||
#define ATRAS -1
|
||
#define NUEVA_BUSQUEDA 0
|
||
#define ADELANTE 1
|
||
|
||
extern int AnoActual;
|
||
|
||
BDatos BSocios; // Base de datos de Socioserencias
|
||
|
||
INFO_SOCIOS SSocios; // Estructura de referencias
|
||
|
||
int OrdenaSocios;
|
||
|
||
extern CONFIG Config;
|
||
|
||
void RastreaFicheroSocios(void);
|
||
|
||
void Error( int code );
|
||
void MuestraDatosSocios( int RowStart );
|
||
|
||
int ComparaRegistrosSocios( const void *A, const void *B );
|
||
void OrdenarComprasSocios(void);
|
||
|
||
void EditItemSocios( char columna, int linea );
|
||
void SociosNuevoRegistro( INFO_SOCIOS *MSSocios );
|
||
void MuestraSocios( char columna, int linea, char como );
|
||
void ObtenCoordenadasSocios( char columna, char linea, int *X0, int *Y0, int *X1, int *Y1 );
|
||
void OrdenarSocios(void);
|
||
|
||
void ObtenCoordenadasMatch( char Row, int *X0, int *Y0, int *X1, int *Y1 );
|
||
void MatchDrawSocios( char Row, INFO_SOCIOS MSocios, char como );
|
||
int Match_Socios( INFO_SOCIOS A, INFO_SOCIOS B );
|
||
void EditMatchSocios( char Row, INFO_SOCIOS * MSocios );
|
||
int ObtenMatchSocios( INFO_SOCIOS *MSocios );
|
||
|
||
int InsertaSocios( int pos );
|
||
void EliminaCompraSocios( int pos );
|
||
|
||
|
||
void ImprimeSocioserencias( char como );
|
||
void ImprimeCabeceraSocios( char como, FILE *file_out );
|
||
void DibujaPantallaSocios( void );
|
||
|
||
void ObtenCoordenadasMatch( char Row, int *X0, int *Y0, int *X1, int *Y1 );
|
||
void MatchDrawSocios( char Row, INFO_SOCIOS MSocios, char como ) ;
|
||
void EditMatchSocios( char Row, INFO_SOCIOS * MSocios ) ;
|
||
int ObtenMatchSocios( INFO_SOCIOS *MSocios ) ;
|
||
int Match_Socios( INFO_SOCIOS A, INFO_SOCIOS B ) ;
|
||
void BuscaSocios( char TipoBusqueda, char *CurrRow, int *CurrSocios );
|
||
|
||
|
||
void MuestraDatosComprasSocios( int RowStart );
|
||
|
||
int CurrSociosC; // Producto sobre el que estamos posicionados a golpes
|
||
|
||
|
||
// ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
|
||
// Û Parte principal del m¢dulo Û
|
||
// ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
|
||
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* InfoProducto *|
|
||
|* *|
|
||
|* Descripci¢n: *|
|
||
|* Controla la introduccion de datos y muestreo asi como todo *|
|
||
|* el interfaz de usuario... *|
|
||
|* *|
|
||
|* Entradas: (ninguna) *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void GestionSocios(void)
|
||
{
|
||
struct Boton_Texto BT[9];
|
||
long i;
|
||
int ConmutarSocios = 0;
|
||
|
||
BT[0].x = 58; BT[0].y = 1; strcpy( BT[0].Texto, " &Men£ Principal "); BT[0].ID_T1 = 0; BT[0].ID_T2 = 50;
|
||
BT[1].x = 50; BT[1].y = 3; strcpy( BT[1].Texto, " &Insertar Reg"); BT[1].ID_T1 = 0; BT[1].ID_T2 = 23;
|
||
|
||
BT[2].x = 66; BT[2].y = 3; strcpy( BT[2].Texto, " &Eliminar Reg"); BT[2].ID_T1 = 0; BT[2].ID_T2 = 18;
|
||
BT[3].x = 51; BT[3].y = 5; strcpy( BT[3].Texto, " &<--"); BT[3].ID_T1 = 0; BT[3].ID_T2 = 0;
|
||
|
||
BT[4].x = 58; BT[4].y = 5; strcpy( BT[4].Texto, " &Buscar Socio"); BT[4].ID_T1 = 0; BT[4].ID_T2 = 48;
|
||
BT[5].x = 74; BT[5].y = 5; strcpy( BT[5].Texto, " --&>"); BT[5].ID_T1 = 0; BT[5].ID_T2 = 0;
|
||
|
||
BT[6].x = 55; BT[6].y = 7; strcpy( BT[6].Texto, " &Reordenar Base de Datos"); BT[6].ID_T1 = 0; BT[6].ID_T2 = 19;
|
||
BT[7].x = 35; BT[7].y = 4; strcpy( BT[7].Texto, " &Compras Soc"); BT[7].ID_T1 = 0; BT[7].ID_T2 = 46;
|
||
BT[8].x = 32; BT[8].y = 7; strcpy( BT[8].Texto, " &Estadisticas Soc"); BT[8].ID_T1 = 0; BT[8].ID_T2 = 18;
|
||
|
||
char buffer[100], ok = 0;
|
||
int BPush, key;
|
||
|
||
char oldCol;
|
||
char CurrRow; // Linea sobre la que estamos
|
||
char CurrCol; // Columna sobre la que estamos
|
||
int CurrSocios; // Producto sobre el que estamos posicionados a golpes
|
||
int CurrTopSocios; // Producto sobre el que estamos posicionados a golpes
|
||
|
||
_setcursortype( _NOCURSOR );
|
||
DibujaPantallaSocios();
|
||
|
||
sprintf( buffer, "Socios.%03d", AnoActual );
|
||
|
||
if ( BSocios.AbrirReg( buffer, sizeof( INFO_SOCIOS ) ) == ERROR )
|
||
Error(0x01);
|
||
|
||
// Si no hay registros, creamos uno almenos.
|
||
if ( BSocios.Registros() == 0 )
|
||
{
|
||
SociosNuevoRegistro( &SSocios );
|
||
if ( BSocios.InsReg( (void *)&SSocios, BSocios.Registros(), ARRIBA ) == ERROR )
|
||
Error(0x01);
|
||
}
|
||
|
||
CurrSocios = 0; CurrRow = 0;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosSocios( CurrRow + CurrSocios );
|
||
|
||
if ( BSocios.LeeReg( (void *)&SSocios, 0 ) == ERROR )
|
||
Error(0x03);
|
||
|
||
CurrCol = 0; oldCol = -1;
|
||
CurrTopSocios = 0; CurrSociosC = SSocios.NCompras - 1;
|
||
MuestraDatosComprasSocios( SSocios.NCompras - 1 );
|
||
|
||
do {
|
||
if ( CurrCol != oldCol )
|
||
{
|
||
oldCol = CurrCol;
|
||
}
|
||
|
||
MuestraSocios( CurrCol, ( CurrCol < 6 ) ? CurrRow : CurrTopSocios, INTENSO );
|
||
BPush = Funcion_Botones(STD_BY, 9, BT);
|
||
MuestraSocios( CurrCol, ( CurrCol < 6 ) ? CurrRow : CurrTopSocios, 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 );
|
||
EditItemSocios( CurrCol, ( CurrCol < 6 ) ? CurrRow : CurrTopSocios );
|
||
_setcursortype( _NOCURSOR );
|
||
if ( BSocios.EscribeReg( (void *)&SSocios, (CurrRow + CurrSocios) ) == ERROR )
|
||
Error(0x04);
|
||
break;
|
||
case -1: // Hay una tecla especial en BUFFER
|
||
switch( getch() )
|
||
{
|
||
// Flecha Izquierda
|
||
case 75:
|
||
case 15:
|
||
CurrCol--;
|
||
if ( ConmutarSocios == 0 )
|
||
{
|
||
if ( CurrCol < 0 ) CurrCol = 5;
|
||
} else {
|
||
if ( CurrCol < 6 ) CurrCol = 7;
|
||
}
|
||
break;
|
||
// Flecha Derecha
|
||
case 77:
|
||
case 9:
|
||
CurrCol++;
|
||
if ( ConmutarSocios == 0 )
|
||
{
|
||
if ( CurrCol > 5 ) CurrCol = 0;
|
||
} else {
|
||
if ( CurrCol > 7 ) CurrCol = 6;
|
||
}
|
||
break;
|
||
// Flecha Arriba
|
||
case 72:
|
||
if ( ConmutarSocios == 0 )
|
||
{
|
||
if ( (CurrRow + CurrSocios) > 0 )
|
||
{
|
||
if ( ( CurrRow ) <= 0 )
|
||
{
|
||
CurrRow = NLINEAS_REF - 1; CurrSocios -= NLINEAS_REF;
|
||
if ( CurrSocios < 0 ) CurrSocios = 0;
|
||
|
||
while( ( CurrRow + CurrSocios ) >= BSocios.Registros() && CurrRow > 0 ) CurrRow--;
|
||
while( ( CurrRow + CurrSocios ) >= BSocios.Registros() && CurrSocios > 0 ) CurrSocios++;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosSocios( CurrSocios );
|
||
} else {
|
||
CurrRow --; if ( CurrRow < 0 ) CurrRow = 0;
|
||
}
|
||
}
|
||
|
||
if ( BSocios.LeeReg( (void *)&SSocios, (CurrSocios + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
CurrTopSocios = 0; CurrSociosC = SSocios.NCompras - 1;
|
||
MuestraDatosComprasSocios( SSocios.NCompras - 1 );
|
||
} else {
|
||
if ( (CurrSociosC + CurrTopSocios) > 0 )
|
||
{
|
||
if ( ( CurrTopSocios ) <= 0 )
|
||
{
|
||
CurrTopSocios = NLINEAS_REFs - 1; CurrSociosC -= NLINEAS_REFs;
|
||
if ( CurrSociosC < 0 ) CurrSociosC = 0;
|
||
|
||
while( ( CurrTopSocios + CurrSociosC ) >= SSocios.NCompras && CurrTopSocios > 0 ) CurrTopSocios--;
|
||
while( ( CurrTopSocios + CurrSociosC ) >= SSocios.NCompras && CurrSociosC > 0 ) CurrSociosC++;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosComprasSocios( CurrSociosC );
|
||
} else {
|
||
CurrTopSocios --; if ( CurrTopSocios < 0 ) CurrTopSocios = 0;
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
// Flecha Abajo
|
||
case 80:
|
||
if ( ConmutarSocios == 0 )
|
||
{
|
||
if ( ( CurrRow + CurrSocios ) < BSocios.Registros() - 1 )
|
||
{
|
||
|
||
if ( ( CurrRow ) >= NLINEAS_REF - 1 )
|
||
{
|
||
CurrRow = 0; CurrSocios += NLINEAS_REF;
|
||
|
||
while ( (CurrSocios + CurrRow) >= BSocios.Registros() ) CurrSocios--;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosSocios( CurrSocios );
|
||
} else
|
||
CurrRow++;
|
||
}
|
||
if ( BSocios.LeeReg( (void *)&SSocios, (CurrSocios + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
CurrTopSocios = 0; CurrSociosC = SSocios.NCompras - 1;
|
||
MuestraDatosComprasSocios( SSocios.NCompras - 1 );
|
||
} else {
|
||
if ( ( CurrTopSocios + CurrSociosC ) < SSocios.NCompras - 1 )
|
||
{
|
||
|
||
if ( ( CurrTopSocios ) >= NLINEAS_REFs - 1 )
|
||
{
|
||
CurrTopSocios = 0; CurrSociosC += NLINEAS_REFs;
|
||
|
||
while ( (CurrSociosC + CurrTopSocios) >= SSocios.NCompras ) CurrSocios--;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosComprasSocios( CurrSociosC );
|
||
} else
|
||
CurrTopSocios++;
|
||
}
|
||
}
|
||
break;
|
||
// Inicio
|
||
case 71:
|
||
if ( ConmutarSocios == 0 )
|
||
{
|
||
CurrRow = 0;
|
||
if ( CurrSocios != 0 )
|
||
{
|
||
CurrSocios = 0;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosSocios( CurrSocios );
|
||
}
|
||
|
||
if ( BSocios.LeeReg( (void *)&SSocios, (CurrSocios + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
CurrTopSocios = 0; CurrSociosC = SSocios.NCompras - 1;
|
||
MuestraDatosComprasSocios( SSocios.NCompras - 1 );
|
||
} else {
|
||
CurrTopSocios = CurrSociosC = 0;
|
||
MuestraDatosComprasSocios( 0 );
|
||
}
|
||
break;
|
||
// Fin
|
||
case 79:
|
||
if ( ConmutarSocios == 0 )
|
||
{
|
||
CurrRow = 0;
|
||
if ( CurrSocios != BSocios.Registros() - NLINEAS_REF )
|
||
{
|
||
CurrSocios = BSocios.Registros() - NLINEAS_REF;
|
||
while( CurrSocios >= BSocios.Registros() ) CurrSocios--;
|
||
if ( CurrSocios < 0 ) {
|
||
CurrSocios = 0;
|
||
CurrRow = BSocios.Registros()-1;
|
||
}
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosSocios( CurrSocios );
|
||
}
|
||
|
||
if ( BSocios.LeeReg( (void *)&SSocios, (CurrSocios + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
CurrTopSocios = 0; CurrSociosC = SSocios.NCompras - 1;
|
||
MuestraDatosComprasSocios( SSocios.NCompras - 1 );
|
||
} else {
|
||
CurrTopSocios = 0;
|
||
CurrSociosC = SSocios.NCompras - 1;
|
||
MuestraDatosComprasSocios( CurrSociosC );
|
||
}
|
||
|
||
break;
|
||
// AvanceR pido
|
||
case 81:
|
||
if ( ConmutarSocios == 0 )
|
||
{
|
||
CurrRow = 0; CurrSocios += NLINEAS_REF;
|
||
|
||
while ( (CurrSocios + CurrRow) >= BSocios.Registros() ) CurrSocios--;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosSocios( CurrSocios );
|
||
if ( BSocios.LeeReg( (void *)&SSocios, (CurrSocios + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
CurrTopSocios = 0; CurrSociosC = SSocios.NCompras - 1;
|
||
MuestraDatosComprasSocios( SSocios.NCompras - 1 );
|
||
} else {
|
||
CurrTopSocios = 0; CurrSociosC += NLINEAS_REFs;
|
||
|
||
while ( (CurrSociosC + CurrTopSocios) >= SSocios.NCompras ) CurrSociosC--;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosComprasSocios( CurrSociosC );
|
||
}
|
||
break;
|
||
// Retroceso R pido
|
||
case 73:
|
||
if ( ConmutarSocios == 0 )
|
||
{
|
||
CurrRow = NLINEAS_REF - 1; CurrSocios -= NLINEAS_REF;
|
||
if ( CurrSocios < 0 ) CurrSocios = 0;
|
||
|
||
while( ( CurrRow + CurrSocios ) >= BSocios.Registros() && CurrRow > 0 ) CurrRow--;
|
||
while( ( CurrRow + CurrSocios ) >= BSocios.Registros() && CurrSocios > 0 ) CurrSocios++;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosSocios( CurrSocios );
|
||
if ( BSocios.LeeReg( (void *)&SSocios, (CurrSocios + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
CurrTopSocios = 0; CurrSociosC = SSocios.NCompras - 1;
|
||
MuestraDatosComprasSocios( SSocios.NCompras - 1 );
|
||
}else{
|
||
CurrTopSocios = NLINEAS_REFs - 1; CurrSociosC -= NLINEAS_REFs;
|
||
if ( CurrSociosC < 0 ) CurrSociosC = 0;
|
||
|
||
while( ( CurrTopSocios + CurrSociosC ) >= SSocios.NCompras && CurrTopSocios > 0 ) CurrTopSocios--;
|
||
while( ( CurrTopSocios + CurrSociosC ) >= SSocios.NCompras && CurrSociosC > 0 ) CurrSociosC++;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosComprasSocios( CurrSociosC );
|
||
}
|
||
break;
|
||
|
||
}
|
||
break;
|
||
// Menu Principal
|
||
case 1:
|
||
ok = 1;
|
||
break;
|
||
// Eliminar
|
||
case 3:
|
||
while( kbhit() ) getch();
|
||
if ( ConmutarSocios == 0 )
|
||
{
|
||
if ( Optar( 1, "ATENCION", "Eliminar un gasto interno", "confirme eliminacion", NULL ) )
|
||
{
|
||
if ( BSocios.DelReg( CurrSocios + CurrRow ) == ERROR )
|
||
Error(0x05);
|
||
if ( BSocios.Registros() == 0 )
|
||
{
|
||
SociosNuevoRegistro( &SSocios );
|
||
if ( BSocios.InsReg( (void *)&SSocios, BSocios.Registros(), ARRIBA ) == ERROR )
|
||
Error(0x02);
|
||
CurrRow = 0;
|
||
} else
|
||
|
||
// Si he borrado el £ltimo registro subo una linea
|
||
if ( (CurrSocios+CurrRow) >= ( BSocios.Registros() - 2 ) )
|
||
{
|
||
if ( (CurrRow + CurrSocios) > 0 )
|
||
{
|
||
if ( ( CurrRow ) <= 0 )
|
||
{
|
||
CurrRow = NLINEAS_REF - 1; CurrSocios -= NLINEAS_REF;
|
||
if ( CurrSocios < 0 ) CurrSocios = 0;
|
||
|
||
while( ( CurrRow + CurrSocios ) >= BSocios.Registros() && CurrRow > 0 ) CurrRow--;
|
||
while( ( CurrRow + CurrSocios ) >= BSocios.Registros() && CurrSocios > 0 ) CurrSocios++;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosSocios( CurrSocios );
|
||
} else {
|
||
CurrRow --; if ( CurrRow < 0 ) CurrRow = 0;
|
||
}
|
||
}
|
||
|
||
if ( BSocios.LeeReg( (void *)&SSocios, (CurrSocios + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
}
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosSocios( CurrSocios );
|
||
if ( BSocios.LeeReg( (void *)&SSocios, (CurrSocios + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
}
|
||
CurrTopSocios = 0; CurrSociosC = SSocios.NCompras - 1;
|
||
MuestraDatosComprasSocios( SSocios.NCompras - 1 );
|
||
} else {
|
||
if ( Optar( 1, "ATENCION", "Eliminar un la compra", "de uno de sus clientes", NULL ) )
|
||
{
|
||
EliminaCompraSocios( CurrSociosC + CurrTopSocios );
|
||
if ( BSocios.EscribeReg( (void *)&SSocios, (CurrRow + CurrSocios) ) == ERROR )
|
||
Error(0x04);
|
||
|
||
if ( SSocios.NCompras == 0 )
|
||
{
|
||
InsertaSocios( SSocios.NCompras );
|
||
if ( BSocios.EscribeReg( (void *)&SSocios, (CurrRow + CurrSocios) ) == ERROR )
|
||
Error(0x04);
|
||
CurrTopSocios = 0;
|
||
} else
|
||
|
||
// Si he borrado el £ltimo registro subo una linea
|
||
if ( (CurrSociosC+CurrTopSocios) >= ( SSocios.NCompras - 2 ) )
|
||
{
|
||
if ( (CurrTopSocios + CurrSociosC) > 0 )
|
||
{
|
||
if ( ( CurrTopSocios ) <= 0 )
|
||
{
|
||
CurrTopSocios = NLINEAS_REFs - 1; CurrSociosC -= NLINEAS_REFs;
|
||
if ( CurrSociosC < 0 ) CurrSociosC = 0;
|
||
|
||
while( ( CurrTopSocios + CurrSociosC ) >= SSocios.NCompras && CurrTopSocios > 0 ) CurrTopSocios--;
|
||
while( ( CurrTopSocios + CurrSociosC ) >= SSocios.NCompras && CurrSociosC > 0 ) CurrSociosC++;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosComprasSocios( CurrSociosC );
|
||
} else {
|
||
CurrTopSocios --; if ( CurrTopSocios < 0 ) CurrTopSocios = 0;
|
||
}
|
||
}
|
||
}
|
||
|
||
if ( BSocios.EscribeReg( (void *)&SSocios, (CurrRow + CurrSocios) ) == ERROR )
|
||
Error(0x04);
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosComprasSocios( CurrSociosC );
|
||
}
|
||
|
||
}
|
||
break;
|
||
// Insertar
|
||
case 2:
|
||
if ( ConmutarSocios == 0 )
|
||
{
|
||
SociosNuevoRegistro( &SSocios );
|
||
if ( BSocios.InsReg( (void *)&SSocios, (CurrSocios + CurrRow), ARRIBA ) == ERROR )
|
||
Error(0x02);
|
||
if ( ( CurrRow + CurrSocios ) < BSocios.Registros() - 1 )
|
||
{
|
||
|
||
if ( ( CurrRow ) >= NLINEAS_REF - 1 )
|
||
{
|
||
CurrRow = 0; CurrSocios += NLINEAS_REF;
|
||
|
||
while ( (CurrSocios + CurrRow) >= BSocios.Registros() ) CurrSocios--;
|
||
|
||
} else
|
||
CurrRow++;
|
||
}
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosSocios( CurrSocios );
|
||
if ( BSocios.LeeReg( (void *)&SSocios, (CurrSocios + CurrRow) ) == ERROR )
|
||
Error(0x03);
|
||
CurrTopSocios = 0; CurrSociosC = SSocios.NCompras - 1;
|
||
MuestraDatosComprasSocios( SSocios.NCompras - 1 );
|
||
} else {
|
||
if ( InsertaSocios( (CurrSociosC + CurrTopSocios) ) != ERROR )
|
||
{
|
||
if ( ( CurrTopSocios + CurrSociosC ) < SSocios.NCompras - 1 )
|
||
{
|
||
|
||
if ( ( CurrTopSocios ) >= NLINEAS_REFs - 1 )
|
||
{
|
||
CurrTopSocios = 0; CurrSociosC += NLINEAS_REFs;
|
||
|
||
while ( (CurrSociosC + CurrTopSocios) >= SSocios.NCompras ) CurrSociosC--;
|
||
|
||
} else
|
||
CurrTopSocios++;
|
||
}
|
||
|
||
if ( BSocios.EscribeReg( (void *)&SSocios, (CurrRow + CurrSocios) ) == ERROR )
|
||
Error(0x04);
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosComprasSocios( CurrSociosC );
|
||
}
|
||
}
|
||
break;
|
||
|
||
// Ordenar
|
||
case 7:
|
||
if ( ConmutarSocios == 0 )
|
||
{
|
||
OrdenarSocios();
|
||
|
||
CurrSocios = 0; CurrRow = 0;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosSocios( CurrRow + CurrSocios );
|
||
if ( BSocios.LeeReg( (void *)&SSocios, 0 ) == ERROR )
|
||
Error(0x03);
|
||
CurrCol = 0;
|
||
CurrTopSocios = 0; CurrSociosC = SSocios.NCompras - 1;
|
||
MuestraDatosComprasSocios( SSocios.NCompras - 1 );
|
||
} else {
|
||
OrdenarComprasSocios();
|
||
MuestraDatosComprasSocios( CurrTopSocios + CurrSociosC );
|
||
|
||
}
|
||
break;
|
||
// Conmutar
|
||
case 8:
|
||
ConmutarSocios = !ConmutarSocios;
|
||
if ( ConmutarSocios == 0 ) CurrCol = 0 ; else CurrCol = 6;
|
||
break;
|
||
// Rastrear
|
||
case 9:
|
||
RastreaFicheroSocios();
|
||
break;
|
||
|
||
|
||
default:
|
||
while( kbhit() ) getch();
|
||
break;
|
||
// Busqueda Atras
|
||
case 4:
|
||
BuscaSocios( ATRAS, &CurrRow, &CurrSocios );
|
||
break;
|
||
// Buscar
|
||
case 5:
|
||
BuscaSocios( NUEVA_BUSQUEDA, &CurrRow, &CurrSocios );
|
||
break;
|
||
// Busqueda Adelante
|
||
case 6:
|
||
BuscaSocios( ADELANTE, &CurrRow, &CurrSocios );
|
||
break;
|
||
}
|
||
|
||
} while( !ok );
|
||
|
||
BSocios.CerrarReg();
|
||
}
|
||
|
||
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* MuestraDatosSocios *|
|
||
|* *|
|
||
|* 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 MuestraDatosSocios( int RowStart )
|
||
{
|
||
int linea, campo;
|
||
char dev;
|
||
|
||
// Imprimo la NLINEAS_REF que caben en la pantalla
|
||
dev = OK;
|
||
for ( linea=0; linea < NLINEAS_REF && dev == OK; linea++ )
|
||
{
|
||
dev = BSocios.LeeReg( (void *)&SSocios, RowStart + linea );
|
||
if ( dev == OK )
|
||
|
||
// Por cada linea hay 6 campos, ehhh!!!
|
||
for ( campo=0; campo < 6; campo++ )
|
||
MuestraSocios( campo, linea, NORMAL );
|
||
}
|
||
|
||
// Ahora limpio los restantes huecos si los hay
|
||
if ( dev != OK )
|
||
{
|
||
linea--;
|
||
|
||
textbackground( BLACK );
|
||
textcolor( WHITE );
|
||
for ( ; linea < NLINEAS_REF; linea++ )
|
||
for ( campo=0; campo < 6; campo++ )
|
||
{
|
||
gotoxy( 1, linea + 13 );
|
||
cprintf( "³ ³ ³ ³ ³ ³");
|
||
}
|
||
}
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* MuestraDatosComprasSocios *|
|
||
|* *|
|
||
|* 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 MuestraDatosComprasSocios( int RowStart )
|
||
{
|
||
int linea, campo;
|
||
char dev;
|
||
|
||
// Imprimo la NLINEAS_REF que caben en la pantalla
|
||
dev = OK;
|
||
for ( linea=0; linea < 6 && dev == OK; linea++ )
|
||
{
|
||
dev = ( RowStart + linea ) < SSocios.NCompras ? OK : ERROR;
|
||
|
||
if ( dev == OK )
|
||
|
||
// Por cada linea hay 2 campos, ehhh!!!
|
||
for ( campo=6; campo < 8; campo++ )
|
||
MuestraSocios( campo, linea, NORMAL );
|
||
}
|
||
|
||
// Ahora limpio los restantes huecos si los hay
|
||
if ( dev != OK )
|
||
{
|
||
linea--;
|
||
|
||
textbackground( BLACK );
|
||
textcolor( WHITE );
|
||
for ( ; linea < 6; linea++ )
|
||
for ( campo=6; campo < 8; campo++ )
|
||
{
|
||
gotoxy( 1, linea + 3 );
|
||
cprintf( "³ ³ ³");
|
||
}
|
||
}
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* MuestraSocios *|
|
||
|* *|
|
||
|* 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 MuestraSocios( char columna, int linea, char como )
|
||
{
|
||
char buffer[80];
|
||
char buffer1[80];
|
||
|
||
int X0, Y0, X1, Y1;
|
||
|
||
ObtenCoordenadasSocios( columna, linea, &X0, &Y0, &X1, &Y1 );
|
||
|
||
switch( columna )
|
||
{
|
||
// N§ Socio
|
||
case 0:
|
||
sprintf ( buffer, " %04ld ", SSocios.NSocio );
|
||
break;
|
||
// Nombre
|
||
case 1:
|
||
sprintf ( buffer, "%15s", SSocios.Nombre );
|
||
break;
|
||
// Apellido
|
||
case 2:
|
||
sprintf ( buffer, "%20s", SSocios.Apellido );
|
||
break;
|
||
// Direccion
|
||
case 3:
|
||
sprintf ( buffer, "%25s", SSocios.Direccion );
|
||
break;
|
||
// N§
|
||
case 4:
|
||
sprintf ( buffer, "%3d", SSocios.Num );
|
||
break;
|
||
// Piso
|
||
case 5:
|
||
sprintf ( buffer, "%4s", SSocios.Piso );
|
||
break;
|
||
|
||
|
||
// A partir de aqui corresponde a las compras del socio...
|
||
// Fecha
|
||
case 6:
|
||
sprintf ( buffer, " %02d-%02d-%02d ", (int)SSocios.CSocios[CurrSociosC+linea].dia, (int)SSocios.CSocios[CurrSociosC+linea].mes, AnoActual );
|
||
break;
|
||
// Cantidad
|
||
case 7:
|
||
formatea_u_long( SSocios.CSocios[CurrSociosC+linea].Cantidad, buffer1 );
|
||
sprintf ( buffer, " %10s ", buffer1 );
|
||
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 );
|
||
|
||
}
|
||
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* EditItemSocios *|
|
||
|* *|
|
||
|* 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 EditItemSocios( char columna, int linea )
|
||
{
|
||
char buffer[80];
|
||
|
||
int X0, Y0, X1, Y1;
|
||
|
||
ObtenCoordenadasSocios( columna, linea, &X0, &Y0, &X1, &Y1 );
|
||
|
||
switch( columna )
|
||
{
|
||
// Numero de Socio
|
||
case 0:
|
||
sprintf ( buffer, "%ld", SSocios.NSocio );
|
||
if ( !( InputCadenaG( buffer, 1, 4, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
SSocios.NSocio = atol( buffer );
|
||
break;
|
||
// Nombre
|
||
case 1:
|
||
strcpy ( buffer, SSocios.Nombre );
|
||
if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SSocios.Nombre, buffer );
|
||
break;
|
||
// Apellido
|
||
case 2:
|
||
strcpy ( buffer, SSocios.Apellido );
|
||
if ( !( InputCadenaG( buffer, 0, 20, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SSocios.Apellido, buffer );
|
||
break;
|
||
// Direccion
|
||
case 3:
|
||
strcpy ( buffer, SSocios.Direccion );
|
||
if ( !( InputCadenaG( buffer, 0, 25, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SSocios.Direccion, buffer );
|
||
break;
|
||
// N§
|
||
case 4:
|
||
sprintf ( buffer, "%d", SSocios.Num );
|
||
if ( !( InputCadenaG( buffer, 1, 2, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
SSocios.Num = atoi( buffer );
|
||
break;
|
||
// Piso
|
||
case 5:
|
||
strcpy ( buffer, SSocios.Piso );
|
||
if ( !( InputCadenaG( buffer, 0, 4, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SSocios.Piso, buffer );
|
||
break;
|
||
|
||
|
||
|
||
// Apartir de aqui empiezan los gatos de los socios
|
||
// Fecha
|
||
case 6:
|
||
sprintf ( buffer, "%02d%02d", (int)SSocios.CSocios[CurrSociosC+linea].dia, (int)SSocios.CSocios[CurrSociosC+linea].mes );
|
||
if ( !( InputCadenaG( buffer, 1, 4, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
if ( atol(buffer)!=0 && ( (buffer[0]-'0')*10 + (buffer[1]-'0') ) <= 31 && ( (buffer[2]-'0')*10 + (buffer[3]-'0') ) <= 12 )
|
||
{
|
||
SSocios.CSocios[CurrSociosC+linea].dia = (char)((buffer[0]-'0')*10 + (buffer[1]-'0'));
|
||
SSocios.CSocios[CurrSociosC+linea].mes = (char)((buffer[2]-'0')*10 + (buffer[3]-'0'));
|
||
}
|
||
break;
|
||
// Cantidad
|
||
case 7:
|
||
sprintf ( buffer, "%ld", SSocios.CSocios[CurrSociosC+linea].Cantidad );
|
||
if ( !( InputCadenaG( buffer, 0, 6, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
SSocios.CSocios[CurrSociosC+linea].Cantidad = atol( buffer );
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* ObtenCoordenadasSocios *|
|
||
|* *|
|
||
|* 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 ObtenCoordenadasSocios( char columna, char linea, int *X0, int *Y0, int *X1, int *Y1 )
|
||
{
|
||
|
||
if ( columna < 6 )
|
||
{
|
||
*Y0 = 13 + linea;
|
||
*Y1 = 13 + linea;
|
||
} else {
|
||
*Y0 = 3 + linea;
|
||
*Y1 = 3 + linea;
|
||
}
|
||
|
||
switch( columna )
|
||
{
|
||
case 0:
|
||
*X0 = 2; *X1 = 6;
|
||
break;
|
||
case 1:
|
||
*X0 = 9; *X1 = 15;
|
||
break;
|
||
case 2:
|
||
*X0 = 25; *X1 = 20;
|
||
break;
|
||
case 3:
|
||
*X0 = 46; *X1 = 25;
|
||
break;
|
||
case 4:
|
||
*X0 = 72; *X1 = 3;
|
||
break;
|
||
case 5:
|
||
*X0 = 76; *X1 = 4;
|
||
break;
|
||
|
||
case 6:
|
||
*X0 = 2; *X1 = 10;
|
||
break;
|
||
case 7:
|
||
*X0 = 13; *X1 = 13;
|
||
break;
|
||
|
||
|
||
}
|
||
|
||
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* SociosNuevoRegistro *|
|
||
|* *|
|
||
|* Descripci¢n: *|
|
||
|* Limpia el buffer, para un nuevo registro. *|
|
||
|* *|
|
||
|* Entradas: (ninguna) *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void SociosNuevoRegistro( INFO_SOCIOS *NSSocios )
|
||
{
|
||
int i;
|
||
|
||
NSSocios -> NSocio = 0;
|
||
NSSocios -> Nombre[0] = '\0';
|
||
NSSocios -> Apellido[0] = '\0';
|
||
NSSocios -> Direccion[0] = '\0';
|
||
NSSocios -> Num = 0;
|
||
NSSocios -> Piso[0] = '\0';
|
||
|
||
NSSocios -> NCompras = 1;
|
||
|
||
for ( i = 0; i < 240; i++ )
|
||
{
|
||
NSSocios -> CSocios[i].dia = 0;
|
||
NSSocios -> CSocios[i].mes = 0;
|
||
NSSocios -> CSocios[i].Cantidad = 0;
|
||
}
|
||
NSSocios -> CSocios[0].dia = 0;
|
||
NSSocios -> CSocios[0].mes = 0;
|
||
NSSocios -> CSocios[0].Cantidad = 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) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* ImprimeSocioserencias *|
|
||
|* *|
|
||
|* Descripci¢n: *|
|
||
|* Imprime todas las referencias seg£n se le indique *|
|
||
|* *|
|
||
|* Entradas: *|
|
||
|* Como imprimir las referencias *|
|
||
|* *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void ImprimeSocioserencias( char como )
|
||
{
|
||
long i, old_reg;
|
||
FILE *file_out;
|
||
|
||
old_reg = BSocios.RegActual();
|
||
|
||
if ( !Config.Printer )
|
||
{
|
||
if ( ( file_out = fopen( Config.PrintTo, "w" ) ) == NULL )
|
||
return;
|
||
} else
|
||
file_out = stdprn;
|
||
|
||
ImprimeCabeceraSocios( como, file_out );
|
||
|
||
for ( i=0; i<BSocios.Registros(); i++ )
|
||
{
|
||
BSocios.LeeReg( (void *)&SSocios, i );
|
||
switch( como )
|
||
{
|
||
/*
|
||
// Listado R pido
|
||
case 1:
|
||
|
||
formatea_u_long( (unsigned long)SSocios.CantUnitaria, buffer );
|
||
fprintf( file_out, "%9lu %-30s %-6s ", SSocios.CodigoR, SSocios.Descripcion, buffer );
|
||
formatea_u_long( (unsigned long)SSocios.PrecioCosto, buffer );
|
||
fprintf( file_out, "%-7s ", buffer );
|
||
formatea_u_long( (unsigned long)SSocios.PrecioVenta[0], buffer );
|
||
fprintf( file_out, "%-7s %-10s\n\r", buffer, SSocios.Combinado ? "Combinado" : "" );
|
||
break;
|
||
// Listado Completo
|
||
case 2:
|
||
formatea_u_long( (unsigned long)SSocios.CantUnitaria, buffer );
|
||
fprintf( file_out, "%9lu %-30s %-6s ", SSocios.CodigoR, SSocios.Descripcion, buffer );
|
||
formatea_u_long( (unsigned long)SSocios.PrecioCosto, buffer );
|
||
fprintf( file_out, "%-7s ", buffer );
|
||
formatea_u_long( (unsigned long)SSocios.PrecioVenta[0], buffer );
|
||
fprintf( file_out, "%-7s %-10s\n\r", buffer, SSocios.Combinado ? "Combinado" : "" );
|
||
if ( SSocios.Combinado )
|
||
{
|
||
for ( j=0; j<10; j++ )
|
||
if ( SSocios.CodigosAsociados[j] != 0 )
|
||
fprintf( file_out, " %-7s %9lu", j < 4 ? SSocios.PrecioVenta[j+1] : 0, SSocios.CodigosAsociados[j] );
|
||
}
|
||
break;
|
||
// C¢digos de barra
|
||
case 3:
|
||
break;
|
||
*/
|
||
}
|
||
}
|
||
|
||
if ( !Config.Printer )
|
||
fclose( file_out );
|
||
|
||
BSocios.LeeReg( (void *)&SSocios, old_reg );
|
||
|
||
}
|
||
|
||
void ImprimeCabeceraSocios( 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 DibujaPantallaSocios(void)
|
||
{
|
||
textcolor( WHITE );
|
||
textbackground( BLACK );
|
||
|
||
|
||
cprintf( "\r");
|
||
|
||
cprintf( "³ Fecha ³ Importe ³ \r");
|
||
cprintf( "ÃÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄ´ \r");
|
||
cprintf( "³ ³ ³ \r");
|
||
cprintf( "³ ³ ³ \r");
|
||
cprintf( "³ ³ ³-------- \r");
|
||
cprintf( "³ ³ ³ / \r");
|
||
cprintf( "³ ³ ³ / \r");
|
||
cprintf( "³ ³ ³ / \r");
|
||
cprintf( "ÀÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÙ/ \r");
|
||
cprintf( "ÚÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÂÄÄÄÄ¿\r");
|
||
cprintf( "³N§ Soc³ Nombre Apellidos ³ Direcci¢n ³N§ ³Piso³\r");
|
||
cprintf( "ÃÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÅÄÄÄÄ´\r");
|
||
cprintf( "³ ³ ³ ³ ³ ³\r");
|
||
cprintf( "³ ³ ³ ³ ³ ³\r");
|
||
cprintf( "³ ³ ³ ³ ³ ³\r");
|
||
cprintf( "³ ³ ³ ³ ³ ³\r");
|
||
cprintf( "³ ³ ³ ³ ³ ³\r");
|
||
cprintf( "³ ³ ³ ³ ³ ³\r");
|
||
cprintf( "³ ³ ³ ³ ³ ³\r");
|
||
cprintf( "³ ³ ³ ³ ³ ³\r");
|
||
cprintf( "³ ³ ³ ³ ³ ³\r");
|
||
cprintf( "³ ³ ³ ³ ³ ³\r");
|
||
cprintf( "³ ³ ³ ³ ³ ³\r");
|
||
cprintf( "ÀÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÁÄÄÄÄÙ");
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
void RastreaFicheroSocios(void)
|
||
{
|
||
char buffer[80], ok = 0, dev;
|
||
char buffer1[80];
|
||
int Proveedor; long i;
|
||
long old_pos;
|
||
|
||
long Meses[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||
char MesesF[12][80];
|
||
|
||
Optar( ENCUADRE, "Realizando rastreo...", "Esto puede tardar unos", "minutos, por favor, epere...", NULL );
|
||
|
||
|
||
|
||
old_pos = BSocios.RegActual();
|
||
|
||
dev = OK;
|
||
for ( i=0; i < SSocios.NCompras; i++ )
|
||
{
|
||
if ( SSocios.CSocios[i].mes > 0 && SSocios.CSocios[i].mes <= 12 )
|
||
Meses[ SSocios.CSocios[i].mes - 1 ] += SSocios.CSocios[i].Cantidad;
|
||
}
|
||
|
||
for( i = 0; i < 6; i++ )
|
||
{
|
||
formatea_u_long( Meses[i], buffer );
|
||
formatea_u_long( Meses[i+6], buffer1);
|
||
switch( i )
|
||
{
|
||
case 0: sprintf( MesesF[i], "Enero: %10s Julio: %10s", buffer, buffer1 ); break;
|
||
case 1: sprintf( MesesF[i], "Febrero:%10s Agosto: %10s", buffer, buffer1 ); break;
|
||
case 2: sprintf( MesesF[i], "Marzo: %10s Septiembre: %10s", buffer, buffer1 ); break;
|
||
case 3: sprintf( MesesF[i], "Abril: %10s Octubre: %10s", buffer, buffer1 ); break;
|
||
case 4: sprintf( MesesF[i], "Mayo: %10s Noviembre: %10s", buffer, buffer1 ); break;
|
||
case 5: sprintf( MesesF[i], "Junio: %10s Diciembre: %10s", buffer, buffer1 ); break;
|
||
}
|
||
}
|
||
|
||
|
||
Optar( ENCUADRE, NULL );
|
||
|
||
Optar( 0, "Ratreo concluido", MesesF[0], MesesF[1], MesesF[2], MesesF[3], MesesF[4], MesesF[5], NULL );
|
||
while( kbhit() ) getch();
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
void OrdenarSocios(void)
|
||
{
|
||
/*
|
||
BDatos BSocios; // Base de datos de Socioserencias
|
||
INFO_SOCIOS SSocios; // Estructura de referencias
|
||
|
||
int OrdenaSocios;
|
||
*/
|
||
struct Boton_Texto BT[4];
|
||
int devolver;
|
||
|
||
BT[0].x = 32; BT[0].y = 9; strcpy( BT[0].Texto, " &N£mero de Socio "); BT[0].ID_T1 = 0; BT[0].ID_T2 = 0;
|
||
BT[1].x = 32; BT[1].y = 11; strcpy( BT[1].Texto, " &Nombre y Apellidos"); BT[1].ID_T1 = 0; BT[1].ID_T2 = 0;
|
||
BT[2].x = 32; BT[2].y = 13; strcpy( BT[2].Texto, " &Direcci¢n "); BT[2].ID_T1 = 0; BT[2].ID_T2 = 30;
|
||
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 )
|
||
{
|
||
OrdenaSocios = devolver;
|
||
BSocios.SortReg( ComparaRegistrosSocios );
|
||
}
|
||
|
||
Optar( ENCUADRE, NULL );
|
||
|
||
}
|
||
|
||
|
||
int ComparaRegistrosSocios( const void *A, const void *B )
|
||
{
|
||
int dev;
|
||
|
||
// Tipos de ordenaciones posibles
|
||
switch( OrdenaSocios )
|
||
{
|
||
// Por N§ de Socio
|
||
case 1:
|
||
if ( ( ((INFO_SOCIOS *)A) -> NSocio ) < ( ((INFO_SOCIOS *)B) -> NSocio ) ) return -1;
|
||
if ( ( ((INFO_SOCIOS *)A) -> NSocio ) == ( ((INFO_SOCIOS *)B) -> NSocio ) ) return 0;
|
||
if ( ( ((INFO_SOCIOS *)A) -> NSocio ) > ( ((INFO_SOCIOS *)B) -> NSocio ) ) return 1;
|
||
break;
|
||
// Por Nombre y Apellido
|
||
case 2:
|
||
dev = strcmpi( ( ((INFO_SOCIOS *)A) -> Nombre ), ( ((INFO_SOCIOS *)B) -> Nombre ) );
|
||
if ( dev == 0 )
|
||
dev = strcmpi( ( ((INFO_SOCIOS *)A) -> Apellido ), ( ((INFO_SOCIOS *)B) -> Apellido ) );
|
||
return dev;
|
||
// Direccion
|
||
case 3:
|
||
return strcmpi( ( ((INFO_SOCIOS *)A) -> Direccion ), ( ((INFO_SOCIOS *)B) -> Direccion ) );
|
||
// Fecha
|
||
case 4:
|
||
if ( ( ((struct ComprasSocios *)A) -> mes ) < ( ((struct ComprasSocios *)B) -> mes ) ) return -1;
|
||
if ( ( ((struct ComprasSocios *)A) -> mes ) > ( ((struct ComprasSocios *)B) -> mes ) ) return 1;
|
||
|
||
if ( ( ((struct ComprasSocios *)A) -> dia ) < ( ((struct ComprasSocios *)B) -> dia ) ) return -1;
|
||
if ( ( ((struct ComprasSocios *)A) -> dia ) > ( ((struct ComprasSocios *)B) -> dia ) ) return 1;
|
||
return 0;
|
||
// Cantidad
|
||
case 5:
|
||
if ( ( ((struct ComprasSocios *)A) -> Cantidad ) < ( ((struct ComprasSocios *)B) -> Cantidad ) ) return -1;
|
||
if ( ( ((struct ComprasSocios *)A) -> Cantidad ) == ( ((struct ComprasSocios *)B) -> Cantidad ) ) return 0;
|
||
if ( ( ((struct ComprasSocios *)A) -> Cantidad ) > ( ((struct ComprasSocios *)B) -> Cantidad ) ) return 1;
|
||
break;
|
||
|
||
|
||
}
|
||
|
||
return -1;
|
||
}
|
||
|
||
|
||
|
||
int InsertaSocios( int pos )
|
||
{
|
||
int avance;
|
||
|
||
if ( pos > 238 )
|
||
return ERROR;
|
||
|
||
SSocios.NCompras ++;
|
||
|
||
avance = SSocios.NCompras - 1;
|
||
|
||
while( avance > pos )
|
||
{
|
||
SSocios.CSocios[avance].dia = SSocios.CSocios[ avance - 1 ].dia;
|
||
SSocios.CSocios[avance].mes = SSocios.CSocios[ avance - 1 ].mes;
|
||
SSocios.CSocios[avance].Cantidad = SSocios.CSocios[ avance - 1 ].Cantidad;
|
||
avance--;
|
||
}
|
||
|
||
SSocios.CSocios[pos+1].dia = 0;
|
||
SSocios.CSocios[pos+1].mes = 0;
|
||
SSocios.CSocios[pos+1].Cantidad = 0;
|
||
|
||
return OK;
|
||
|
||
}
|
||
|
||
void EliminaCompraSocios( int pos )
|
||
{
|
||
int avance;
|
||
|
||
SSocios.NCompras --;
|
||
|
||
if ( SSocios.NCompras < 0 )
|
||
{
|
||
SSocios.NCompras = 1;
|
||
SSocios.CSocios[0].dia = 0;
|
||
SSocios.CSocios[0].mes = 0;
|
||
SSocios.CSocios[0].Cantidad = 0;
|
||
} else {
|
||
avance = pos;
|
||
|
||
while( avance < SSocios.NCompras )
|
||
{
|
||
SSocios.CSocios[avance].dia = SSocios.CSocios[ avance + 1 ].dia;
|
||
SSocios.CSocios[avance].mes = SSocios.CSocios[ avance + 1 ].mes;
|
||
SSocios.CSocios[avance].Cantidad = SSocios.CSocios[ avance + 1 ].Cantidad;
|
||
avance++;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
void OrdenarComprasSocios(void)
|
||
{
|
||
struct Boton_Texto BT[4];
|
||
int devolver;
|
||
|
||
BT[0].x = 32; BT[0].y = 9; strcpy( BT[0].Texto, " &Fecha "); BT[0].ID_T1 = 0; BT[0].ID_T2 = 0;
|
||
BT[1].x = 32; BT[1].y = 11; strcpy( BT[1].Texto, " &Cantidad "); BT[1].ID_T1 = 0; BT[1].ID_T2 = 0;
|
||
BT[2].x = 32; BT[2].y = 13; strcpy( BT[2].Texto, " &InfoMundear "); BT[2].ID_T1 = 0; BT[2].ID_T2 = 0;
|
||
BT[3].x = 32; BT[3].y = 15; strcpy( BT[3].Texto, " &Cancelar operacion"); BT[3].ID_T1 = 0; BT[3].ID_T2 = 0;
|
||
|
||
Optar( ENCUADRE, "Elija orden a seguir", NULL );
|
||
|
||
while( ( devolver = Funcion_Botones(STD_BY, 4, BT) ) < 1 || devolver > 4 ) while ( kbhit() ) getch();
|
||
|
||
if ( devolver != 4 )
|
||
{
|
||
OrdenaSocios = devolver+3;
|
||
qsort( SSocios.CSocios, SSocios.NCompras, sizeof( struct ComprasSocios ), ComparaRegistrosSocios );
|
||
}
|
||
|
||
Optar( ENCUADRE, NULL );
|
||
|
||
}
|
||
|
||
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* BuscaSocios *|
|
||
|* *|
|
||
|* 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 BuscaSocios( char TipoBusqueda, char *CurrRow, int *CurrSocios )
|
||
{
|
||
static INFO_SOCIOS MSocios;
|
||
char enc; long i;
|
||
|
||
|
||
switch ( TipoBusqueda )
|
||
{
|
||
case NUEVA_BUSQUEDA:
|
||
if ( ObtenMatchSocios( &MSocios ) != OK )
|
||
return;
|
||
i = 0;
|
||
break;
|
||
case ATRAS:
|
||
case ADELANTE:
|
||
i = ( *CurrRow + *CurrSocios )+TipoBusqueda;
|
||
if ( i < 0 || i >= BSocios.Registros() ) return;
|
||
break;
|
||
}
|
||
|
||
Optar( ENCUADRE, "Comando: Buscar", "Ahora se inica", "la busqueda elegida", NULL );
|
||
enc = 0;
|
||
while ( i < BSocios.Registros() && !enc )
|
||
{
|
||
if ( BSocios.LeeReg( (void *)&SSocios, i ) == ERROR )
|
||
Error( 0x03 );
|
||
if ( Match_Socios( SSocios, MSocios ) )
|
||
enc = 1;
|
||
else
|
||
i++;
|
||
}
|
||
|
||
Optar( ENCUADRE, NULL );
|
||
|
||
if ( enc )
|
||
{
|
||
*CurrRow = 0; *CurrSocios = i;
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosSocios( *CurrRow + *CurrSocios );
|
||
if ( BSocios.LeeReg( (void *)&SSocios, 0 ) == ERROR )
|
||
Error(0x03);
|
||
MuestraDatosComprasSocios( SSocios.NCompras );
|
||
} 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;
|
||
}
|
||
|
||
if ( BSocios.LeeReg( (void *)&SSocios, (*CurrRow + *CurrSocios) ) == ERROR )
|
||
Error( 0x03 );
|
||
|
||
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* Match_Socios *|
|
||
|* *|
|
||
|* Descripci¢n: *|
|
||
|* Compara dos registros y devuelve la posible coincidencia *|
|
||
|* *|
|
||
|* Entradas: *|
|
||
|* Registros a comparar *|
|
||
|* *|
|
||
|* Salidas: *|
|
||
|* Resultado de la comparaci¢n *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
int Match_Socios( INFO_SOCIOS A, INFO_SOCIOS B )
|
||
{
|
||
if ( B.NSocio != 0 )
|
||
return (A.NSocio == B.NSocio );
|
||
if ( B.Apellido[0] != '\0' )
|
||
return ( strncmpi( A.Apellido, B.Apellido, strlen( B.Apellido ) ) == 0 );
|
||
if ( B.Nombre[0] != '\0' )
|
||
return ( strncmpi( A.Nombre, B.Nombre, strlen( B.Nombre ) ) == 0 );
|
||
if ( B.Direccion != '\0' )
|
||
return ( strncmpi( A.Direccion, B.Direccion, strlen( B.Direccion ) ) == 0 );
|
||
|
||
return 0;
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* ObtenMatchSocios *|
|
||
|* *|
|
||
|* 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 ObtenMatchSocios( INFO_SOCIOS *MSocios )
|
||
{
|
||
struct Boton_Texto BT[6];
|
||
|
||
BT[0].x = 22; BT[0].y = 15; strcpy( BT[0].Texto, " &Aceptar "); BT[0].ID_T1 = 00; BT[0].ID_T2 = 0;
|
||
BT[1].x = 51; BT[1].y = 15; strcpy( BT[1].Texto, " &Cancelar"); BT[1].ID_T1 = 00; BT[1].ID_T2 = 0;
|
||
|
||
char Row, ok, i;
|
||
int BPush, key, DEV;
|
||
|
||
Optar( ENCUADRE, "Comando: Buscar", "N§ Socio: ", "Nombre: ", "Apellido: ", "Direcci¢n: ", NULL );
|
||
|
||
ok = 0; Row = 0;
|
||
|
||
SociosNuevoRegistro( MSocios );
|
||
|
||
do
|
||
{
|
||
MatchDrawSocios(Row, *MSocios, INTENSO);
|
||
BPush = Funcion_Botones(STD_BY, 2, BT);
|
||
MatchDrawSocios(Row, *MSocios, 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 );
|
||
EditMatchSocios( Row, MSocios );
|
||
for ( i=0; i < 6; i++ )
|
||
MatchDrawSocios(i, *MSocios, NORMAL);
|
||
break;
|
||
case -1:
|
||
switch ( getch() )
|
||
{
|
||
// Flecha Izquierda
|
||
case 75:
|
||
case 15:
|
||
// Flecha Arriba
|
||
case 72:
|
||
Row--; if ( Row < 0 ) Row = 3;
|
||
break;
|
||
// Flecha Derecha
|
||
case 77:
|
||
case 9:
|
||
// Flecha Abajo
|
||
case 80:
|
||
Row++; if ( Row > 3 ) Row = 0;
|
||
break;
|
||
}
|
||
break;
|
||
case 1:
|
||
DEV = OK; ok = 1;
|
||
break;
|
||
case 2:
|
||
DEV = ERROR; ok = 1;
|
||
break;
|
||
}
|
||
|
||
} while ( !ok );
|
||
|
||
Optar( ENCUADRE, NULL );
|
||
|
||
return DEV;
|
||
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* EditMatchSocios *|
|
||
|* *|
|
||
|* Descripci¢n: *|
|
||
|* Edita el patron de busqueda *|
|
||
|* *|
|
||
|* Entradas: *|
|
||
|* Campo a editar, y lugar donde almacenarlo *|
|
||
|* *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void EditMatchSocios( char Row, INFO_SOCIOS * MSocios )
|
||
{
|
||
int X0, Y0, X1, Y1;
|
||
char buffer[80];
|
||
|
||
ObtenCoordenadasMatch( Row, &X0, &Y0, &X1, &Y1 );
|
||
|
||
switch( Row )
|
||
{
|
||
case 0:
|
||
sprintf( buffer, "%lu", MSocios -> NSocio );
|
||
if ( !( InputCadenaG( buffer, 1, 9, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
{
|
||
SociosNuevoRegistro( MSocios );
|
||
MSocios -> NSocio = atol(buffer);
|
||
}
|
||
break;
|
||
case 1:
|
||
strcpy( buffer, MSocios -> Nombre );
|
||
if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
{
|
||
SociosNuevoRegistro( MSocios );
|
||
strcpy ( MSocios -> Nombre, buffer );
|
||
}
|
||
break;
|
||
case 2:
|
||
strcpy( buffer, MSocios -> Apellido );
|
||
if ( !( InputCadenaG( buffer, 0, 20, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
{
|
||
SociosNuevoRegistro( MSocios );
|
||
strcpy ( MSocios -> Apellido, buffer );
|
||
}
|
||
break;
|
||
case 3:
|
||
strcpy( buffer, MSocios -> Direccion );
|
||
if ( !( InputCadenaG( buffer, 0, 20, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
{
|
||
SociosNuevoRegistro( MSocios );
|
||
strcpy ( MSocios -> Direccion, buffer );
|
||
}
|
||
break;
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* MatchDrawSocios *|
|
||
|* *|
|
||
|* Descripci¢n: *|
|
||
|* Escribe los distintos campos seg£n se le indique *|
|
||
|* *|
|
||
|* Entradas: *|
|
||
|* Campo a mostrar, lugar donde se encuentra, y como mostrarlo *|
|
||
|* *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void MatchDrawSocios( char Row, INFO_SOCIOS MSocios, char como )
|
||
{
|
||
int X0, Y0, X1, Y1;
|
||
char buffer[80], buffer1[80];
|
||
|
||
ObtenCoordenadasMatch( Row, &X0, &Y0, &X1, &Y1 );
|
||
|
||
switch( Row )
|
||
{
|
||
case 0:
|
||
sprintf( buffer, " %9ld", MSocios.NSocio );
|
||
break;
|
||
case 1:
|
||
sprintf( buffer, "%15s", MSocios.Nombre );
|
||
break;
|
||
case 2:
|
||
sprintf( buffer, "%20s", MSocios.Apellido );
|
||
break;
|
||
case 3:
|
||
sprintf( buffer, "%20s", MSocios.Direccion );
|
||
break;
|
||
}
|
||
|
||
textbackground( ( como == NORMAL ) ? Config.TxtBgN : Config.TxtBgI );
|
||
textcolor ( ( como == NORMAL ) ? Config.TxtFgN : Config.TxtFgI );
|
||
|
||
gotoxy( X0, Y0 );
|
||
cprintf( "%s", buffer );
|
||
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* MatchDrawSocios *|
|
||
|* *|
|
||
|* Descripci¢n: *|
|
||
|* Obtiene las coordenadas relativas al campo dado. *|
|
||
|* *|
|
||
|* Entradas: *|
|
||
|* Campo a obtener las coordenadas, y coordenadas de salida *|
|
||
|* *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void ObtenCoordenadasMatch( char Row, int *X0, int *Y0, int *X1, int *Y1 )
|
||
{
|
||
|
||
switch( Row )
|
||
{
|
||
case 0:
|
||
*X0 = 35; *X1 = 10;
|
||
*Y0 = 9; *Y1 = 9;
|
||
break;
|
||
case 1:
|
||
*X0 = 35; *X1 = 15;
|
||
*Y0 = 10; *Y1 = 10;
|
||
break;
|
||
case 2:
|
||
*X0 = 35; *X1 = 20;
|
||
*Y0 = 11; *Y1 = 11;
|
||
break;
|
||
case 3:
|
||
*X0 = 35; *X1 = 20;
|
||
*Y0 = 12; *Y1 = 12;
|
||
break;
|
||
}
|
||
|
||
}
|
||
|