1534 lines
56 KiB
C++
1534 lines
56 KiB
C++
#include <io.h>
|
||
#include <dir.h>
|
||
#include <alloc.h>
|
||
#include <conio.h>
|
||
#include <string.h>
|
||
#include <stdlib.h>
|
||
#include <graphics.h>
|
||
|
||
#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_EMPR 9
|
||
#define NLINEAS_EMPRelegir 10
|
||
|
||
BDatos BEmpr; // Base de datos de Empreedores
|
||
INFO_EMPRESAS SEmpr; // Estructura de Empreedores
|
||
|
||
/*************************************\
|
||
| |
|
||
| Parte Principal del M¢dulo |
|
||
| |
|
||
\*************************************/
|
||
void MuestraDatosVEmpr( int linea);
|
||
int MatchEmpresa( long CEmpresa, int *Registros );
|
||
int CompruebaPulsoConexion( void );
|
||
void InicializaNuevasEmpresas( void );
|
||
void MuestraAyudaEmpr( char columna );
|
||
void MuestraDatosEmpr( long RowStart );
|
||
int EmpresaDuplicada( long NEmpresa );
|
||
void EditItemEmpr( char columna, int linea );
|
||
void EmprNuevoRegistro( INFO_EMPRESAS *MSEmpr );
|
||
void MuestraEmpr( char columna, int linea, char como );
|
||
void ObtenCoordenadasEmpr( char columna, char linea, int *X0, int *Y0, int *X1, int *Y1 );
|
||
|
||
/*************************************\
|
||
| |
|
||
| Parte Secundaria del M¢dulo |
|
||
| |
|
||
| Secci¢n para escoger Empresa |
|
||
| |
|
||
\*************************************/
|
||
void EscogeEmpresaActiva( void );
|
||
void MuestraDatosEmprElegir( long RowStart );
|
||
void MuestraEmprElegir( int linea, char como );
|
||
void ObtenCoordenadasEmprCmp( char linea, int *X0, int *Y0, int *X1, int *Y1 );
|
||
extern void MarcaSubItemSeleccionado( int Sec, int Columna, char como );
|
||
|
||
|
||
/*************************************\
|
||
| |
|
||
| Parte Tercera del M¢dulo |
|
||
| |
|
||
| Secci¢n para la impresi¢n |
|
||
| |
|
||
\*************************************/
|
||
void MuestraImpresionesEmpr( void );
|
||
void ImprimeEmpreedores( char como );
|
||
void ImprimeCabeceraEmpr( char como, FILE *file_out );
|
||
|
||
|
||
|
||
|
||
// ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
|
||
// Û Parte principal del m¢dulo Û
|
||
// ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
|
||
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* InfoEmpreedores *|
|
||
|* *|
|
||
|* Descripci¢n: *|
|
||
|* Controla la introduccion de datos y muestreo asi como todo *|
|
||
|* el interfaz de usuario... *|
|
||
|* *|
|
||
|* Entradas: (ninguna) *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void InfoEmpresas(void)
|
||
{
|
||
char buffer[100], ok = 0;
|
||
int BPush, key;
|
||
|
||
char oldCol = -1;
|
||
char CurrRow; // Linea sobre la que estamos
|
||
char CurrCol; // Columna sobre la que estamos
|
||
long CurrEmpr; // 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( 90, "systm\\Tpv.img"); // Imprime botones estaticos 'Seccion 30'
|
||
|
||
sprintf( buffer, "datos\\empresas.dbf" );
|
||
|
||
if ( BEmpr.AbrirReg( buffer, sizeof( INFO_EMPRESAS ) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
|
||
// Si no hay registros, creamos uno almenos.
|
||
if ( BEmpr.Registros() == 0 )
|
||
{
|
||
EmprNuevoRegistro( &SEmpr );
|
||
if ( BEmpr.InsReg( (void *)&SEmpr, BEmpr.Registros(), ARRIBA ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
}
|
||
|
||
CurrEmpr = 0; CurrRow = 0;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
|
||
MuestraDatosEmpr( CurrRow + CurrEmpr );
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, 0 ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
MuestraDatosVEmpr( CurrRow );
|
||
|
||
CurrCol = 0;
|
||
|
||
do {
|
||
if ( CurrCol != oldCol )
|
||
{
|
||
oldCol = CurrCol; MuestraAyudaEmpr( CurrCol );
|
||
}
|
||
|
||
MuestraEmpr( CurrCol, CurrRow, INTENSO );
|
||
BPush = Comprueba_Secuencia( 2, NULL );
|
||
MuestraEmpr( CurrCol, CurrRow, NORMAL );
|
||
|
||
switch ( BPush )
|
||
{
|
||
case 0: // No se pulso ningun BOTON
|
||
while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER
|
||
if ( ( BPush = CompruebaPulsoConexion() ) != 0 )
|
||
{
|
||
MuestraEmpr( BPush, CurrRow, INTENSO );
|
||
if ( BEmpr.EscribeReg( (void *)&SEmpr, (CurrRow + CurrEmpr) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
}
|
||
break;
|
||
case -2: // Hay una tecla normal en BUFFER
|
||
if ( ( key = getch() ) != 27 )
|
||
{
|
||
if ( key != 13 )
|
||
ungetch( key );
|
||
EditItemEmpr( CurrCol, CurrRow );
|
||
if ( BEmpr.EscribeReg( (void *)&SEmpr, (CurrRow + CurrEmpr) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
MuestraEmpr( CurrCol, CurrRow, NORMAL );
|
||
CurrCol++; if ( CurrCol > 8 ) CurrCol = 8;
|
||
}
|
||
break;
|
||
case -1: // Hay una tecla especial en BUFFER
|
||
switch( getch() )
|
||
{
|
||
// Flecha Izquierda
|
||
case 75:
|
||
case 15:
|
||
CurrCol--; if ( CurrCol < 0 ) CurrCol = 14;
|
||
break;
|
||
// Flecha Derecha
|
||
case 77:
|
||
case 9:
|
||
CurrCol++; if ( CurrCol > 14 ) CurrCol = 0;
|
||
break;
|
||
// Flecha Arriba
|
||
case 72:
|
||
if ( CurrCol < 4 )
|
||
{
|
||
if ( (CurrRow + CurrEmpr) > 0 )
|
||
{
|
||
if ( ( CurrRow ) <= 0 )
|
||
{
|
||
CurrRow = NLINEAS_EMPR - 1; CurrEmpr -= NLINEAS_EMPR;
|
||
if ( CurrEmpr < 0 ) CurrEmpr = 0;
|
||
|
||
while( ( CurrRow + CurrEmpr ) >= BEmpr.Registros() && CurrRow > 0 ) CurrRow--;
|
||
while( ( CurrRow + CurrEmpr ) >= BEmpr.Registros() && CurrEmpr > 0 ) CurrEmpr++;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosEmpr( CurrEmpr );
|
||
} else {
|
||
CurrRow --; if ( CurrRow < 0 ) CurrRow = 0;
|
||
}
|
||
}
|
||
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + CurrRow) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
MuestraDatosVEmpr( CurrRow );
|
||
} else {
|
||
CurrCol--; if ( CurrCol < 0 ) CurrCol = 14;
|
||
}
|
||
break;
|
||
// Flecha Abajo
|
||
case 80:
|
||
if ( CurrCol < 4 )
|
||
{
|
||
if ( ( CurrRow + CurrEmpr ) < BEmpr.Registros() - 1 )
|
||
{
|
||
|
||
if ( ( CurrRow ) >= NLINEAS_EMPR - 1 )
|
||
{
|
||
CurrRow = 0; CurrEmpr += NLINEAS_EMPR;
|
||
|
||
while ( (CurrEmpr + CurrRow) >= BEmpr.Registros() ) CurrEmpr--;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosEmpr( CurrEmpr );
|
||
} else
|
||
CurrRow++;
|
||
}
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + CurrRow) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
MuestraDatosVEmpr( CurrRow );
|
||
} else {
|
||
CurrCol++; if ( CurrCol > 14 ) CurrCol = 0;
|
||
}
|
||
break;
|
||
// Inicio
|
||
case 71:
|
||
CurrRow = 0;
|
||
if ( CurrEmpr != 0 )
|
||
{
|
||
CurrEmpr = 0;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosEmpr( CurrEmpr );
|
||
}
|
||
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + CurrRow) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
MuestraDatosVEmpr( CurrRow );
|
||
break;
|
||
// Fin
|
||
case 79:
|
||
CurrRow = 0;
|
||
if ( CurrEmpr != BEmpr.Registros() - NLINEAS_EMPR )
|
||
{
|
||
CurrEmpr = BEmpr.Registros() - NLINEAS_EMPR;
|
||
if ( CurrEmpr < 0 )
|
||
{
|
||
CurrEmpr = 0;
|
||
CurrRow = BEmpr.Registros()-1;
|
||
}
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosEmpr( CurrEmpr );
|
||
}
|
||
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + CurrRow) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
MuestraDatosVEmpr( CurrRow );
|
||
break;
|
||
}
|
||
break;
|
||
// Imprimir Empresas
|
||
case 1:
|
||
MuestraImpresionesEmpr();
|
||
break;
|
||
// Menu Principal
|
||
case 2:
|
||
ok = 1;
|
||
break;
|
||
#ifndef DEMOSTRACION
|
||
// Eliminar
|
||
case 3:
|
||
if ( strcmpi( PideClave( " C¢digo Acceso !!!", "la eliminici¢n de empresa" ), SEmpr.AccessCode ) == 0 )
|
||
{
|
||
|
||
if ( Optar( 1, "ATENCION", "Eliminar el proveedor", "provoc ra la perdida de datos", "para los informaes!!!", NULL ) )
|
||
{
|
||
if ( BEmpr.DelReg( CurrEmpr + CurrRow ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
if ( BEmpr.Registros() == 0 )
|
||
{
|
||
EmprNuevoRegistro( &SEmpr );
|
||
if ( BEmpr.InsReg( (void *)&SEmpr, BEmpr.Registros(), ARRIBA ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
CurrRow = 0;
|
||
} else
|
||
|
||
// Si he borrado el £ltimo registro subo una linea
|
||
if ( (CurrEmpr+CurrRow) >= ( BEmpr.Registros() - 2 ) )
|
||
{
|
||
if ( (CurrRow + CurrEmpr) > 0 )
|
||
{
|
||
if ( ( CurrRow ) <= 0 )
|
||
{
|
||
CurrRow = NLINEAS_EMPR - 1; CurrEmpr -= NLINEAS_EMPR;
|
||
if ( CurrEmpr < 0 ) CurrEmpr = 0;
|
||
|
||
while( ( CurrRow + CurrEmpr ) >= BEmpr.Registros() && CurrRow > 0 ) CurrRow--;
|
||
while( ( CurrRow + CurrEmpr ) >= BEmpr.Registros() && CurrEmpr > 0 ) CurrEmpr++;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosEmpr( CurrEmpr );
|
||
} else {
|
||
CurrRow --; if ( CurrRow < 0 ) CurrRow = 0;
|
||
}
|
||
}
|
||
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + CurrRow) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
MuestraDatosVEmpr( CurrRow );
|
||
}
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosEmpr( CurrEmpr );
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + CurrRow) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
MuestraDatosVEmpr( CurrRow );
|
||
}
|
||
}
|
||
break;
|
||
// Insertar
|
||
case 4:
|
||
EmprNuevoRegistro( &SEmpr );
|
||
if ( BEmpr.InsReg( (void *)&SEmpr, (CurrEmpr + CurrRow), ARRIBA ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
if ( ( CurrRow + CurrEmpr ) < BEmpr.Registros() - 1 )
|
||
{
|
||
|
||
if ( ( CurrRow ) >= NLINEAS_EMPR - 1 )
|
||
{
|
||
CurrRow = 0; CurrEmpr += NLINEAS_EMPR;
|
||
|
||
while ( (CurrEmpr + CurrRow) >= BEmpr.Registros() ) CurrEmpr--;
|
||
|
||
} else
|
||
CurrRow++;
|
||
}
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosEmpr( CurrEmpr );
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + CurrRow) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
MuestraDatosVEmpr( CurrRow );
|
||
|
||
break;
|
||
#else
|
||
// Eliminar//Insertar
|
||
case 3:
|
||
case 4:
|
||
Optar( 0, "VERSION DEMOSTRACION", "En esta versi¢n no se", "permiten eliminar ni insertar", "nuevos registros...", NULL );
|
||
break;
|
||
#endif
|
||
// Retroceso R pido
|
||
case 5:
|
||
#ifndef DEMOSTRACION
|
||
CurrRow = NLINEAS_EMPR - 1; CurrEmpr -= NLINEAS_EMPR;
|
||
if ( CurrEmpr < 0 ) CurrEmpr = 0;
|
||
|
||
while( ( CurrRow + CurrEmpr ) >= BEmpr.Registros() && CurrRow > 0 ) CurrRow--;
|
||
while( ( CurrRow + CurrEmpr ) >= BEmpr.Registros() && CurrEmpr > 0 ) CurrEmpr++;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosEmpr( CurrEmpr );
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + CurrRow) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
MuestraDatosVEmpr( CurrRow );
|
||
#endif
|
||
break;
|
||
// Busqueda Atras
|
||
case 6:
|
||
break;
|
||
// Buscar
|
||
case 7:
|
||
break;
|
||
// Busqueda Adelante
|
||
case 8:
|
||
break;
|
||
// AvanceR pido
|
||
case 9:
|
||
#ifndef DEMOSTRACION
|
||
CurrRow = 0; CurrEmpr += NLINEAS_EMPR;
|
||
|
||
while ( (CurrEmpr + CurrRow) >= BEmpr.Registros() ) CurrEmpr--;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosEmpr( CurrEmpr );
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + CurrRow) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
MuestraDatosVEmpr( CurrRow );
|
||
#endif
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
} while( !ok );
|
||
|
||
#ifndef DEMOSTRACION
|
||
InicializaNuevasEmpresas();
|
||
#else
|
||
Optar( 0, "VERSION DEMOSTRACION", "No se reevaluar n las empresas", "que cambien de c¢digo...", NULL );
|
||
#endif
|
||
|
||
BEmpr.CerrarReg();
|
||
}
|
||
|
||
#ifndef DEMOSTRACION
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* InicializaNuevasEmpresas *|
|
||
|* *|
|
||
|* Descripci¢n: *|
|
||
|* Repasa todas las empresas para ver si existen sus *|
|
||
|* directorios, y en caso contrario los crea... *|
|
||
|* *|
|
||
|* Entradas: (ninguna) *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void InicializaNuevasEmpresas( void )
|
||
{
|
||
long i;
|
||
char buffer[80];
|
||
|
||
for ( i = 0; i < BEmpr.Registros(); i++ )
|
||
{
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, i ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
sprintf( buffer, "datos\\EMP%05d", SEmpr.CodigoR );
|
||
if ( access( buffer, 0 ) != 0 )
|
||
mkdir( buffer );
|
||
}
|
||
}
|
||
#endif
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* MuestraDatosEmpr *|
|
||
|* *|
|
||
|* 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 MuestraDatosEmpr( long RowStart )
|
||
{
|
||
int linea, campo;
|
||
int dev;
|
||
int X0, Y0, X1, Y1;
|
||
|
||
// Imprimo la NLINEAS_EMPR que caben en la pantalla
|
||
dev = OK;
|
||
for ( linea=0; linea < NLINEAS_EMPR && (RowStart + linea) < BEmpr.Registros()/*dev == OK*/; linea++ )
|
||
{
|
||
dev = BEmpr.LeeReg( (void *)&SEmpr, RowStart + linea );
|
||
if ( dev == OK )
|
||
// Por cada linea hay 4 campos, ehhh!!!
|
||
for ( campo=0; campo < 4; campo++ )
|
||
MuestraEmpr( campo, linea, NORMAL );
|
||
}
|
||
|
||
// Ahora limpio los restantes huecos si los hay
|
||
if ( dev != OK )
|
||
{
|
||
linea--;
|
||
setfillstyle( SOLID_FILL, Config.TxtBgN );
|
||
for ( ; linea < NLINEAS_EMPR; linea++ )
|
||
for ( campo=0; campo < 4; campo++ )
|
||
{
|
||
ObtenCoordenadasEmpr( campo, linea, &X0, &Y0, &X1, &Y1 );
|
||
bar( X0, Y0, X1, Y1 );
|
||
}
|
||
}
|
||
}
|
||
|
||
void MuestraDatosVEmpr( int linea )
|
||
{
|
||
int campo;
|
||
|
||
// Mostramos los campos que faltan, ( 1¦ Linea )
|
||
// mas 1 que pertenecen a las estrellas
|
||
for ( campo=4; campo < 15+1; campo++ )
|
||
MuestraEmpr( campo, linea, NORMAL );
|
||
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* MuestraEmpr *|
|
||
|* *|
|
||
|* 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 MuestraEmpr( char columna, int linea, char como )
|
||
{
|
||
char buffer[80], draw;
|
||
char buffer1[80], i;
|
||
|
||
int X0, Y0, X1, Y1;
|
||
|
||
ObtenCoordenadasEmpr( columna, linea, &X0, &Y0, &X1, &Y1 );
|
||
|
||
draw = 1;
|
||
|
||
|
||
switch( columna )
|
||
{
|
||
// Codigo
|
||
case 0:
|
||
sprintf ( buffer, " %09lu", SEmpr.CodigoR );
|
||
break;
|
||
// Nombre de la empresa
|
||
case 1:
|
||
sprintf ( buffer, "%30s", SEmpr.Empresa );
|
||
break;
|
||
// Direccion IP / N£mero de tel‚fono
|
||
case 2:
|
||
sprintf ( buffer, "%15s", SEmpr.IP_tlf );
|
||
break;
|
||
// Codigo Acceso a esa empresa
|
||
case 3:
|
||
sprintf ( buffer, "%15s", SEmpr.AccessCode[0] == '\0' ? "Sin Codigo" : "Con C¢digo" );
|
||
break;
|
||
|
||
// Codigo
|
||
case 4:
|
||
sprintf ( buffer, "%09lu", SEmpr.CodigoR );
|
||
break;
|
||
// NIF / CIF
|
||
case 5:
|
||
sprintf ( buffer, "%10s", SEmpr.Cif );
|
||
break;
|
||
// Nombre de la empresa
|
||
case 6:
|
||
sprintf ( buffer, "%29s", SEmpr.Empresa );
|
||
break;
|
||
// Gestor de la Empresa
|
||
case 7:
|
||
sprintf ( buffer, "%29s", SEmpr.GestorEmpresa );
|
||
break;
|
||
// Direccion
|
||
case 8:
|
||
sprintf ( buffer, "%36s", SEmpr.Direccion );
|
||
break;
|
||
// Localidad
|
||
case 9:
|
||
sprintf ( buffer, "%15s", SEmpr.Poblacion );
|
||
break;
|
||
// Provincia
|
||
case 10:
|
||
sprintf ( buffer, "%15s", SEmpr.Provincia );
|
||
break;
|
||
// Codigo Postal
|
||
case 11:
|
||
formatea_long( SEmpr.CodPost, buffer1 );
|
||
sprintf ( buffer, "%7s", buffer1 );
|
||
break;
|
||
// Telefono
|
||
case 12:
|
||
sprintf ( buffer, "% 15s", SEmpr.Telefono1 );
|
||
break;
|
||
// Fax
|
||
case 13:
|
||
sprintf ( buffer, "%15s", SEmpr.Fax );
|
||
break;
|
||
|
||
// Comentario
|
||
case 14:
|
||
draw = 0;
|
||
setfillstyle( SOLID_FILL, ( como == NORMAL ) ? Config.TxtBgN : Config.TxtBgI );
|
||
bar( X0, Y0, X1, Y1 );
|
||
settextstyle( SMALL_FONT, HORIZ_DIR, 4 );
|
||
setcolor ( ( como == NORMAL ) ? Config.TxtFgN : Config.TxtFgI );
|
||
for ( i = 0; i < 4; i++ )
|
||
outtextxy( X0, Y0 + 14*i, SEmpr.Notas[i] );
|
||
settextstyle( SMALL_FONT, HORIZ_DIR, 5 );
|
||
break;
|
||
|
||
// Estellas
|
||
case 15:
|
||
if ( ( SEmpr.Estrellas & ( 0x01 << (columna - 15) ) ) >> (columna - 15 ) )
|
||
ponicono( X0+5, Y0+5, led_on, 1 );
|
||
else
|
||
ponicono( X0+5, Y0+5, led_off, 1 );
|
||
// En las estrellas no hay que imprimir nada
|
||
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 );
|
||
}
|
||
}
|
||
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* MuestraAyudaEmpr *|
|
||
|* *|
|
||
|* Descripci¢n: *|
|
||
|* Muestra una peque¤a descripcion del contenido para el campo *|
|
||
|* *|
|
||
|* Entradas: *|
|
||
|* columna campo ha mostar su ayuda *|
|
||
|* *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void MuestraAyudaEmpr( char columna )
|
||
{
|
||
char buffer1[80];
|
||
|
||
switch( columna )
|
||
{
|
||
// Codigo
|
||
case 0:
|
||
sprintf ( buffer1, "Introduzca el codigo que desea asignar a la empresa" );
|
||
break;
|
||
// Nombre de la empresa
|
||
case 1:
|
||
sprintf ( buffer1, "Nombre de la empresa" );
|
||
break;
|
||
// Direccion de IP / tlf
|
||
case 2:
|
||
sprintf ( buffer1, "Direcci¢n IP, o n§ de tel‚fono ( nada == maquina actual )" );
|
||
break;
|
||
// Codigo acceso
|
||
case 3:
|
||
sprintf ( buffer1, "C¢digo de acceso a la empresa" );
|
||
break;
|
||
|
||
// Codigo
|
||
case 4:
|
||
sprintf ( buffer1, "C¢digo de proveedor" );
|
||
break;
|
||
// Nif / Cif
|
||
case 5:
|
||
sprintf ( buffer1, "N.I.F. o C.I.F. del proveedor" );
|
||
break;
|
||
// Nombre de la empresa
|
||
case 6:
|
||
sprintf ( buffer1, "Nombre de la empresa" );
|
||
break;
|
||
// Gestor de la empresa
|
||
case 7:
|
||
sprintf ( buffer1, "Gestor de la empresa" );
|
||
break;
|
||
// Direccion
|
||
case 8:
|
||
sprintf ( buffer1, "Direccion completa del proveedor" );
|
||
break;
|
||
// Poblacion
|
||
case 9:
|
||
sprintf ( buffer1, "Localidad del proveedor" );
|
||
break;
|
||
// Emprincia
|
||
case 10:
|
||
sprintf ( buffer1, "Provincia" );
|
||
break;
|
||
// C¢digo postal
|
||
case 11:
|
||
sprintf ( buffer1, "C¢digo Postal" );
|
||
break;
|
||
// Telefono
|
||
case 12:
|
||
sprintf ( buffer1, "N£mero de tel‚fono del proveedor" );
|
||
break;
|
||
// Fax
|
||
case 13:
|
||
sprintf ( buffer1, "Fax o segundo tel‚fono del proveedor" );
|
||
break;
|
||
case 14:
|
||
sprintf ( buffer1, "Breves notas sobre el proveedor" );
|
||
break;
|
||
}
|
||
|
||
// Ayuda reducida
|
||
setfillstyle( SOLID_FILL, EGA_BLACK ); bar( 7, 457, 498, 473 );
|
||
// Imprime la ayudita
|
||
setcolor( EGA_WHITE ); outtextxy( 7, 457, buffer1 );
|
||
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* EditItemEmpr *|
|
||
|* *|
|
||
|* 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 EditItemEmpr( char columna, int linea )
|
||
{
|
||
char buffer[80];
|
||
|
||
int X0, Y0, X1, Y1;
|
||
|
||
ObtenCoordenadasEmpr( columna, linea, &X0, &Y0, &X1, &Y1 );
|
||
|
||
switch( columna )
|
||
{
|
||
// Codigo Real
|
||
case 0:
|
||
case 4:
|
||
#ifndef DEMOSTRACION
|
||
sprintf ( buffer, "%lu", SEmpr.CodigoR );
|
||
if ( !( InputCadenaG( buffer, 1, 5, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
{
|
||
SEmpr.CodigoR = 0;
|
||
if ( BEmpr.EscribeReg( (void *)&SEmpr, BEmpr.RegActual() ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
if ( atol( buffer ) != 0 )
|
||
{
|
||
if ( EmpresaDuplicada( atol( buffer ) ) == ERROR )
|
||
Optar( 0, "EMPRESA DUPLICADA", "Ese c¢digo esta duplicado", "cada empresa debe", "tener un c¢digo distinto", NULL );
|
||
}
|
||
SEmpr.CodigoR = atol( buffer );
|
||
}
|
||
|
||
MuestraEmpr( 0, linea, NORMAL );
|
||
MuestraEmpr( 4, linea, NORMAL );
|
||
#else
|
||
Optar( 0, "VERSION DEMOSTRACION", "En esta versi¢n no se", "permite modificar el", "c¢digo de empresa...", NULL );
|
||
#endif
|
||
break;
|
||
// Nomrbe Empresa
|
||
case 1:
|
||
case 6:
|
||
strcpy ( buffer, SEmpr.Empresa );
|
||
if ( !( InputCadenaG( buffer, 0, 30, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SEmpr.Empresa, buffer );
|
||
MuestraEmpr( 1, linea, NORMAL );
|
||
MuestraEmpr( 6, linea, NORMAL );
|
||
break;
|
||
// Telefono
|
||
case 2:
|
||
sprintf ( buffer, "%s", SEmpr.IP_tlf );
|
||
if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SEmpr.IP_tlf, buffer );
|
||
break;
|
||
case 12:
|
||
sprintf ( buffer, "%s", SEmpr.Telefono1 );
|
||
if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SEmpr.Telefono1, buffer );
|
||
break;
|
||
// C¢digo de acceso
|
||
case 3:
|
||
#ifndef DEMOSTRACION
|
||
if ( strcmpi( PideClave( "Antigua clave", "comprobar validez" ), SEmpr.AccessCode ) == 0 )
|
||
{
|
||
strcpy( buffer, PideClave( "Nueva Clave", "cambiarla." ) );
|
||
if ( PideClave( "Comfirmacion", "confirmar la misma" ) == buffer )
|
||
strcpy(SEmpr.AccessCode, buffer);
|
||
}
|
||
#else
|
||
Optar( 0, "VERSION DEMOSTRACION", "En esta versi¢n no se", "permiten m¢dificar la clave.", NULL );
|
||
#endif
|
||
|
||
break;
|
||
// Fax
|
||
case 13:
|
||
sprintf ( buffer, "%s", SEmpr.Fax );
|
||
if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SEmpr.Fax, buffer );
|
||
break;
|
||
|
||
|
||
// CIF / NIF
|
||
case 5:
|
||
sprintf ( buffer, "%s", SEmpr.Cif );
|
||
if ( !( InputCadenaG( buffer, 0, 10, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SEmpr.Cif, buffer );
|
||
break;
|
||
|
||
// Gestor de la empresa
|
||
case 7:
|
||
sprintf ( buffer, "%s", SEmpr.GestorEmpresa );
|
||
if ( !( InputCadenaG( buffer, 0, 29, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SEmpr.GestorEmpresa, buffer );
|
||
break;
|
||
|
||
// Direccion
|
||
case 8:
|
||
sprintf ( buffer, "%s", SEmpr.Direccion );
|
||
if ( !( InputCadenaG( buffer, 0, 37, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SEmpr.Direccion, buffer );
|
||
break;
|
||
// Poblaci¢n
|
||
case 9:
|
||
sprintf ( buffer, "%s", SEmpr.Poblacion );
|
||
if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SEmpr.Poblacion, buffer );
|
||
break;
|
||
// Empresa
|
||
case 10:
|
||
sprintf ( buffer, "%s", SEmpr.Provincia );
|
||
if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
strcpy ( SEmpr.Provincia, buffer );
|
||
break;
|
||
// C¢digo Postal
|
||
case 11:
|
||
sprintf ( buffer, "%lu", SEmpr.CodPost );
|
||
if ( !( InputCadenaG( buffer, 0, 5, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) )
|
||
SEmpr.CodPost = atol ( buffer );
|
||
break;
|
||
// Comentario
|
||
case 14:
|
||
settextstyle( SMALL_FONT, HORIZ_DIR, 4 );
|
||
EditComentario( (char *)(&SEmpr.Notas[0][0]), 3, 37, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1, 14 );
|
||
settextstyle( SMALL_FONT, HORIZ_DIR, 5 );
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
|
||
#ifndef DEMOSTRACION
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* EmpresaDuplicada *|
|
||
|* *|
|
||
|* Descripci¢n: *|
|
||
|* Comprueba que el n§ que le pasamos como par metro no esta *|
|
||
|* duplicado *|
|
||
|* Entradas: *|
|
||
|* Empresa a comprobar su duplicado *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
int EmpresaDuplicada( long NEmpresa )
|
||
{
|
||
long i, oldPos;
|
||
char dev;
|
||
|
||
oldPos = BEmpr.RegActual();
|
||
|
||
dev = OK;
|
||
for ( i = 0; i < BEmpr.Registros(); i++ )
|
||
{
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, i ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
if ( SEmpr.CodigoR == NEmpresa )
|
||
{
|
||
dev = ERROR;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, oldPos ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
|
||
return dev;
|
||
}
|
||
#endif
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* ObtenCoordenadasEmpr *|
|
||
|* *|
|
||
|* 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 ObtenCoordenadasEmpr( char columna, char linea, int *X0, int *Y0, int *X1, int *Y1 )
|
||
{
|
||
|
||
// Calculamos la Y0, Y1 para la linea dada ( SOLO columna < 6 )
|
||
*Y0 = 264 + 19*linea;
|
||
*Y1 = *Y0 + 17;
|
||
|
||
switch( columna )
|
||
{
|
||
case 0:
|
||
*X0 = 7; *X1 = 98;
|
||
break;
|
||
case 1:
|
||
*X0 = 107; *X1 = 358;
|
||
break;
|
||
case 2:
|
||
*X0 = 367; *X1 = 495;
|
||
break;
|
||
case 3:
|
||
*X0 = 505; *X1 = 633;
|
||
break;
|
||
|
||
case 4:
|
||
*X0 = 67; *Y0 = 37;
|
||
*X1 = 148; *Y1 = 58;
|
||
break;
|
||
case 5:
|
||
*X0 = 247; *Y0 = 37;
|
||
*X1 = 388; *Y1 = 58;
|
||
break;
|
||
case 6:
|
||
*X0 = 152; *Y0 = 62;
|
||
*X1 = 390; *Y1 = 83;
|
||
break;
|
||
case 7:
|
||
*X0 = 152; *Y0 = 87;
|
||
*X1 = 390; *Y1 = 108;
|
||
break;
|
||
case 8:
|
||
*X0 = 92; *Y0 = 112;
|
||
*X1 = 388; *Y1 = 133;
|
||
break;
|
||
case 9:
|
||
*X0 = 92; *Y0 = 137;
|
||
*X1 = 223; *Y1 = 158;
|
||
break;
|
||
case 10:
|
||
*X0 = 312; *Y0 = 137;
|
||
*X1 = 438; *Y1 = 158;
|
||
break;
|
||
case 11:
|
||
*X0 = 522; *Y0 = 137;
|
||
*X1 = 598; *Y1 = 158;
|
||
break;
|
||
case 12:
|
||
*X0 = 92; *Y0 = 162;
|
||
*X1 = 245; *Y1 = 183;
|
||
break;
|
||
case 13:
|
||
*X0 = 255; *Y0 = 162;
|
||
*X1 = 388; *Y1 = 183;
|
||
break;
|
||
|
||
case 14:
|
||
*X0 = 402; *Y0 = 165;
|
||
*X1 = 633; *Y1 = 221;
|
||
break;
|
||
|
||
case 15:
|
||
*X0 = 90 + 30 + 30 * ( columna - 15 ); *Y0 = 190;
|
||
*X1 = *X0 + 25; *Y1 = 215;
|
||
break;
|
||
}
|
||
|
||
*X0 += 2;
|
||
*X1 -= 2;
|
||
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* EmprNuevoRegistro *|
|
||
|* *|
|
||
|* Descripci¢n: *|
|
||
|* Limpia el buffer, para un nuevo registro. *|
|
||
|* *|
|
||
|* Entradas: (ninguna) *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void EmprNuevoRegistro( INFO_EMPRESAS *NSEmpr )
|
||
{
|
||
int i;
|
||
|
||
NSEmpr -> CodigoR = 0; // Codigos asiignados a los proveedores
|
||
strcpy( NSEmpr -> Empresa, "" ); // Nombre de la empresa
|
||
strcpy( NSEmpr -> GestorEmpresa, "" ); // Gestor de la empresa
|
||
|
||
strcpy( NSEmpr -> Telefono1, "" ); // Tel‚fono y fax del proveedor
|
||
strcpy( NSEmpr -> Fax, "" ); //
|
||
|
||
strcpy( NSEmpr -> IP_tlf, "" ); // Direccion IP o telefono de contacto
|
||
strcpy( NSEmpr -> AccessCode,"" ); // C¢digo de acceso
|
||
|
||
strcpy( NSEmpr -> Direccion, "" ); // Direccion
|
||
strcpy( NSEmpr -> Numero, "" ); // Numero
|
||
|
||
strcpy( NSEmpr -> Poblacion, "" ); // Poblacion
|
||
strcpy( NSEmpr -> Provincia, "" ); // Emprincia
|
||
NSEmpr -> CodPost = 0; // C¢digo Postal
|
||
|
||
NSEmpr -> Estrellas = 0; // Estrellas ( lo que imagina el cliente )
|
||
|
||
for ( i = 0; i < 4; i++ )
|
||
strcpy( NSEmpr -> Notas[i], "" );
|
||
|
||
}
|
||
|
||
int CompruebaPulsoConexion(void)
|
||
{
|
||
char enc, i;
|
||
|
||
enc = 0;
|
||
|
||
for ( i=0; i < 1; i++ )
|
||
{
|
||
if ( y_raton > 190 && y_raton < 215 &&
|
||
x_raton > ( 90 + 30 + 30 * i ) && x_raton < ( 90 + 30 + 30 * i + 25 ) )
|
||
{
|
||
if ( SEmpr.Estrellas & ( 0x01 << i ) )
|
||
SEmpr.Estrellas -= ( 0x01 << i );
|
||
else
|
||
SEmpr.Estrellas += ( 0x01 << i );
|
||
|
||
enc = 14 + i + 1;
|
||
break;
|
||
}
|
||
}
|
||
|
||
Anclar_Raton();
|
||
|
||
return enc;
|
||
}
|
||
|
||
|
||
|
||
// ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
|
||
// Û 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 MuestraImpresionesEmpr(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( 22, "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 );
|
||
|
||
ImprimeEmpreedores( dev );
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* ImprimeEmpreedores *|
|
||
|* *|
|
||
|* Descripci¢n: *|
|
||
|* Imprime todas las referencias seg£n se le indique *|
|
||
|* *|
|
||
|* Entradas: *|
|
||
|* Como imprimir las referencias *|
|
||
|* *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void ImprimeEmpreedores( char como )
|
||
{
|
||
long i, old_reg;
|
||
|
||
|
||
FILE *file_out;
|
||
|
||
old_reg = BEmpr.RegActual();
|
||
|
||
if ( !Config.Impresora.Printer )
|
||
{
|
||
if ( ( file_out = fopen( Config.Impresora.PrintTo, "w" ) ) == NULL )
|
||
return;
|
||
} else
|
||
file_out = stdprn;
|
||
|
||
ImprimeCabeceraEmpr(como, file_out);
|
||
|
||
for ( i=0; i<BEmpr.Registros(); i++ )
|
||
{
|
||
BEmpr.LeeReg( (void *)&SEmpr, i );
|
||
switch( como )
|
||
{
|
||
// Listado R pido
|
||
case 1:
|
||
fprintf( file_out, "%9lu %-30s %-15s %-15s\n\r", SEmpr.CodigoR, SEmpr.Empresa, SEmpr.Telefono1, SEmpr.Fax );
|
||
break;
|
||
// Listado Completo
|
||
case 2:
|
||
fprintf( file_out, "\n\r" );
|
||
fprintf( file_out, "\n\r" );
|
||
fprintf( file_out, "N§ Empreedor: %9lu\n\r", SEmpr.CodigoR );
|
||
fprintf( file_out, "\n\r" );
|
||
fprintf( file_out, "Nombre Empreedor: %s\n\r", SEmpr.Empresa );
|
||
fprintf( file_out, "\n\r" );
|
||
fprintf( file_out, "Telefono: %-15s Fax: %-15s\n\r", SEmpr.Telefono1, SEmpr.Fax );
|
||
fprintf( file_out, "\n\r" );
|
||
fprintf( file_out, "Direccion: %s %s%s\n\r", SEmpr.Direccion, SEmpr.Numero[0] == '\0' ? "" : ", n§ ", SEmpr.Numero );
|
||
fprintf( file_out, "\n\r" );
|
||
fprintf( file_out, "\n\r" );
|
||
break;
|
||
// C¢digos de barra
|
||
case 3:
|
||
break;
|
||
}
|
||
}
|
||
|
||
if ( !Config.Impresora.Printer )
|
||
fclose( file_out );
|
||
|
||
BEmpr.LeeReg( (void *)&SEmpr, old_reg );
|
||
|
||
}
|
||
|
||
void ImprimeCabeceraEmpr( char como, FILE *file_out )
|
||
{
|
||
|
||
switch( como )
|
||
{
|
||
// Listado R pido
|
||
case 1:
|
||
fprintf( file_out, "Codigo Emprvedor Tel‚fono Fax\n\r");
|
||
break;
|
||
// Listado Completo
|
||
case 2:
|
||
// C¢digos de barra
|
||
case 3:
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
// ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
|
||
// Û Despliega lista de Empresas Û
|
||
// ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
|
||
|
||
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* EscogeEmpresaActiva *|
|
||
|* *|
|
||
|* Descripci¢n: *|
|
||
|* Escoge la empresa designada y la confirma con su c¢digo... *|
|
||
|* ( Si no hay c¢digo no se comprueba, si es invalido no habr *|
|
||
|* empresa activa... ) *|
|
||
|* *|
|
||
|* Entradas: Linea en la que comenzar el despliegue *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
void EscogeEmpresaActiva( void )
|
||
{
|
||
char buffer[80], ok, BPush;
|
||
|
||
long CurrRow;
|
||
long CurrEmpr;
|
||
|
||
sprintf( buffer, "datos\\empresas.dbf" );
|
||
|
||
if ( BEmpr.AbrirReg( buffer, sizeof( INFO_EMPRESAS ) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
// Si no hay empresas no podemos editar nada
|
||
if ( BEmpr.Registros() == 0 )
|
||
{
|
||
Optar( 0, " ATENCION !!!", "No existen empresas", "las cuales se puedan", "gestionar. Debe crear una.", NULL );
|
||
BEmpr.CerrarReg();
|
||
return;
|
||
}
|
||
|
||
CurrEmpr = CurrRow = 0;
|
||
|
||
MuestraDatosEmprElegir( CurrRow + CurrEmpr );
|
||
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + CurrRow) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
|
||
ok = 0;
|
||
do {
|
||
|
||
MarcaSubItemSeleccionado( 8, 9 - CurrRow, INTENSO );
|
||
BPush = Comprueba_Secuencia( 8, RatonVentas );
|
||
MarcaSubItemSeleccionado( 8, 9 - 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 ( getch() == 13 )
|
||
{
|
||
sprintf( NEmpresa, "EMP%05d", SEmpr.CodigoR );
|
||
ok = 1;
|
||
}
|
||
|
||
while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER
|
||
break;
|
||
case -1: // Hay una tecla especial en BUFFER
|
||
switch( getch() )
|
||
{
|
||
// Inicio
|
||
case 71:
|
||
CurrRow = 0;
|
||
if ( CurrEmpr != 0 )
|
||
{
|
||
CurrEmpr = 0;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosEmprElegir( CurrEmpr );
|
||
}
|
||
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + CurrRow) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
break;
|
||
// Fin
|
||
case 79:
|
||
CurrRow = 0;
|
||
if ( CurrEmpr != BEmpr.Registros() - NLINEAS_EMPRelegir )
|
||
{
|
||
CurrEmpr = BEmpr.Registros() - NLINEAS_EMPRelegir;
|
||
if ( CurrEmpr < 0 )
|
||
{
|
||
CurrEmpr = 0;
|
||
CurrRow = BEmpr.Registros()-1;
|
||
}
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosEmprElegir( CurrEmpr );
|
||
}
|
||
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + CurrRow) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
break;
|
||
// Flecha Arriba
|
||
case 72:
|
||
if ( ( CurrRow + CurrEmpr ) < ( BEmpr.Registros() - 1 ) )
|
||
{
|
||
|
||
if ( ( CurrRow ) >= NLINEAS_EMPRelegir - 1 )
|
||
{
|
||
CurrRow = 0; CurrEmpr += NLINEAS_EMPRelegir;
|
||
|
||
while ( (CurrEmpr + CurrRow) >= BEmpr.Registros() ) CurrEmpr--;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosEmprElegir( CurrRow + CurrEmpr );
|
||
} else
|
||
CurrRow++;
|
||
}
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + CurrRow) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
break;
|
||
// Retroceso R pido
|
||
case 73:
|
||
CurrRow = NLINEAS_EMPRelegir - 1; CurrEmpr -= NLINEAS_EMPRelegir;
|
||
if ( CurrEmpr < 0 ) CurrEmpr = 0;
|
||
|
||
while( ( CurrRow + CurrEmpr ) >= BEmpr.Registros() && CurrRow > 0 ) CurrRow--;
|
||
while( ( CurrRow + CurrEmpr ) >= BEmpr.Registros() && CurrEmpr > 0 ) CurrEmpr++;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosEmprElegir( CurrRow + CurrEmpr );
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + CurrRow) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
break;
|
||
// AvanceR pido
|
||
case 81:
|
||
CurrRow = 0; CurrEmpr += NLINEAS_EMPRelegir;
|
||
|
||
while ( (CurrEmpr + CurrRow) >= BEmpr.Registros() ) CurrEmpr--;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosEmprElegir( CurrRow + CurrEmpr );
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + CurrRow) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
break;
|
||
// Flecha Abajo
|
||
case 80:
|
||
if ( (CurrRow + CurrEmpr) > 0 )
|
||
{
|
||
if ( ( CurrRow ) <= 0 )
|
||
{
|
||
CurrRow = NLINEAS_EMPRelegir - 1; CurrEmpr -= NLINEAS_EMPRelegir;
|
||
if ( CurrEmpr < 0 ) CurrEmpr = 0;
|
||
|
||
while( ( CurrRow + CurrEmpr ) >= BEmpr.Registros() && CurrRow > 0 ) CurrRow--;
|
||
while( ( CurrRow + CurrEmpr ) >= BEmpr.Registros() && CurrEmpr > 0 ) CurrEmpr++;
|
||
|
||
// Mostramos datos hasta que se nos acabe la pantalla
|
||
MuestraDatosEmprElegir( CurrRow + CurrEmpr );
|
||
} else {
|
||
CurrRow --; if ( CurrRow < 0 ) CurrRow = 0;
|
||
}
|
||
}
|
||
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + CurrRow) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
break;
|
||
}
|
||
while( kbhit() ) getch();
|
||
break;
|
||
case 1:
|
||
case 2:
|
||
case 3:
|
||
case 4:
|
||
case 5:
|
||
case 6:
|
||
case 7:
|
||
case 8:
|
||
case 9:
|
||
case 10:
|
||
if ( ( CurrEmpr + 9 - ( BPush - 1 ) ) < BEmpr.Registros() )
|
||
{
|
||
if ( BEmpr.LeeReg( (void *)&SEmpr, (CurrEmpr + 9 - ( BPush - 1 ) ) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
sprintf( NEmpresa, "EMP%05d", SEmpr.CodigoR );
|
||
ok = 1;
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
} while ( !ok );
|
||
|
||
BEmpr.CerrarReg();
|
||
}
|
||
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* MuestraDatosEmprElegir *|
|
||
|* *|
|
||
|* 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 MuestraDatosEmprElegir( long RowStart )
|
||
{
|
||
int linea;
|
||
char dev;
|
||
int X0, Y0, X1, Y1;
|
||
|
||
// Imprimo la NLINEAS_CMP que caben en la pantalla
|
||
dev = OK;
|
||
for ( linea=0; linea < NLINEAS_EMPRelegir && linea < BEmpr.Registros(); linea++ )
|
||
{
|
||
dev = BEmpr.LeeReg( (void *)&SEmpr, RowStart + linea );
|
||
if ( dev == OK )
|
||
MuestraEmprElegir( linea, NORMAL );
|
||
}
|
||
|
||
// Ahora limpio los restantes huecos si los hay
|
||
if ( linea < NLINEAS_EMPRelegir )
|
||
{
|
||
setfillstyle( SOLID_FILL, 7 );
|
||
for ( ; linea < NLINEAS_EMPRelegir; linea++ )
|
||
{
|
||
ObtenCoordenadasEmprCmp( linea, &X0, &Y0, &X1, &Y1 );
|
||
bar( X0, Y0, X1, Y1 );
|
||
}
|
||
}
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* ObtenCoordenadasEmprCmp *|
|
||
|* *|
|
||
|* 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 ObtenCoordenadasEmprCmp( char linea, int *X0, int *Y0, int *X1, int *Y1 )
|
||
{
|
||
|
||
*Y1 = 77 + 20*(9-linea) ;
|
||
*Y0 = *Y1 + 13 ;
|
||
|
||
*X0 = 113;
|
||
*X1 = 294;
|
||
|
||
}
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* MuestraEmprElegir *|
|
||
|* *|
|
||
|* 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 MuestraEmprElegir( int linea, char como )
|
||
{
|
||
char buffer[80];
|
||
|
||
int X0, Y0, X1, Y1;
|
||
|
||
ObtenCoordenadasEmprCmp( linea, &X0, &Y0, &X1, &Y1 );
|
||
|
||
sprintf ( buffer, "%21s", SEmpr.Empresa );
|
||
|
||
setfillstyle( SOLID_FILL, 7 );//( como == NORMAL ) ? Config.TxtBgN : Config.TxtBgI );
|
||
bar( X0, Y0, X1, Y1 );
|
||
// setcolor ( ( como == NORMAL ) ? Config.TxtFgN : Config.TxtFgI );
|
||
// outtextxy( X0+2, Y1, buffer );
|
||
TextoDoble( X0+2, Y1, buffer );
|
||
}
|
||
|
||
|
||
|
||
/**************************************************************************\
|
||
|* *|
|
||
|* MatchEmpresa *|
|
||
|* *|
|
||
|* Descripci¢n: *|
|
||
|* Encuentra la empresa que se le pasa como par metro... *|
|
||
|* *|
|
||
|* Entradas: *|
|
||
|* Codigo de la Empresa, Lugar donde guardar el n§ de Registros *|
|
||
|* Salidas: (ninguna) *|
|
||
|* *|
|
||
\**************************************************************************/
|
||
int MatchEmpresa( long CEmpresa, int *Registros )
|
||
{
|
||
long i;
|
||
char dev, buffer[80];
|
||
|
||
sprintf( buffer, "datos\\empresas.dbf" );
|
||
|
||
if ( BEmpr.AbrirReg( buffer, sizeof( INFO_EMPRESAS ) ) == ERROR )
|
||
Error(0x01, BEmpr.cError);
|
||
|
||
*Registros = BEmpr.Registros();
|
||
|
||
dev = ERROR;
|
||
for ( i=0; i<BEmpr.Registros(); i++ )
|
||
{
|
||
BEmpr.LeeReg( (void *)&SEmpr, i );
|
||
if ( SEmpr.CodigoR == CEmpresa )
|
||
{
|
||
dev = OK;
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
BEmpr.CerrarReg();
|
||
|
||
return dev;
|
||
|
||
} |