commit 0cb8c5868ea23b5377af66e772675399fdd4ecb1 Author: jdg Date: Sun Sep 12 20:19:47 2021 +0200 First commit 07/10/1996 diff --git a/DUMMY.DBF b/DUMMY.DBF new file mode 100644 index 0000000..8ad0b6a Binary files /dev/null and b/DUMMY.DBF differ diff --git a/M.BAT b/M.BAT new file mode 100644 index 0000000..a91abbc --- /dev/null +++ b/M.BAT @@ -0,0 +1 @@ +mailings \ No newline at end of file diff --git a/M.TXT b/M.TXT new file mode 100644 index 0000000..7e964f2 --- /dev/null +++ b/M.TXT @@ -0,0 +1,200 @@ +Busqueda: + + CodR CodB + Nombre + P.C P.V + [ Combinados ] + +---------------------------- + + + + MesActual + DiaActual + + + SCmpInx.Registros[DiaActual] El dia 1 es el registro 1 + el registro 0 debe contener el inicio de + todo, -> 0 <- + + Lo unico que debe contener el indice es: + + + long Registros[13]; // Que son los inicios de cada + // uno de los registros por dia... + + // TOTAL: 52 bytes. + + +Codigo Descripcion Unidades Proveedor Costo + + + +14400 bps + +Alicante, 134.000 + + ___ ___ + ---__________--- +___---ùùù ùùù---___ +---___ Dragonet ___--- + ---__________--- + + +Martes / cambiar por miercoles ( 424 09 84 / Reyes ) + +Provedisa + + +a¤ana vienen para, + 926 85 36 50 __ Rosa + + + + + Win + + + + N§ Piso + + + _________________ + / \ +| Balance Diario | + \__________________/ + + 1 Archivo / mes + | + | /--- + | | + | | Hora ( 1, 2, 3, 4, 5, 6 ) * 31 dias + | | + | | + Ã-| Total Vendido ( 1, 2, 3, ..., 31 ) + | | /\ + | | || | Hora 1: + | | ³³___/ Hora 2: + | | À----\ Hora 3: + | | | Hora 4: + | | | Hora 5: + | | | Hora 6: + | | + | | Total Ganado ( 1, 2, 3, ..., 31 ) { Descontando Gastos a Vendido } + | | + | | N§ Tickets, N§ Cambio * 31 dias + | | Ú------------------¿ + | | | 1, 2, 3, ..., 31 | + | | N§ Empleado Nombre | Vendido | + | | + | | + | | Estructura char Hora[6]; + | | de datos long TotalVendido[6]; + | | diaria long BeneficioBruto; + | | long Gastos; + | | int Tickets; + | | int Cambio; + | | hora AperturaCaja; + | | hora FinCaja; + | | + | | + | \___ + | Ú------------------¿ Ú------------------¿ Ú------------------¿ + | | 1, 2, 3, ..., 31 | | 1, 2, 3, ..., 31 | | 1, 2, 3, ..., 31 | + À-> Ref. Nombre | Cant. | | Ventas Pv T. | | Ventas PCosto | + /\ + || | 8 :> 12 + ³³___/ 12 :> 16 + À----\ 16 :> 20 + | 20 :> 24 + | 24 :> 4 + | 4 :> 8 + + Estructura unificada de productos vendidos + + + long CodigoR; + char Nombre[30+1]; + unsigned int Cantidad[31][5]; + unsigned long PrecioVenta[31]; + unsigned long PrecioCosto[31]; + + + + + Productos vendidos, N§ Tickets: xxx.xxx.xx ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ + desde: __ hasta __ Cambio: x.xxx ³ Nombre Vendido ³ + ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ Intentos Salir: xxx.xx ³---------------------³ + ³ Ref. Producto T.Unds ³ Salidas Menu P: x ³ ³ +ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ³ + ³ ³ ³ 8 : 12 x ³ ³ ³ + ³ ³ ³ 12 : 16 xx ³ ³ ³ + ³ ³ ³ 16 : 20 x.xx ³ ³ ³ + ³ ³ ³ 20 : 24 x ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + ³ ³ ³ 24 : 4 xx ³ + ³ ³ ³ 4 : 8 x ³ Inicio Caja: XX:XX:xx + ³ ³ ³--------------------³ Fin Caja: XX:XX:xx + ³ ³ ³ ToTal Ventas: x.xx ³ + ³ ³ ³ ³ + ³ ³ ³ Gastos: x.xxx ³ + ³ ³ ³--------------------³ + ³ ³ ³ Beneficios: xx.xxx ³ + ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ + ³ Notas: ³ + ³ ³ + ³ ³ + ³ ³ + ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + + + Codigo: 64.621 + Datos: 42.107 + + 101010100 + + 123400000 + + Bar Con ocho basta + Puerto de los azores, n§ 7 + Junto al tacher, + tlf, 492-16-05 ( Antonio, el padre ) + Ya est  cerrado, y todo desmontado para recogerlo + + + + + + + + + 11111111- - + 22222222- - + 33333333- - + 44444444 - - + 55555555 - - + 66666666 - - + 77777777 - - + 88888888 - - + 99999999 - - + 00000000 - + - + - + + + + + + + + Codigos No... + + C¢digo (numerico 9) + Nombre (alfa 35) + Domicilio 35 + Poblacion + Provincia + CP. + Cif/Nif. + Tlf. diff --git a/MAILINGS.DBF b/MAILINGS.DBF new file mode 100644 index 0000000..a8e7adb Binary files /dev/null and b/MAILINGS.DBF differ diff --git a/MAILINGS.DSK b/MAILINGS.DSK new file mode 100644 index 0000000..ca31248 Binary files /dev/null and b/MAILINGS.DSK differ diff --git a/MAILINGS.EXE b/MAILINGS.EXE new file mode 100644 index 0000000..4d40d4b Binary files /dev/null and b/MAILINGS.EXE differ diff --git a/MAILINGS.PRJ b/MAILINGS.PRJ new file mode 100644 index 0000000..1752230 Binary files /dev/null and b/MAILINGS.PRJ differ diff --git a/MAIL_.H b/MAIL_.H new file mode 100644 index 0000000..1201ce7 --- /dev/null +++ b/MAIL_.H @@ -0,0 +1,99 @@ +#include + +#define DIBUJA 1 +#define DEPRIME 2 +#define Dibuja_Todos 3 +#define COMPRUEBA 4 +#define STD_BY 5 + +#define NORMAL 0 +#define INTENSO 1 + +#define ATRAS -1 +#define NUEVA_BUSQUEDA 0 +#define ADELANTE 1 + +#define SEC_OPTAR 5 +#define ENCUADRE 3 + +// Niveles de acceso al programa +#define TOTAL 0 +#define USUARIO 1 +#define NINGUNO 2 + + +typedef struct +{ + char FillBgS, FillBgC; + char NumFg, NumBg, NumLn; + char TxtBgN, TxtBgI, TxtFgN, TxtFgI; + char Printer, PrintTo[80]; +} CONFIG; + + +typedef struct +{ + long Codigo; + char NIF[10+1]; + char Nombre[45+1]; + + char Direccion[40+1]; + char Num[4+1]; + char Piso[4+1]; + + char Localidad[25+1]; + char Provincia[15+1]; + + long CodPostal; + + char Cod1; + char Cod2; + char Cod3; +} MAILINGS; + + + + + + + +int Optar( int optar, ... ); +void ponicono(int x,int y,char matriz[18][18], char pos); +void formatea_u_long( unsigned long Numero, char *Inter_Chg); +int InputCadenaG(char *s, int numalp, int lmax, int cc, int cf, int X0, int Y0, int X1, int Y1); +void Error( int code ); + + +// M¢dulo de referencias +void InfoProductos(void); + +// M¢dulo de Compras +void ComprasDiarias( int NivelAcceso ); + +// Informacion de los proveedores +void InfoProveedores(void); + +//ÛÛ +void espera_soltar(void); +void espera_pulsar(void); +void activa_raton(void); +void desactiva_raton(void); +void inicializa_raton_texto(void); +struct Boton_Texto{ + char x; char y; + char Texto[80]; + + int ID_T1; + int ID_T2; +}; + + + +int Funcion_Botones(int Funcion, int nBotones, struct Boton_Texto *Boton_Texto); + +extern int boton_izq, boton_der; +extern int x_raton, y_raton, RATON; + +//ÛÛ + +extern int AnoActual; diff --git a/MAIL_M.CPP b/MAIL_M.CPP new file mode 100644 index 0000000..7a542e3 --- /dev/null +++ b/MAIL_M.CPP @@ -0,0 +1,334 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "d:\program\src_dos\libs\bdatos\bdatos.hh" +#include "mail_.h" + + +CONFIG Config = { + 1, BLUE, + RED, WHITE, BLACK, + BLACK, WHITE, 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 Mailings(void); + +void PideAnoActual(void); + +void DibujaPantallaGastosInt(void); + +int boton_izq; int boton_der; +int x_raton, y_raton, RATON = 1; + + +int main(void) +{ + int ok; + + inicializa_raton_texto(); + if( RATON ) desactiva_raton(); + + + ok = 0; + + + MenuPrincipal(); + sleep( 5 ); + + Mailings(); + clrscr(); + + printf( "\nJos‚ David Guill‚n || _-ùFuTuRe ViSiOnù-_ || 1996 (c)" ); + printf( "\nJoshua G¢mez Garcia | Spiral Software || 1996 (c)" ); + printf( "\n " ); + printf( "\n e-mail: Jose-David.Guill‚n@cs.us.es " ); + printf( "\n infomundo@arrakis.es " ); + printf( "\n " ); + printf( "\n " ); + printf( "\n Ü ÜÄÄ Ü Ü ³ ÚÄÄÄ¿ " ); + printf( "\n Û ÜÄ¿ÛÄÄ ÜÄÄ¿Û\\/Û Ü ÜÄ¿ÜÄ´ ÜÄ¿ ³ þ ³ " ); + printf( "\n Û Û ³Û Û__³Û Û Û_³ Û ³Û_³ Û_³ ÀßßßÙ " ); + printf( "\n" ); + + + _setcursortype(_NORMALCURSOR); + +return 0; + +} + +int MenuPrincipal(void) +{ + _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"); + textcolor( RED ); + 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"); + textcolor( LIGHTGRAY ); + cprintf(" ³ ³ ³\\ ³ ³ ÚÄÄ¿ ÜÜ ÜÜ ÜÜÜ ÜÜÜ Ü |> | _ Å\n\r"); + cprintf(" ³ ³ ³ \\³ ÚÄÄ´ ³ÄÄÙ Û ß Û ÛÜÛ Û ÛßÛ Ûß ÛßÛ |> () |> ( |-| |\n\r"); + cprintf(" ÀÄÄ Á Á Á ÀÄÄÙ ÀÄÄÙ ß ß ß ß ß ßßß ß ßßß \n\r"); + cprintf(" \n\r"); + cprintf(" \n\r"); + textcolor( RED ); + cprintf(" \n\r"); + + return 0; +} + + +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; +} + + + + diff --git a/MAIL_PR.CPP b/MAIL_PR.CPP new file mode 100644 index 0000000..9006b67 --- /dev/null +++ b/MAIL_PR.CPP @@ -0,0 +1,1158 @@ +#include +#include +#include +#include + +#include "d:\program\src_dos\libs\bdatos\bdatos.hh" +#include "mail_.h" + +#define NLINEAS_REF 18 + +BDatos BMailings; // Base de datos de Mailingserencias +MAILINGS SMailings; // Estructura de referencias +MAILINGS BHtmp; // Estructura de referencias + +#define COD1 15 +#define COD2 15 +#define COD3 15 + + //123456789-123456789-12345 +char Codigo3[15][25+1] = { " ( sin codigo ) ", + "InfoMundo. Jos‚ David (c)", + "Linea 2 Codigo 3 ", + "Linea 3 Codigo 3 ", + "Linea 4 Codigo 3 ", + "Linea 5 Codigo 3 ", + "Linea 6 Codigo 3 ", + "Linea 7 Codigo 3 ", + "Linea 8 Codigo 3 ", + "Linea 9 Codigo 3 ", + "Linea 0 Codigo 3 ", + "Linea a Codigo 3 ", + "Linea b Codigo 3 ", + "Linea c Codigo 3 ", + "Linea d Codigo 3 " }; + +char Codigo2[15][25+1] = { " ( sin codigo ) ", + "para un miembro de ", + "Linea 2 Codigo 2 ", + "Linea 3 Codigo 2 ", + "Linea 4 Codigo 2 ", + "Linea 5 Codigo 2 ", + "Linea 6 Codigo 2 ", + "Linea 7 Codigo 2 ", + "Linea 8 Codigo 2 ", + "Linea 9 Codigo 2 ", + "Linea 0 Codigo 2 ", + "Linea a Codigo 2 ", + "Linea b Codigo 2 ", + "Linea c Codigo 2 ", + "Linea d Codigo 2 " }; + +char Codigo1[15][25+1] = { " ( sin codigo ) ", + "Programa Realizado por y ", + "Linea 2 Codigo 1 ", + "Linea 3 Codigo 1 ", + "Linea 4 Codigo 1 ", + "Linea 5 Codigo 1 ", + "Linea 6 Codigo 1 ", + "Linea 7 Codigo 1 ", + "Linea 8 Codigo 1 ", + "Linea 9 Codigo 1 ", + "Linea 0 Codigo 1 ", + "Linea a Codigo 1 ", + "Linea b Codigo 1 ", + "Linea c Codigo 1 ", + "Linea d Codigo 1 " }; + +int OrdenMailings; + +extern CONFIG Config; + +void RastreaFicheroGastosi(void); + +void Error( int code ); +void MuestraDatosMailings( void ); + +void DibujaPantallaMatch(void); + +void Imprimir( void ); + +int ComparaRegistrosPrecio( const void *A, const void *B ); + +void EditItemMailings( char columna ); +void MailingsNuevoRegistro( MAILINGS *MSMailings ); +void MuestraMailings( char columna, char como ); +void ObtenCoordenadasMailings( char columna, int *X0, int *Y0, int *X1, int *Y1 ); +void OrdenaMailings(void); + +void ObtenCoordenadasMatchPr( char Row, int *X0, int *Y0, int *X1, int *Y1 ); +void MatchDrawMailings( char Row, MAILINGS MMailings, char como ); +void BuscaMailings( char TipoBusqueda, char *CurrRow, long *CurrMailings ); +int Match_Mailings( MAILINGS A, MAILINGS B ); +void EditMatchMailings( char Row, MAILINGS * MMailings ); +int ObtenMatchMailings( void/*MAILINGS *MMailings*/ ); + + + +void ImprimeMailingserencias( char como ); +void ImprimeCabeceraMailings( char como, FILE *file_out ); +void DibujaPantallaArticulos( void ); + + +// ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß +// Û Parte principal del m¢dulo Û +// ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ + + char CurrRow; // Linea sobre la que estamos + long CurrMailings; // Producto sobre el que estamos posicionados a golpes + + + /**************************************************************************\ +|* *| +|* InfoProducto *| +|* *| +|* Descripci¢n: *| +|* Controla la introduccion de datos y muestreo asi como todo *| +|* el interfaz de usuario... *| +|* *| +|* Entradas: (ninguna) *| +|* Salidas: (ninguna) *| +|* *| + \**************************************************************************/ +void Mailings(void) +{ +struct Boton_Texto BT[6]; +BDatos BDummy; + +BT[0].x = 1; BT[0].y = 1; strcpy( BT[0].Texto, " &Salir "); BT[0].ID_T1 = 0; BT[0].ID_T2 = 31; +BT[1].x = 20; BT[1].y = 1; strcpy( BT[1].Texto, " &Insertar "); BT[1].ID_T1 = 0; BT[1].ID_T2 = 23; + +BT[2].x = 33; BT[2].y = 1; strcpy( BT[2].Texto, " &Borrar ."); BT[2].ID_T1 = 0; BT[2].ID_T2 = 48; +BT[3].x = 47; BT[3].y = 1; strcpy( BT[3].Texto, " &Ordenar"); BT[3].ID_T1 = 0; BT[3].ID_T2 = 24; + +BT[4].x = 58; BT[4].y = 1; strcpy( BT[4].Texto, " b&Uscar"); BT[4].ID_T1 = 0; BT[4].ID_T2 = 22; +BT[5].x = 72; BT[5].y = 1; strcpy( BT[5].Texto, " im&Pr. "); BT[5].ID_T1 = 0; BT[5].ID_T2 = 25; + + char ok = 0; + int BPush, key; + + char oldCol; + char CurrCol; // Columna sobre la que estamos + + _setcursortype( _NOCURSOR ); + DibujaPantallaArticulos(); +/* + if ( BDummy.AbrirReg( "dummy.dbf", sizeof( MAILINGS ) ) == ERROR ) + Error(0x01); +*/ + + if ( BMailings.AbrirReg( "mailings.dbf", sizeof( MAILINGS ) ) == ERROR ) + Error(0x01); +/* + for ( CurrMailings=0; CurrMailings < BDummy.Registros(); CurrMailings++) + { + BDummy.LeeReg( (void *)&SMailings, CurrMailings ); + BMailings.InsReg( (void *)&SMailings, BMailings.Registros(), ARRIBA ); + } + + BDummy.CerrarReg(); +*/ + // Si no hay registros, creamos uno almenos. + if ( BMailings.Registros() == 0 ) + { + MailingsNuevoRegistro( &SMailings ); + if ( BMailings.InsReg( (void *)&SMailings, BMailings.Registros(), ARRIBA ) == ERROR ) + Error(0x02); +/* + for ( long i = 0; i < 1000; i++ ) + { + SMailings.Codigo = 1000 - i; + sprintf( SMailings.Nombre, "%03d-%03d-%03d-%03d", i, i, i, i ); + if ( BMailings.InsReg( (void *)&SMailings, BMailings.Registros(), ARRIBA ) == ERROR ) + Error(0x02); + } +*/ + } + + CurrMailings = 0; CurrRow = 0; + + if ( BMailings.LeeReg( (void *)&SMailings, 0 ) == ERROR ) + Error(0x03); + MuestraDatosMailings( ); + + CurrCol = 0; oldCol = -1; + + do { + if ( CurrCol != oldCol ) + { + oldCol = CurrCol; + } + + MuestraMailings( CurrCol, INTENSO ); + BPush = Funcion_Botones(STD_BY, 6, BT); + MuestraMailings( CurrCol, NORMAL ); + + switch ( BPush ) + { + case 0: // No se pulso ningun BOTON + while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER + break; + case -2: // Hay una tecla normal en BUFFER + if ( ( key = getch() ) != 13 && key != 27 ) + ungetch( key ); + EditItemMailings( CurrCol ); + _setcursortype( _NOCURSOR ); + if ( BMailings.EscribeReg( (void *)&SMailings, (CurrRow + CurrMailings) ) == ERROR ) + Error(0x04); + while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER + MuestraMailings( CurrCol, NORMAL ); + CurrCol++; if ( CurrCol > 10 ) CurrCol = 0; + break; + case -1: // Hay una tecla especial en BUFFER + switch( getch() ) + { + // Flecha Izquierda + case 75: + case 15: + CurrCol--; if ( CurrCol < 0 ) CurrCol = 10; + break; + // Flecha Derecha + case 77: + case 9: + CurrCol++; if ( CurrCol > 10 ) CurrCol = 0; + break; + // Flecha Arriba + case 72: + if ( CurrMailings > 0 ) + CurrMailings--; + if ( BMailings.LeeReg( (void *)&SMailings, (CurrMailings + CurrRow) ) == ERROR ) + Error(0x03); + MuestraDatosMailings( ); + break; + // Flecha Abajo + case 80: + if ( ( CurrRow + CurrMailings ) < BMailings.Registros() - 1 ) + CurrMailings ++; + if ( BMailings.LeeReg( (void *)&SMailings, (CurrMailings + CurrRow) ) == ERROR ) + Error(0x03); + MuestraDatosMailings( ); + break; + // Inicio + case 71: + CurrMailings = 0; + if ( BMailings.LeeReg( (void *)&SMailings, (CurrMailings + CurrRow) ) == ERROR ) + Error(0x03); + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosMailings( ); + break; + // Fin + case 79: + CurrMailings = BMailings.Registros()-1; + if ( BMailings.LeeReg( (void *)&SMailings, (CurrMailings + CurrRow) ) == ERROR ) + Error(0x03); + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosMailings( ); + + break; + // AvanceR pido + case 81: + CurrMailings += NLINEAS_REF; + + while ( (CurrMailings + CurrRow) >= BMailings.Registros() ) CurrMailings--; + + if ( BMailings.LeeReg( (void *)&SMailings, (CurrMailings + CurrRow) ) == ERROR ) + Error(0x03); + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosMailings( ); + + break; + // Retroceso R pido + case 73: + CurrMailings -= NLINEAS_REF; + if ( CurrMailings < 0 ) CurrMailings = 0; + + while( ( CurrRow + CurrMailings ) >= BMailings.Registros() && CurrMailings > 0 ) CurrMailings++; + + if ( BMailings.LeeReg( (void *)&SMailings, (CurrMailings + CurrRow) ) == ERROR ) + Error(0x03); + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosMailings( ); + break; + + // Gastos por proveedor + case 82: + BuscaMailings( ATRAS, &CurrRow, &CurrMailings ); + break; + + // Gastos por proveedor + case 83: + BuscaMailings( ADELANTE, &CurrRow, &CurrMailings ); + break; + + } + while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER + break; + // Imprimir Lista de socios + case 6: + Imprimir(); + DibujaPantallaArticulos(); + if ( BMailings.LeeReg( (void *)&SMailings, CurrRow + CurrMailings ) == ERROR ) + Error(0x03); + MuestraDatosMailings( ); + break; + // Menu Principal + case 1: + ok = 1; + break; + // Eliminar + case 3: + while( kbhit() ) getch(); + if ( Optar( 1, "ATENCION", "Eliminar  un Registro", "confirme eliminacion", NULL ) ) + { + if ( BMailings.DelReg( CurrMailings + CurrRow ) == ERROR ) + Error(0x04); + if ( BMailings.Registros() == 0 ) + { + MailingsNuevoRegistro( &SMailings ); + if ( BMailings.InsReg( (void *)&SMailings, BMailings.Registros(), ARRIBA ) == ERROR ) + Error(0x02); + CurrRow = 0; + } + + CurrMailings--; if ( CurrMailings < 0 ) CurrMailings = 0; + + if ( BMailings.LeeReg( (void *)&SMailings, (CurrMailings + CurrRow) ) == ERROR ) + Error(0x03); + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosMailings( ); + } + break; + // Insertar + case 2: + MailingsNuevoRegistro( &SMailings ); + CurrRow = 0; CurrMailings = BMailings.Registros(); + if ( BMailings.InsReg( (void *)&SMailings, (CurrMailings + CurrRow), ARRIBA ) == ERROR ) + Error(0x02); + + if ( BMailings.LeeReg( (void *)&SMailings, (CurrMailings + CurrRow) ) == ERROR ) + Error(0x03); + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosMailings( ); + + break; + + // Ordenar + case 4: + OrdenaMailings(); + CurrMailings = 0; CurrRow = 0; + + if ( BMailings.LeeReg( (void *)&SMailings, 0 ) == ERROR ) + Error(0x03); + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosMailings( ); + + CurrCol = 0; + + break; + // Gastos por proveedor + case 5: + BuscaMailings( NUEVA_BUSQUEDA, &CurrRow, &CurrMailings ); + break; + default: + while( kbhit() ) getch(); + break; + } + + } while( !ok ); + + BMailings.CerrarReg(); + +} + + + + /**************************************************************************\ +|* *| +|* MuestraDatosMailings *| +|* *| +|* 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 MuestraDatosMailings( void ) +{ + int campo; + // Por cada linea hay 12 campos, ehhh!!! + for ( campo=0; campo < 11; campo++ ) + MuestraMailings( campo, NORMAL ); + + gotoxy( 70, 24 ); printf( "%8ld", CurrMailings + CurrRow ); + +} + + /**************************************************************************\ +|* *| +|* MuestraMailings *| +|* *| +|* 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 MuestraMailings( char columna, char como ) +{ + char buffer[80]; + char buffer1[80]; + + int X0, Y0, X1, Y1; + + ObtenCoordenadasMailings( columna, &X0, &Y0, &X1, &Y1 ); + + switch( columna ) + { + // Codigo + case 0: + sprintf ( buffer, " %9ld", SMailings.Codigo ); + break; + // NIF + case 1: + sprintf ( buffer, "%-15s", SMailings.NIF ); + break; + // Nombre + case 2: + sprintf ( buffer, "%-45s", SMailings.Nombre ); + break; + // Direccion + case 3: + sprintf ( buffer, "%-33s", SMailings.Direccion ); + break; + // Piso + case 4: + sprintf ( buffer, "%-4s", SMailings.Piso ); + break; + // Localidad + case 5: + sprintf ( buffer, "%-25s", SMailings.Localidad ); + break; + // Provincia + case 6: + sprintf ( buffer, "%-15s", SMailings.Provincia ); + break; + // Cod. Postal + case 7: + formatea_u_long( SMailings.CodPostal, buffer1 ); + sprintf ( buffer, "%6s", buffer1 ); + break; + // Cod 1 + case 8: + sprintf ( buffer, "%25s", Codigo1[ SMailings.Cod1 ] ); + break; + // Cod 2 + case 9: + sprintf ( buffer, "%25s", Codigo2[ SMailings.Cod2 ] ); + break; + // Cod 3 + case 10: + sprintf ( buffer, "%25s", Codigo3[ SMailings.Cod3 ] ); + break; + } + + textbackground( ( como == NORMAL ) ? Config.TxtBgN : Config.TxtBgI ); + strnset( buffer1, 32, X1 ); + + textcolor( ( como == NORMAL ) ? Config.TxtFgN : Config.TxtFgI ); + gotoxy( X0, Y0 ); + cprintf( "%s", buffer ); + +} + + + /**************************************************************************\ +|* *| +|* EditItemMailings *| +|* *| +|* 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 EditItemMailings( char columna ) +{ + char buffer[80]; + + int X0, Y0, X1, Y1; + + ObtenCoordenadasMailings( columna, &X0, &Y0, &X1, &Y1 ); + + switch( columna ) + { + // Codigo + case 0: + sprintf ( buffer, "%ld", SMailings.Codigo ); + if ( !( InputCadenaG( buffer, 1, 9, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + SMailings.Codigo = atol ( buffer ); + break; + // NIF + case 1: + strcpy ( buffer, SMailings.NIF ); + if ( !( InputCadenaG( buffer, 0, 10, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + strcpy ( SMailings.NIF, buffer ); + break; + // Nombre + case 2: + strcpy ( buffer, SMailings.Nombre ); + if ( !( InputCadenaG( buffer, 0, 37, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + strcpy ( SMailings.Nombre, buffer ); + break; + // Direccion + case 3: + strcpy ( buffer, SMailings.Direccion ); + if ( !( InputCadenaG( buffer, 0, 33, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + strcpy( SMailings.Direccion, buffer ); + break; + // Piso + case 4: + strcpy ( buffer, SMailings.Piso ); + if ( !( InputCadenaG( buffer, 0, 4, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + strcpy ( SMailings.Piso, buffer ); + break; + // Localidad + case 5: + strcpy ( buffer, SMailings.Localidad ); + if ( !( InputCadenaG( buffer, 0, 25, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + strcpy ( SMailings.Localidad, buffer ); + break; + // Provincia + case 6: + strcpy ( buffer, SMailings.Provincia ); + if ( !( InputCadenaG( buffer, 0, 15, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + strcpy ( SMailings.Provincia, buffer ); + break; + // Cod. Postal + case 7: + sprintf ( buffer, "%ld", SMailings.CodPostal ); + if ( !( InputCadenaG( buffer, 1, 5, Config.TxtBgN, Config.TxtFgN, X0, Y0, X1, Y1) >> 8 ) ) + SMailings.CodPostal = atol( buffer ); + break; + // Cod. 1 + case 8: + SMailings.Cod1 = ( (SMailings.Cod1++) % COD1 ); + break; + // Cod. 2 + case 9: + SMailings.Cod2 = ( (SMailings.Cod2++) % COD2 ); + break; + // Cod. 3 + case 10: + SMailings.Cod3 = ( (SMailings.Cod3++) % COD3 ); + break; + } + while( kbhit() ) getch(); +} + + /**************************************************************************\ +|* *| +|* ObtenCoordenadasMailings *| +|* *| +|* 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 ObtenCoordenadasMailings( char columna, int *X0, int *Y0, int *X1, int *Y1 ) +{ + + // Calculamos la Y0, Y1 para la linea dada ( SOLO columna < 6 ) + + switch( columna ) + { + case 0: + *X0 = 23; *X1 = 10; + *Y0 = *Y1 = 5; + break; + case 1: + *X0 = 59; *X1 = 15; + *Y0 = *Y1 = 5; + break; + case 2: + *X0 = 11; *X1 = 45; + *Y0 = *Y1 = 7; + break; + case 3: + *X0 = 15; *X1 = 33; + *Y0 = *Y1 =10; + break; + case 4: + *X0 = 62; *X1 = 4; + *Y0 = *Y1 =10; + break; + case 5: + *X0 = 15; *X1 = 25; + *Y0 = *Y1 =13; + break; + case 6: + *X0 = 57; *X1 = 15; + *Y0 = *Y1 = 13; + break; + case 7: + *X0 = 17; *X1 = 6; + *Y0 = *Y1 = 16; + break; + case 8: + *X0 = 13; *X1 = 2; + *Y0 = *Y1 = 21; + break; + case 9: + *X0 = 54; *X1 = 2; + *Y0 = *Y1 = 21; + break; + case 10: + *X0 = 50; *X1 = 2; + *Y0 = *Y1 = 23; + break; + } + + +} + + /**************************************************************************\ +|* *| +|* MailingsNuevoRegistro *| +|* *| +|* Descripci¢n: *| +|* Limpia el buffer, para un nuevo registro. *| +|* *| +|* Entradas: (ninguna) *| +|* Salidas: (ninguna) *| +|* *| + \**************************************************************************/ +void MailingsNuevoRegistro( MAILINGS *NSMailings ) +{ + + NSMailings -> Codigo = 0; + NSMailings -> NIF[0] = '\0'; + + NSMailings -> Nombre[0] = '\0'; + + NSMailings -> Direccion[0] = '\0'; + NSMailings -> Piso[0] = '\0'; + + NSMailings -> Localidad[0] = '\0'; + NSMailings -> Provincia[0] = '\0'; + + NSMailings -> CodPostal = 0 ; + + NSMailings -> Cod1 = 0 ; + NSMailings -> Cod2 = 0 ; + NSMailings -> Cod3 = 0 ; + +} + + + + +// ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß +// Û Parte secundaria del m¢dulo Û +// Û Û +// Û Secci¢n de Busqueda de refecencias Û +// ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ + + /**************************************************************************\ +|* *| +|* MuestraImpresionesRed *| +|* *| +|* Descripci¢n: *| +|* Muestra un cuadro con las distintas opciones de impresi¢n *| +|* *| +|* Entradas:(ninguna) *| +|* Salidas: (ninguna) *| +|* *| + \**************************************************************************/ + + + /**************************************************************************\ +|* *| +|* ImprimeMailingserencias *| +|* *| +|* Descripci¢n: *| +|* Imprime todas las referencias seg£n se le indique *| +|* *| +|* Entradas: *| +|* Como imprimir las referencias *| +|* *| +|* Salidas: (ninguna) *| +|* *| + \**************************************************************************/ +void Imprimir( void ) +{ + long i, old_reg; + FILE *file_out; + char buffer[80], dev; + static MAILINGS MMailings; + + + old_reg = BMailings.RegActual(); + + MailingsNuevoRegistro( &SMailings ); + if ( ObtenMatchMailings( /*&MMailings*/ ) != OK ) + return; + MMailings = SMailings; + + if ( !Config.Printer ) + { + if ( ( file_out = fopen( Config.PrintTo, "w" ) ) == NULL ) + return; + } else + + file_out = stdprn; + + for ( i=0; i Direccion ), ( ((MAILINGS *)B) -> Direccion ) ); + break; + // Por Precio + case 2: + dev = strcmpi( ( ((MAILINGS *)A) -> Nombre ), ( ((MAILINGS *)B) -> Nombre ) ); + return dev; + case 1: + if ( ( ((MAILINGS *)A) -> Codigo ) < ( ((MAILINGS *)B) -> Codigo ) ) return -1; + if ( ( ((MAILINGS *)A) -> Codigo ) > ( ((MAILINGS *)B) -> Codigo ) ) return 1; + +/* + if ( ( ((MAILINGS *)A) -> Cod1 ) < ( ((MAILINGS *)B) -> Cod1 ) ) return -1; + if ( ( ((MAILINGS *)A) -> Cod1 ) > ( ((MAILINGS *)B) -> Cod1 ) ) return 1; + + if ( ( ((MAILINGS *)A) -> Cod2 ) < ( ((MAILINGS *)B) -> Cod3 ) ) return -1; + if ( ( ((MAILINGS *)A) -> Cod2 ) > ( ((MAILINGS *)B) -> Cod3 ) ) return 1; + + if ( ( ((MAILINGS *)A) -> Cod3 ) < ( ((MAILINGS *)B) -> Cod3 ) ) return -1; + if ( ( ((MAILINGS *)A) -> Cod3 ) > ( ((MAILINGS *)B) -> Cod3 ) ) return 1; +*/ + return 0; + } + return 0; +} + + +void OrdenaMailings(void) +{ +/* +BDatos BMailings; // Base de datos de Mailingserencias +MAILINGS SMailings; // Estructura de referencias + +int OrdenMailings; +*/ +struct Boton_Texto BT[4]; +int devolver; + +BT[0].x = 32; BT[0].y = 9; strcpy( BT[0].Texto, " C&¢digo "); BT[0].ID_T1 = 0; BT[0].ID_T2 = 24; +BT[1].x = 32; BT[1].y = 11; strcpy( BT[1].Texto, " &Nombre "); BT[1].ID_T1 = 0; BT[1].ID_T2 = 49; +BT[2].x = 32; BT[2].y = 13; strcpy( BT[2].Texto, " &Direccion "); BT[2].ID_T1 = 0; BT[2].ID_T2 = 32; +BT[3].x = 32; BT[3].y = 15; strcpy( BT[3].Texto, " &Cancelar operacion"); BT[3].ID_T1 = 0; BT[3].ID_T2 = 46; + + Optar( ENCUADRE, "Elija orden a seguir", NULL ); + + while( ( devolver = Funcion_Botones(STD_BY, 4, BT) ) < 1 || devolver > 4 ) while ( kbhit() ) getch(); + + if ( devolver != 4 ) + { + OrdenMailings = devolver; + BMailings.SortReg( ComparaRegistrosPrecio ); + } + + Optar( ENCUADRE, NULL ); + +} + + + + /**************************************************************************\ +|* *| +|* BuscaMailings *| +|* *| +|* Descripci¢n: *| +|* Busca una referencia por su n§ o descripcion *| +|* *| +|* Entradas: *| +|* ATRAS Busca otra coincidencia hacia atras *| +|* NUEVA_BUSQUEDA Inicia una nueva busqueda *| +|* ADELANTE Busca otra coincidencia hacia delante *| +|* *| +|* Salidas: (ninguna) *| +|* *| + \**************************************************************************/ +void BuscaMailings( char TipoBusqueda, char *CurrRow, long *CurrMailings ) +{ + static MAILINGS MMailings; + char enc; long i; + + + switch ( TipoBusqueda ) + { + case NUEVA_BUSQUEDA: + MailingsNuevoRegistro( &SMailings ); + if ( ObtenMatchMailings( /*&MMailings*/ ) != OK ) + return; + MMailings = SMailings; + i = 0; + break; + case ATRAS: + case ADELANTE: + i = ( *CurrRow + *CurrMailings )+TipoBusqueda; + if ( i < 0 || i >= BMailings.Registros() ) return; + break; + } + + Optar( ENCUADRE, "Comando: Buscar", "Ahora se inica", "la busqueda elegida", NULL ); + enc = 0; + while ( i < BMailings.Registros() && !enc ) + { + if ( BMailings.LeeReg( (void *)&SMailings, i ) == ERROR ) + Error( 0x03 ); + if ( Match_Mailings( SMailings, MMailings ) ) + enc = 1; + else + i++; + } + + Optar( ENCUADRE, NULL ); + + if ( enc ) + { + *CurrRow = 0; *CurrMailings = i; + if ( BMailings.LeeReg( (void *)&SMailings, i ) == ERROR ) + Error( 0x03 ); + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosMailings( ); + } 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; + } + + DibujaPantallaArticulos(); + + if ( BMailings.LeeReg( (void *)&SMailings, (*CurrRow + *CurrMailings) ) == ERROR ) + Error( 0x03 ); + + // Mostramos datos hasta que se nos acabe la pantalla + MuestraDatosMailings( ); + +} + + /**************************************************************************\ +|* *| +|* Match_Mailings *| +|* *| +|* Descripci¢n: *| +|* Compara dos registros y devuelve la posible coincidencia *| +|* *| +|* Entradas: *| +|* Registros a comparar *| +|* *| +|* Salidas: *| +|* Resultado de la comparaci¢n *| +|* *| + \**************************************************************************/ +int Match_Mailings( MAILINGS A, MAILINGS B ) +{ + int enc = 1; + + if ( B.NIF != '\0' ) + enc = ( strncmpi( A.NIF, B.NIF, strlen( B.NIF ) ) == 0 ); + + if ( B.Codigo != 0 ) + enc = B.Codigo == A.Codigo; + if ( B.Nombre[0] != '\0' ) + enc = ( strncmpi( A.Nombre, B.Nombre, strlen( B.Nombre ) ) == 0 ); + if ( B.Localidad[0] != '\0' ) + enc = ( strncmpi( A.Localidad, B.Localidad, strlen( B.Localidad ) ) == 0 ); + if ( B.Provincia[0] != '\0' ) + enc = ( strncmpi( A.Provincia, B.Provincia, strlen( B.Provincia ) ) == 0 ); + if ( B.CodPostal != 0 ) + enc = A.CodPostal == B.CodPostal; + if ( B.Cod1 != 0 ) + enc = A.Cod1 == B.Cod1; + if ( B.Cod2 != 0 ) + enc = A.Cod2 == B.Cod2; + if ( B.Cod3 != 0 ) + enc = A.Cod3 == B.Cod3; + + return enc; +} + + /**************************************************************************\ +|* *| +|* ObtenMatchMailings *| +|* *| +|* 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 ObtenMatchMailings( /*MAILINGS *MMailings*/void ) +{ +struct Boton_Texto BT[6]; + +BT[0].x = 65; BT[0].y = 20; strcpy( BT[0].Texto, " acep&Tar "); BT[0].ID_T1 = 00; BT[0].ID_T2 = 20; +BT[1].x = 65; BT[1].y = 22; strcpy( BT[1].Texto, " &Cancelar"); BT[1].ID_T1 = 00; BT[1].ID_T2 = 46; + + char Row, ok; + int BPush, key, DEV; + + DibujaPantallaArticulos(); + + ok = 0; Row = 0; + + do + { + MuestraMailings( Row, INTENSO ); + BPush = Funcion_Botones(STD_BY, 2, BT); + MuestraMailings( Row, 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 ); + EditItemMailings( Row ); + break; + case -1: + switch ( getch() ) + { + // Flecha Izquierda + case 75: + case 15: + // Flecha Arriba + case 72: + Row--; if ( Row < 0 ) Row = 11; + break; + // Flecha Derecha + case 77: + case 9: + // Flecha Abajo + case 80: + Row++; if ( Row > 11 ) Row = 0; + break; + } + break; + case 1: + DEV = OK; ok = 1; + break; + case 2: + DEV = ERROR; ok = 1; + break; + } + + } while ( !ok ); + + return DEV; + +} + + + +void Error( int code ) +{ + + printf( "\nSe produjo un codigo de error %d, subcodigo no disponible \n\r", code ); + switch( code ) + { + case 0: + printf( "\n Error incocumentado " ); + break; + case 1: + printf( "\n Error abriendo " ); + break; + case 2: + printf( "\n Error insertando " ); + break; + case 3: + printf( "\n Error leyendo " ); + break; + case 4: + printf( "\n Error escribiendo " ); + break; + case 5: + printf( "\n Error borrando " ); + break; + }; + + exit(code); +} + + diff --git a/MAIL_TL.CPP b/MAIL_TL.CPP new file mode 100644 index 0000000..26c0d80 --- /dev/null +++ b/MAIL_TL.CPP @@ -0,0 +1,277 @@ +#include +#include +#include +#include +#include +#include +#include + +#define BLANCO EGA_WHITE +#define ENCUADRE 3 +#define SEC_OPTAR 5 + +#include "mail_.h" + +void BEEP(void); + + /**************************************************************************\ +|* *| +|* InputCadenaG *| +|* *| +|* Descripci¢n: *| +|* Edita una cadena en formato gr fico *| +|* *| +|* Entradas: *| +|* Puntero a los datos editados *| +|* 0 alfanumerico 1 numerico *| +|* longitud de la cadena (TEXTO/NUMERO) *| +|* color del texto *| +|* color de fondo *| +|* Limites de acotacion *| +|* *| +|* Salidas: (ninguna) *| +|* *| +|* *| + \**************************************************************************/ +int InputCadenaG(char *s, int numalp, int lmax, int cc, int cf, int X0, int Y0, int X1, int Y1) +{ + // A todas las y les sumaba antes +RoW*12 parametro que indica la linea + + int ls; // longitud cadena + char Status = 0; + char *s1; // puntero a cadena inicial + int c, ok, i; + + s1 = s; // inicio cadena + + textbackground( cf ); + + gotoxy( X0, Y0 ); + for ( i = 0; i < X1; i++ ) + putch( 32 ); + textcolor( cc ); + gotoxy( X0, Y0 ); + cprintf( "%s", s1 ); + + _setcursortype( _SOLIDCURSOR ); + + ls = strlen ( s ); // Longitud de actual + + s += ls; // se coloca en el final + + do{ + c = getch(); // obtiene tecla + + if ( c == 27 ) Status = 1; + + ok = ( c == 27 || c == 13 || c == 0); // 13 = INTRO || Especiales + + if ( c == 8 && ls > 0 && !ok ) { // 8 = Back Space + ls--; + s--; + + *s = '\0'; + + gotoxy( X0, Y0 ); + for ( i = 0; i < X1; i++ ) + putch( 32 ); + textcolor( cc ); + gotoxy( X0, Y0 ); + cprintf( "%s", s1 ); + + + } else { + if ( !numalp && c >= 32 && c <= 254 && ls < lmax) { + + *s++ = c; + ls++; + + *s = '\0'; + + gotoxy( X0, Y0 ); + for ( i = 0; i < X1; i++ ) + putch( 32 ); + textcolor( cc ); + gotoxy( X0, Y0 ); + cprintf( "%s", s1 ); + + } else { + if ( numalp && isdigit(c) && ls < lmax) { + *s++ = c; + ls++; + + *s = '\0'; // Cero final + + gotoxy( X0, Y0 ); + for ( i = 0; i < X1; i++ ) + putch( 32 ); + textcolor( cc ); + gotoxy( X0, Y0 ); + cprintf( "%s", s1 ); + + } + /*ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ*/ + else if( c == 27 ) {*s='\0'; ok = 1; } + /*ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ*/ + else BEEP(); + } + } + + }while(!ok); + + _setcursortype( _NOCURSOR ); + + ok = 1; + *s = ' '; + while( ok && ls >= 0 ) { + if(*s==' ') { *s = '\0'; s--; ls--; + } else { s++; ok = 0; } + } + + *s = '\0'; + + while(kbhit()) getch(); // Vacia Buffer impidiendo falsas + // pulsaciones... + + return ( (Status<<8) + (ls&0x00FF) ); +} + +void BEEP(void) +{ + + sound(440); + delay(50); + nosound(); + +} + + +void formatea_u_long( unsigned long Numero, char *Inter_Chg) +{ + char Buffer1[80]; + + int c; + + sprintf(Buffer1, "%lu", Numero); + + Inter_Chg[0]='\0'; + + strrev(Buffer1); + + c = strlen( Buffer1 ); + + while( c >= 3 ) + { + + c -= 3; + strncat( Inter_Chg, Buffer1, 3); + + strrev(Buffer1); + + Buffer1[c] = '\0'; + + strrev(Buffer1); + + if(strlen(Buffer1)!=0) + strcat( Inter_Chg, "." ); + } + + strcat( Inter_Chg, Buffer1); + strrev(Inter_Chg); + + +/*// return Buffer2;*/ +} + + +int Optar( int optar, ... ) +{ +struct Boton_Texto BT[6]; +int devolver = 0; + +BT[0].x = 22; BT[0].y = 15; strcpy( BT[0].Texto, " acep&Tar "); BT[0].ID_T1 = 00; BT[0].ID_T2 = 20; +BT[1].x = 51; BT[1].y = 15; strcpy( BT[1].Texto, " &Cancelar"); BT[1].ID_T1 = 00; BT[1].ID_T2 = 46; + + static char fondo[4096]; + static char Memoria = 0; + + int DEV = 0, ok = 0, linea = 0; + int Center; char *buff; + + va_list ap; + va_start( ap, &optar ); + + if ( Memoria == 1 ) + { + puttext( 21, 5, 63, 17, (void *)fondo ); Memoria = 0; + if ( optar == ENCUADRE ) return DEV; + } + + Memoria = 1; + + gettext( 21, 5, 63, 17, (void *)fondo ); + +textbackground( BLACK ); +textcolor( CYAN ); +gotoxy( 21, 5 ); cprintf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"); +gotoxy( 21, 6 ); cprintf("³ ³"); +gotoxy( 21, 7 ); cprintf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´"); +gotoxy( 21, 8 ); cprintf("³ ³"); +gotoxy( 21, 9 ); cprintf("³ ³"); +gotoxy( 21, 10 ); cprintf("³ ³"); +gotoxy( 21, 11 ); cprintf("³ ³"); +gotoxy( 21, 12 ); cprintf("³ ³"); +gotoxy( 21, 13 ); cprintf("³ ³"); +gotoxy( 21, 14 ); cprintf("³ ³"); +gotoxy( 21, 15 ); cprintf("³ ³"); +gotoxy( 21, 16 ); cprintf("³ ³"); +gotoxy( 21, 17 ); cprintf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"); + + + + textcolor( RED ); + linea = 0; + while ( (buff = va_arg(ap, char *)) != NULL ) + { + Center = (42 - strlen( buff ) ) / 2; + gotoxy( 21+Center+1, ( (linea == 0 ) ? 6 : 8 + linea ) ); + cprintf( "%s", buff ); + linea++; + } + + va_end(ap); + + if ( optar != ENCUADRE ) + { + ok = 0; while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER + if ( optar == 1 ) + do { + switch( Funcion_Botones(STD_BY, 2, BT) ) + { + case 0: // No se pulso ningun BOTON + case -2: + case -1: + while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER + if ( optar == 0 ) ok = 1; + break; + case 1: + DEV = 1; ok = 1; + break; + case 2: + DEV = 0; ok = 1; + break; + } + }while( !ok ); + else { espera_pulsar(); espera_soltar(); } + + puttext( 21, 5, 63, 17, (void *)fondo ); + + Memoria = 0; + + } + + return DEV; +} + + + diff --git a/PRNFILE.OUT b/PRNFILE.OUT new file mode 100644 index 0000000..54a81dc --- /dev/null +++ b/PRNFILE.OUT @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..257ec8c --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +#MAILINGS + + +*07/10/1996* + +ToDo: wwtcf? + + +![screenshot](/MAILINGS.png "Screenshot")