LosArcosChicos/ZOR_MM.CPP
2021-09-12 20:24:08 +02:00

401 lines
11 KiB
C++
Raw 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 <dos.h>
#include <conio.h>
#include<bios.h>
#include<dos.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
#include "d:\program\src_dos\libs\bdatos\bdatos.hh"
#include "zorr.h"
CONFIG Config = {
1, BLUE,
RED, WHITE, BLACK,
BLACK, RED, WHITE, BLACK,
0, { "PrnFile.out" }
};
#define OFF 0
#define ON 1
#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif
#define GESTION_DE_SOCIOS 1
#define LISTA_DE_PRECIOS 2
#define GASTOS_INTERNOS 3
#define SALIR 4
int MenuPrincipal(void);
void ListaPrecios(void);
void GestionSocios(void);
extern void GastosInternos(void);
void PideAnoActual(void);
void DibujaPantallaGastosInt(void);
int boton_izq; int boton_der;
int x_raton, y_raton, RATON = 1;
//ÛÛ
int AnoActual;
int main(void)
{
int ok;
struct date d;
getdate( &d );
AnoActual = d.da_year - ( d.da_year / 100 ) * 100;
inicializa_raton_texto();
if( RATON ) desactiva_raton();
PideAnoActual();
ok = 0;
do {
switch( MenuPrincipal() )
{
case GESTION_DE_SOCIOS:
GestionSocios();
break;
case LISTA_DE_PRECIOS:
ListaPrecios();
break;
case GASTOS_INTERNOS:
GastosInternos();
break;
case SALIR:
ok = 1;
break;
}
} while ( !ok ) ;
return 0;
}
int MenuPrincipal(void)
{
struct Boton_Texto BT[4];
int devolver = 0;
BT[0].x = 29; BT[0].y = 9; strcpy( BT[0].Texto, " &Gestion de Socios "); BT[0].ID_T1 = 71; BT[0].ID_T2 = 0;
BT[1].x = 29; BT[1].y = 12; strcpy( BT[1].Texto, " &Listado de Precios "); BT[1].ID_T1 = 76; BT[1].ID_T2 = 0;
BT[2].x = 29; BT[2].y = 15; strcpy( BT[2].Texto, " Ga&stos internos "); BT[2].ID_T1 = 83; BT[2].ID_T2 = 0;
BT[3].x = 29; BT[3].y = 18; strcpy( BT[3].Texto, " S&ALIR al DOS "); BT[3].ID_T1 = 65; BT[3].ID_T2 = 0;
_setcursortype(_NOCURSOR);
textcolor( WHITE );
textbackground( BLACK );
clrscr();
cprintf(" \n\r");
cprintf(" Ü ÜÜÜ ÜÜÜ ÜÜÜ ÜÜÜ ÜÜ ÜÜÜ ÜÜÜ ÜÜ Ü Ü Ü ÜÜ ÜÜÜ ÜÜÜ \n\r");
cprintf(" Û Û Û ÛÜÜ ÛÜÛ ÛÜÛ Û Û Û ÛÜÜ Û ÛÜÛ Û Û Û Û ÛÜÜ \n\r");
cprintf(" ÛÜÜ ÛÜÛ ÜÜÛ Û Û ÛßÜ ÛÜ ÛÜÛ ÜÜÛ ÛÜ Û Û Û ÛÜ ÛÜÛ ÜÜÛ \n\r");
cprintf(" \n\r");
cprintf(" \n\r");
cprintf(" ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ \n\r");
cprintf(" ³ ³ \n\r");
cprintf(" ³ ³ \n\r");
cprintf(" ³ ³ \n\r");
cprintf(" ³ ³ \n\r");
cprintf(" ³ ³ \n\r");
cprintf(" ³ ³ \n\r");
cprintf(" ³ ³ \n\r");
cprintf(" ³ ³ \n\r");
cprintf(" ³ ³ \n\r");
cprintf(" ³ ³ \n\r");
cprintf(" ³ ³ \n\r");
cprintf(" ³ ³ \n\r");
cprintf(" ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ \n\r");
while( ( devolver = Funcion_Botones(STD_BY, 4, BT) ) < 1 || devolver > 4 ) while ( kbhit() ) getch();
_setcursortype(_NORMALCURSOR);
return devolver;
}
int Funcion_Botones(int Funcion, int nBotones, struct Boton_Texto *Boton_Texto)
{
char i;
int DEVOLVER = -1;
int longitud, key, key2;
switch( Funcion ) {
case DIBUJA:
highvideo();
textcolor(BLACK);
textbackground(11);
gotoxy(Boton_Texto[nBotones].x, Boton_Texto[nBotones].y);
DEVOLVER = 0;
longitud = strlen( Boton_Texto[nBotones].Texto );
while( DEVOLVER <= longitud ) {
if( Boton_Texto[nBotones].Texto[DEVOLVER] == '&' ) {
DEVOLVER ++;
textcolor(RED);
cprintf("%c", Boton_Texto[nBotones].Texto[DEVOLVER]);
textcolor(BLACK);
} else cprintf("%c", Boton_Texto[nBotones].Texto[DEVOLVER]);
DEVOLVER ++;
}
// cprintf("%s", Texto);
textbackground(7); // ±SALIR±Ü
cprintf("ß"); // ßßßßßßß
gotoxy(Boton_Texto[nBotones].x+1, Boton_Texto[nBotones].y+1);
for(i = 0; i < longitud; i ++ ) // ±±±±±±±Ü
cprintf("Ü"); // ßßßßßßß
break;
case DEPRIME:
highvideo();
textcolor(BLACK);
textbackground(11);
gotoxy(Boton_Texto[nBotones].x, Boton_Texto[nBotones].y);
DEVOLVER = 0;
longitud = strlen( Boton_Texto[nBotones].Texto );
////////////////
textbackground(BLACK);
while( DEVOLVER <= (longitud+1) ) {
if( Boton_Texto[nBotones].Texto[DEVOLVER] == '&' ) {
DEVOLVER ++;
}
cprintf(" ");
DEVOLVER ++;
}
textbackground(11);
gotoxy(Boton_Texto[nBotones].x+1, Boton_Texto[nBotones].y+1);
DEVOLVER = 0;
while( DEVOLVER <= longitud ) {
if( Boton_Texto[nBotones].Texto[DEVOLVER] == '&' ) {
DEVOLVER ++;
textcolor(RED);
cprintf("%c", Boton_Texto[nBotones].Texto[DEVOLVER]);
textcolor(BLACK);
} else cprintf("%c", Boton_Texto[nBotones].Texto[DEVOLVER]);
DEVOLVER ++;
}
// cprintf("%s", Texto); //
// ±±±±±±±
break;
case Dibuja_Todos:
for( i=0; i < nBotones; i++)
Funcion_Botones( DIBUJA, i, Boton_Texto);
break;
case COMPRUEBA:
if( bioskey(1)!=0 ) {
key = toupper( getch() ); DEVOLVER = -2;
if ( key == 0 ) { key2 = toupper( getch() ); DEVOLVER = -1; }
for( i=0; i < nBotones && DEVOLVER <= -1; i++){
if( key == Boton_Texto[i].ID_T1 ) {
if( key == 0 ) {
if( key2 == Boton_Texto[i].ID_T2 ){
DEVOLVER = (i + 1);
Funcion_Botones( DEPRIME, (DEVOLVER-1), Boton_Texto);
delay(150);
//sleep(1);
Funcion_Botones( DIBUJA, (DEVOLVER-1), Boton_Texto);
}
} else
{ DEVOLVER = (i + 1);
Funcion_Botones( DEPRIME, (DEVOLVER-1), Boton_Texto);
delay(150);
//sleep(1);
Funcion_Botones( DIBUJA, (DEVOLVER-1), Boton_Texto);
}
}
}
if( DEVOLVER == -2 )
{ ungetch(key); }
if( DEVOLVER == -1 )
{ ungetch(key2); }
} else if( RATON ) {
DEVOLVER = 0;
for( i=0; i < nBotones && DEVOLVER == 0; i++) {
longitud = strlen( Boton_Texto[i].Texto );
if ( (x_raton+1) >= Boton_Texto[i].x && (x_raton+1) <= ( Boton_Texto[i].x + longitud -1) &&
y_raton == (Boton_Texto[i].y-1) ) { DEVOLVER = (i + 1);
Funcion_Botones( DEPRIME, (DEVOLVER-1), Boton_Texto);
if( RATON ) activa_raton();
espera_soltar();
if( RATON ) desactiva_raton();
// delay(150);
Funcion_Botones( DIBUJA, (DEVOLVER-1), Boton_Texto);
}
}
}
break;
case STD_BY:
Funcion_Botones(Dibuja_Todos, nBotones, Boton_Texto);
do{
if( RATON ) activa_raton();
if( RATON ) espera_pulsar(); else while( bioskey(1)==0 );
if( RATON ) desactiva_raton();
DEVOLVER = Funcion_Botones(COMPRUEBA, nBotones, Boton_Texto);
}while(DEVOLVER==0 && bioskey(1)==0 );
}
return DEVOLVER;
}
void inicializa_raton_texto(void)
{
union REGS ent, sal;
ent.x.ax = 0;
int86(0x33, &ent, &sal); /* averigua si hay rat¢n conectado */
if(sal.x.ax==0) { RATON = 0; return; }
ent.x.ax = 15;
ent.x.cx = 8;
ent.x.dx = 16;
int86(0x33, &ent, &sal); /* fija la raz¢n mickey/pixel */
ent.x.ax = 7;
ent.x.cx = 0;
ent.x.dx = 639;
int86(0x33, &ent, &sal); /* fija la posici¢n m x. y m¡n. horizontal */
ent.x.ax = 8;
ent.x.cx = 0;
ent.x.dx = 199;
int86(0x33, &ent, &sal); /* fija la posici¢n m x. y m¡n. vertical */
ent.x.ax = 4;
ent.x.cx = 320;
ent.x.dx = 100;
int86(0x33, &ent, &sal); /* fija la posici¢n del rat¢n */
ent.x.ax = 1;
int86(0x33, &ent, &sal); /* muestra el puntero del rat¢n */
}
void activa_raton(void)
{
union REGS ent, sal;
ent.x.ax = 1;
int86(0x33, &ent, &sal);
}
void desactiva_raton(void)
{
union REGS ent, sal;
ent.x.ax = 2;
int86(0x33, &ent, &sal);
}
void espera_pulsar(void)
{
union REGS ent, sal;
do{
if(bioskey(1)!=0) break;
ent.x.ax = 3;
int86(0x33, &ent, &sal); /* lee posici¢n y estados del bot¢n */
}while((sal.x.bx & 3)==0);
boton_izq=sal.x.bx & 1;
boton_der=(sal.x.bx >> 1) & 1;
x_raton= (sal.x.cx >> 1) / 4; // / 8
y_raton= (sal.x.dx)/8; // /8
}
void espera_soltar(void)
{
union REGS ent, sal;
do{
ent.x.ax = 3;
int86(0x33, &ent, &sal); /* lee posici¢n y estados del bot¢n */
}while((sal.x.bx & 3)!=0);
boton_izq=sal.x.bx & 1;
boton_der=(sal.x.bx >> 1) & 1;
x_raton=sal.x.cx >> 1;
y_raton=sal.x.dx;
}
void PideAnoActual(void)
{
char buffer[80];
BDatos SociosO, SociosD;
INFO_SOCIOS Socios;
struct ComprasSocios Vacia;
int r; long i;
Optar( ENCUADRE, "Transacci¢n en curso", "ú-ú", "A¤o: ", NULL );
sprintf( buffer, "%d", AnoActual );
while ( ( InputCadenaG( buffer, 1, 2, Config.TxtBgN, Config.TxtFgN, 40, 10, 2, 11) >> 8 ) );
AnoActual = atoi( buffer );
Optar( ENCUADRE, NULL );
// Comprobamos que existe una base de datos para esa fecha
sprintf( buffer, "socios.%03d", AnoActual );
if ( access(buffer, 0) != 0)
{
sprintf( buffer, "socios.%03d", AnoActual - 1 );
// Si el a¤o anterior existe, lo copiamos
if ( access(buffer, 0) == 0)
{
if ( Optar( 1, "Nuevo a¤o en curso", "El a¤o de la transaccion", "no existe, desea inicializarlo", "Esto puede llevar unos minutos", NULL ) )
{
if ( SociosO.AbrirReg( buffer, sizeof( INFO_SOCIOS ) ) == ERROR )
Error(0x01);
sprintf( buffer, "socios.%03d", AnoActual );
if ( SociosD.AbrirReg( buffer, sizeof( INFO_SOCIOS ) ) == ERROR )
Error(0x01);
i = 0;
for ( ; SociosO.LeeReg( (void *)&Socios, i ) == OK; i++ )
{
for ( r=0; r < 240; r++ )
Socios.CSocios[r].dia = Socios.CSocios[r].mes = Socios.CSocios[r].Cantidad = 0;
SociosD.InsReg( (void *)&Socios, SociosD.Registros(), ARRIBA );
}
}
} else {
Optar( 0, "ATENCION", "No existen datos para ese", "a¤o, se crear  una nueva base", "de datos, (a partir de cero)", NULL );
}
}
}