#include #include #include #include #include #include "c:\program\src_dos\libs\make_bot\make_bot.h" #include "c:\program\src_dos\libs\bdatos\bdatos.hh" #include "tpv_def.h" #define NLINEAS_EMPL 6 BDatos BEmpl; // Base de datos de Empleados INFO_EMPLEADOS SEmpl; // Estructura de Empleados /*************************************\ | | | Parte Principal del M¢dulo | | | \*************************************/ void MuestraDatosV2Empl( void ); void MuestraDatosVEmpl( int linea); void MuestraDatosEmpl( long RowStart ); void MuestraAyudaEmpl( char columna ); void EditItemEmpl( char columna, int linea ); void EmplNuevoRegistro( INFO_EMPLEADOS *MSEmpl ); void MuestraEmpl( char columna, int linea, char como ); void ObtenCoordenadasEmpl( char columna, char linea, int *X0, int *Y0, int *X1, int *Y1 ); /*************************************\ | | | Parte Secundaria del M¢dulo | | | | Secci¢n de Busqueda de proveedores | | | \*************************************/ void ObtenCoordenadasMatchEmpl( char Row, int *X0, int *Y0, int *X1, int *Y1 ); void MatchDrawEmpl( char Row, INFO_EMPLEADOS MEmpl, char como ); void BuscaEmpl( char TipoBusqueda, char *CurrRow, long *CurrEmpl ); int Match_Empl( INFO_EMPLEADOS A, INFO_EMPLEADOS B ); void EditMatchEmpl( char Row, INFO_EMPLEADOS * MEmpl ); int ObtenMatchEmpl( INFO_EMPLEADOS *MEmpl ); /*************************************\ | | | Parte Tercera del M¢dulo | | | | Secci¢n para la impresi¢n | | | \*************************************/ void ImprimeCabeceraEmpl( char como, FILE *file_out ); void MuestraImpresionesEmpl( void ); void ImprimeEmpleados( char como ); void ImprimeFichaEmpleado( void ); // ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß // Û Parte principal del m¢dulo Û // ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ /**************************************************************************\ |* *| |* InfoEmpleados *| |* *| |* Descripci¢n: *| |* Controla la introduccion de datos y muestreo asi como todo *| |* el interfaz de usuario... *| |* *| |* Entradas: (ninguna) *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ void InfoEmpleados(void) { char buffer[80], ok = 0; int BPush, key; char oldCol = -1; char CurrRow; // Linea sobre la que estamos char CurrCol; // Columna sobre la que estamos long CurrEmpl; // Producto sobre el que estamos posicionados a golpes // Rellenamos la pantalla con un fondo atractivo... setfillstyle( Config.FillBgS, Config.FillBgC ); bar( 0, 0, 640, 480 ); Imprime_Estaticos( 70, "systm\\Tpv.img"); // Imprime botones estaticos 'Seccion 30' sprintf( buffer, "datos\\%s\\info_emp.dbf", NEmpresa ); if ( BEmpl.AbrirReg( buffer, sizeof( INFO_EMPLEADOS ) ) == ERROR ) Error(0x01, BEmpl.cError); // Si no hay registros, creamos uno almenos. if ( BEmpl.Registros() == 0 ) { EmplNuevoRegistro( &SEmpl ); if ( BEmpl.InsReg( (void *)&SEmpl, BEmpl.Registros(), ARRIBA ) == ERROR ) Error(0x01, BEmpl.cError); } CurrEmpl = 0; CurrRow = 0; // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( CurrRow + CurrEmpl ); if ( BEmpl.LeeReg( (void *)&SEmpl, 0 ) == ERROR ) Error(0x01, BEmpl.cError); MuestraDatosVEmpl( CurrRow ); CurrCol = 0; do { if ( CurrCol != oldCol ) { oldCol = CurrCol; MuestraAyudaEmpl( CurrCol ); } MuestraEmpl( CurrCol, CurrRow, INTENSO ); BPush = Comprueba_Secuencia( 2, NULL ); MuestraEmpl( 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 #ifndef DEMOSTRACION if ( ( key = getch() ) != 27 ) { if ( key != 13 ) ungetch( key ); EditItemEmpl( CurrCol, CurrRow ); if ( BEmpl.EscribeReg( (void *)&SEmpl, (CurrRow + CurrEmpl) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraEmpl( CurrCol, CurrRow, NORMAL ); CurrCol++; if ( CurrCol > 14 ) CurrCol = 0; } #else while( kbhit() ) getch(); Optar( 0, "VERSION DEMOSTRACION", "En esta versi¢n no se", "permite editar el campo", "de los empleados...", NULL ); #endif break; case -1: // Hay una tecla especial en BUFFER switch( getch() ) { // Flecha Izquierda case 75: case 15: CurrCol--; if ( CurrCol < 0 ) CurrCol = 19; break; // Flecha Derecha case 77: case 9: CurrCol++; if ( CurrCol > 19 ) CurrCol = 0; break; // Flecha Arriba case 72: if ( CurrCol > 14 ) { if ( (CurrRow + CurrEmpl) > 0 ) { if ( ( CurrRow ) <= 0 ) { CurrRow = NLINEAS_EMPL - 1; CurrEmpl -= NLINEAS_EMPL; if ( CurrEmpl < 0 ) CurrEmpl = 0; while( ( CurrRow + CurrEmpl ) >= BEmpl.Registros() && CurrRow > 0 ) CurrRow--; while( ( CurrRow + CurrEmpl ) >= BEmpl.Registros() && CurrEmpl > 0 ) CurrEmpl++; // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( CurrEmpl ); } else { CurrRow --; if ( CurrRow < 0 ) CurrRow = 0; } } if ( BEmpl.LeeReg( (void *)&SEmpl, (CurrEmpl + CurrRow) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraDatosVEmpl( CurrRow ); } else { CurrCol--; if ( CurrCol < 0 ) CurrCol = 14; } break; // Flecha Abajo case 80: if ( CurrCol > 14 ) { if ( ( CurrRow + CurrEmpl ) < BEmpl.Registros() - 1 ) { if ( ( CurrRow ) >= NLINEAS_EMPL - 1 ) { CurrRow = 0; CurrEmpl += NLINEAS_EMPL; while ( (CurrEmpl + CurrRow) >= BEmpl.Registros() ) CurrEmpl--; // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( CurrEmpl ); } else CurrRow++; } if ( BEmpl.LeeReg( (void *)&SEmpl, (CurrEmpl + CurrRow) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraDatosVEmpl( CurrRow ); } else { CurrCol++; if ( CurrCol > 14 ) CurrCol = 0; } break; #ifndef DEMOSTRACION // Inicio case 71: CurrRow = 0; if ( CurrEmpl != 0 ) { CurrEmpl = 0; // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( CurrEmpl ); } if ( BEmpl.LeeReg( (void *)&SEmpl, (CurrEmpl + CurrRow) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraDatosVEmpl( CurrRow ); break; // Fin case 79: CurrRow = 0; if ( CurrEmpl != BEmpl.Registros() - NLINEAS_EMPL ) { CurrEmpl = BEmpl.Registros() - NLINEAS_EMPL; if ( CurrEmpl < 0 ) { CurrEmpl = 0; CurrRow = BEmpl.Registros()-1; } // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( CurrEmpl ); } if ( BEmpl.LeeReg( (void *)&SEmpl, (CurrEmpl + CurrRow) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraDatosVEmpl( CurrRow ); break; #endif } break; // Imprimir Emplerencias case 1: MuestraImpresionesEmpl(); break; // Menu Principal case 2: ok = 1; break; #ifndef DEMOSTRACION // Eliminar case 3: if ( Optar( 1, "ATENCION", "Seguro que desea eliminar", "este empleado?? El siguiente no", "puede tener el mismo c¢digo", NULL ) ) { if ( BEmpl.DelReg( CurrEmpl + CurrRow ) == ERROR ) Error(0x01, BEmpl.cError); if ( BEmpl.Registros() == 0 ) { EmplNuevoRegistro( &SEmpl ); if ( BEmpl.InsReg( (void *)&SEmpl, BEmpl.Registros(), ARRIBA ) == ERROR ) Error(0x01, BEmpl.cError); CurrRow = 0; } else // Si he borrado el £ltimo registro subo una linea if ( (CurrEmpl+CurrRow) >= ( BEmpl.Registros() - 2 ) ) { if ( (CurrRow + CurrEmpl) > 0 ) { if ( ( CurrRow ) <= 0 ) { CurrRow = NLINEAS_EMPL - 1; CurrEmpl -= NLINEAS_EMPL; if ( CurrEmpl < 0 ) CurrEmpl = 0; while( ( CurrRow + CurrEmpl ) >= BEmpl.Registros() && CurrRow > 0 ) CurrRow--; while( ( CurrRow + CurrEmpl ) >= BEmpl.Registros() && CurrEmpl > 0 ) CurrEmpl++; // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( CurrEmpl ); } else { CurrRow --; if ( CurrRow < 0 ) CurrRow = 0; } } if ( BEmpl.LeeReg( (void *)&SEmpl, (CurrEmpl + CurrRow) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraDatosVEmpl( CurrRow ); } // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( CurrEmpl ); if ( BEmpl.LeeReg( (void *)&SEmpl, (CurrEmpl + CurrRow) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraDatosVEmpl( CurrRow ); } break; // Insertar case 4: EmplNuevoRegistro( &SEmpl ); if ( BEmpl.InsReg( (void *)&SEmpl, (CurrEmpl + CurrRow), ARRIBA ) == ERROR ) Error(0x01, BEmpl.cError); if ( ( CurrRow + CurrEmpl ) < BEmpl.Registros() - 1 ) { if ( ( CurrRow ) >= NLINEAS_EMPL - 1 ) { CurrRow = 0; CurrEmpl += NLINEAS_EMPL; while ( (CurrEmpl + CurrRow) >= BEmpl.Registros() ) CurrEmpl--; } else CurrRow++; } // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( CurrEmpl ); if ( BEmpl.LeeReg( (void *)&SEmpl, (CurrEmpl + CurrRow) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraDatosVEmpl( CurrRow ); break; #else case 3: case 4: Optar( 0, "VERSION DEMOSTRACION", "En esta versi¢n no se", "permiten eliminar o insertar", "nuevos registros...", NULL ); break; #endif // Retroceso R pido case 5: #ifndef DEMOSTRACION CurrRow = NLINEAS_EMPL - 1; CurrEmpl -= NLINEAS_EMPL; if ( CurrEmpl < 0 ) CurrEmpl = 0; while( ( CurrRow + CurrEmpl ) >= BEmpl.Registros() && CurrRow > 0 ) CurrRow--; while( ( CurrRow + CurrEmpl ) >= BEmpl.Registros() && CurrEmpl > 0 ) CurrEmpl++; // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( CurrEmpl ); if ( BEmpl.LeeReg( (void *)&SEmpl, (CurrEmpl + CurrRow) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraDatosVEmpl( CurrRow ); #endif break; // Busqueda Atras case 6: BuscaEmpl( ATRAS, &CurrRow, &CurrEmpl ); MuestraDatosVEmpl( CurrRow ); break; // Buscar case 7: BuscaEmpl( NUEVA_BUSQUEDA, &CurrRow, &CurrEmpl ); MuestraDatosVEmpl( CurrRow ); break; // Busqueda Adelante case 8: BuscaEmpl( ADELANTE, &CurrRow, &CurrEmpl ); MuestraDatosVEmpl( CurrRow ); break; // AvanceR pido case 9: #ifndef DEMOSTRACION CurrRow = 0; CurrEmpl += NLINEAS_EMPL; while ( (CurrEmpl + CurrRow) >= BEmpl.Registros() ) CurrEmpl--; // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( CurrEmpl ); if ( BEmpl.LeeReg( (void *)&SEmpl, (CurrEmpl + CurrRow) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraDatosVEmpl( CurrRow ); #endif break; default: break; } } while( !ok ); BEmpl.CerrarReg(); } /**************************************************************************\ |* *| |* MuestraDatosEmpl *| |* *| |* 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 MuestraDatosEmpl( long RowStart ) { int linea, campo; char dev; int X0, Y0, X1, Y1; // Imprimo la NLINEAS_EMPL que caben en la pantalla dev = OK; for ( linea=0; linea < NLINEAS_EMPL && dev == OK; linea++ ) { dev = BEmpl.LeeReg( (void *)&SEmpl, RowStart + linea ); if ( dev == OK ) // Por cada linea hay 4 campos, ehhh!!! for ( campo=15; campo < 20; campo++ ) MuestraEmpl( campo, linea, NORMAL ); } // Ahora limpio los restantes huecos si los hay if ( dev != OK ) { linea--; setfillstyle( SOLID_FILL, Config.TxtBgN ); for ( ; linea < NLINEAS_EMPL; linea++ ) for ( campo=15; campo < 20; campo++ ) { ObtenCoordenadasEmpl( campo, linea, &X0, &Y0, &X1, &Y1 ); bar( X0, Y0, X1, Y1 ); } } } void MuestraDatosVEmpl( int linea ) { int campo; // Mostramos los campos que faltan, ( 1¦ Linea ) // for ( campo=0; campo < 15; campo++ ) MuestraEmpl( campo, linea, NORMAL ); } /**************************************************************************\ |* *| |* MuestraEmpl *| |* *| |* 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 MuestraEmpl( char columna, int linea, char como ) { char buffer[80]; char buffer1[80], draw; int X0, Y0, X1, Y1; ObtenCoordenadasEmpl( columna, linea, &X0, &Y0, &X1, &Y1 ); draw = 1; switch( columna ) { // Codigo case 0: sprintf ( buffer, " %07lu", SEmpl.CodigoR ); // MuestraEmpl( 15, linea, como ); break; // Nombre del proveedor case 1: sprintf ( buffer, "%15s", SEmpl.Nombre ); // MuestraEmpl( 16, linea, como ); break; // Apellido1 case 2: sprintf ( buffer, "%15s", SEmpl.Apellido1 ); // MuestraEmpl( 17, linea, como ); break; // Apellido2 case 3: sprintf ( buffer, "%15s", SEmpl.Apellido2 ); // MuestraEmpl( 18, linea, como ); break; // Direccion case 4: sprintf ( buffer, "%15s", SEmpl.Direccion ); break; // Numero case 5: sprintf ( buffer, "%4s", SEmpl.Num ); break; // Piso case 6: sprintf ( buffer, "%4s", SEmpl.Piso ); break; // Poblacion case 7: sprintf ( buffer, "%15s", SEmpl.Poblacion ); break; // Provincia case 8: sprintf ( buffer, " %15s", SEmpl.Provincia ); break; // Codigo Postal case 9: formatea_u_long( SEmpl.CodPostal, buffer1 ); sprintf ( buffer, " %6s", buffer1 ); break; // Telefono 1 case 10: sprintf ( buffer, "%15s", SEmpl.Telefono1 ); MuestraEmpl( 19, linea, como ); break; // Telefono 2 case 11: sprintf ( buffer, " %15s", SEmpl.Telefono2 ); break; // NIF case 12: sprintf ( buffer, " %10s", SEmpl.NIF ); break; // Inicio Contrato case 13: sprintf( buffer, "%02d-%02d-%04d", (int)SEmpl.InicioContrato.da_day, (int)SEmpl.InicioContrato.da_mon, SEmpl.InicioContrato.da_year ); break; // Fin Contrato case 14: sprintf( buffer, "%02d-%02d-%04d", (int)SEmpl.FinContrato.da_day, (int)SEmpl.FinContrato.da_mon, SEmpl.FinContrato.da_year ); break; // Lineas de Apoyo // Codigo case 15: sprintf ( buffer, " %07lu", SEmpl.CodigoR ); break; // Nombre del proveedor case 16: sprintf ( buffer, "%15s", SEmpl.Nombre ); break; // Apellido1 case 17: sprintf ( buffer, "%15s", SEmpl.Apellido1 ); break; // Apellido2 case 18: sprintf ( buffer, "%15s", SEmpl.Apellido2 ); break; // Telefono 1 case 19: sprintf ( buffer, " %15s", SEmpl.Telefono1 ); break; case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: case 38: case 39: case 40: draw = 0; break; } if ( draw ) { setfillstyle( SOLID_FILL, ( como == NORMAL ) ? Config.TxtBgN : Config.TxtBgI ); bar( X0, Y0, X1, Y1 ); setcolor ( ( como == NORMAL ) ? Config.TxtFgN : Config.TxtFgI ); outtextxy( X0+2, Y0, buffer ); } else { Imprime_Bordes( 7, ( columna - 20 + 1 ), ( como == NORMAL ) ? -1 : 11 ); } } /**************************************************************************\ |* *| |* MuestraAyudaEmpl *| |* *| |* Descripci¢n: *| |* Muestra una peque¤a descripcion del contenido para el campo *| |* *| |* Entradas: *| |* columna campo ha mostar su ayuda *| |* *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ void MuestraAyudaEmpl( char columna ) { char buffer1[80]; switch( columna ) { // Codigo case 0: sprintf ( buffer1, "Introduzca el codigo que desea asignar al vendedor" ); break; // Nombre del Vendedor case 1: sprintf ( buffer1, "Nombre del vendedor" ); break; // Apellido 1 case 2: sprintf ( buffer1, "Primer apellido del vendedor" ); break; // Apellido 2 case 3: sprintf ( buffer1, "Segundo apellido del vendedor" ); break; // Direccion case 4: sprintf ( buffer1, "Direccion del empleado" ); break; // Numero case 5: sprintf ( buffer1, "N£mero, Bloque o Plaza" ); break; // Piso case 6: sprintf ( buffer1, "Piso o Letra" ); break; // Localidad case 7: sprintf ( buffer1, "Localidad" ); break; // Provincia case 8: sprintf ( buffer1, "Provincia" ); break; // C¢digo Postal case 9: sprintf ( buffer1, "C¢digo Postal" ); break; // Tel‚fono 1 case 10: sprintf ( buffer1, "Tel‚fono 1" ); break; // Tel‚fono 2 case 11: sprintf ( buffer1, "Tel‚fono 2" ); break; // Nif case 12: sprintf ( buffer1, "N£mero de Identificaci¢n Fiscal" ); break; // Fecha Inicio de contrato case 13: sprintf ( buffer1, "Fecha inicio del contrato" ); break; // Fecha fin contrato case 14: sprintf ( buffer1, "Fecha final del contrato" ); break; // Cuadro de busqueda r pida case 15: case 16: case 17: case 18: case 19: sprintf ( buffer1, "Visualizaci¢n r pida de los empleados" ); break; case 20: sprintf ( buffer1, "Articulos: Referencia de los Articulos" ); break; case 21: sprintf ( buffer1, "Articulos: Visualizacion del Stock Actual" ); break; case 22: sprintf ( buffer1, "Articulos: Graficas Ventas de Articulo" ); break; case 23: sprintf ( buffer1, "Proveedores: Fichas de los proveedores" ); break; case 24: sprintf ( buffer1, "Proveedores: Informe de compras seg£n Prov." ); break; case 25: sprintf ( buffer1, "Empleados: Fichas personales de empleados" ); break; case 26: sprintf ( buffer1, "Empleados: Permisos de acceso (modulo actual)" ); break; case 27: sprintf ( buffer1, "Empleados: Graficas de ventas por empleado" ); break; case 28: sprintf ( buffer1, "Compras: Compras Generales ( Mensuales/Dia )" ); break; case 29: sprintf ( buffer1, "Compras: Graficas de compras" ); break; case 30: sprintf ( buffer1, "Gst Ventas: Inicio de la caja diaria" ); break; case 31: sprintf ( buffer1, "Gst Ventas: Balance de caja. Informe del dia" ); break; case 32: sprintf ( buffer1, "Gst Ventas: Balance mensual de ventas" ); break; case 33: sprintf ( buffer1, "Gst Ventas: Gestion de Clientes" ); break; case 34: sprintf ( buffer1, "Pgr. Ext.: Permiso de ejecucion de Pgr. Ext." ); break; case 35: sprintf ( buffer1, "Miscelanea: Cambio de los mensajes del Prot." ); break; case 36: sprintf ( buffer1, "Miscelanea: Futura Ampliacion del Programa" ); break; case 37: sprintf ( buffer1, "Miscelanea: Futura Ampliacion del Programa" ); break; case 38: sprintf ( buffer1, "Miscelanea: Gestion de las bases de datos" ); break; case 39: sprintf ( buffer1, "Miscelanea: Configuracion de los Pgr. Ext." ); break; case 40: sprintf ( buffer1, "Miscelanea: Configuracion del Entorno Visual" ); break; } // Ayuda reducida setfillstyle( SOLID_FILL, EGA_BLACK ); bar( 7, 457, 498, 473 ); // Imprime la ayudita setcolor( EGA_WHITE ); outtextxy( 7, 457, buffer1 ); } /**************************************************************************\ |* *| |* EditItemEmpl *| |* *| |* 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 EditItemEmpl( char columna, int linea ) { char buffer[80]; int X0, Y0, X1, Y1; ObtenCoordenadasEmpl( columna, linea, &X0, &Y0, &X1, &Y1 ); switch( columna ) { // Codigo Real case 0: sprintf ( buffer, "%lu", SEmpl.CodigoR ); if ( !( InputCadenaG( buffer, 1, 7, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) SEmpl.CodigoR = atol( buffer ); MuestraEmpl( 15, linea, NORMAL ); break; // Nombre del empleado case 1: strcpy ( buffer, SEmpl.Nombre ); if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) strcpy ( SEmpl.Nombre, buffer ); MuestraEmpl( 16, linea, NORMAL ); break; // Apellifo 1 case 2: strcpy ( buffer, SEmpl.Apellido1 ); if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) strcpy ( SEmpl.Apellido1, buffer ); MuestraEmpl( 17, linea, NORMAL ); break; // Apellifo 2 case 3: strcpy ( buffer, SEmpl.Apellido2 ); if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) strcpy ( SEmpl.Apellido2, buffer ); MuestraEmpl( 18, linea, NORMAL ); break; // Direccion case 4: sprintf ( buffer, "%s", SEmpl.Direccion ); if ( !( InputCadenaG( buffer, 0, 25, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) strcpy ( SEmpl.Direccion, buffer ); break; // Num case 5: sprintf ( buffer, "%s", SEmpl.Num ); if ( !( InputCadenaG( buffer, 0, 4, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) strcpy ( SEmpl.Num, buffer ); break; // Piso case 6: sprintf ( buffer, "%s", SEmpl.Piso ); if ( !( InputCadenaG( buffer, 0, 4, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) strcpy ( SEmpl.Piso, buffer ); break; // Poblaci¢n case 7: sprintf ( buffer, "%s", SEmpl.Poblacion ); if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) strcpy ( SEmpl.Poblacion, buffer ); break; // Provincia case 8: sprintf ( buffer, "%s", SEmpl.Provincia ); if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) strcpy ( SEmpl.Provincia, buffer ); break; // C¢digo Postal case 9: sprintf ( buffer, "%ld", SEmpl.CodPostal ); if ( !( InputCadenaG( buffer, 0, 5, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) SEmpl.CodPostal = atol ( buffer ); break; // Telefono 1 case 10: sprintf ( buffer, "%s", SEmpl.Telefono1 ); if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) strcpy ( SEmpl.Telefono1, buffer ); break; // Telefono 2 case 11: sprintf ( buffer, "%s", SEmpl.Telefono2 ); if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) strcpy ( SEmpl.Telefono2, buffer ); break; // NIF case 12: strcpy ( buffer, SEmpl.NIF ); if ( !( InputCadenaG( buffer, 0, 10, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) strcpy ( SEmpl.NIF, buffer ); break; // Fecha inicio contrato case 13: sprintf( buffer, "%02d%02d%04d", (int)SEmpl.InicioContrato.da_day, (int)SEmpl.InicioContrato.da_mon, SEmpl.InicioContrato.da_year ); if ( !( InputCadenaG( buffer, 0, 8, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) { if ( strlen( buffer ) == 8 ) { SEmpl.InicioContrato.da_day = (buffer[0]-'0')*10 + (buffer[1]-'0'); SEmpl.InicioContrato.da_mon = (buffer[2]-'0')*10 + (buffer[3]-'0'); SEmpl.InicioContrato.da_year = (buffer[4]-'0')*1000 + (buffer[5]-'0')*100 + (buffer[6]-'0')*10 + (buffer[7]-'0'); } } break; // Fecha fin contrato case 14: sprintf( buffer, "%02d%02d%04d", (int)SEmpl.FinContrato.da_day, (int)SEmpl.FinContrato.da_mon, SEmpl.FinContrato.da_year ); if ( !( InputCadenaG( buffer, 0, 8, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) { if ( strlen( buffer ) == 8 ) { SEmpl.FinContrato.da_day = (buffer[0]-'0')*10 + (buffer[1]-'0'); SEmpl.FinContrato.da_mon = (buffer[2]-'0')*10 + (buffer[3]-'0'); SEmpl.FinContrato.da_year = (buffer[4]-'0')*1000 + (buffer[5]-'0')*100 + (buffer[6]-'0')*10 + (buffer[7]-'0'); } } break; // Observaciones case 15: break; } while( kbhit() ) getch(); } /**************************************************************************\ |* *| |* ObtenCoordenadasEmpl *| |* *| |* 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 ObtenCoordenadasEmpl( char columna, char linea, int *X0, int *Y0, int *X1, int *Y1 ) { // Calculamos la Y0, Y1 para la linea dada ( SOLO columna < 6 ) *Y0 = 332 + 19*linea; *Y1 = *Y0 + 17; switch( columna ) { case 0: *X0 = 97; *X1 = 178; *Y0 = 94; *Y1 = 114; break; case 1: *X0 = 97; *X1 = 223; *Y0 = 124; *Y1 = 144; break; case 2: *X0 = 97; *X1 = 223; *Y0 = 154; *Y1 = 174; break; case 3: *X0 = 312; *X1 = 458; *Y0 = 154; *Y1 = 174; break; case 4: *X0 = 97; *X1 = 353; *Y0 = 184; *Y1 = 204; break; case 5: *X0 = 412; *X1 = 458; *Y0 = 184; *Y1 = 204; break; case 6: *X0 = 542; *X1 = 588; *Y0 = 184; *Y1 = 204; break; case 7: *X0 = 97; *X1 = 223; *Y0 = 214; *Y1 = 234; break; case 8: *X0 = 312; *X1 = 458; *Y0 = 214; *Y1 = 234; break; case 9: *X0 = 542; *X1 = 618; *Y0 = 214; *Y1 = 234; break; case 10: *X0 = 97; *X1 = 223; *Y0 = 244; *Y1 = 264; break; case 11: *X0 = 312; *X1 = 458; *Y0 = 244; *Y1 = 264; break; case 12: *X0 = 97; *X1 = 223; *Y0 = 274; *Y1 = 294; break; case 13: *X0 = 362; *X1 = 458; *Y0 = 274; *Y1 = 294; break; case 14: *X0 = 522; *X1 = 618; *Y0 = 274; *Y1 = 294; break; case 15: *X0 = 7; *X1 = 78; break; case 16: *X0 = 87; *X1 = 213; break; case 17: *X0 = 222; *X1 = 348; break; case 18: *X0 = 357; *X1 = 483; break; case 19: *X0 = 492; *X1 = 633; break; case 20: case 21: case 22: *X0 = 180; *X1 = 200; *X0 -= 2; *Y0 = 24 + 20 * ( columna - 20 ) ; *Y1 = *Y0 + 18; break; case 23: case 24: *X0 = 180; *X1 = 200; *X0 -= 2; *Y0 = 24 + 20 * ( columna - 20 + 1 ) ; *Y1 = *Y0 + 18; break; case 25: case 26: case 27: *X0 = 180; *X1 = 200; *X0 -= 2; *Y0 = 24 + 20 * ( columna - 20 + 2 ) ; *Y1 = *Y0 + 18; break; case 28: case 29: *X0 = 180; *X1 = 200; *X0 -= 2; *Y0 = 24 + 20 * ( columna - 20 + 3 ) ; *Y1 = *Y0 + 18; break; case 30: case 31: case 32: case 33: *X0 = 390; *X1 = 410; *X0 -= 2; *Y0 = 24 + 20 * ( columna - 23 ) ; *Y1 = *Y0 + 18; break; case 34: *X0 = 390; *X1 = 410; *X0 -= 2; *Y0 = 24 + 20 * ( columna - 23 + 1 ) ; *Y1 = *Y0 + 18; break; case 35: case 36: case 37: case 38: case 39: case 40: case 41: *X0 = 600; *X1 = 620; *X0 -= 2; *Y0 = 24 + 20 * ( columna - 28 ) ; *Y1 = *Y0 + 18; break; } *X0 += 2; *X1 -= 2; } /**************************************************************************\ |* *| |* EmplNuevoRegistro *| |* *| |* Descripci¢n: *| |* Limpia el buffer, para un nuevo registro. *| |* *| |* Entradas: (ninguna) *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ void EmplNuevoRegistro( INFO_EMPLEADOS *NSEmpl ) { char i; NSEmpl -> CodigoR = 0; NSEmpl -> Nombre[0] = '\0'; NSEmpl -> Apellido1[0] = '\0'; NSEmpl -> Apellido2[0] = '\0'; NSEmpl -> Direccion[0] = '\0'; NSEmpl -> Num[0] = '\0'; NSEmpl -> Piso[0] = '\0'; NSEmpl -> CodPostal = 0; NSEmpl -> Telefono1[0] = '\0'; NSEmpl -> Telefono2[0] = '\0'; NSEmpl -> NIF[0] = '\0'; NSEmpl -> InicioContrato.da_day = 0; NSEmpl -> InicioContrato.da_mon = 0; NSEmpl -> InicioContrato.da_year = 0; NSEmpl -> FinContrato.da_day = 0; NSEmpl -> InicioContrato.da_mon = 0; NSEmpl -> InicioContrato.da_year = 0; NSEmpl -> Password[0] = '\0'; for ( i = 0; i < 4; i++ ) NSEmpl -> Observaciones[i][0] = '\0'; for ( i = 0; i < 30; i++ ) NSEmpl -> Acceso[i] = 0; } // ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß // Û Parte secundaria del m¢dulo Û // Û Û // Û Secci¢n de Busqueda de refecencias Û // ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ /**************************************************************************\ |* *| |* BuscaEmpl *| |* *| |* Descripci¢n: *| |* Busca un empleado por sus distintos campos. *| |* *| |* Entradas: *| |* ATRAS Busca otra coincidencia hacia atras *| |* NUEVA_BUSQUEDA Inicia una nueva busqueda *| |* ADELANTE Busca otra coincidencia hacia delante *| |* *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ void BuscaEmpl( char TipoBusqueda, char *CurrRow, long *CurrEmpl ) { static INFO_EMPLEADOS MEmpl; char enc; long i; switch ( TipoBusqueda ) { case NUEVA_BUSQUEDA: if ( ObtenMatchEmpl( &MEmpl ) != OK ) return; i = 0; break; case ATRAS: case ADELANTE: i = ( *CurrRow + *CurrEmpl ) + TipoBusqueda; break; } Optar( ENCUADRE, "Comando: Buscar", "Ahora se inica", "la busqueda elegida", NULL ); enc = 0; while ( i < BEmpl.Registros() && !enc ) { if ( BEmpl.LeeReg( (void *)&SEmpl, i ) == ERROR ) Error( 0x01, BEmpl.cError); if ( Match_Empl( SEmpl, MEmpl ) ) enc = 1; else i++; } Optar( ENCUADRE, NULL ); if ( enc ) { *CurrRow = 0; *CurrEmpl = i; // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( *CurrRow + *CurrEmpl ); if ( BEmpl.LeeReg( (void *)&SEmpl, ( *CurrRow + *CurrEmpl ) ) == ERROR ) Error(0x01, BEmpl.cError); // MuestraDatosVEmpl( *CurrRow ); } 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 ( BEmpl.LeeReg( (void *)&SEmpl, (*CurrRow + *CurrEmpl) ) == ERROR ) Error( 0x01, BEmpl.cError); } /**************************************************************************\ |* *| |* Match_Empl *| |* *| |* Descripci¢n: *| |* Compara dos registros y devuelve la posible coincidencia *| |* *| |* Entradas: *| |* Registros a comparar *| |* *| |* Salidas: *| |* Resultado de la comparaci¢n *| |* *| \**************************************************************************/ int Match_Empl( INFO_EMPLEADOS A, INFO_EMPLEADOS B ) { if ( B.CodigoR != 0 ) return (A.CodigoR == B.CodigoR); if ( B.Nombre[0] != '\0' ) return ( strncmpi( A.Nombre, B.Nombre, strlen( B.Nombre ) ) == 0 ); if ( B.Apellido1[0] != '\0' ) return ( strncmpi( A.Apellido1, B.Apellido1, strlen( B.Apellido1 ) ) == 0 ); if ( B.Direccion[0] != '\0' ) return ( strncmpi( A.Direccion, B.Direccion, strlen( B.Direccion ) ) == 0 ); return 0; } /**************************************************************************\ |* *| |* ObtenMatchEmpl *| |* *| |* 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 ObtenMatchEmpl( INFO_EMPLEADOS *MEmpl ) { char Row, ok, i; int BPush, key, DEV; struct textsettingstype texttypeinfo; gettextsettings( &texttypeinfo ); Optar( ENCUADRE, "Comando: Buscar", NULL ); Imprime_Estaticos( 74, "systm\\tpv.img" ); ok = 0; Row = 0; EmplNuevoRegistro( MEmpl ); do { MatchDrawEmpl(Row, *MEmpl, INTENSO); BPush = Comprueba_Secuencia( SEC_OPTAR, NULL ); MatchDrawEmpl(Row, *MEmpl, 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 ); EditMatchEmpl( Row, MEmpl ); for ( i=0; i < 4; i++ ) MatchDrawEmpl(i, *MEmpl, 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 ); settextstyle( texttypeinfo.font, texttypeinfo.direction, texttypeinfo.charsize ); return DEV; } /**************************************************************************\ |* *| |* EditMatchEmpl *| |* *| |* Descripci¢n: *| |* Edita el patron de busqueda *| |* *| |* Entradas: *| |* Campo a editar, y lugar donde almacenarlo *| |* *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ void EditMatchEmpl( char Row, INFO_EMPLEADOS * MEmpl ) { int X0, Y0, X1, Y1; char buffer[80]; ObtenCoordenadasMatchEmpl( Row, &X0, &Y0, &X1, &Y1 ); switch( Row ) { // Codigo case 0: sprintf( buffer, "%lu", MEmpl -> CodigoR ); if ( !( InputCadenaG( buffer, 1, 9, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) { EmplNuevoRegistro( MEmpl ); MEmpl -> CodigoR = atol(buffer); } break; // Nombre case 1: sprintf( buffer, "%s", MEmpl -> Nombre ); if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) { EmplNuevoRegistro( MEmpl ); strcpy ( MEmpl -> Nombre, buffer ); } break; // Apellido 1 case 2: sprintf( buffer, "%s", MEmpl -> Apellido1 ); if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) { EmplNuevoRegistro( MEmpl ); strcpy ( MEmpl -> Apellido1, buffer ); } break; // Direccion case 3: sprintf( buffer, "%s", MEmpl -> Direccion ); if ( !( InputCadenaG( buffer, 0, 25, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) { EmplNuevoRegistro( MEmpl ); strcpy ( MEmpl -> Direccion, buffer ); } break; } } /**************************************************************************\ |* *| |* MatchDrawEmpl *| |* *| |* 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 MatchDrawEmpl( char Row, INFO_EMPLEADOS MEmpl, char como ) { int X0, Y0, X1, Y1; char buffer[80]; ObtenCoordenadasMatchEmpl( Row, &X0, &Y0, &X1, &Y1 ); switch( Row ) { case 0: sprintf( buffer, " %9lu", MEmpl.CodigoR ); break; case 1: strncpy( buffer, MEmpl.Nombre, 15 ); break; case 2: strncpy( buffer, MEmpl.Apellido1, 15 ); break; case 3: strncpy( buffer, MEmpl.Direccion, 25 ); break; } setfillstyle( SOLID_FILL, ( como == NORMAL ) ? Config.TxtBgN : Config.TxtBgI ); bar( X0, Y0, X1, Y1 ); setcolor ( ( como == NORMAL ) ? Config.TxtFgN : Config.TxtFgI ); outtextxy( X0+2, Y0, buffer ); } /**************************************************************************\ |* *| |* MatchDrawEmpl *| |* *| |* Descripci¢n: *| |* Obtiene las coordenadas relativas al campo dado. *| |* *| |* Entradas: *| |* Campo a obtener las coordenadas, y coordenadas de salida *| |* *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ void ObtenCoordenadasMatchEmpl( char Row, int *X0, int *Y0, int *X1, int *Y1 ) { switch( Row ) { case 0: *X0 = 265; *X1 = 365; *Y0 = 200; *Y1 = 220; break; case 1: *X0 = 265; *X1 = 465; *Y0 = 225; *Y1 = 245; break; case 2: *X0 = 265; *X1 = 465; *Y0 = 250; *Y1 = 275; break; case 3: *X0 = 265; *X1 = 465; *Y0 = 280; *Y1 = 305; break; case 4: *X0 = 385; *X1 = 465; *Y0 = 250; *Y1 = 275; break; case 5: *X0 = 330; *X1 = 365; *Y0 = 275; *Y1 = 300; break; } (*X0) ++; (*Y0) ++; (*X1) --; (*Y1) --; } // ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß // Û Parte secundaria del m¢dulo Û // Û Û // Û Secci¢n de Busqueda de refecencias Û // ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ /**************************************************************************\ |* *| |* MuestraImpresiones *| |* *| |* Descripci¢n: *| |* Muestra un cuadro con las distintas opciones de impresi¢n *| |* *| |* Entradas:(ninguna) *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ void MuestraImpresionesEmpl(void) { void far *fondo; struct textsettingstype texttypeinfo; char ok, dev; if ( ( fondo = farmalloc ( JD_imagesize( 170, 165, 470, 315 ) ) ) != NULL ) { gettextsettings( &texttypeinfo ); getimage( 170, 165, 470, 315, fondo ); Imprime_Estaticos( 73, "systm\\tpv.img" ); settextstyle( texttypeinfo.font, texttypeinfo.direction, texttypeinfo.charsize ); ok = 0; do { switch( Comprueba_Secuencia( 3, NULL ) ) { case 0: case -1: case -2: while( kbhit() ) getch(); break; // Cancelar case 1: dev = 0; ok = 1; break; // Listado r pido case 2: dev = 1; ok = 1; break; // Listado completo case 3: dev = 2; ok = 1; break; // Codigos de barra case 4: dev = 3; ok = 1; break; } } while( !ok ); putimage( 170, 165, fondo, COPY_PUT ); farfree( fondo ); if ( dev == 3 ) ImprimeFichaEmpleado(); else ImprimeEmpleados( dev ); } } /**************************************************************************\ |* *| |* ImprimeEmpleados *| |* *| |* Descripci¢n: *| |* Imprime todas las referencias seg£n se le indique *| |* *| |* Entradas: *| |* Como imprimir las referencias *| |* *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ void ImprimeEmpleados( char como ) { long i, old_reg; char buffer[80]; FILE *file_out; old_reg = BEmpl.RegActual(); if ( !Config.Impresora.Printer ) { if ( ( file_out = fopen( Config.Impresora.PrintTo, "w" ) ) == NULL ) return; } else file_out = stdprn; ImprimeCabeceraEmpl(como, file_out); for ( i=0; i= 1 && BPush <= 21 ) { ObtenCoordenadasEmpl( (BPush - 1 + 20), 0, &X0, &Y0, &X1, &Y1 ); if ( SEmpl.Acceso[BPush - 1] ) { SEmpl.Acceso[BPush - 1] = 0; ponicono( X0+5, Y0+5, led_off, 1 ); } else { SEmpl.Acceso[BPush - 1] = 1; ponicono( X0+5, Y0+5, led_on, 1 ); } if ( BEmpl.EscribeReg( (void *)&SEmpl, (CurrRow + CurrEmpl) ) == ERROR ) Error(0x01, BEmpl.cError); } } Anclar_Raton(); break; case -2: // Hay una tecla normal en BUFFER while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER ObtenCoordenadasEmpl( CurrCol, 0, &X0, &Y0, &X1, &Y1 ); if ( CurrCol >= 20 && CurrCol < 41 ) { if ( SEmpl.Acceso[CurrCol - 20] ) { SEmpl.Acceso[CurrCol - 20] = 0; ponicono( X0+5, Y0+5, led_off, 1 ); } else { SEmpl.Acceso[CurrCol - 20] = 1; ponicono( X0+5, Y0+5, led_on, 1 ); } } if ( BEmpl.EscribeReg( (void *)&SEmpl, (CurrRow + CurrEmpl) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraEmpl( CurrCol, CurrRow, NORMAL ); CurrCol++; if ( CurrCol > 40 ) CurrCol = 20; break; case -1: // Hay una tecla especial en BUFFER switch( getch() ) { // Flecha Izquierda case 75: case 15: CurrCol--; if ( CurrCol < 15 ) CurrCol = 40; break; // Flecha Derecha case 77: case 9: CurrCol++; if ( CurrCol > 40 ) CurrCol = 15; break; // Flecha Arriba case 72: if ( CurrCol < 20 ) { if ( (CurrRow + CurrEmpl) > 0 ) { if ( ( CurrRow ) <= 0 ) { CurrRow = NLINEAS_EMPL - 1; CurrEmpl -= NLINEAS_EMPL; if ( CurrEmpl < 0 ) CurrEmpl = 0; while( ( CurrRow + CurrEmpl ) >= BEmpl.Registros() && CurrRow > 0 ) CurrRow--; while( ( CurrRow + CurrEmpl ) >= BEmpl.Registros() && CurrEmpl > 0 ) CurrEmpl++; // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( CurrEmpl ); } else { CurrRow --; if ( CurrRow < 0 ) CurrRow = 0; } } if ( BEmpl.LeeReg( (void *)&SEmpl, (CurrEmpl + CurrRow) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraDatosV2Empl(); } else { CurrCol--; if ( CurrCol < 20 ) CurrCol = 40; } break; // Flecha Abajo case 80: if ( CurrCol < 20 ) { if ( ( CurrRow + CurrEmpl ) < BEmpl.Registros() - 1 ) { if ( ( CurrRow ) >= NLINEAS_EMPL - 1 ) { CurrRow = 0; CurrEmpl += NLINEAS_EMPL; while ( (CurrEmpl + CurrRow) >= BEmpl.Registros() ) CurrEmpl--; // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( CurrEmpl ); } else CurrRow++; } if ( BEmpl.LeeReg( (void *)&SEmpl, (CurrEmpl + CurrRow) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraDatosV2Empl(); } else { CurrCol++; if ( CurrCol > 40 ) CurrCol = 20; } break; // Inicio case 71: CurrRow = 0; if ( CurrEmpl != 0 ) { CurrEmpl = 0; // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( CurrEmpl ); } if ( BEmpl.LeeReg( (void *)&SEmpl, (CurrEmpl + CurrRow) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraDatosV2Empl(); break; // Fin case 79: CurrRow = 0; if ( CurrEmpl != BEmpl.Registros() - NLINEAS_EMPL ) { CurrEmpl = BEmpl.Registros() - NLINEAS_EMPL; if ( CurrEmpl < 0 ) { CurrEmpl = 0; CurrRow = BEmpl.Registros()-1; } // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( CurrEmpl ); } if ( BEmpl.LeeReg( (void *)&SEmpl, (CurrEmpl + CurrRow) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraDatosV2Empl(); break; } break; // Menu Principal case 2: ok = 1; break; // Retroceso R pido case 5: CurrRow = NLINEAS_EMPL - 1; CurrEmpl -= NLINEAS_EMPL; if ( CurrEmpl < 0 ) CurrEmpl = 0; while( ( CurrRow + CurrEmpl ) >= BEmpl.Registros() && CurrRow > 0 ) CurrRow--; while( ( CurrRow + CurrEmpl ) >= BEmpl.Registros() && CurrEmpl > 0 ) CurrEmpl++; // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( CurrEmpl ); if ( BEmpl.LeeReg( (void *)&SEmpl, (CurrEmpl + CurrRow) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraDatosV2Empl(); break; // Busqueda Atras case 6: BuscaEmpl( ATRAS, &CurrRow, &CurrEmpl ); break; // Buscar case 7: BuscaEmpl( NUEVA_BUSQUEDA, &CurrRow, &CurrEmpl ); break; // Busqueda Adelante case 8: BuscaEmpl( ADELANTE, &CurrRow, &CurrEmpl ); break; // AvanceR pido case 9: CurrRow = 0; CurrEmpl += NLINEAS_EMPL; while ( (CurrEmpl + CurrRow) >= BEmpl.Registros() ) CurrEmpl--; // Mostramos datos hasta que se nos acabe la pantalla MuestraDatosEmpl( CurrEmpl ); if ( BEmpl.LeeReg( (void *)&SEmpl, (CurrEmpl + CurrRow) ) == ERROR ) Error(0x01, BEmpl.cError); MuestraDatosV2Empl(); break; default: break; } } while( !ok ); BEmpl.CerrarReg(); } void MuestraDatosV2Empl(void) { int campo; int X0, Y0, X1, Y1; // Mostramos los campos que faltan, ( 1¦ Linea ) // for ( campo=20; campo < 41; campo++ ) { ObtenCoordenadasEmpl( campo, 0, &X0, &Y0, &X1, &Y1 ); if ( SEmpl.Acceso[campo - 20] ) ponicono( X0+5, Y0+5, led_on, 1 ); else ponicono( X0+5, Y0+5, led_off, 1 ); } }