commit 885bf44ba6213faeeb68a2c93085998916b6f0dd Author: jdg Date: Sun Sep 12 20:24:08 2021 +0200 First commit 04/09/1996 diff --git a/ARTICULO.DBF b/ARTICULO.DBF new file mode 100644 index 0000000..0aa48d6 Binary files /dev/null and b/ARTICULO.DBF differ diff --git a/GASTOSI.000 b/GASTOSI.000 new file mode 100644 index 0000000..eda474e Binary files /dev/null and b/GASTOSI.000 differ diff --git a/GASTOSI.096 b/GASTOSI.096 new file mode 100644 index 0000000..ae3d0da Binary files /dev/null and b/GASTOSI.096 differ diff --git a/GASTOSI.097 b/GASTOSI.097 new file mode 100644 index 0000000..c8c1696 Binary files /dev/null and b/GASTOSI.097 differ diff --git a/P.EXE b/P.EXE new file mode 100644 index 0000000..3cbbe3f Binary files /dev/null and b/P.EXE differ diff --git a/PRNFILE.OUT b/PRNFILE.OUT new file mode 100644 index 0000000..575de6a --- /dev/null +++ b/PRNFILE.OUT @@ -0,0 +1,2 @@ +C¢digo Proveedor Cant.Unt P.Costo P.Venta Combinado + \ No newline at end of file diff --git a/R.BAT b/R.BAT new file mode 100644 index 0000000..2a341f9 --- /dev/null +++ b/R.BAT @@ -0,0 +1 @@ +edit zorr.img diff --git a/README.md b/README.md new file mode 100644 index 0000000..75e0c84 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +#LosArcosChicos + + +*04/09/1996* + +ToDo: wwtcf? + + +![screenshot](/LosArcosChicos.png "Screenshot") diff --git a/SOCIOS.096 b/SOCIOS.096 new file mode 100644 index 0000000..68a6add Binary files /dev/null and b/SOCIOS.096 differ diff --git a/SOCIOS.097 b/SOCIOS.097 new file mode 100644 index 0000000..165b46e Binary files /dev/null and b/SOCIOS.097 differ diff --git a/TXT_LP.CPP b/TXT_LP.CPP new file mode 100644 index 0000000..9276f43 --- /dev/null +++ b/TXT_LP.CPP @@ -0,0 +1,933 @@ +#include +#include +#include +#include + +#include "d:\program\src_dos\libs\bdatos\bdatos.hh" +#include "zorr.h" + +#define NLINEAS_REF 18 + +BDatos BCompras; // Base de datos de Compraserencias +INFO_PRECIOS SCompras; // Estructura de referencias + +int OrdenGestionInterna; + +extern CONFIG Config; + +void RastreaFicheroGastosi(void); + +void Error( int code ); +void MuestraDatosCompras( int RowStart ); + +int ComparaRegistros( const void *A, const void *B ); + +void EditItemCompras( char columna, int linea ); +void ComprasNuevoRegistro( INFO_PRECIOS *MSCompras ); +void MuestraCompras( char columna, int linea, char como ); +void ObtenCoordenadasCompras( char columna, char linea, int *X0, int *Y0, int *X1, int *Y1 ); +void OrdenarGastosi(void); + +void ObtenCoordenadasMatch( char Row, int *X0, int *Y0, int *X1, int *Y1 ); +void MatchDrawCompras( char Row, INFO_PRECIOS MCompras, char como ); +void BuscaCompras( char TipoBusqueda, char *CurrRow, int *CurrCompras ); +int Match_Compras( INFO_PRECIOS A, INFO_PRECIOS B ); +void EditMatchCompras( char Row, INFO_PRECIOS * MCompras ); +int ObtenMatchCompras( INFO_PRECIOS *MCompras ); + + + +void ImprimeCompraserencias( char como ); +void ImprimeCabeceraCompras( char como, FILE *file_out ); +void DibujaPantallaGastosInt( void ); + + +// ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß +// Û 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 GastosInternos(void) +{ +struct Boton_Texto BT[6]; + + +BT[0].x = 1; BT[0].y = 1; strcpy( BT[0].Texto, " &Men£ Principal "); BT[0].ID_T1 = 0; BT[0].ID_T2 = 50; +BT[1].x = 20; BT[1].y = 1; strcpy( BT[1].Texto, " &Ins. Art."); BT[1].ID_T1 = 0; BT[1].ID_T2 = 23; + +BT[2].x = 33; BT[2].y = 1; strcpy( BT[2].Texto, " &Borr. Art."); 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, " &Gast.Prov."); BT[4].ID_T1 = 0; BT[4].ID_T2 = 0; +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 buffer[100], ok = 0; + int BPush, key; + + char oldCol; + char CurrRow; // Linea sobre la que estamos + char CurrCol; // Columna sobre la que estamos + long CurrCompras; // Producto sobre el que estamos posicionados a golpes + + _setcursortype( _NOCURSOR ); + DibujaPantallaGastosInt(); + + sprintf( buffer, "GastosI.%03d", AnoActual ); + if ( BCompras.AbrirReg( buffer, sizeof( INFO_PRECIOS ) ) == ERROR ) + Error(0x01); + + // Si no hay registros, creamos uno almenos. + if ( BCompras.Registros() == 0 ) + { + ComprasNuevoRegistro( &SCompras ); + if ( BCompras.InsReg( (void *)&SCompras, BCompras.Registros(), ARRIBA ) == ERROR ) + Error(0x02); + } + + CurrCompras = 0; CurrRow = 0; + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosCompras( CurrRow + CurrCompras ); + if ( BCompras.LeeReg( (void *)&SCompras, 0 ) == ERROR ) + Error(0x03); + + CurrCol = 0; oldCol = -1; + + do { + if ( CurrCol != oldCol ) + { + oldCol = CurrCol; + } + + MuestraCompras( CurrCol, CurrRow, INTENSO ); + BPush = Funcion_Botones(STD_BY, 6, BT); + MuestraCompras( CurrCol, CurrRow, 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 ); + EditItemCompras( CurrCol, CurrRow ); + _setcursortype( _NOCURSOR ); + if ( BCompras.EscribeReg( (void *)&SCompras, (CurrRow + CurrCompras) ) == ERROR ) + Error(0x04); + while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER + break; + case -1: // Hay una tecla especial en BUFFER + switch( getch() ) + { + // Flecha Izquierda + case 75: + case 15: + CurrCol--; if ( CurrCol < 0 ) CurrCol = 5; + break; + // Flecha Derecha + case 77: + case 9: + CurrCol++; if ( CurrCol > 5 ) CurrCol = 0; + break; + // Flecha Arriba + case 72: + if ( (CurrRow + CurrCompras) > 0 ) + { + if ( ( CurrRow ) <= 0 ) + { + CurrRow = NLINEAS_REF - 1; CurrCompras -= NLINEAS_REF; + if ( CurrCompras < 0 ) CurrCompras = 0; + + while( ( CurrRow + CurrCompras ) >= BCompras.Registros() && CurrRow > 0 ) CurrRow--; + while( ( CurrRow + CurrCompras ) >= BCompras.Registros() && CurrCompras > 0 ) CurrCompras++; + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosCompras( CurrCompras ); + } else { + CurrRow --; if ( CurrRow < 0 ) CurrRow = 0; + } + } + + if ( BCompras.LeeReg( (void *)&SCompras, (CurrCompras + CurrRow) ) == ERROR ) + Error(0x03); + break; + // Flecha Abajo + case 80: + if ( ( CurrRow + CurrCompras ) < BCompras.Registros() - 1 ) + { + + if ( ( CurrRow ) >= NLINEAS_REF - 1 ) + { + CurrRow = 0; CurrCompras += NLINEAS_REF; + + while ( (CurrCompras + CurrRow) >= BCompras.Registros() ) CurrCompras--; + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosCompras( CurrCompras ); + } else + CurrRow++; + } + if ( BCompras.LeeReg( (void *)&SCompras, (CurrCompras + CurrRow) ) == ERROR ) + Error(0x03); + break; + // Inicio + case 71: + CurrRow = 0; + if ( CurrCompras != 0 ) + { + CurrCompras = 0; + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosCompras( CurrCompras ); + } + + if ( BCompras.LeeReg( (void *)&SCompras, (CurrCompras + CurrRow) ) == ERROR ) + Error(0x03); + + break; + // Fin + case 79: + CurrRow = 0; + if ( CurrCompras != BCompras.Registros() - NLINEAS_REF ) + { + CurrCompras = BCompras.Registros() - NLINEAS_REF; + while( CurrCompras >= BCompras.Registros() ) CurrCompras--; + if ( CurrCompras < 0 ) { + CurrCompras = 0; + CurrRow = BCompras.Registros()-1; + } + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosCompras( CurrCompras ); + } + + if ( BCompras.LeeReg( (void *)&SCompras, (CurrCompras + CurrRow) ) == ERROR ) + Error(0x03); + + break; + // AvanceR pido + case 81: + CurrRow = 0; CurrCompras += NLINEAS_REF; + + while ( (CurrCompras + CurrRow) >= BCompras.Registros() ) CurrCompras--; + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosCompras( CurrCompras ); + if ( BCompras.LeeReg( (void *)&SCompras, (CurrCompras + CurrRow) ) == ERROR ) + Error(0x03); + + break; + // Retroceso R pido + case 73: + CurrRow = NLINEAS_REF - 1; CurrCompras -= NLINEAS_REF; + if ( CurrCompras < 0 ) CurrCompras = 0; + + while( ( CurrRow + CurrCompras ) >= BCompras.Registros() && CurrRow > 0 ) CurrRow--; + while( ( CurrRow + CurrCompras ) >= BCompras.Registros() && CurrCompras > 0 ) CurrCompras++; + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosCompras( CurrCompras ); + if ( BCompras.LeeReg( (void *)&SCompras, (CurrCompras + CurrRow) ) == ERROR ) + Error(0x03); + + break; + + } + while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER + break; + // Imprimir Lista de socios + case 6: +// MuestraImpresionesCompras(); + break; + // Menu Principal + case 1: + ok = 1; + break; + // Eliminar + case 3: + while( kbhit() ) getch(); + if ( Optar( 1, "ATENCION", "Eliminar  un gasto interno", "confirme eliminacion", NULL ) ) + { + if ( BCompras.DelReg( CurrCompras + CurrRow ) == ERROR ) + Error(0x05); + if ( BCompras.Registros() == 0 ) + { + ComprasNuevoRegistro( &SCompras ); + if ( BCompras.InsReg( (void *)&SCompras, BCompras.Registros(), ARRIBA ) == ERROR ) + Error(0x02); + CurrRow = 0; + } else + + // Si he borrado el £ltimo registro subo una linea + if ( (CurrCompras+CurrRow) >= ( BCompras.Registros() - 2 ) ) + { + if ( (CurrRow + CurrCompras) > 0 ) + { + if ( ( CurrRow ) <= 0 ) + { + CurrRow = NLINEAS_REF - 1; CurrCompras -= NLINEAS_REF; + if ( CurrCompras < 0 ) CurrCompras = 0; + + while( ( CurrRow + CurrCompras ) >= BCompras.Registros() && CurrRow > 0 ) CurrRow--; + while( ( CurrRow + CurrCompras ) >= BCompras.Registros() && CurrCompras > 0 ) CurrCompras++; + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosCompras( CurrCompras ); + } else { + CurrRow --; if ( CurrRow < 0 ) CurrRow = 0; + } + } + + if ( BCompras.LeeReg( (void *)&SCompras, (CurrCompras + CurrRow) ) == ERROR ) + Error(0x03); + } + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosCompras( CurrCompras ); + if ( BCompras.LeeReg( (void *)&SCompras, (CurrCompras + CurrRow) ) == ERROR ) + Error(0x03); + } + break; + // Insertar + case 2: + ComprasNuevoRegistro( &SCompras ); + if ( BCompras.InsReg( (void *)&SCompras, (CurrCompras + CurrRow), ARRIBA ) == ERROR ) + Error(0x02); + if ( ( CurrRow + CurrCompras ) < BCompras.Registros() - 1 ) + { + + if ( ( CurrRow ) >= NLINEAS_REF - 1 ) + { + CurrRow = 0; CurrCompras += NLINEAS_REF; + + while ( (CurrCompras + CurrRow) >= BCompras.Registros() ) CurrCompras--; + + } else + CurrRow++; + } + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosCompras( CurrCompras ); + if ( BCompras.LeeReg( (void *)&SCompras, (CurrCompras + CurrRow) ) == ERROR ) + Error(0x03); + + break; + + // Ordenar + case 4: + OrdenarGastosi(); + CurrCompras = 0; CurrRow = 0; + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosCompras( CurrRow + CurrCompras ); + if ( BCompras.LeeReg( (void *)&SCompras, 0 ) == ERROR ) + Error(0x03); + + CurrCol = 0; + + break; + // Gastos por proveedor + case 5: + RastreaFicheroGastosi(); + break; + default: + while( kbhit() ) getch(); + break; + } + + } while( !ok ); + + BCompras.CerrarReg(); +} + + + + /**************************************************************************\ +|* *| +|* MuestraDatosCompras *| +|* *| +|* 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 MuestraDatosCompras( 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 = BCompras.LeeReg( (void *)&SCompras, RowStart + linea ); + if ( dev == OK ) + // Por cada linea hay 6 campos, ehhh!!! + for ( campo=0; campo < 6; campo++ ) + MuestraCompras( 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 + 6 ); + cprintf( "³ ³ ³ ³ ³ ³ ³"); + } + } +} + + /**************************************************************************\ +|* *| +|* MuestraCompras *| +|* *| +|* 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 MuestraCompras( char columna, int linea, char como ) +{ + char buffer[80]; + char buffer1[80]; + + int X0, Y0, X1, Y1; + + ObtenCoordenadasCompras( columna, linea, &X0, &Y0, &X1, &Y1 ); + + switch( columna ) + { + // Fecha + case 0: + sprintf ( buffer, " %02d-%02d-%02d ", (int)SCompras.Fecha.da_day, (int)SCompras.Fecha.da_mon, SCompras.Fecha.da_year ); + break; + // Articulo + case 1: + sprintf ( buffer, "%24s", SCompras.Articulo ); + break; + // Cantidades + case 2: + sprintf ( buffer, " %04d", SCompras.Cantidades ); + break; + // Precio + case 3: + formatea_u_long( SCompras.Precio, buffer1 ); + sprintf ( buffer, " %7s", buffer1 ); + break; + // Total + case 4: + formatea_u_long( SCompras.Precio * SCompras.Cantidades, buffer1 ); + sprintf ( buffer, "%13s", buffer1 ); + break; + // N§ Proveedor + case 5: + sprintf ( buffer, " %03d", SCompras.Proveedor ); + 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 ); + +} + + + /**************************************************************************\ +|* *| +|* EditItemCompras *| +|* *| +|* 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 EditItemCompras( char columna, int linea ) +{ + char buffer[80]; + + int X0, Y0, X1, Y1; + + ObtenCoordenadasCompras( columna, linea, &X0, &Y0, &X1, &Y1 ); + + switch( columna ) + { + // Fecha + case 0: + sprintf ( buffer, "%02d%02d", (int)SCompras.Fecha.da_day, (int)SCompras.Fecha.da_mon ); + if ( !( InputCadenaG( buffer, 1, 4, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + if ( ( (buffer[0]-'0')*10 + (buffer[1]-'0') ) <= 31 && ( (buffer[2]-'0')*10 + (buffer[3]-'0') ) <= 12 ) + { + SCompras.Fecha.da_day = (char)((buffer[0]-'0')*10 + (buffer[1]-'0')); + SCompras.Fecha.da_mon = (char)((buffer[2]-'0')*10 + (buffer[3]-'0')); + SCompras.Fecha.da_year = AnoActual; + } + break; + // Articulo + case 1: + strcpy ( buffer, SCompras.Articulo ); + if ( !( InputCadenaG( buffer, 0, 24, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + strcpy ( SCompras.Articulo, buffer ); + break; + // Cantidad + case 2: + sprintf ( buffer, "%d", SCompras.Cantidades ); + if ( !( InputCadenaG( buffer, 0, 4, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + { + SCompras.Cantidades = atoi( buffer ); + MuestraCompras( 4, linea, NORMAL ); + } + break; + // Precio + case 3: + sprintf ( buffer, "%ld", SCompras.Precio ); + if ( !( InputCadenaG( buffer, 0, 6, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + { + SCompras.Precio = atol( buffer ); + MuestraCompras( 4, linea, NORMAL ); + } + break; + //Total + case 4: + break; + // Proveedor + case 5: + sprintf ( buffer, "%d", SCompras.Proveedor ); + if ( !( InputCadenaG( buffer, 0, 3, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + SCompras.Proveedor = atoi( buffer ); + break; + } + +} + + /**************************************************************************\ +|* *| +|* ObtenCoordenadasCompras *| +|* *| +|* 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 ObtenCoordenadasCompras( char columna, char linea, int *X0, int *Y0, int *X1, int *Y1 ) +{ + + // Calculamos la Y0, Y1 para la linea dada ( SOLO columna < 6 ) + *Y0 = 6 + linea; + *Y1 = 6 + linea; + + switch( columna ) + { + case 0: + *X0 = 2; *X1 = 10; + break; + case 1: + *X0 = 13; *X1 = 24; + break; + case 2: + *X0 = 38; *X1 = 7; + break; + case 3: + *X0 = 46; *X1 = 10; + break; + case 4: + *X0 = 57; *X1 = 13; + break; + case 5: + *X0 = 71; *X1 = 9; + break; + } + + +} + + /**************************************************************************\ +|* *| +|* ComprasNuevoRegistro *| +|* *| +|* Descripci¢n: *| +|* Limpia el buffer, para un nuevo registro. *| +|* *| +|* Entradas: (ninguna) *| +|* Salidas: (ninguna) *| +|* *| + \**************************************************************************/ +void ComprasNuevoRegistro( INFO_PRECIOS *NSCompras ) +{ + + NSCompras -> Fecha.da_day = 0; + NSCompras -> Fecha.da_mon = 0; + NSCompras -> Fecha.da_year = AnoActual; + + NSCompras -> Articulo[0] = '\0'; + NSCompras -> Cantidades = 0; + NSCompras -> Precio = 0; + NSCompras -> Proveedor = 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) *| +|* *| + \**************************************************************************/ + + + /**************************************************************************\ +|* *| +|* ImprimeCompraserencias *| +|* *| +|* Descripci¢n: *| +|* Imprime todas las referencias seg£n se le indique *| +|* *| +|* Entradas: *| +|* Como imprimir las referencias *| +|* *| +|* Salidas: (ninguna) *| +|* *| + \**************************************************************************/ +void ImprimeCompraserencias( char como ) +{ + long i, old_reg; + FILE *file_out; + + old_reg = BCompras.RegActual(); + + if ( !Config.Printer ) + { + if ( ( file_out = fopen( Config.PrintTo, "w" ) ) == NULL ) + return; + } else + file_out = stdprn; + + ImprimeCabeceraCompras( como, file_out ); + + for ( i=0; i> 8 ) ) + { + Proveedor = atoi( buffer ); + ok = 1; + } + Optar( ENCUADRE, NULL ); + + if ( ok == 1 ) + { + Optar( ENCUADRE, "Realizando rastreo...", "Esto puede tardar unos", "minutos, por favor, epere...", NULL ); + + + + old_pos = BCompras.RegActual(); + + dev = OK; + for ( i=0; i < BCompras.Registros(); i++ ) + { + BCompras.LeeReg( (void *)&SCompras, i ); + if ( SCompras.Proveedor == Proveedor ) + { + if ( SCompras.Fecha.da_mon > 0 && SCompras.Fecha.da_mon <= 12 ) + Meses[ SCompras.Fecha.da_mon - 1 ] += SCompras.Cantidades * SCompras.Precio; + } + } + + 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, "Rastreo concluido", MesesF[0], MesesF[1], MesesF[2], MesesF[3], MesesF[4], MesesF[5], NULL ); + while( kbhit() ) getch(); + + BCompras.LeeReg( (void *)&SCompras, old_pos ); + } + + + + +} + + + +void OrdenarGastosi(void) +{ +/* +BDatos BCompras; // Base de datos de Compraserencias +INFO_PRECIOS SCompras; // Estructura de referencias + +int OrdenGestionInterna; +*/ +struct Boton_Texto BT[4]; +int devolver; + +BT[0].x = 32; BT[0].y = 9; strcpy( BT[0].Texto, " &Fecha de compra "); BT[0].ID_T1 = 0; BT[0].ID_T2 = 0; +BT[1].x = 32; BT[1].y = 11; strcpy( BT[1].Texto, " &Nombre de Articulo"); BT[1].ID_T1 = 0; BT[1].ID_T2 = 0; +BT[2].x = 32; BT[2].y = 13; strcpy( BT[2].Texto, " &Proveedor del Art "); 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 ) + { + OrdenGestionInterna = devolver; + BCompras.SortReg( ComparaRegistros ); + } + + Optar( ENCUADRE, NULL ); + +} + + +int ComparaRegistros( const void *A, const void *B ) +{ + // Tipos de ordenaciones posibles + switch( OrdenGestionInterna ) + { + // Por Proveedor + case 3: + if ( ( ((INFO_PRECIOS *)A) -> Proveedor ) < ( ((INFO_PRECIOS *)B) -> Proveedor ) ) return -1; + if ( ( ((INFO_PRECIOS *)A) -> Proveedor ) == ( ((INFO_PRECIOS *)B) -> Proveedor ) ) return 0; + if ( ( ((INFO_PRECIOS *)A) -> Proveedor ) > ( ((INFO_PRECIOS *)B) -> Proveedor ) ) return 1; + break; + // Por Articulo + case 2: + return strcmpi( ( ((INFO_PRECIOS *)A) -> Articulo ), ( ((INFO_PRECIOS *)B) -> Articulo ) ); + case 1: + if ( ( ((INFO_PRECIOS *)A) -> Fecha.da_year ) < ( ((INFO_PRECIOS *)B) -> Fecha.da_year ) ) return -1; + if ( ( ((INFO_PRECIOS *)A) -> Fecha.da_year ) > ( ((INFO_PRECIOS *)B) -> Fecha.da_year ) ) return 1; + + if ( ( ((INFO_PRECIOS *)A) -> Fecha.da_mon ) < ( ((INFO_PRECIOS *)B) -> Fecha.da_mon ) ) return -1; + if ( ( ((INFO_PRECIOS *)A) -> Fecha.da_mon ) > ( ((INFO_PRECIOS *)B) -> Fecha.da_mon ) ) return 1; + + if ( ( ((INFO_PRECIOS *)A) -> Fecha.da_day ) < ( ((INFO_PRECIOS *)B) -> Fecha.da_day ) ) return -1; + if ( ( ((INFO_PRECIOS *)A) -> Fecha.da_day ) > ( ((INFO_PRECIOS *)B) -> Fecha.da_day ) ) return 1; + return 0; + } + + return -1; +} + + + + + diff --git a/TXT_LPR.CPP b/TXT_LPR.CPP new file mode 100644 index 0000000..2cb3aa6 --- /dev/null +++ b/TXT_LPR.CPP @@ -0,0 +1,1088 @@ +#include +#include +#include +#include + +#include "d:\program\src_dos\libs\bdatos\bdatos.hh" +#include "zorr.h" + +#define NLINEAS_REF 18 + +BDatos BPrecios; // Base de datos de Precioserencias +INFO_ARTICULOS SPrecios; // Estructura de referencias + +int OrdenPrecios; + +extern CONFIG Config; + +void RastreaFicheroGastosi(void); + +void Error( int code ); +void MuestraDatosPrecios( int RowStart ); + +int ComparaRegistrosPrecio( const void *A, const void *B ); + +void EditItemPrecios( char columna, int linea ); +void PreciosNuevoRegistro( INFO_ARTICULOS *MSPrecios ); +void MuestraPrecios( char columna, int linea, char como ); +void ObtenCoordenadasPrecios( char columna, char linea, int *X0, int *Y0, int *X1, int *Y1 ); +void OrdenaPrecios(void); + +void ObtenCoordenadasMatchPr( char Row, int *X0, int *Y0, int *X1, int *Y1 ); +void MatchDrawPrecios( char Row, INFO_ARTICULOS MPrecios, char como ); +void BuscaPrecios( char TipoBusqueda, char *CurrRow, int *CurrPrecios ); +int Match_Precios( INFO_ARTICULOS A, INFO_ARTICULOS B ); +void EditMatchPrecios( char Row, INFO_ARTICULOS * MPrecios ); +int ObtenMatchPrecios( INFO_ARTICULOS *MPrecios ); + + + +void ImprimePrecioserencias( char como ); +void ImprimeCabeceraPrecios( char como, FILE *file_out ); +void DibujaPantallaArticulos( void ); + + +// ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß +// Û 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 ListaPrecios(void) +{ +struct Boton_Texto BT[6]; + + +BT[0].x = 1; BT[0].y = 1; strcpy( BT[0].Texto, " &Men£ Principal "); BT[0].ID_T1 = 0; BT[0].ID_T2 = 50; +BT[1].x = 20; BT[1].y = 1; strcpy( BT[1].Texto, " &Ins. Art."); BT[1].ID_T1 = 0; BT[1].ID_T2 = 23; + +BT[2].x = 33; BT[2].y = 1; strcpy( BT[2].Texto, " &Borr. Art."); 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, " &Buscar"); BT[4].ID_T1 = 0; BT[4].ID_T2 = 48; +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 buffer[100], ok = 0; + int BPush, key; + + char oldCol; + char CurrRow; // Linea sobre la que estamos + char CurrCol; // Columna sobre la que estamos + int CurrPrecios; // Producto sobre el que estamos posicionados a golpes + + _setcursortype( _NOCURSOR ); + DibujaPantallaArticulos(); + + if ( BPrecios.AbrirReg( "Articulo.dbf", sizeof( INFO_ARTICULOS ) ) == ERROR ) + Error(0x00); + + // Si no hay registros, creamos uno almenos. + if ( BPrecios.Registros() == 0 ) + { + PreciosNuevoRegistro( &SPrecios ); + if ( BPrecios.InsReg( (void *)&SPrecios, BPrecios.Registros(), ARRIBA ) == ERROR ) + Error(0x00); + } + + CurrPrecios = 0; CurrRow = 0; + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosPrecios( CurrRow + CurrPrecios ); + if ( BPrecios.LeeReg( (void *)&SPrecios, 0 ) == ERROR ) + Error(0x00); + + CurrCol = 0; oldCol = -1; + + do { + if ( CurrCol != oldCol ) + { + oldCol = CurrCol; + } + + MuestraPrecios( CurrCol, CurrRow, INTENSO ); + BPush = Funcion_Botones(STD_BY, 6, BT); + MuestraPrecios( CurrCol, CurrRow, 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 ); + EditItemPrecios( CurrCol, CurrRow ); + _setcursortype( _NOCURSOR ); + if ( BPrecios.EscribeReg( (void *)&SPrecios, (CurrRow + CurrPrecios) ) == ERROR ) + Error(0x00); + while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER + break; + case -1: // Hay una tecla especial en BUFFER + switch( getch() ) + { + // Flecha Izquierda + case 75: + case 15: + CurrCol--; if ( CurrCol < 0 ) CurrCol = 3; + break; + // Flecha Derecha + case 77: + case 9: + CurrCol++; if ( CurrCol > 3 ) CurrCol = 0; + break; + // Flecha Arriba + case 72: + if ( (CurrRow + CurrPrecios) > 0 ) + { + if ( ( CurrRow ) <= 0 ) + { + CurrRow = NLINEAS_REF - 1; CurrPrecios -= NLINEAS_REF; + if ( CurrPrecios < 0 ) CurrPrecios = 0; + + while( ( CurrRow + CurrPrecios ) >= BPrecios.Registros() && CurrRow > 0 ) CurrRow--; + while( ( CurrRow + CurrPrecios ) >= BPrecios.Registros() && CurrPrecios > 0 ) CurrPrecios++; + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosPrecios( CurrPrecios ); + } else { + CurrRow --; if ( CurrRow < 0 ) CurrRow = 0; + } + } + + if ( BPrecios.LeeReg( (void *)&SPrecios, (CurrPrecios + CurrRow) ) == ERROR ) + Error(0x00); + break; + // Flecha Abajo + case 80: + if ( ( CurrRow + CurrPrecios ) < BPrecios.Registros() - 1 ) + { + + if ( ( CurrRow ) >= NLINEAS_REF - 1 ) + { + CurrRow = 0; CurrPrecios += NLINEAS_REF; + + while ( (CurrPrecios + CurrRow) >= BPrecios.Registros() ) CurrPrecios--; + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosPrecios( CurrPrecios ); + } else + CurrRow++; + } + if ( BPrecios.LeeReg( (void *)&SPrecios, (CurrPrecios + CurrRow) ) == ERROR ) + Error(0x00); + break; + // Inicio + case 71: + CurrRow = 0; + if ( CurrPrecios != 0 ) + { + CurrPrecios = 0; + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosPrecios( CurrPrecios ); + } + + if ( BPrecios.LeeReg( (void *)&SPrecios, (CurrPrecios + CurrRow) ) == ERROR ) + Error(0x00); + + break; + // Fin + case 79: + CurrRow = 0; + if ( CurrPrecios != BPrecios.Registros() - NLINEAS_REF ) + { + CurrPrecios = BPrecios.Registros() - NLINEAS_REF; + while( CurrPrecios >= BPrecios.Registros() ) CurrPrecios--; + if ( CurrPrecios < 0 ) + { + CurrPrecios = 0; + CurrRow = BPrecios.Registros()-1; + } + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosPrecios( CurrPrecios ); + } + + if ( BPrecios.LeeReg( (void *)&SPrecios, (CurrPrecios + CurrRow) ) == ERROR ) + Error(0x00); + + break; + // AvanceR pido + case 81: + CurrRow = 0; CurrPrecios += NLINEAS_REF; + + while ( (CurrPrecios + CurrRow) >= BPrecios.Registros() ) CurrPrecios--; + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosPrecios( CurrPrecios ); + if ( BPrecios.LeeReg( (void *)&SPrecios, (CurrPrecios + CurrRow) ) == ERROR ) + Error(0x00); + + break; + // Retroceso R pido + case 73: + CurrRow = NLINEAS_REF - 1; CurrPrecios -= NLINEAS_REF; + if ( CurrPrecios < 0 ) CurrPrecios = 0; + + while( ( CurrRow + CurrPrecios ) >= BPrecios.Registros() && CurrRow > 0 ) CurrRow--; + while( ( CurrRow + CurrPrecios ) >= BPrecios.Registros() && CurrPrecios > 0 ) CurrPrecios++; + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosPrecios( CurrPrecios ); + if ( BPrecios.LeeReg( (void *)&SPrecios, (CurrPrecios + CurrRow) ) == ERROR ) + Error(0x00); + + break; + // Gastos por proveedor + case 82: + BuscaPrecios( ATRAS, &CurrRow, &CurrPrecios ); + break; + // Gastos por proveedor + case 83: + BuscaPrecios( ADELANTE, &CurrRow, &CurrPrecios ); + break; + + } + while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER + break; + // Imprimir Lista de socios + case 6: +// MuestraImpresionesPrecios(); + break; + // Menu Principal + case 1: + ok = 1; + break; + // Eliminar + case 3: + while( kbhit() ) getch(); + if ( Optar( 1, "ATENCION", "Eliminar  un articulo", "confirme eliminacion", NULL ) ) + { + if ( BPrecios.DelReg( CurrPrecios + CurrRow ) == ERROR ) + Error(0x00); + if ( BPrecios.Registros() == 0 ) + { + PreciosNuevoRegistro( &SPrecios ); + if ( BPrecios.InsReg( (void *)&SPrecios, BPrecios.Registros(), ARRIBA ) == ERROR ) + Error(0x00); + CurrRow = 0; + } else + + // Si he borrado el £ltimo registro subo una linea + if ( (CurrPrecios+CurrRow) >= ( BPrecios.Registros() - 2 ) ) + { + if ( (CurrRow + CurrPrecios) > 0 ) + { + if ( ( CurrRow ) <= 0 ) + { + CurrRow = NLINEAS_REF - 1; CurrPrecios -= NLINEAS_REF; + if ( CurrPrecios < 0 ) CurrPrecios = 0; + + while( ( CurrRow + CurrPrecios ) >= BPrecios.Registros() && CurrRow > 0 ) CurrRow--; + while( ( CurrRow + CurrPrecios ) >= BPrecios.Registros() && CurrPrecios > 0 ) CurrPrecios++; + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosPrecios( CurrPrecios ); + } else { + CurrRow --; if ( CurrRow < 0 ) CurrRow = 0; + } + } + + if ( BPrecios.LeeReg( (void *)&SPrecios, (CurrPrecios + CurrRow) ) == ERROR ) + Error(0x00); + } + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosPrecios( CurrPrecios ); + if ( BPrecios.LeeReg( (void *)&SPrecios, (CurrPrecios + CurrRow) ) == ERROR ) + Error(0x00); + } + break; + // Insertar + case 2: + PreciosNuevoRegistro( &SPrecios ); + if ( BPrecios.InsReg( (void *)&SPrecios, (CurrPrecios + CurrRow), ARRIBA ) == ERROR ) + Error(0x00); + if ( ( CurrRow + CurrPrecios ) < BPrecios.Registros() - 1 ) + { + + if ( ( CurrRow ) >= NLINEAS_REF - 1 ) + { + CurrRow = 0; CurrPrecios += NLINEAS_REF; + + while ( (CurrPrecios + CurrRow) >= BPrecios.Registros() ) CurrPrecios--; + + } else + CurrRow++; + } + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosPrecios( CurrPrecios ); + if ( BPrecios.LeeReg( (void *)&SPrecios, (CurrPrecios + CurrRow) ) == ERROR ) + Error(0x00); + + break; + + // Ordenar + case 4: + OrdenaPrecios(); + CurrPrecios = 0; CurrRow = 0; + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosPrecios( CurrRow + CurrPrecios ); + if ( BPrecios.LeeReg( (void *)&SPrecios, 0 ) == ERROR ) + Error(0x00); + + CurrCol = 0; + + break; + // Gastos por proveedor + case 5: + BuscaPrecios( NUEVA_BUSQUEDA, &CurrRow, &CurrPrecios ); + break; + default: + while( kbhit() ) getch(); + break; + } + + } while( !ok ); + + BPrecios.CerrarReg(); +} + + + + /**************************************************************************\ +|* *| +|* MuestraDatosPrecios *| +|* *| +|* 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 MuestraDatosPrecios( 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 = BPrecios.LeeReg( (void *)&SPrecios, RowStart + linea ); + if ( dev == OK ) + // Por cada linea hay 4 campos, ehhh!!! + for ( campo=0; campo < 4; campo++ ) + MuestraPrecios( campo, linea, NORMAL ); + } + + // Ahora limpio los restantes huecos si los hay + if ( dev != OK ) + { + linea--; + + textbackground( BLACK ); + textcolor( WHITE ); + for ( ; linea < NLINEAS_REF; linea++ ) + gotoxy( 1, linea + 6 ); + cprintf( "³ ³ ³ ³ ³"); + + } +} + + /**************************************************************************\ +|* *| +|* MuestraPrecios *| +|* *| +|* 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 MuestraPrecios( char columna, int linea, char como ) +{ + char buffer[80]; + char buffer1[80]; + + int X0, Y0, X1, Y1; + + ObtenCoordenadasPrecios( columna, linea, &X0, &Y0, &X1, &Y1 ); + + switch( columna ) + { + // Articulo + case 0: + sprintf ( buffer, "%42s", (int)SPrecios.Articulo ); + break; + // Precio Articulo + case 1: + formatea_u_long( SPrecios.Precio, buffer1 ); + sprintf ( buffer, "%11s", buffer1 ); + break; + // Precio Articulo2 + case 2: + formatea_u_long( SPrecios.PrecioArt, buffer1 ); + sprintf ( buffer, "%11s", buffer1 ); + break; + // Ubicacion + case 3: + sprintf ( buffer, "%11s", SPrecios.Ubicacion ); + 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 ); + +} + + + /**************************************************************************\ +|* *| +|* EditItemPrecios *| +|* *| +|* 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 EditItemPrecios( char columna, int linea ) +{ + char buffer[80]; + + int X0, Y0, X1, Y1; + + ObtenCoordenadasPrecios( columna, linea, &X0, &Y0, &X1, &Y1 ); + + switch( columna ) + { + // Articulo + case 0: + strcpy ( buffer, SPrecios.Articulo ); + if ( !( InputCadenaG( buffer, 0, 42, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + strcpy ( SPrecios.Articulo, buffer ); + break; + // Precio Articulo + case 1: + sprintf ( buffer, "%ld", SPrecios.Precio ); + if ( !( InputCadenaG( buffer, 1, 9, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + SPrecios.Precio = atol( buffer ); + break; + // Precio Articulo + case 2: + sprintf ( buffer, "%ld", SPrecios.PrecioArt ); + if ( !( InputCadenaG( buffer, 1, 9, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + SPrecios.PrecioArt = atol( buffer ); + break; + // Ubicacion + case 3: + strcpy ( buffer, SPrecios.Ubicacion ); + if ( !( InputCadenaG( buffer, 0, 11, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + strcpy ( SPrecios.Ubicacion, buffer ); + break; + } +} + + /**************************************************************************\ +|* *| +|* ObtenCoordenadasPrecios *| +|* *| +|* 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 ObtenCoordenadasPrecios( char columna, char linea, int *X0, int *Y0, int *X1, int *Y1 ) +{ + + // Calculamos la Y0, Y1 para la linea dada ( SOLO columna < 6 ) + *Y0 = 6 + linea; + *Y1 = 6 + linea; + + switch( columna ) + { + case 0: + *X0 = 2; *X1 = 42; + break; + case 1: + *X0 = 45; *X1 = 11; + break; + case 2: + *X0 = 57; *X1 = 11; + break; + case 3: + *X0 = 69; *X1 = 11; + break; + } + + +} + + /**************************************************************************\ +|* *| +|* PreciosNuevoRegistro *| +|* *| +|* Descripci¢n: *| +|* Limpia el buffer, para un nuevo registro. *| +|* *| +|* Entradas: (ninguna) *| +|* Salidas: (ninguna) *| +|* *| + \**************************************************************************/ +void PreciosNuevoRegistro( INFO_ARTICULOS *NSPrecios ) +{ + + + NSPrecios -> Articulo[0] = '\0'; + NSPrecios -> Ubicacion[0] = '\0'; + NSPrecios -> Precio = 0; + NSPrecios -> PrecioArt = 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) *| +|* *| + \**************************************************************************/ + + + /**************************************************************************\ +|* *| +|* ImprimePrecioserencias *| +|* *| +|* Descripci¢n: *| +|* Imprime todas las referencias seg£n se le indique *| +|* *| +|* Entradas: *| +|* Como imprimir las referencias *| +|* *| +|* Salidas: (ninguna) *| +|* *| + \**************************************************************************/ +void ImprimePrecioserencias( char como ) +{ + long i, old_reg; + FILE *file_out; + + old_reg = BPrecios.RegActual(); + + if ( !Config.Printer ) + { + if ( ( file_out = fopen( Config.PrintTo, "w" ) ) == NULL ) + return; + } else + file_out = stdprn; + + ImprimeCabeceraPrecios( como, file_out ); + + for ( i=0; i Precio ) < ( ((INFO_ARTICULOS *)B) -> Precio ) ) return -1; + if ( ( ((INFO_ARTICULOS *)A) -> Precio ) == ( ((INFO_ARTICULOS *)B) -> Precio ) ) return 0; + if ( ( ((INFO_ARTICULOS *)A) -> Precio ) > ( ((INFO_ARTICULOS *)B) -> Precio ) ) return 1; + break; + // Por Precio + case 2: + return strcmpi( ( ((INFO_ARTICULOS *)A) -> Articulo ), ( ((INFO_ARTICULOS *)B) -> Articulo ) ); + case 1: + return strcmpi( ( ((INFO_ARTICULOS *)A) -> Ubicacion ), ( ((INFO_ARTICULOS *)B) -> Ubicacion ) ); + } + + return -1; +} + + +void OrdenaPrecios(void) +{ +/* +BDatos BPrecios; // Base de datos de Precioserencias +INFO_ARTICULOS SPrecios; // Estructura de referencias + +int OrdenPrecios; +*/ +struct Boton_Texto BT[4]; +int devolver; + +BT[0].x = 32; BT[0].y = 9; strcpy( BT[0].Texto, " &Ubicacion "); BT[0].ID_T1 = 0; BT[0].ID_T2 = 0; +BT[1].x = 32; BT[1].y = 11; strcpy( BT[1].Texto, " &Nombre de Articulo"); BT[1].ID_T1 = 0; BT[1].ID_T2 = 0; +BT[2].x = 32; BT[2].y = 13; strcpy( BT[2].Texto, " &Precio de Articulo"); 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 ) + { + OrdenPrecios = devolver; + BPrecios.SortReg( ComparaRegistrosPrecio ); + } + + Optar( ENCUADRE, NULL ); + +} + + + + /**************************************************************************\ +|* *| +|* BuscaPrecios *| +|* *| +|* 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 BuscaPrecios( char TipoBusqueda, char *CurrRow, int *CurrPrecios ) +{ + static INFO_ARTICULOS MPrecios; + char enc; long i; + + + switch ( TipoBusqueda ) + { + case NUEVA_BUSQUEDA: + if ( ObtenMatchPrecios( &MPrecios ) != OK ) + return; + i = 0; + break; + case ATRAS: + case ADELANTE: + i = ( *CurrRow + *CurrPrecios )+TipoBusqueda; + if ( i < 0 || i >= BPrecios.Registros() ) return; + break; + } + + Optar( ENCUADRE, "Comando: Buscar", "Ahora se inica", "la busqueda elegida", NULL ); + enc = 0; + while ( i < BPrecios.Registros() && !enc ) + { + if ( BPrecios.LeeReg( (void *)&SPrecios, i ) == ERROR ) + Error( 0x00 ); + if ( Match_Precios( SPrecios, MPrecios ) ) + enc = 1; + else + i++; + } + + Optar( ENCUADRE, NULL ); + + if ( enc ) + { + *CurrRow = 0; *CurrPrecios = i; + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosPrecios( *CurrRow + *CurrPrecios ); + if ( BPrecios.LeeReg( (void *)&SPrecios, 0 ) == ERROR ) + Error(0x00); + } 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 ( BPrecios.LeeReg( (void *)&SPrecios, (*CurrRow + *CurrPrecios) ) == ERROR ) + Error( 0x00 ); + + +} + + /**************************************************************************\ +|* *| +|* Match_Precios *| +|* *| +|* Descripci¢n: *| +|* Compara dos registros y devuelve la posible coincidencia *| +|* *| +|* Entradas: *| +|* Registros a comparar *| +|* *| +|* Salidas: *| +|* Resultado de la comparaci¢n *| +|* *| + \**************************************************************************/ +int Match_Precios( INFO_ARTICULOS A, INFO_ARTICULOS B ) +{ + if ( B.Precio != 0 ) + return (A.Precio == B.Precio ); + if ( B.Articulo[0] != '\0' ) + return ( strncmpi( A.Articulo, B.Articulo, strlen( B.Articulo ) ) == 0 ); + if ( B.Ubicacion[0] != '\0' ) + return ( strncmpi( A.Ubicacion, B.Ubicacion, strlen( B.Ubicacion ) ) == 0 ); + return 0; +} + + /**************************************************************************\ +|* *| +|* ObtenMatchPrecios *| +|* *| +|* 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 ObtenMatchPrecios( INFO_ARTICULOS *MPrecios ) +{ +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", "Articulo: ", "Precio: ", "Ubicaci¢n: ", NULL ); + + ok = 0; Row = 0; + + PreciosNuevoRegistro( MPrecios ); + + do + { + MatchDrawPrecios(Row, *MPrecios, INTENSO); + BPush = Funcion_Botones(STD_BY, 2, BT); + MatchDrawPrecios(Row, *MPrecios, 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 ); + EditMatchPrecios( Row, MPrecios ); + for ( i=0; i < 6; i++ ) + MatchDrawPrecios(i, *MPrecios, NORMAL); + break; + case -1: + switch ( getch() ) + { + // Flecha Izquierda + case 75: + case 15: + // Flecha Arriba + case 72: + Row--; if ( Row < 0 ) Row = 2; + break; + // Flecha Derecha + case 77: + case 9: + // Flecha Abajo + case 80: + Row++; if ( Row > 2 ) 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; + +} + + /**************************************************************************\ +|* *| +|* EditMatchPrecios *| +|* *| +|* Descripci¢n: *| +|* Edita el patron de busqueda *| +|* *| +|* Entradas: *| +|* Campo a editar, y lugar donde almacenarlo *| +|* *| +|* Salidas: (ninguna) *| +|* *| + \**************************************************************************/ +void EditMatchPrecios( char Row, INFO_ARTICULOS * MPrecios ) +{ + int X0, Y0, X1, Y1; + char buffer[80]; + + ObtenCoordenadasMatchPr( Row, &X0, &Y0, &X1, &Y1 ); + + switch( Row ) + { + case 1: + sprintf( buffer, "%lu", MPrecios -> Precio ); + if ( !( InputCadenaG( buffer, 1, 9, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + { + PreciosNuevoRegistro( MPrecios ); + MPrecios -> Precio = atol(buffer); + } + break; + case 0: + strcpy( buffer, MPrecios -> Articulo ); + if ( !( InputCadenaG( buffer, 0, 20, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + { + PreciosNuevoRegistro( MPrecios ); + strcpy ( MPrecios -> Articulo, buffer ); + } + break; + case 2: + strcpy( buffer, MPrecios -> Ubicacion ); + if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + { + PreciosNuevoRegistro( MPrecios ); + strcpy ( MPrecios -> Ubicacion, buffer ); + } + break; + } + + + +} + + /**************************************************************************\ +|* *| +|* MatchDrawPrecios *| +|* *| +|* 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 MatchDrawPrecios( char Row, INFO_ARTICULOS MPrecios, char como ) +{ + int X0, Y0, X1, Y1; + char buffer[80], buffer1[80]; + + ObtenCoordenadasMatchPr( Row, &X0, &Y0, &X1, &Y1 ); + + switch( Row ) + { + case 1: + sprintf( buffer, " %9ld", MPrecios.Precio ); + break; + case 0: + sprintf( buffer, "%15s", MPrecios.Articulo ); + break; + case 2: + sprintf( buffer, "%20s", MPrecios.Ubicacion ); + break; + } + + textbackground( ( como == NORMAL ) ? Config.TxtBgN : Config.TxtBgI ); + textcolor ( ( como == NORMAL ) ? Config.TxtFgN : Config.TxtFgI ); + + gotoxy( X0, Y0 ); + cprintf( "%s", buffer ); + +} + + /**************************************************************************\ +|* *| +|* MatchDrawPrecios *| +|* *| +|* Descripci¢n: *| +|* Obtiene las coordenadas relativas al campo dado. *| +|* *| +|* Entradas: *| +|* Campo a obtener las coordenadas, y coordenadas de salida *| +|* *| +|* Salidas: (ninguna) *| +|* *| + \**************************************************************************/ +void ObtenCoordenadasMatchPr( 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; + } + +} + diff --git a/TXT_SOC.CPP b/TXT_SOC.CPP new file mode 100644 index 0000000..9490025 --- /dev/null +++ b/TXT_SOC.CPP @@ -0,0 +1,1609 @@ +#include +#include +#include +#include + +#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 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; + } + +} + diff --git a/TXT_UTL.CPP b/TXT_UTL.CPP new file mode 100644 index 0000000..7dc5347 --- /dev/null +++ b/TXT_UTL.CPP @@ -0,0 +1,277 @@ +#include +#include +#include +#include +#include +#include +#include + +#define BLANCO EGA_WHITE +#define ENCUADRE 3 +#define SEC_OPTAR 5 + +#include "zorr.h" + +void BEEP(void); + + /**************************************************************************\ +|* *| +|* InputCadenaG *| +|* *| +|* Descripci¢n: *| +|* Edita una cadena en formato gr fico *| +|* *| +|* Entradas: *| +|* Puntero a los datos editados *| +|* 0 alfanumerico 1 numerico *| +|* longitud de la cadena (TEXTO/NUMERO) *| +|* color del texto *| +|* color de fondo *| +|* Limites de acotacion *| +|* *| +|* Salidas: (ninguna) *| +|* *| +|* *| + \**************************************************************************/ +int InputCadenaG(char *s, int numalp, int lmax, int cc, int cf, int X0, int Y0, int X1, int Y1) +{ + // A todas las y les sumaba antes +RoW*12 parametro que indica la linea + + int ls; // longitud cadena + char Status = 0; + char *s1; // puntero a cadena inicial + int c, ok, i; + + s1 = s; // inicio cadena + + textbackground( cf ); + + gotoxy( X0, Y0 ); + for ( i = 0; i < X1; i++ ) + putch( 32 ); + textcolor( cc ); + gotoxy( X0, Y0 ); + cprintf( "%s", s1 ); + + _setcursortype( _SOLIDCURSOR ); + + ls = strlen ( s ); // Longitud de actual + + s += ls; // se coloca en el final + + do{ + c = getch(); // obtiene tecla + + if ( c == 27 ) Status = 1; + + ok = ( c == 27 || c == 13 || c == 0); // 13 = INTRO || Especiales + + if ( c == 8 && ls > 0 && !ok ) { // 8 = Back Space + ls--; + s--; + + *s = '\0'; + + gotoxy( X0, Y0 ); + for ( i = 0; i < X1; i++ ) + putch( 32 ); + textcolor( cc ); + gotoxy( X0, Y0 ); + cprintf( "%s", s1 ); + + + } else { + if ( !numalp && c >= 32 && c <= 254 && ls < lmax) { + + *s++ = c; + ls++; + + *s = '\0'; + + gotoxy( X0, Y0 ); + for ( i = 0; i < X1; i++ ) + putch( 32 ); + textcolor( cc ); + gotoxy( X0, Y0 ); + cprintf( "%s", s1 ); + + } else { + if ( numalp && isdigit(c) && ls < lmax) { + *s++ = c; + ls++; + + *s = '\0'; // Cero final + + gotoxy( X0, Y0 ); + for ( i = 0; i < X1; i++ ) + putch( 32 ); + textcolor( cc ); + gotoxy( X0, Y0 ); + cprintf( "%s", s1 ); + + } + /*ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ*/ + else if( c == 27 ) {*s='\0'; ok = 1; } + /*ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ*/ + else BEEP(); + } + } + + }while(!ok); + + _setcursortype( _NOCURSOR ); + + ok = 1; + *s = ' '; + while( ok && ls >= 0 ) { + if(*s==' ') { *s = '\0'; s--; ls--; + } else { s++; ok = 0; } + } + + *s = '\0'; + + while(kbhit()) getch(); // Vacia Buffer impidiendo falsas + // pulsaciones... + + return ( (Status<<8) + (ls&0x00FF) ); +} + +void BEEP(void) +{ + + sound(440); + delay(50); + nosound(); + +} + + +void formatea_u_long( unsigned long Numero, char *Inter_Chg) +{ + char Buffer1[80]; + + int c; + + sprintf(Buffer1, "%lu", Numero); + + Inter_Chg[0]='\0'; + + strrev(Buffer1); + + c = strlen( Buffer1 ); + + while( c >= 3 ) + { + + c -= 3; + strncat( Inter_Chg, Buffer1, 3); + + strrev(Buffer1); + + Buffer1[c] = '\0'; + + strrev(Buffer1); + + if(strlen(Buffer1)!=0) + strcat( Inter_Chg, "." ); + } + + strcat( Inter_Chg, Buffer1); + strrev(Inter_Chg); + + +/*// return Buffer2;*/ +} + + +int Optar( int optar, ... ) +{ +struct Boton_Texto BT[6]; +int devolver = 0; + +BT[0].x = 22; BT[0].y = 15; strcpy( BT[0].Texto, " &Aceptar "); BT[0].ID_T1 = 00; BT[0].ID_T2 = 30; +BT[1].x = 51; BT[1].y = 15; strcpy( BT[1].Texto, " &Cancelar"); BT[1].ID_T1 = 00; BT[1].ID_T2 = 46; + + static char fondo[4096]; + static char Memoria = 0; + + int DEV = 0, ok = 0, linea = 0; + int Center; char *buff; + + va_list ap; + va_start( ap, &optar ); + + if ( Memoria == 1 ) + { + puttext( 21, 5, 63, 17, (void *)fondo ); Memoria = 0; + if ( optar == ENCUADRE ) return DEV; + } + + Memoria = 1; + + gettext( 21, 5, 63, 17, (void *)fondo ); + +textbackground( BLACK ); +textcolor( CYAN ); +gotoxy( 21, 5 ); cprintf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"); +gotoxy( 21, 6 ); cprintf("³ ³"); +gotoxy( 21, 7 ); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´"); +gotoxy( 21, 8 ); cprintf("³ ³"); +gotoxy( 21, 9 ); cprintf("³ ³"); +gotoxy( 21, 10 ); cprintf("³ ³"); +gotoxy( 21, 11 ); cprintf("³ ³"); +gotoxy( 21, 12 ); cprintf("³ ³"); +gotoxy( 21, 13 ); cprintf("³ ³"); +gotoxy( 21, 14 ); cprintf("³ ³"); +gotoxy( 21, 15 ); cprintf("³ ³"); +gotoxy( 21, 16 ); cprintf("³ ³"); +gotoxy( 21, 17 ); cprintf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"); + + + + textcolor( RED ); + linea = 0; + while ( (buff = va_arg(ap, char *)) != NULL ) + { + Center = (42 - strlen( buff ) ) / 2; + gotoxy( 21+Center+1, ( (linea == 0 ) ? 6 : 8 + linea ) ); + cprintf( "%s", buff ); + linea++; + } + + va_end(ap); + + if ( optar != ENCUADRE ) + { + ok = 0; while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER + if ( optar == 1 ) + do { + switch( Funcion_Botones(STD_BY, 2, BT) ) + { + case 0: // No se pulso ningun BOTON + case -2: + case -1: + while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER + if ( optar == 0 ) ok = 1; + break; + case 1: + DEV = 1; ok = 1; + break; + case 2: + DEV = 0; ok = 1; + break; + } + }while( !ok ); + else { espera_pulsar(); espera_soltar(); } + + puttext( 21, 5, 63, 17, (void *)fondo ); + + Memoria = 0; + + } + + return DEV; +} + + + diff --git a/ZORR.DSK b/ZORR.DSK new file mode 100644 index 0000000..ecdccb0 Binary files /dev/null and b/ZORR.DSK differ diff --git a/ZORR.EXE b/ZORR.EXE new file mode 100644 index 0000000..28a7a20 Binary files /dev/null and b/ZORR.EXE differ diff --git a/ZORR.H b/ZORR.H new file mode 100644 index 0000000..f8af447 --- /dev/null +++ b/ZORR.H @@ -0,0 +1,124 @@ +#include + +#define DIBUJA 1 +#define DEPRIME 2 +#define Dibuja_Todos 3 +#define COMPRUEBA 4 +#define STD_BY 5 + +#define NORMAL 0 +#define INTENSO 1 + +#define ATRAS -1 +#define NUEVA_BUSQUEDA 0 +#define ADELANTE 1 + +#define SEC_OPTAR 5 +#define ENCUADRE 3 + +// Niveles de acceso al programa +#define TOTAL 0 +#define USUARIO 1 +#define NINGUNO 2 + + +typedef struct +{ + char FillBgS, FillBgC; + char NumFg, NumBg, NumLn; + char TxtBgN, TxtBgI, TxtFgN, TxtFgI; + char Printer, PrintTo[80]; +} CONFIG; + + +struct hora +{ + char min; // Minutos y hora + char hora; +}; + +struct ComprasSocios +{ + unsigned char dia; + unsigned char mes; + long Cantidad; +}; + +typedef struct +{ + long NSocio; + char Nombre[15+1]; + char Apellido[20+1]; + char Direccion[25+1]; + int Num; + char Piso[4+1]; + + int NCompras; + struct ComprasSocios CSocios[240]; + +} INFO_SOCIOS; + +typedef struct +{ + struct date Fecha; + char Articulo[25+1]; + int Proveedor; + long Precio; + int Cantidades; +} INFO_PRECIOS; + +typedef struct +{ + char Articulo[45+1]; + long Precio; + char Ubicacion[14+1]; + long PrecioArt; +} INFO_ARTICULOS; + + + + + + + + +int Optar( int optar, ... ); +void ponicono(int x,int y,char matriz[18][18], char pos); +void formatea_u_long( unsigned long Numero, char *Inter_Chg); +int InputCadenaG(char *s, int numalp, int lmax, int cc, int cf, int X0, int Y0, int X1, int Y1); +void Error( int code ); + + +// M¢dulo de referencias +void InfoProductos(void); + +// M¢dulo de Compras +void ComprasDiarias( int NivelAcceso ); + +// Informacion de los proveedores +void InfoProveedores(void); + +//ÛÛ +void espera_soltar(void); +void espera_pulsar(void); +void activa_raton(void); +void desactiva_raton(void); +void inicializa_raton_texto(void); +struct Boton_Texto{ + char x; char y; + char Texto[80]; + + int ID_T1; + int ID_T2; +}; + + + +int Funcion_Botones(int Funcion, int nBotones, struct Boton_Texto *Boton_Texto); + +extern int boton_izq, boton_der; +extern int x_raton, y_raton, RATON; + +//ÛÛ + +extern int AnoActual; diff --git a/ZORR.IMG b/ZORR.IMG new file mode 100644 index 0000000..3d3cc86 --- /dev/null +++ b/ZORR.IMG @@ -0,0 +1,443 @@ + +** +** Codigo fuente para MAKE_BOTON +** + +***************************************************************************** +* +* ATENCION !!! +* ALTERAR ESTE FICHERO, CAUSARA EL MALFUNCIONAMIENTO DEL +* PROGRAMA DE APOYO... ( ERRORES NO DOCUMENTADOS ) +* +***************************************************************************** + +#5 + + + +************************************************ Botones D: 1 +**** **** Botones S: 10 +** M¢dulo de Ventas ** +**** **** +************************************************ +!1, 6 +$ 605, 5, 635, 120, 7, 63, 56, 2, 2, 000, 000 * Impr. £ltimo ticket +$ 490, 5, 590, 30, 7, 63, 56, 2, 2, 000, 000 * Impr. Tickets +$ 490, 50, 590, 75, 7, 63, 56, 2, 2, 000, 000 * Cobro completo +$ 490, 95, 590, 120, 7, 63, 56, 2, 2, 000, 000 * Servicio en mesa +$ 420, 5, 450, 120, 7, 63, 56, 2, 2, 000, 000 * Gastos / Compras +$ 380, 5, 410, 120, 7, 63, 56, 2, 2, 000, 000 * Menu Principal + +­10 + + + +************************************************ Botones D: 2 +**** **** Botones S: 20 +** M¢dulo de Referencias ** +**** **** +************************************************ +!2, 9 + +$ 400, 40, 515, 65, 7, 63, 56, 2, 2, 000, 23 +$ 520, 40, 635, 65, 7, 63, 56, 2, 2, 000, 50 +$ 400, 70, 515, 95, 7, 63, 56, 2, 2, 000, 83 +$ 520, 70, 635, 95, 7, 63, 56, 2, 2, 000, 82 +$ 400, 100, 440, 125, 7, 63, 56, 2, 2, 000, 73 +$ 445, 100, 475, 125, 7, 63, 56, 2, 2, 000, 71 +$ 480, 100, 555, 125, 7, 63, 56, 2, 2, 000, 48 +$ 560, 100, 590, 125, 7, 63, 56, 2, 2, 000, 79 +$ 595, 100, 635, 125, 7, 63, 56, 2, 2, 000, 81 + +­20 +& 400, 5, 635, 30, 7, 63, 56, 2, 2 +| 400, 7, 2, 5, 0, 0, Listado de Socios, +| 401, 8, 2, 5, 0, 63, Listado de Socios, + +& 400, 40, 515, 65, 7, 63, 56, 2, 2 +| 400, 42, 2, 5, 0, 0, Imprimir Soc., +| 401, 43, 2, 5, 0, 63, Imprimir Soc., + | 400, 43, 2, 5, 0, 0, _, + | 401, 44, 2, 5, 0, 63, _, + +& 520, 40, 635, 65, 7, 63, 56, 2, 2 +| 518, 42, 2, 5, 0, 0, Men£ Principal, +| 519, 43, 2, 5, 0, 63, Men£ Principal, + | 518, 43, 2, 5, 0, 0, _, + | 519, 44, 2, 5, 0, 63, _, + +& 400, 70, 515, 95, 7, 63, 56, 2, 2 +| 400, 72, 2, 5, 0, 0, Eliminar Soc., +| 401, 73, 2, 5, 0, 63, Eliminar Soc., +& 520, 70, 635, 95, 7, 63, 56, 2, 2 +| 518, 72, 2, 5, 0, 0, Insertar Soc., +| 519, 73, 2, 5, 0, 63, Insertar Soc., + +& 400, 100, 440, 125, 7, 63, 56, 2, 2 +| 400, 102, 2, 5, 0, 0, <<, +| 401, 103, 2, 5, 0, 63, <<, +& 445, 100, 475, 125, 7, 63, 56, 2, 2 +| 445, 102, 2, 5, 0, 0, <-, +| 446, 103, 2, 5, 0, 63, <-, + +& 480, 100, 555, 125, 7, 63, 56, 2, 2 +| 480, 102, 2, 5, 0, 0, Buscar, +| 481, 103, 2, 5, 0, 63, Buscar, + +& 560, 100, 590, 125, 7, 63, 56, 2, 2 +| 560, 102, 2, 5, 0, 0, ->, +| 561, 103, 2, 5, 0, 63, ->, +& 595, 100, 635, 125, 7, 63, 56, 2, 2 +| 595, 102, 2, 5, 0, 0, >>, +| 596, 103, 2, 5, 0, 63, >>, + +& 5, 130, 635, 155, 7, 63, 56, 2, 2 +| 10, 132, 2, 5, 0, 63, N§ Socio Nombre Direcci¢n, +| 11, 133, 2, 5, 0, 0, N§ Socio Nombre Direcci¢n, + +& 5, 160, 80, 450, 63, 7, 56, 2, 2 +& 85, 160, 345, 450, 63, 7, 56, 2, 2 +& 350, 160, 635, 450, 63, 7, 56, 2, 2 + + +* Linea de fondo para ayudas +& 5, 455, 500, 475, 0, 63, 56, 0, 2 +& 505, 455, 635, 475, 63, 0, 0, 0, 2 + +************************************************ Botones D: +**** **** Botones S: 21 +** M¢dulo buscar asociado a Referencias ** +**** **** +************************************************ + +­21 +& 260, 200, 360, 220, 63, 0, 56, 0, 2 +& 365, 200, 465, 220, 63, 0, 56, 0, 2 +& 260, 225, 465, 245, 63, 0, 56, 0, 2 + +& 235, 250, 315, 275, 63, 0, 56, 0, 2 +& 385, 250, 465, 275, 63, 0, 56, 0, 2 + +& 330, 275, 365, 300, 63, 0, 56, 0, 2 + +| 175, 200, 2, 6, 0, 0, Cod.Art:, +| 176, 201, 2, 6, 0, 63, Cod.Art:, +| 175, 225, 2, 6, 0, 0, Nombre:, +| 176, 226, 2, 6, 0, 63, Nombre:, +| 175, 250, 2, 6, 0, 0, P.C.: P.V.P.:, +| 176, 251, 2, 6, 0, 63, P.C.: P.V.P.:, +| 175, 275, 2, 6, 0, 0, COMBINADOS -> [ ], +| 176, 276, 2, 6, 0, 63, COMBINADOS -> [ ], + + + +************************************************ Botones D: 3 +**** **** Botones S: 22 +** M¢dulo imprimir asociado a Referencias ** +**** **** +************************************************ +!3, 4 + +$ 180, 200, 220, 305, 1, 56, 63, 2, 2, 000, 46 +$ 230, 200, 460, 230, 7, 56, 63, 2, 2, 000, 19 +$ 230, 235, 460, 270, 7, 56, 63, 2, 2, 000, 24 +$ 230, 275, 460, 305, 7, 56, 63, 2, 2, 000, 48 + +­22 +& 170, 165, 470, 315, 7, 63, 56, 0, 2 +& 172, 167, 468, 190, 1, 56, 63, 0, 2 +| 175, 167, 2, 6, 0, 0, Impresion de Referencias, +| 175, 168, 2, 6, 0, 63, Impresion de Referencias, + +& 180, 200, 220, 305, 1, 56, 63, 2, 2 +| 190, 200, 2, 6, 1, 0, Cancelar , +| 191, 201, 2, 6, 1, 63, Cancelar , + | 191, 201, 2, 6, 1, 0, _ , + | 192, 202, 2, 6, 1, 63, _ , + +& 230, 200, 460, 230, 7, 56, 63, 2, 2 +| 230, 202, 2, 6, 0, 0, Listado r pido, +| 231, 203, 2, 6, 0, 63, Listado r pido, + | 231, 203, 2, 6, 0, 0, _, + | 232, 204, 2, 6, 0, 63, _, +& 230, 235, 460, 270, 7, 56, 63, 2, 2 +| 230, 237, 2, 6, 0, 0, Listado completo, +| 231, 238, 2, 6, 0, 63, Listado completo, + | 231, 238, 2, 6, 0, 0, _, + | 232, 239, 2, 6, 0, 63, _, +& 230, 275, 460, 305, 7, 56, 63, 2, 2 +| 230, 277, 2, 6, 0, 0, C¢digos de barra, +| 231, 278, 2, 6, 0, 63, C¢digos de barra, + | 231, 278, 2, 6, 0, 0, _, + | 232, 279, 2, 6, 0, 63, _, + + +************************************************ Botones D: 2 +**** **** Botones S: 30 +** M¢dulo para la Gestion de los Proveedores ** +**** **** +************************************************ +­30 +& 400, 5, 635, 30, 7, 63, 56, 2, 2 +| 400, 7, 2, 5, 0, 0, Gestion de Proveedores, +| 401, 8, 2, 5, 0, 63, Gestion de Proveedores, + +& 400, 40, 515, 65, 7, 63, 56, 2, 2 +| 400, 42, 2, 5, 0, 0, Imprimir Prov., +| 401, 43, 2, 5, 0, 63, Imprimir Prov., + | 400, 43, 2, 5, 0, 0, _, + | 401, 44, 2, 5, 0, 63, _, + +& 520, 40, 635, 65, 7, 63, 56, 2, 2 +| 518, 42, 2, 5, 0, 0, Men£ Principal, +| 519, 43, 2, 5, 0, 63, Men£ Principal, + | 518, 43, 2, 5, 0, 0, _, + | 519, 44, 2, 5, 0, 63, _, + +& 400, 70, 515, 95, 7, 63, 56, 2, 2 +| 400, 72, 2, 5, 0, 0, Eliminar Prov., +| 401, 73, 2, 5, 0, 63, Eliminar Prov., +& 520, 70, 635, 95, 7, 63, 56, 2, 2 +| 518, 72, 2, 5, 0, 0, Insertar Prov., +| 519, 73, 2, 5, 0, 63, Insertar Prov., + +& 400, 100, 440, 125, 7, 63, 56, 2, 2 +| 400, 102, 2, 5, 0, 0, <<, +| 401, 103, 2, 5, 0, 63, <<, +& 445, 100, 475, 125, 7, 63, 56, 2, 2 +| 445, 102, 2, 5, 0, 0, <-, +| 446, 103, 2, 5, 0, 63, <-, + +& 480, 100, 555, 125, 7, 63, 56, 2, 2 +| 480, 102, 2, 5, 0, 0, Buscar, +| 481, 103, 2, 5, 0, 63, Buscar, + +& 560, 100, 590, 125, 7, 63, 56, 2, 2 +| 560, 102, 2, 5, 0, 0, ->, +| 561, 103, 2, 5, 0, 63, ->, +& 595, 100, 635, 125, 7, 63, 56, 2, 2 +| 595, 102, 2, 5, 0, 0, >>, +| 596, 103, 2, 5, 0, 63, >>, + +| 5, 40, 2, 5, 0, 0, Direccion Num, +| 6, 41, 2, 5, 0, 63, Direccion Num, +& 88, 35, 308, 60, 63, 7, 56, 2, 2 +& 355, 35, 390, 60, 63, 7, 56, 2, 2 + +| 5, 65, 2, 5, 0, 0, Poblacion Provincia, +| 6, 66, 2, 5, 0, 63, Poblaci¢n Provincia, +& 88, 65, 210, 90, 63, 7, 56, 2, 2 +& 290, 66, 390, 91, 63, 7, 56, 2, 2 + +| 5, 95, 2, 5, 0, 0, Cd.Postal Estr., +| 6, 96, 2, 5, 0, 63, Cd.Postal Estr., +& 88, 95, 188, 120, 63, 7, 56, 2, 2 + +& 245, 95, 270, 120, 7, 63, 56, 2, 2 +& 275, 95, 300, 120, 7, 63, 56, 2, 2 +& 305, 95, 330, 120, 7, 63, 56, 2, 2 +& 335, 95, 360, 120, 7, 63, 56, 2, 2 +& 365, 95, 390, 120, 7, 63, 56, 2, 2 + + +& 5, 130, 635, 155, 7, 63, 56, 2, 2 +| 5, 135, 2, 5, 0, 0, C¢digo Proveedor Tel‚fono 1 N§ de Fax, +| 6, 136, 2, 5, 0, 63, C¢digo Proveedor Tel‚fono 1 N§ de Fax, + +& 5, 160, 100, 450, 63, 7, 56, 2, 2 +& 105, 160, 360, 450, 63, 7, 56, 2, 2 +& 365, 160, 497, 450, 63, 7, 56, 2, 2 +& 503, 160, 635, 450, 63, 7, 56, 2, 2 + +* Linea de fondo para ayudas +& 5, 455, 500, 475, 0, 63, 56, 0, 2 +& 505, 455, 635, 475, 63, 0, 0, 0, 2 + +************************************************ Botones D: +**** **** Botones S: 31 +** M¢dulo buscar asociado a Proveedores ** +**** **** +************************************************ + +­31 +& 265, 200, 365, 220, 63, 0, 56, 0, 2 +& 265, 225, 465, 245, 63, 0, 56, 0, 2 +& 265, 250, 465, 275, 63, 0, 56, 0, 2 +& 265, 280, 465, 305, 63, 0, 56, 0, 2 + +| 175, 200, 2, 6, 0, 0, Cod.Art:, + | 176, 201, 2, 6, 0, 63, Cod.Art:, +| 175, 225, 2, 6, 0, 0, Proveed., + | 176, 226, 2, 6, 0, 63, Proveed., +| 175, 250, 2, 6, 0, 0, Direccion, + | 176, 251, 2, 6, 0, 63, Direccion, +| 175, 275, 2, 6, 0, 0, Poblacion, + | 176, 276, 2, 6, 0, 63, Poblacion, + + + +************************************************ Botones D: 2 +**** **** Botones S: 40 +** M¢dulo de Compras Diarias ** +**** **** +************************************************ +­40 +& 400, 5, 635, 30, 7, 63, 56, 2, 2 +| 400, 7, 2, 5, 0, 0, Gastos Diarios:, +| 401, 8, 2, 5, 0, 63, Gastos Diarios:, + +& 400, 40, 515, 65, 7, 63, 56, 2, 2 +| 400, 42, 2, 5, 0, 0, Imprimir Comp., +| 401, 43, 2, 5, 0, 63, Imprimir Comp., + | 400, 43, 2, 5, 0, 0, _, + | 401, 44, 2, 5, 0, 63, _, + +& 520, 40, 635, 65, 7, 63, 56, 2, 2 +| 518, 42, 2, 5, 0, 0, Men£ Principal, +| 519, 43, 2, 5, 0, 63, Men£ Principal, + | 518, 43, 2, 5, 0, 0, _, + | 519, 44, 2, 5, 0, 63, _, + +& 400, 70, 515, 95, 7, 63, 56, 2, 2 +| 400, 72, 2, 5, 0, 0, Eliminar Gasto, +| 401, 73, 2, 5, 0, 63, Eliminar Gasto, +& 520, 70, 635, 95, 7, 63, 56, 2, 2 +| 518, 72, 2, 5, 0, 0, Insertar Gasto, +| 519, 73, 2, 5, 0, 63, Insertar Gasto, + +& 400, 100, 440, 125, 7, 63, 56, 2, 2 +| 400, 102, 2, 5, 0, 0, <<, +| 401, 103, 2, 5, 0, 63, <<, +& 445, 100, 475, 125, 7, 63, 56, 2, 2 +| 445, 102, 2, 5, 0, 0, <-, +| 446, 103, 2, 5, 0, 63, <-, + +& 480, 100, 555, 125, 7, 63, 56, 2, 2 +| 480, 102, 2, 5, 0, 0, Buscar, +| 481, 103, 2, 5, 0, 63, Buscar, + +& 560, 100, 590, 125, 7, 63, 56, 2, 2 +| 560, 102, 2, 5, 0, 0, ->, +| 561, 103, 2, 5, 0, 63, ->, +& 595, 100, 635, 125, 7, 63, 56, 2, 2 +| 595, 102, 2, 5, 0, 0, >>, +| 596, 103, 2, 5, 0, 63, >>, + +& 5, 130, 635, 155, 7, 63, 56, 2, 2 +| 5, 135, 2, 5, 0, 0, C¢digo Descripcion Unds. Proveedor P. Costo, +| 6, 136, 2, 5, 0, 63, C¢digo Descripcion Unds. Proveedor P. Costo, + +& 5, 160, 100, 450, 63, 7, 56, 2, 2 +& 105, 160, 360, 450, 63, 7, 56, 2, 2 +& 365, 160, 415, 450, 63, 7, 56, 2, 2 +& 420, 160, 545, 450, 63, 7, 56, 2, 2 +& 550, 160, 635, 450, 63, 7, 56, 2, 2 + + +* Linea de fondo para ayudas +& 5, 455, 500, 475, 0, 63, 56, 0, 2 +& 505, 455, 635, 475, 63, 0, 0, 0, 2 + +************************************************ Botones D: 4 +**** **** Botones S: 45 +** Calendario para Compras Diarias ** +**** **** +************************************************ + +!4, 44 + +* Domingos +$ 350, 5, 380, 25, 4, 63, 56, 2, 2, 000, 000 +$ 350, 25, 380, 45, 4, 63, 56, 2, 2, 000, 000 +$ 350, 45, 380, 65, 4, 63, 56, 2, 2, 000, 000 +$ 350, 65, 380, 85, 4, 63, 56, 2, 2, 000, 000 +$ 350, 85, 380, 105, 4, 63, 56, 2, 2, 000, 000 +$ 350, 105, 380, 125, 4, 63, 56, 2, 2, 000, 000 + +* Sabado +$ 320, 5, 350, 25, 4, 63, 56, 2, 2, 000, 000 +$ 320, 25, 350, 45, 4, 63, 56, 2, 2, 000, 000 +$ 320, 45, 350, 65, 4, 63, 56, 2, 2, 000, 000 +$ 320, 65, 350, 85, 4, 63, 56, 2, 2, 000, 000 +$ 320, 85, 350, 105, 4, 63, 56, 2, 2, 000, 000 +$ 320, 105, 350, 125, 4, 63, 56, 2, 2, 000, 000 + +* Viernes +$ 290, 5, 320, 25, 9, 63, 56, 2, 2, 000, 000 +$ 290, 25, 320, 45, 9, 63, 56, 2, 2, 000, 000 +$ 290, 45, 320, 65, 9, 63, 56, 2, 2, 000, 000 +$ 290, 65, 320, 85, 9, 63, 56, 2, 2, 000, 000 +$ 290, 85, 320, 105, 9, 63, 56, 2, 2, 000, 000 +$ 290, 105, 320, 125, 9, 63, 56, 2, 2, 000, 000 + +* Jueves +$ 260, 5, 290, 25, 9, 63, 56, 2, 2, 000, 000 +$ 260, 25, 290, 45, 9, 63, 56, 2, 2, 000, 000 +$ 260, 45, 290, 65, 9, 63, 56, 2, 2, 000, 000 +$ 260, 65, 290, 85, 9, 63, 56, 2, 2, 000, 000 +$ 260, 85, 290, 105, 9, 63, 56, 2, 2, 000, 000 +$ 260, 105, 290, 125, 9, 63, 56, 2, 2, 000, 000 + +* Miercoles +$ 230, 5, 260, 25, 9, 63, 56, 2, 2, 000, 000 +$ 230, 25, 260, 45, 9, 63, 56, 2, 2, 000, 000 +$ 230, 45, 260, 65, 9, 63, 56, 2, 2, 000, 000 +$ 230, 65, 260, 85, 9, 63, 56, 2, 2, 000, 000 +$ 230, 85, 260, 105, 9, 63, 56, 2, 2, 000, 000 +$ 230, 105, 260, 125, 9, 63, 56, 2, 2, 000, 000 + +* Martes +$ 200, 5, 230, 25, 9, 63, 56, 2, 2, 000, 000 +$ 200, 25, 230, 45, 9, 63, 56, 2, 2, 000, 000 +$ 200, 45, 230, 65, 9, 63, 56, 2, 2, 000, 000 +$ 200, 65, 230, 85, 9, 63, 56, 2, 2, 000, 000 +$ 200, 85, 230, 105, 9, 63, 56, 2, 2, 000, 000 +$ 200, 105, 230, 125, 9, 63, 56, 2, 2, 000, 000 + +* Lunes +$ 170, 5, 200, 25, 9, 63, 56, 2, 2, 000, 000 +$ 170, 25, 200, 45, 9, 63, 56, 2, 2, 000, 000 +$ 170, 45, 200, 65, 9, 63, 56, 2, 2, 000, 000 +$ 170, 65, 200, 85, 9, 63, 56, 2, 2, 000, 000 +$ 170, 85, 200, 105, 9, 63, 56, 2, 2, 000, 000 +$ 170, 105, 200, 125, 9, 63, 56, 2, 2, 000, 000 + +* Mes Anterior +$ 145, 5, 165, 62, 7, 56, 63, 1, 2, 000, 000 + +* Mes Siguiente +$ 145, 68, 165, 125, 7, 56, 63, 1, 2, 000, 000 + +­45 + +* Nombre del Mes +& 120, 5, 140, 125, 7, 56, 63, 1, 2 + + + +************************************************ Botones D: 5 +**** **** Botones S: 100 +** Parte Utilizada por Optar ** +**** **** +************************************************ +!5, 2 + +$ 170, 320, 270, 350, 7, 63, 56, 2, 2, 000, 30 +$ 370, 320, 470, 350, 7, 63, 56, 2, 2, 000, 46 + +­100 +& 170, 165, 470, 315, 7, 63, 56, 0, 2 +& 172, 167, 468, 190, 1, 56, 63, 0, 2 + +& 170, 320, 270, 350, 7, 63, 56, 2, 2 +| 175, 325, 2, 6, 0, 63, Aceptar, +| 176, 326, 2, 6, 0, 0, Aceptar, +| 175, 327, 2, 6, 0, 63, _, +| 176, 328, 2, 6, 0, 0, _, + +& 370, 320, 470, 350, 7, 63, 56, 2, 2 +| 373, 325, 2, 6, 0, 63, Cancelar, +| 374, 326, 2, 6, 0, 0, Cancelar, +| 373, 327, 2, 6, 0, 63, _, +| 374, 328, 2, 6, 0, 0, _, + diff --git a/ZORR.PRJ b/ZORR.PRJ new file mode 100644 index 0000000..b6b52bf Binary files /dev/null and b/ZORR.PRJ differ diff --git a/ZORR.RAR b/ZORR.RAR new file mode 100644 index 0000000..b151adf Binary files /dev/null and b/ZORR.RAR differ diff --git a/ZOR_MM.CPP b/ZOR_MM.CPP new file mode 100644 index 0000000..ea4f055 --- /dev/null +++ b/ZOR_MM.CPP @@ -0,0 +1,400 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "d:\program\src_dos\libs\bdatos\bdatos.hh" +#include "zorr.h" + + +CONFIG Config = { + 1, BLUE, + RED, WHITE, BLACK, + BLACK, RED, WHITE, BLACK, + 0, { "PrnFile.out" } + }; + +#define OFF 0 +#define ON 1 + +#ifdef __cplusplus + #define __CPPARGS ... +#else + #define __CPPARGS +#endif + + +#define GESTION_DE_SOCIOS 1 +#define LISTA_DE_PRECIOS 2 +#define GASTOS_INTERNOS 3 +#define SALIR 4 + + + +int MenuPrincipal(void); + +void ListaPrecios(void); +void GestionSocios(void); +extern void GastosInternos(void); +void PideAnoActual(void); + +void DibujaPantallaGastosInt(void); + +int boton_izq; int boton_der; +int x_raton, y_raton, RATON = 1; + +//ÛÛ + +int AnoActual; + +int main(void) +{ + int ok; + struct date d; + getdate( &d ); + AnoActual = d.da_year - ( d.da_year / 100 ) * 100; + + inicializa_raton_texto(); + if( RATON ) desactiva_raton(); + + PideAnoActual(); + + ok = 0; + do { + + switch( MenuPrincipal() ) + { + case GESTION_DE_SOCIOS: + GestionSocios(); + break; + case LISTA_DE_PRECIOS: + ListaPrecios(); + break; + case GASTOS_INTERNOS: + GastosInternos(); + break; + case SALIR: + ok = 1; + break; + } + + } while ( !ok ) ; + + +return 0; + +} + +int MenuPrincipal(void) +{ +struct Boton_Texto BT[4]; +int devolver = 0; + +BT[0].x = 29; BT[0].y = 9; strcpy( BT[0].Texto, " &Gestion de Socios "); BT[0].ID_T1 = 71; BT[0].ID_T2 = 0; +BT[1].x = 29; BT[1].y = 12; strcpy( BT[1].Texto, " &Listado de Precios "); BT[1].ID_T1 = 76; BT[1].ID_T2 = 0; + +BT[2].x = 29; BT[2].y = 15; strcpy( BT[2].Texto, " Ga&stos internos "); BT[2].ID_T1 = 83; BT[2].ID_T2 = 0; +BT[3].x = 29; BT[3].y = 18; strcpy( BT[3].Texto, " S&ALIR al DOS "); BT[3].ID_T1 = 65; BT[3].ID_T2 = 0; + + + _setcursortype(_NOCURSOR); + textcolor( WHITE ); + textbackground( BLACK ); + clrscr(); + + cprintf(" \n\r"); + cprintf(" Ü ÜÜÜ ÜÜÜ ÜÜÜ ÜÜÜ ÜÜ ÜÜÜ ÜÜÜ ÜÜ Ü Ü Ü ÜÜ ÜÜÜ ÜÜÜ \n\r"); + cprintf(" Û Û Û ÛÜÜ ÛÜÛ ÛÜÛ Û Û Û ÛÜÜ Û ÛÜÛ Û Û Û Û ÛÜÜ \n\r"); + cprintf(" ÛÜÜ ÛÜÛ ÜÜÛ Û Û ÛßÜ ÛÜ ÛÜÛ ÜÜÛ ÛÜ Û Û Û ÛÜ ÛÜÛ ÜÜÛ \n\r"); + cprintf(" \n\r"); + cprintf(" \n\r"); + cprintf(" ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ \n\r"); + cprintf(" ³ ³ \n\r"); + cprintf(" ³ ³ \n\r"); + cprintf(" ³ ³ \n\r"); + cprintf(" ³ ³ \n\r"); + cprintf(" ³ ³ \n\r"); + cprintf(" ³ ³ \n\r"); + cprintf(" ³ ³ \n\r"); + cprintf(" ³ ³ \n\r"); + cprintf(" ³ ³ \n\r"); + cprintf(" ³ ³ \n\r"); + cprintf(" ³ ³ \n\r"); + cprintf(" ³ ³ \n\r"); + cprintf(" ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ \n\r"); + + while( ( devolver = Funcion_Botones(STD_BY, 4, BT) ) < 1 || devolver > 4 ) while ( kbhit() ) getch(); + + _setcursortype(_NORMALCURSOR); + return devolver; +} + + +int Funcion_Botones(int Funcion, int nBotones, struct Boton_Texto *Boton_Texto) +{ + + char i; + int DEVOLVER = -1; + int longitud, key, key2; + + switch( Funcion ) { + case DIBUJA: + highvideo(); + textcolor(BLACK); + textbackground(11); + gotoxy(Boton_Texto[nBotones].x, Boton_Texto[nBotones].y); + DEVOLVER = 0; + longitud = strlen( Boton_Texto[nBotones].Texto ); + while( DEVOLVER <= longitud ) { + if( Boton_Texto[nBotones].Texto[DEVOLVER] == '&' ) { + DEVOLVER ++; + textcolor(RED); + cprintf("%c", Boton_Texto[nBotones].Texto[DEVOLVER]); + textcolor(BLACK); + } else cprintf("%c", Boton_Texto[nBotones].Texto[DEVOLVER]); + DEVOLVER ++; + } + + // cprintf("%s", Texto); + + textbackground(7); // ±SALIR±Ü + cprintf("ß"); // ßßßßßßß + gotoxy(Boton_Texto[nBotones].x+1, Boton_Texto[nBotones].y+1); + for(i = 0; i < longitud; i ++ ) // ±±±±±±±Ü + cprintf("Ü"); // ßßßßßßß + break; + case DEPRIME: + highvideo(); + textcolor(BLACK); + textbackground(11); + gotoxy(Boton_Texto[nBotones].x, Boton_Texto[nBotones].y); + DEVOLVER = 0; + longitud = strlen( Boton_Texto[nBotones].Texto ); + //////////////// + textbackground(BLACK); + while( DEVOLVER <= (longitud+1) ) { + if( Boton_Texto[nBotones].Texto[DEVOLVER] == '&' ) { + DEVOLVER ++; + } + cprintf(" "); + DEVOLVER ++; + } + textbackground(11); + gotoxy(Boton_Texto[nBotones].x+1, Boton_Texto[nBotones].y+1); + DEVOLVER = 0; + while( DEVOLVER <= longitud ) { + + if( Boton_Texto[nBotones].Texto[DEVOLVER] == '&' ) { + DEVOLVER ++; + textcolor(RED); + cprintf("%c", Boton_Texto[nBotones].Texto[DEVOLVER]); + textcolor(BLACK); + } else cprintf("%c", Boton_Texto[nBotones].Texto[DEVOLVER]); + DEVOLVER ++; + } +// cprintf("%s", Texto); // + // ±±±±±±± + break; + case Dibuja_Todos: + for( i=0; i < nBotones; i++) + Funcion_Botones( DIBUJA, i, Boton_Texto); + break; + case COMPRUEBA: + if( bioskey(1)!=0 ) { + key = toupper( getch() ); DEVOLVER = -2; + if ( key == 0 ) { key2 = toupper( getch() ); DEVOLVER = -1; } + for( i=0; i < nBotones && DEVOLVER <= -1; i++){ + if( key == Boton_Texto[i].ID_T1 ) { + if( key == 0 ) { + if( key2 == Boton_Texto[i].ID_T2 ){ + DEVOLVER = (i + 1); + Funcion_Botones( DEPRIME, (DEVOLVER-1), Boton_Texto); + delay(150); + //sleep(1); + Funcion_Botones( DIBUJA, (DEVOLVER-1), Boton_Texto); + } + } else + { DEVOLVER = (i + 1); + Funcion_Botones( DEPRIME, (DEVOLVER-1), Boton_Texto); + delay(150); + //sleep(1); + Funcion_Botones( DIBUJA, (DEVOLVER-1), Boton_Texto); + } + } + } + + if( DEVOLVER == -2 ) + { ungetch(key); } + + if( DEVOLVER == -1 ) + { ungetch(key2); } + + + } else if( RATON ) { + DEVOLVER = 0; + for( i=0; i < nBotones && DEVOLVER == 0; i++) { + longitud = strlen( Boton_Texto[i].Texto ); + if ( (x_raton+1) >= Boton_Texto[i].x && (x_raton+1) <= ( Boton_Texto[i].x + longitud -1) && + y_raton == (Boton_Texto[i].y-1) ) { DEVOLVER = (i + 1); + Funcion_Botones( DEPRIME, (DEVOLVER-1), Boton_Texto); + if( RATON ) activa_raton(); + espera_soltar(); + if( RATON ) desactiva_raton(); +// delay(150); + Funcion_Botones( DIBUJA, (DEVOLVER-1), Boton_Texto); + } + } + } + break; + case STD_BY: + Funcion_Botones(Dibuja_Todos, nBotones, Boton_Texto); + do{ + if( RATON ) activa_raton(); + if( RATON ) espera_pulsar(); else while( bioskey(1)==0 ); + if( RATON ) desactiva_raton(); + DEVOLVER = Funcion_Botones(COMPRUEBA, nBotones, Boton_Texto); + }while(DEVOLVER==0 && bioskey(1)==0 ); + + } + return DEVOLVER; +} + +void inicializa_raton_texto(void) +{ + union REGS ent, sal; + + ent.x.ax = 0; + int86(0x33, &ent, &sal); /* averigua si hay rat¢n conectado */ + + if(sal.x.ax==0) { RATON = 0; return; } + + ent.x.ax = 15; + ent.x.cx = 8; + ent.x.dx = 16; + int86(0x33, &ent, &sal); /* fija la raz¢n mickey/pixel */ + + ent.x.ax = 7; + ent.x.cx = 0; + ent.x.dx = 639; + int86(0x33, &ent, &sal); /* fija la posici¢n m x. y m¡n. horizontal */ + + ent.x.ax = 8; + ent.x.cx = 0; + ent.x.dx = 199; + int86(0x33, &ent, &sal); /* fija la posici¢n m x. y m¡n. vertical */ + + ent.x.ax = 4; + ent.x.cx = 320; + ent.x.dx = 100; + int86(0x33, &ent, &sal); /* fija la posici¢n del rat¢n */ + + ent.x.ax = 1; + int86(0x33, &ent, &sal); /* muestra el puntero del rat¢n */ +} +void activa_raton(void) +{ + union REGS ent, sal; + + ent.x.ax = 1; + int86(0x33, &ent, &sal); +} + +void desactiva_raton(void) +{ + union REGS ent, sal; + + ent.x.ax = 2; + int86(0x33, &ent, &sal); +} + +void espera_pulsar(void) +{ + union REGS ent, sal; + + do{ + if(bioskey(1)!=0) break; + ent.x.ax = 3; + int86(0x33, &ent, &sal); /* lee posici¢n y estados del bot¢n */ + }while((sal.x.bx & 3)==0); + boton_izq=sal.x.bx & 1; + boton_der=(sal.x.bx >> 1) & 1; + x_raton= (sal.x.cx >> 1) / 4; // / 8 + y_raton= (sal.x.dx)/8; // /8 +} + +void espera_soltar(void) +{ + union REGS ent, sal; + + do{ + ent.x.ax = 3; + int86(0x33, &ent, &sal); /* lee posici¢n y estados del bot¢n */ + }while((sal.x.bx & 3)!=0); + boton_izq=sal.x.bx & 1; + boton_der=(sal.x.bx >> 1) & 1; + x_raton=sal.x.cx >> 1; + y_raton=sal.x.dx; +} + + + + +void PideAnoActual(void) +{ + char buffer[80]; + BDatos SociosO, SociosD; + INFO_SOCIOS Socios; + + struct ComprasSocios Vacia; + int r; long i; + + + + Optar( ENCUADRE, "Transacci¢n en curso", "ú-ú", "A¤o: ", NULL ); + + sprintf( buffer, "%d", AnoActual ); + while ( ( InputCadenaG( buffer, 1, 2, Config.TxtBgN, Config.TxtFgN, 40, 10, 2, 11) >> 8 ) ); + + AnoActual = atoi( buffer ); + + Optar( ENCUADRE, NULL ); + + // Comprobamos que existe una base de datos para esa fecha + sprintf( buffer, "socios.%03d", AnoActual ); + if ( access(buffer, 0) != 0) + { + sprintf( buffer, "socios.%03d", AnoActual - 1 ); + // Si el a¤o anterior existe, lo copiamos + if ( access(buffer, 0) == 0) + { + if ( Optar( 1, "Nuevo a¤o en curso", "El a¤o de la transaccion", "no existe, desea inicializarlo", "Esto puede llevar unos minutos", NULL ) ) + { + if ( SociosO.AbrirReg( buffer, sizeof( INFO_SOCIOS ) ) == ERROR ) + Error(0x01); + sprintf( buffer, "socios.%03d", AnoActual ); + if ( SociosD.AbrirReg( buffer, sizeof( INFO_SOCIOS ) ) == ERROR ) + Error(0x01); + i = 0; + for ( ; SociosO.LeeReg( (void *)&Socios, i ) == OK; i++ ) + { + for ( r=0; r < 240; r++ ) + Socios.CSocios[r].dia = Socios.CSocios[r].mes = Socios.CSocios[r].Cantidad = 0; + + SociosD.InsReg( (void *)&Socios, SociosD.Registros(), ARRIBA ); + } + } + + } else { + Optar( 0, "ATENCION", "No existen datos para ese", "a¤o, se crear  una nueva base", "de datos, (a partir de cero)", NULL ); + } + + + } + + +}