TPV/TPV_GBD.CPP
2021-09-08 21:44:52 +02:00

757 lines
29 KiB
C++
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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
#define CONTRAE 0
#define EXPANDE 1
extern INFO_EMPRESAS SEmpr; // Estructura de Empreedores
typedef struct
{
// Datos de uso p£blico (->ú<-)
char file[13]; // archivo vinculado a la rama
// Datos privados
char Titulo[80]; // Titulo de la rama
char Disponible; // Indica si esta o no el item disponible
unsigned char nivel; // Nivel de profundidad en el cual estamos
char ExpCont; // La rama es:
// Expansible 1 Nada -1
// Contraible 0
char Estado; // La rama esta:
// Expandida 1
// Contraida 0
char Visible; // Es visible en estos momentos?
} ARBOL_EXPANSIBLE;
ARBOL_EXPANSIBLE *InfoGBD; // Informacion sobre la empresa
/*************************************\
| |
| Parte Principal del M¢dulo |
| |
\*************************************/
void ImportaFicheros(void);
void ExportaFicheros( int CurrRow );
void GestionBaseDatos(void);
void EscalaLogotipo( char * File, int X, int Y );
void ContraeExpandeRama( ARBOL_EXPANSIBLE *DesdeAqui, char ContraeExpande );
void IntroduceDatos( char *titulo, char *file, unsigned char nivel, char ExpCont, char Estado, char Visible, int i );
int RecopilaInformacion( int *Nodos );
void MuestraDatosGBD( ARBOL_EXPANSIBLE *DesdeAqui );
void MuestraGDB( ARBOL_EXPANSIBLE *EstaRama, char RowPhysic, char COMO );
/*************************************\
| |
| Parte Tercera del M¢dulo |
| |
| Secci¢n para la impresi¢n |
| |
\*************************************/
void ImprimeInformacion(void);
// ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
// Û Parte principal del m¢dulo Û
// ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
/**************************************************************************\
|* *|
|* GestionBaseDatos *|
|* *|
|* Descripci¢n: *|
|* Controla todas las bases de datos, existentes en el disco *|
|* duro, de la empresa activa. *|
|* Los datos cuelgan del nombre de la empresa, clasificados *|
|* por a¤o, tema y dentro de este, mes, si corresponde... *|
|* *|
|* *|
|* Entradas: (ninguna) *|
|* Salidas: (ninguna) *|
|* *|
\**************************************************************************/
void GestionBaseDatos(void)
{
char buffer2[100], ok = 0;
char buffer[100];
int BPush, key, i;
int CurrRow; // Linea sobre la que estamos
int RowPhysic; // Linea F¡sica sobre la que estamos
int NLineasT; // N§ total de lineas
// Rellenamos la pantalla con un fondo atractivo...
setfillstyle( Config.FillBgS, Config.FillBgC ); bar( 0, 0, 640, 480 );
Imprime_Estaticos( 130, "systm\\Tpv.img"); // Imprime botones estaticos 'Seccion 30'
sprintf( buffer, "datos\\%s\\tpv.pcx", NEmpresa );
if ( access( buffer, 0 ) != 0 )
sprintf( buffer, "systm\\tpv.pcx" );
EscalaLogotipo( buffer, 275, 5 );
Optar( ENCUADRE, "Recopilando informaci¢n", "Se esta recopilando toda", "la informaci¢n disponible", "acerca de su empresa:", "Por favor, espere...", NULL );
if ( RecopilaInformacion( &NLineasT ) == ERROR )
{
Optar( ENCUADRE, "Recopilando informaci¢n", "Se esta recopilando toda", "la informaci¢n disponible", "acerca de su empresa:", "Por favor, espere...", NULL );
Optar( 0, "Memoria insuficiente", "No se a podido alojar la", "cantidad de memoria requerida", "libere memoria antes de", "volver a intertarlo.", NULL );
return;
}
Optar( ENCUADRE, "Recopilando informaci¢n", "Se esta recopilando toda", "la informaci¢n disponible", "acerca de su empresa:", "Por favor, espere...", NULL );
settextstyle( SMALL_FONT, HORIZ_DIR, 4 );
// Mostramos datos hasta que se nos acabe la pantalla
RowPhysic = CurrRow = 0;
MuestraDatosGBD( &InfoGBD[CurrRow] );
do {
MuestraGDB( &InfoGBD[CurrRow], RowPhysic, INTENSO );
BPush = Comprueba_Secuencia( 2, NULL );
MuestraGDB( &InfoGBD[CurrRow], RowPhysic, 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
switch ( getch() )
{
// Contrae la rama
case 27:
ContraeExpandeRama( &InfoGBD[CurrRow], CONTRAE );
setfillstyle( SOLID_FILL, 0 ); bar ( 12, 12, 263, 443 );
RowPhysic = CurrRow = 0;
MuestraDatosGBD( &InfoGBD[CurrRow] );
break;
// Contrae/Expande rama, dependiendo del estado
case 13:
ContraeExpandeRama( &InfoGBD[CurrRow], InfoGBD[CurrRow].Estado == EXPANDE ? CONTRAE : EXPANDE );
setfillstyle( SOLID_FILL, 0 ); bar ( 12, 12, 263, 443 );
RowPhysic = CurrRow = 0;
MuestraDatosGBD( &InfoGBD[CurrRow] );
break;
}
break;
case -1: // Hay una tecla especial en BUFFER
switch( getch() )
{
// Flecha Izquierda
case 75:
case 15:
// Flecha Arriba
case 72:
if ( CurrRow > 0 )
{
RowPhysic --;
do {
CurrRow--;
} while( CurrRow > 0 && !InfoGBD[CurrRow].Visible );
}
if ( RowPhysic < 0 )
{
i = 0;
do {
CurrRow--;
if ( InfoGBD[CurrRow].Visible )
i ++;
} while( CurrRow > 0 && i != 28 );
setfillstyle( SOLID_FILL, 0 ); bar ( 12, 12, 263, 443 );
MuestraDatosGBD( &InfoGBD[CurrRow] );
RowPhysic = 0;
//
RowPhysic += 27;
i = 0;
do {
CurrRow++;
if ( InfoGBD[CurrRow].Visible )
i++;
} while( i != 27 && strcmp( InfoGBD[CurrRow].Titulo, "TOPE_FINAL" ) != 0 );
if ( !InfoGBD[CurrRow].Visible || strcmp( InfoGBD[CurrRow].Titulo, "TOPE_FINAL" ) == 0 )
{
RowPhysic --;
do {
CurrRow--;
} while( CurrRow > 0 && !InfoGBD[CurrRow].Visible );
}
//
}
break;
// Flecha Derecha
case 77:
case 9:
// Flecha Abajo
case 80:
RowPhysic ++;
do {
CurrRow++;
} while( !InfoGBD[CurrRow].Visible && strcmp( InfoGBD[CurrRow].Titulo, "TOPE_FINAL" ) != 0 );
if ( !InfoGBD[CurrRow].Visible || strcmp( InfoGBD[CurrRow].Titulo, "TOPE_FINAL" ) == 0 )
{
RowPhysic --;
do {
CurrRow--;
} while( CurrRow > 0 && !InfoGBD[CurrRow].Visible );
}
if ( RowPhysic >= 28 )
{
RowPhysic = 0;
setfillstyle( SOLID_FILL, 0 ); bar ( 12, 12, 263, 443 );
MuestraDatosGBD( &InfoGBD[CurrRow] );
}
break;
// Inicio
case 71:
// RowPhysic = CurrRow = 0;
break;
// Fin
case 79:
/*
CurrRow = NLineas-1;
if ( InfoGBD[CurrRow].Estado == CONTRAIDO )
do {
CurrRow--;
} while( CurrRow > 0 && InfoGBD[CurrRow].Estado == CONTRAIDO );
*/
break;
}
break;
// Imprimir Informe detallado
case 1:
break;
// Menu Principal
case 2:
ok = 1;
break;
// Exportar
case 3:
ExportaFicheros( CurrRow );
break;
// Importar
case 4:
ImportaFicheros();
break;
// Retroceso R pido
case 5:
ungetch(75); ungetch(0);
// Inicio
case 6:
ungetch(71); ungetch(0);
break;
// Eliminar Clave
case 7:
// No se permite eliminar TODO, TODO, del tiron
if ( CurrRow == 0 ) break;
if ( InfoGBD[CurrRow].nivel <= InfoGBD[CurrRow+1].nivel )
sprintf( buffer, "toda la clave COMPLETA." );
else
sprintf( buffer, "el siguiente fichero: %s", InfoGBD[CurrRow].file );
Optar( 0, "ALERTA de ELIMINACION!!!", "Se dispone a eliminar", buffer, "¨ Desea continuar ?", NULL );
if ( Optar( 1, "ALERTA de ELIMINACION!!!", "Se dispone a eliminar", buffer, "¨ Esta realmente seguro ?", NULL ) )
{
i = 0;
do {
sprintf( buffer, "datos\\%s\\%s", NEmpresa, InfoGBD[CurrRow + i].file );
unlink( buffer );
i ++;
} while ( InfoGBD[CurrRow + i].nivel <= InfoGBD[CurrRow + i + 1].nivel );
}
// ReEscaneamos el  rbol
free( InfoGBD );
Optar( ENCUADRE, "Recopilando informaci¢n", "Se esta recopilando toda", "la informaci¢n disponible", "acerca de su empresa:", "Por favor, espere...", NULL );
if ( RecopilaInformacion( &NLineasT ) == ERROR )
{
Optar( ENCUADRE, "Recopilando informaci¢n", "Se esta recopilando toda", "la informaci¢n disponible", "acerca de su empresa:", "Por favor, espere...", NULL );
Optar( 0, "Memoria insuficiente", "No se a podido alojar la", "cantidad de memoria requerida", "libere memoria antes de", "volver a intertarlo.", NULL );
return;
}
Optar( ENCUADRE, "Recopilando informaci¢n", "Se esta recopilando toda", "la informaci¢n disponible", "acerca de su empresa:", "Por favor, espere...", NULL );
// Volvemos a mostrar todo
CurrRow--;
MuestraDatosGBD( &InfoGBD[CurrRow] );
break;
// Fin
case 8:
ungetch(79); ungetch(0);
break;
// AvanceR pido
case 9:
ungetch(77); ungetch(0);
break;
#ifndef DEMOSTRACION
#else
#endif
default:
break;
}
} while( !ok );
#ifndef DEMOSTRACION
// Do nothing
#else
Optar( 0, "VERSION DEMOSTRACION", "Cambios realizados no ser n", "llevados a cabo.", NULL );
#endif
free( InfoGBD );
}
void MuestraDatosGBD( ARBOL_EXPANSIBLE *DesdeAqui )
{
int i, j;
for ( i = 0, j = 0; j < 28 && strcmp( DesdeAqui[i].Titulo, "TOPE_FINAL" ) != 0; i++ )
{
if ( DesdeAqui[i].Visible )
{
MuestraGDB( &DesdeAqui[i], j, NORMAL );
j++;
}
}
}
void MuestraGDB( ARBOL_EXPANSIBLE *EstaRama, char RowPhysic, char COMO )
{
char buffer[80];
int Y0, Y1, X0, X1;
Y0 = 20 + 15*RowPhysic;
Y1 = Y0 + 17;
// Ymin => 425
X0 = 20; X1 = 255;
setfillstyle( COMO == NORMAL ? SOLID_FILL : CLOSE_DOT_FILL, COMO == NORMAL ? 0 : Config.TxtBgI );
bar ( X0, Y0, X1, Y1 );
setcolor( COMO == NORMAL ? Config.TxtFgN + 1 : Config.TxtBgN );
// Mostramos si es posible CONTRAERLA/EXPANDIRLA o no se puede hacer nada
sprintf ( buffer, "%s", (EstaRama -> ExpCont) == EXPANDE ?
( (EstaRama -> Estado ) == CONTRAE ? "+" : "-" ) :
" " );
outtextxy ( 20 + 20*(EstaRama -> nivel), Y0, buffer );
if ( strcmp( (EstaRama -> file), "--------.---" ) == 0 )
sprintf ( buffer, "%s", (EstaRama -> Titulo) );
else
sprintf ( buffer, "%s <%s>", (EstaRama -> Titulo), (EstaRama -> file) );
outtextxy ( 35 + 20*(EstaRama -> nivel), Y0, buffer );
}
/**************************************************************************\
|* *|
|* ExportaFicheros *|
|* *|
|* Descripci¢n: *|
|* Lleva la clave seleccionada hacia A:\[NEmpresa] *|
|* *|
|* Entradas: (ninguna) *|
|* Salidas: (ninguna) *|
|* *|
\**************************************************************************/
void ExportaFicheros( int CurrRow )
{
char buffer[80];
int i;
Optar( 0, "Inicio de Exportaci¢n", "Inserte un disco limpio en A:", "Se dispone a copiar la clave", "seleccionada para llevarla", "a otro ordenador, o guardarla.", NULL );
// Iniciamos la exportacion
// Vemos si tenemos suficiente espacio libre
// Creamos en la unidad A:\ el directorio de la empresa, lo
// limpiamos y comenzamos...
sprintf( buffer, "A:\\%s", NEmpresa );
if ( !mkdir(buffer) )
{
Optar( 0, "Error de escritura", "Me es imposible acceder", "a la unidad A:\\", "Proceso Abortado", NULL );
}
i = 0;
do {
// Solo si no es una cabecera...
if ( strcmp( InfoGBD[CurrRow + i].file, "--------.---" ) != 0 )
{
sprintf( buffer, "datos\\%s\\%s", NEmpresa, InfoGBD[CurrRow + i].file );
// ... a copiar los ficheros de [ buffer ] ---->>> [ A:\NEmpresa\InfoGBD[CurrRow + i ].file ]
}
i ++;
} while ( InfoGBD[CurrRow + i].nivel <= InfoGBD[CurrRow + i + 1].nivel );
}
/**************************************************************************\
|* *|
|* ImportaFicheros *|
|* *|
|* Descripci¢n: *|
|* Se trae lo ficheros previamente exportados de A:\[NEmpresa] *|
|* hasta \[NEmpresa] *|
|* *|
|* Entradas: (ninguna) *|
|* Salidas: (ninguna) *|
|* *|
\**************************************************************************/
void ImportaFicheros(void)
{
int i;
struct ffblk ffblk;
char buffer2[80], buffer[80];
if ( !Optar( 1, "Alerta ­­­ Importaci¢n !!!", "Este proceso eliminar  las", "versiones existentes de BDatos", "¨ Desea continuar ?", NULL ) )
return;
Optar( 0, "Inicio de Exportaci¢n", "Inserte un disco limpio en A:", "Se dispone a restaurar la", "clave seleccionada para", "reponerla o actualizarla.", NULL );
// Iniciamos la importacion
sprintf( buffer, "A:\\%s\\*.*", NEmpresa );
i = findfirst(buffer, &ffblk, 0);
while (!i)
{
sprintf( buffer2, "datos\\%s\\%s", NEmpresa, ffblk.ff_name );
// ... a copiar los ficheros de [ A:\NEmpresa\ffblk.ff_name] ---> [ buffer ]
i = findnext(&ffblk);
};
}
#define MOD_SCAL 2
void EscalaLogotipo( char * File, int X, int Y )
{
FILE *fp;
int alto, ancho; unsigned char byte;
int alto2, ancho2;
int scalH = 0, scalV = 0;
int contador;
char color[17] = { 0, EGA_RED, EGA_GREEN, EGA_LIGHTGRAY,
EGA_LIGHTRED, EGA_LIGHTRED, EGA_LIGHTRED, EGA_LIGHTRED,
EGA_LIGHTRED, EGA_LIGHTRED, EGA_LIGHTRED, EGA_LIGHTRED,
EGA_LIGHTRED, EGA_LIGHTRED, EGA_LIGHTRED, EGA_LIGHTRED, EGA_LIGHTRED };
if ( ( fp = fopen ( File, "rb" ) ) != NULL )
{
// Saltamos la cabecera
fseek( fp, 128, SEEK_SET );
alto2 = 0;
for(alto=0; alto<279; alto++)
{
ancho2 = 0;
scalV = (scalV++)%MOD_SCAL;
{
if ( scalV == 1 )
alto2++;
for(ancho=0; ancho<240; )
{
byte=getc(fp);
if(byte<=0xC0)
{
scalH = (scalH++)%MOD_SCAL;
if ( scalH == 1 && scalV == 1)
{
if ( byte != 255 )
putpixel( ancho2+X, alto2+Y, color[byte%16] );
ancho2++;
}
ancho++;
}
else
{
contador=byte&0x3F; byte=getc(fp);
for(; contador>0; contador--)
{
scalH = (scalH++)%MOD_SCAL;
if ( scalH == 1 && scalV == 1)
{
if ( byte != 255 )
putpixel( ancho2+X, alto2+Y, color[byte%16] );
ancho2++;
}
ancho++;
}
}
}
}
}
fclose( fp );
}
}
/**************************************************************************\
|* *|
|* RecopilaInformaci¢n *|
|* *|
|* Descripci¢n: *|
|* Recopila una extensa informaci¢n sobre el estado de las *|
|* bases de datos existentes para la empresa dada, y la *|
|* clasifica por niveles expansibles... *|
|* *|
|* *|
|* Entradas: (ninguna) *|
|* Salidas: (ninguna) *|
|* *|
\**************************************************************************/
int RecopilaInformacion(int *Nodos)
{
struct ffblk ffblk;
int done;
char buffer[80], buffer1[80];
int Anyos[50], N_Anyos; // Como muchos gestionaremos, 50 a¤os
int i, j, k;
char Mes[12][12] = { "Enero ", "Febrero ", "Marzo ", "Abril ", "Mayo ", "Junio ", "Julio ", "Agosto ", "Septiembre", "Octubre ", "Noviembre ", "Diciembre " };
// Total de ficheros:
for ( i=0; i < 50; i++ ) Anyos[i] = 0;
i = 0; j = 0; N_Anyos = 0;
sprintf( buffer, "datos\\%s\\*.*", NEmpresa );
done = findfirst(buffer,&ffblk,0);
while (!done)
{
// Analizamos los a¤os de los que disponemos...
if ( strstr( ffblk.ff_name, "CMP" ) != NULL || strstr( ffblk.ff_name, "VT" ) != NULL )
{
// Obtenemos el a¤o
k = (ffblk.ff_name[4]-'0') * 1000 + (ffblk.ff_name[5]-'0') * 100 + (ffblk.ff_name[6]-'0') * 10 + (ffblk.ff_name[7]-'0') * 1;
// Lo buscamos entre los que ya tenemos y de no encontrarlo lo agregamos
for ( j = 0; j < 50 && Anyos[j] != 0; j++ )
if ( Anyos[j] == k )
break;
if ( j < 50 && Anyos[j] == 0 )
{
N_Anyos++; Anyos[j] = k;
}
}
i++; done = findnext(&ffblk);
};
*Nodos = 1 + // Raiz (N0) con el nombre de la empresa
3 + // Datos que perduran en el tiempo
( 6 * N_Anyos)+ // Datos por a¤o * n£mero de a¤os disponibles
i + // ( n§ total de ficheros )
1 ; // Tope para el final de nuestras funciones...
if ( ( InfoGBD = (ARBOL_EXPANSIBLE *)malloc( sizeof(ARBOL_EXPANSIBLE)*(*Nodos) ) ) == NULL )
return ERROR;
// Nivel 0: Nombre de la empresa
j = 0;
IntroduceDatos( SEmpr.Empresa, "--------.---", 0, 1, 0, 1, j ); j++;
// Nv Ex Es Vis
// Datos que perduran con el tiempo
// Nivel 1:
sprintf( buffer, "datos\\%s\\info_ref.dbf", NEmpresa );
if ( access( buffer, 0 ) == 0 )
{
IntroduceDatos( "Articulos", "info_ref.dbf", 1, 0, 0, 0, j ); j++;
}
sprintf( buffer, "datos\\%s\\info_emp.dbf", NEmpresa );
if ( access( buffer, 0 ) == 0 )
{
IntroduceDatos( "Info Empleados", "info_emp.dbf", 1, 0, 0, 0, j ); j++;
}
sprintf( buffer, "datos\\%s\\mensajes.dbf", NEmpresa );
if ( access( buffer, 0 ) == 0 )
{
IntroduceDatos( "Mensajes Prot.", "mensajes.dbf", 1, 0, 0, 0, j ); j++;
}
for ( i = 0; i < N_Anyos; i++ )
{
sprintf( buffer, "%d", Anyos[i] );
IntroduceDatos( buffer, "--------.---", 1, 1, 0, 0, j/*Tamano bloque*/ ); j++;
// Informacion variable con el tiempo
// Nivel 2:
sprintf( buffer, "datos\\%s\\inf_prv.%03d", NEmpresa, Anyos[i] - ( Anyos[i] / 1000 ) * 1000 );
if ( access( buffer, 0 ) == 0 )
{
sprintf( buffer, "inf_prv.%03d", Anyos[i] - ( Anyos[i] / 1000 ) * 1000 );
IntroduceDatos( "Proveedores", buffer, 2, 0, 0, 0, j/*Tamano bloque*/ ); j++;
}
// Nivel 3clt: Clientes
sprintf( buffer, "datos\\%s\\inf_clt1.dbf", NEmpresa );
sprintf( buffer1, "datos\\%s\\inf_clt2.%03d", NEmpresa, Anyos[i] - ( Anyos[i] / 1000 ) * 1000 );
if ( access( buffer, 0 ) == 0 || access( buffer1, 0 ) == 0)
{
// Nivel 2clt: Clientes
IntroduceDatos( "Clientes", "--------.---", 2, 1, 0, 0, j/*Tamano bloque*/ ); j++;
if ( access( buffer, 0 ) == 0 )
{
IntroduceDatos( "Ficha Clt", "inf_clt1.dbf", 3, 0, 0, 0, j/*Tamano bloque*/ ); j++;
}
if ( access( buffer1, 0 ) == 0 )
{
sprintf( buffer, "inf_clt2.%03d", Anyos[i] - ( Anyos[i] / 1000 ) * 1000 );
IntroduceDatos( "Datos Clt", buffer, 3, 0, 0, 0, j/*Tamano bloque*/ ); j++;
}
}
IntroduceDatos( "Compras", "--------.---", 2, 1, 0, 0, j/*Tamano bloque*/ ); j++;
// Nivel 3cmp: Archivos de compras existentes
for ( k = 0; k < 12; k++ )
{
sprintf( buffer, "datos\\%s\\cmp-%04d.m%02d", NEmpresa, Anyos[i], k+1 );
if ( access( buffer, 0 ) == 0 )
{
sprintf( buffer, "cmp-%04d.m%02d", Anyos[i], k+1 );
IntroduceDatos( Mes[k], buffer, 3, 0, 0, 0, j/*Tamano bloque*/ ); j++;
}
}
IntroduceDatos( "Gestion de Ventas", "--------.---", 2, 1, 0, 0, j/*Tamano bloque*/ ); j++;
IntroduceDatos( "Datos generales", "--------.---", 3, 1, 0, 0, j/*Tamano bloque*/ ); j++;
for ( k = 0; k < 12; k++ )
{
sprintf( buffer, "datos\\%s\\VT1-%04d.m%02d", NEmpresa, Anyos[i], k+1 );
if ( access( buffer, 0 ) == 0 )
{
sprintf( buffer, "VT1-%04d.m%02d", Anyos[i], k+1 );
IntroduceDatos( Mes[k], buffer, 4, 0, 0, 0, j/*Tamano bloque*/ ); j++;
}
}
IntroduceDatos( "Productos Vendidos", "--------.---", 3, 1, 0, 0, j/*Tamano bloque*/ ); j++;
for ( k = 0; k < 12; k++ )
{
sprintf( buffer, "datos\\%s\\VT2-%04d.m%02d", NEmpresa, Anyos[i], k+1 );
if ( access( buffer, 0 ) == 0 )
{
sprintf( buffer, "VT2-%04d.m%02d", Anyos[i], k+1 );
IntroduceDatos( Mes[k], buffer, 4, 0, 0, 0, j/*Tamano bloque*/ ); j++;
}
}
sprintf( buffer, "datos\\%s\\VT3-%04d.M--", NEmpresa, Anyos[i] );
if ( access( buffer, 0 ) == 0 )
{
sprintf( buffer, "VT3-%04d.M--", Anyos[i] );
IntroduceDatos( "Ventas por Empleado", buffer, 3, 0, 0, 0, j/*Tamano bloque*/ ); j++;
}
// Nv Ex Es Vis
}
IntroduceDatos( "TOPE_FINAL", "--------.---", 0, 0, 0, 0, j/*Tamano bloque*/ );
// j--; *Nodos = j;
return OK;
}
/**************************************************************************\
|* *|
|* IntroduceDatos *|
|* *|
|* Descripci¢n: *|
|* Realmente esto no vale para nada, solo para tener que *|
|* escribir menos... *|
|* *|
|* Entradas: Los datos de relleno para la estructura ARBOL_EXPANSIBLE *|
|* *|
|* Salidas: (ninguna) *|
|* *|
\**************************************************************************/
void IntroduceDatos( char *titulo, char *file, unsigned char nivel, char ExpCont, char Estado, char Visible, int i )
{
strcpy( InfoGBD[i].Titulo, titulo );
strcpy( InfoGBD[i].file, file );
InfoGBD[i].nivel = nivel;
InfoGBD[i].ExpCont = ExpCont;
InfoGBD[i].Estado = Estado;
InfoGBD[i].Visible = Visible;
}
/**************************************************************************\
|* *|
|* ContraeExpandeRama *|
|* *|
|* Descripci¢n: *|
|* Contrae o expande la rama seg£n el par metro y apartir del *|
|* punto indicado... *|
|* *|
|* Entradas: Puntero al inicio de la expanci¢n / contraccion *|
|* Accion a ejecutar: CONTRAE / EXPANDE *|
|* *|
|* Salidas: (ninguna) *|
|* *|
\**************************************************************************/
void ContraeExpandeRama( ARBOL_EXPANSIBLE *DesdeAqui, char ContraeExpande )
{
int i;
// Solo si desde el punto donde estamos es Expansible
if ( DesdeAqui -> ExpCont == EXPANDE )
{
DesdeAqui -> Estado = ContraeExpande;
if ( ContraeExpande == CONTRAE )
{
for ( i=0; ( DesdeAqui -> nivel ) < DesdeAqui[i+1].nivel ; i++)
{
DesdeAqui[i+1].Visible = ContraeExpande;
DesdeAqui[i+1].Estado = ContraeExpande;
}
} else {
for ( i=0; DesdeAqui[i+1].nivel > DesdeAqui -> nivel && DesdeAqui[i+1].nivel != 0; i++)
{
if ( ( DesdeAqui -> nivel + 1 ) == DesdeAqui[i+1].nivel )
DesdeAqui[i+1].Visible = ContraeExpande;
}
}
}
}
/*
typedef struct
{
// Datos de uso p£blico (->ú<-)
char file[13]; // archivo vinculado a la rama
// Datos privados
char Titulo[80]; // Titulo de la rama
unsigned char nivel; // Nivel de profundidad en el cual estamos
char ExpCont; // La rama es:
// Expansible 1
// Nada 0
char Estado; // La rama esta:
// Expandida 1
// Contraida 0
} ARBOL_EXPANSIBLE;
*/