commit e1d6aee98f50a41239c033ef62a2ded749a40427 Author: jdg Date: Wed Sep 8 21:43:28 2021 +0200 First commit 11/11/1991 diff --git a/ACERCADE.CPP b/ACERCADE.CPP new file mode 100644 index 0000000..6530e6e --- /dev/null +++ b/ACERCADE.CPP @@ -0,0 +1,245 @@ +#include +#include + +#include +#include +#include + + +#include "..\libs\make_bot\make_bot.h" +#include "sv_graph.h" + +extern void textxy(int x, int y, char *text); + + +void Circulos(int PosX, int PosY, int RadioX, int RadioY, int Velocidad); +void Circulos2(int PosX, int PosY, int RadioX, int RadioY, int Velocidad); +void Circulos3(int PosX, int PosY, int RadioX, int RadioY, int Velocidad); + +void Acerca_de(void){ +struct boton Acerca; + + Acerca.up = 140; Acerca.down = 380; + Acerca.left = 220; Acerca.right = 425; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, Acerca); + Acerca.up = 145; Acerca.down = 375; + Acerca.left = 225; Acerca.right = 420; + ImprimeBoton (1, GRIS_C, GRIS_O, BLANCO, Acerca); + + textxy(240, 170, "Programa realizado por"); + textxy(240, 210, " Jos David Guilln"); + +// Circulos(322, 295, 50, 50, 5); +// getch(); + /*2*/ + Circulos3(322, 295, 50, 50, 5); + +getch(); +} + +void Circulos(int PosX, int PosY, int RadioX, int RadioY, int Velocidad){ + +// Circulo con apariencia de 3D, por: Jos David Guilln + +int x=RadioX, + y=0, + oldx=RadioX, + giro = 0, + vez = 0, + ciclo = 1, + Angulo = 0; + + +do{ + + setcolor(GRIS_C); + ellipse(PosX, PosY, 0+ Angulo, 360+ Angulo, abs(oldx), RadioY ); + ellipse(PosX, PosY, 0/*+*/- Angulo, 360/*+*/- Angulo, RadioX, abs(oldx) ); + +if(giro==1)/*{*/ setcolor(NEGRO); else setcolor(BLANCO); + +/// ellipse(PosX, PosY, 90+ Angulo, 270+ Angulo, abs(x), /*abs(y)*/50 ); +ellipse(PosX, PosY, 0+ Angulo, 90+ Angulo, abs(x), RadioY ); +ellipse(PosX, PosY, 180- Angulo, 270- Angulo, abs(x), RadioY ); + +/// ellipse(PosX, PosY, 0+ Angulo, 180+ Angulo, /*abs(y)*/50, abs(x) ); +ellipse(PosX, PosY, 90/*+*/- Angulo, 180/*+*/- Angulo, RadioX, abs(x)); +ellipse(PosX, PosY, 270/*+*/- Angulo, 360/*+*/- Angulo, RadioX, abs(x) ); + + +if(giro==1)/*{*/ setcolor(BLANCO); else setcolor(NEGRO); + +/// ellipse(PosX, PosY, 270+ Angulo, 90+ Angulo, abs(x), /*abs(y)*/50 ); +ellipse(PosX, PosY, 90+ Angulo, 180+ Angulo, abs(x), RadioY ); +ellipse(PosX, PosY, 270+ Angulo, 360+ Angulo, abs(x), RadioY ); + +/// ellipse(PosX, PosY, 180+ Angulo, 360+ Angulo, /*abs(y)*/50, abs(x) ); +ellipse(PosX, PosY, 0/*+*/- Angulo, 90/*+*/- Angulo, RadioX, abs(x) ); +ellipse(PosX, PosY, 180/*+*/- Angulo, 270/*+*/- Angulo, RadioX, abs(x) ); + + + oldx = x; + + x--; + if(x<=-(RadioX-1) ) x=RadioX; + y--; + if(y<=-(RadioY-1) ) y=RadioY; + +if(ciclo == 0 && x == RadioX ) { ciclo = 1; vez = 0; } else +if(ciclo == 1 && x == RadioX ) { ciclo = 0; vez = 1; } + +if(vez==0){ + if(x<0) giro=1; else giro=0; +} +if(vez==1){ + if(x<0) giro=0; else giro=1; +} + delay(20); + + Angulo+= Velocidad; if( Angulo== 360 ) Angulo=0; + +}while(!kbhit()); + +} + +void Circulos2(int PosX, int PosY, int RadioX, int RadioY, int Velocidad){ + +// Circulo con apariencia de 3D, por: Jos David Guilln + +int x=RadioX, + y=0, + oldx=RadioX, oldx2 = RadioX, oldx3 = RadioX, + giro = 0, + vez = 0, + ciclo = 1, + Angulo = 0; + + +do{ + + setcolor(GRIS_C); + ellipse(PosX, PosY, 0+ Angulo, 360+ Angulo, abs(oldx), RadioY ); + ellipse(PosX, PosY, 0/*+*/- Angulo, 360/*+*/- Angulo, RadioX, abs(oldx) ); + +if(giro==1)/*{*/ setcolor(NEGRO); else setcolor(BLANCO); + +/// ellipse(PosX, PosY, 90+ Angulo, 270+ Angulo, abs(x), /*abs(y)*/50 ); +ellipse(PosX, PosY, 0+ Angulo, 90+ Angulo, abs(x), RadioY ); +ellipse(PosX, PosY, 180- Angulo, 270- Angulo, abs(x), RadioY ); + +/// ellipse(PosX, PosY, 0+ Angulo, 180+ Angulo, /*abs(y)*/50, abs(x) ); +ellipse(PosX, PosY, 90/*+*/- Angulo, 180/*+*/- Angulo, RadioX, abs(x)); +ellipse(PosX, PosY, 270/*+*/- Angulo, 360/*+*/- Angulo, RadioX, abs(x) ); + + +if(giro==1)/*{*/ setcolor(BLANCO); else setcolor(NEGRO); + +/// ellipse(PosX, PosY, 270+ Angulo, 90+ Angulo, abs(x), /*abs(y)*/50 ); +ellipse(PosX, PosY, 90+ Angulo, 180+ Angulo, abs(x), RadioY ); +ellipse(PosX, PosY, 270+ Angulo, 360+ Angulo, abs(x), RadioY ); + +/// ellipse(PosX, PosY, 180+ Angulo, 360+ Angulo, /*abs(y)*/50, abs(x) ); +ellipse(PosX, PosY, 0/*+*/- Angulo, 90/*+*/- Angulo, RadioX, abs(x) ); +ellipse(PosX, PosY, 180/*+*/- Angulo, 270/*+*/- Angulo, RadioX, abs(x) ); + + oldx = oldx2; + oldx2 = oldx3; + oldx3 = x; + + + x--; + if(x<=-(RadioX-1) ) x=RadioX; + y--; + if(y<=-(RadioY-1) ) y=RadioY; + +if(ciclo == 0 && x == RadioX ) { ciclo = 1; vez = 0; } else +if(ciclo == 1 && x == RadioX ) { ciclo = 0; vez = 1; } + +if(vez==0){ + if(x<0) giro=1; else giro=0; +} +if(vez==1){ + if(x<0) giro=0; else giro=1; +} + delay(20); + + Angulo+= Velocidad; if( Angulo== 360 ) Angulo=0; + +}while(!kbhit()); + +} + +void Circulos3(int PosX, int PosY, int RadioX, int RadioY, int Velocidad){ + +// Circulo con apariencia de 3D, por: Jos David Guilln + +int x=RadioX, + y=0, + oldx=RadioX, oldx2 = RadioX, oldx3 = RadioX, + giro = 0, + vez = 0, + ciclo = 1, + Angulo = 0; + + +do{ + + setcolor(GRIS_C); + ellipse(PosX, PosY, 0+ Angulo, 360+ Angulo, abs(oldx), RadioY ); + ellipse(PosX, PosY, 0/*+*/- Angulo, 360/*+*/- Angulo, RadioX, abs(oldx) ); + +if(giro==1)/*{*/ setcolor(NEGRO); else setcolor(BLANCO); + +/// ellipse(PosX, PosY, 90+ Angulo, 270+ Angulo, abs(x), /*abs(y)*/50 ); +ellipse(PosX, PosY, 0+ Angulo, 90+ Angulo, abs(x), RadioY ); +ellipse(PosX, PosY, 180- Angulo, 270- Angulo, abs(x), RadioY ); + +/// ellipse(PosX, PosY, 0+ Angulo, 180+ Angulo, /*abs(y)*/50, abs(x) ); +ellipse(PosX, PosY, 90/*+*/- Angulo, 180/*+*/- Angulo, RadioX, abs(x)); +ellipse(PosX, PosY, 270/*+*/- Angulo, 360/*+*/- Angulo, RadioX, abs(x) ); + + +if(giro==1)/*{*/ setcolor(BLANCO); else setcolor(NEGRO); + +/// ellipse(PosX, PosY, 270+ Angulo, 90+ Angulo, abs(x), /*abs(y)*/50 ); +ellipse(PosX, PosY, 90+ Angulo, 180+ Angulo, abs(x), RadioY ); +ellipse(PosX, PosY, 270+ Angulo, 360+ Angulo, abs(x), RadioY ); + +/// ellipse(PosX, PosY, 180+ Angulo, 360+ Angulo, /*abs(y)*/50, abs(x) ); +ellipse(PosX, PosY, 0/*+*/- Angulo, 90/*+*/- Angulo, RadioX, abs(x) ); +ellipse(PosX, PosY, 180/*+*/- Angulo, 270/*+*/- Angulo, RadioX, abs(x) ); + + oldx = oldx2; + oldx2 = oldx3; + oldx3 = x; + + + x--; + if(x<=-(RadioX-1) ) x=RadioX; + y--; + if(y<=-(RadioY-1) ) y=RadioY; + +if(ciclo == 0 && x == RadioX ) { ciclo = 1; vez = 0; } else +if(ciclo == 1 && x == RadioX ) { ciclo = 0; vez = 1; } + +if(vez==0){ + if(x<0) giro=1; else giro=0; +} +if(vez==1){ + if(x<0) giro=0; else giro=1; +} + delay(20); + + Angulo+= Velocidad; if( Angulo== 360 ) Angulo=0; + + +//////////////////////////////////////////////////////// +//////////////////////////////////////////////////////// +giro = 1; +//////////////////////////////////////////////////////// +//////////////////////////////////////////////////////// + + +}while(!kbhit()); + +} diff --git a/DATOS/BAK/CLIENTES.DAT b/DATOS/BAK/CLIENTES.DAT new file mode 100644 index 0000000..f4cf62b Binary files /dev/null and b/DATOS/BAK/CLIENTES.DAT differ diff --git a/DATOS/BAK/C_INDICE.DAT b/DATOS/BAK/C_INDICE.DAT new file mode 100644 index 0000000..06311e0 Binary files /dev/null and b/DATOS/BAK/C_INDICE.DAT differ diff --git a/DATOS/BAK/SV_C0095.DAT b/DATOS/BAK/SV_C0095.DAT new file mode 100644 index 0000000..4583cac Binary files /dev/null and b/DATOS/BAK/SV_C0095.DAT differ diff --git a/DATOS/BAK/SV_COMP.DAT b/DATOS/BAK/SV_COMP.DAT new file mode 100644 index 0000000..1c23c62 Binary files /dev/null and b/DATOS/BAK/SV_COMP.DAT differ diff --git a/DATOS/BAK/SV_STOCK.DAT b/DATOS/BAK/SV_STOCK.DAT new file mode 100644 index 0000000..418463d Binary files /dev/null and b/DATOS/BAK/SV_STOCK.DAT differ diff --git a/DATOS/BAK/SV_V0195.DAT b/DATOS/BAK/SV_V0195.DAT new file mode 100644 index 0000000..76ab11b Binary files /dev/null and b/DATOS/BAK/SV_V0195.DAT differ diff --git a/DATOS/BAK/SV_V0295.DAT b/DATOS/BAK/SV_V0295.DAT new file mode 100644 index 0000000..2ffc3b1 Binary files /dev/null and b/DATOS/BAK/SV_V0295.DAT differ diff --git a/DATOS/BAK/SV_V0395.DAT b/DATOS/BAK/SV_V0395.DAT new file mode 100644 index 0000000..ec87589 Binary files /dev/null and b/DATOS/BAK/SV_V0395.DAT differ diff --git a/DATOS/BAK/SV_V0495.DAT b/DATOS/BAK/SV_V0495.DAT new file mode 100644 index 0000000..da496c8 Binary files /dev/null and b/DATOS/BAK/SV_V0495.DAT differ diff --git a/DATOS/BAK/SV_V0595.DAT b/DATOS/BAK/SV_V0595.DAT new file mode 100644 index 0000000..fd5275d Binary files /dev/null and b/DATOS/BAK/SV_V0595.DAT differ diff --git a/DATOS/BAK/SV_V0695.DAT b/DATOS/BAK/SV_V0695.DAT new file mode 100644 index 0000000..1c2ccd2 Binary files /dev/null and b/DATOS/BAK/SV_V0695.DAT differ diff --git a/DATOS/BAK/SV_VEND.DAT b/DATOS/BAK/SV_VEND.DAT new file mode 100644 index 0000000..15a3bdf Binary files /dev/null and b/DATOS/BAK/SV_VEND.DAT differ diff --git a/DATOS/BAK/SV__REF.DAT b/DATOS/BAK/SV__REF.DAT new file mode 100644 index 0000000..c8e12d5 Binary files /dev/null and b/DATOS/BAK/SV__REF.DAT differ diff --git a/DATOS/CLIENTES.DAT b/DATOS/CLIENTES.DAT new file mode 100644 index 0000000..1cce24d Binary files /dev/null and b/DATOS/CLIENTES.DAT differ diff --git a/DATOS/C_INDICE.DAT b/DATOS/C_INDICE.DAT new file mode 100644 index 0000000..5ac2593 Binary files /dev/null and b/DATOS/C_INDICE.DAT differ diff --git a/DATOS/LITT.CHR b/DATOS/LITT.CHR new file mode 100644 index 0000000..08c3067 Binary files /dev/null and b/DATOS/LITT.CHR differ diff --git a/DATOS/RUN.BAT b/DATOS/RUN.BAT new file mode 100644 index 0000000..78f8468 --- /dev/null +++ b/DATOS/RUN.BAT @@ -0,0 +1 @@ +..\..\..\out\sv diff --git a/DATOS/SV_C0095.DAT b/DATOS/SV_C0095.DAT new file mode 100644 index 0000000..7e81157 Binary files /dev/null and b/DATOS/SV_C0095.DAT differ diff --git a/DATOS/SV_COMP.DAT b/DATOS/SV_COMP.DAT new file mode 100644 index 0000000..90295d1 Binary files /dev/null and b/DATOS/SV_COMP.DAT differ diff --git a/DATOS/SV_STOCK.DAT b/DATOS/SV_STOCK.DAT new file mode 100644 index 0000000..eaf643e Binary files /dev/null and b/DATOS/SV_STOCK.DAT differ diff --git a/DATOS/SV_V0195.DAT b/DATOS/SV_V0195.DAT new file mode 100644 index 0000000..76ab11b Binary files /dev/null and b/DATOS/SV_V0195.DAT differ diff --git a/DATOS/SV_V0295.DAT b/DATOS/SV_V0295.DAT new file mode 100644 index 0000000..2ffc3b1 Binary files /dev/null and b/DATOS/SV_V0295.DAT differ diff --git a/DATOS/SV_V0395.DAT b/DATOS/SV_V0395.DAT new file mode 100644 index 0000000..ec87589 Binary files /dev/null and b/DATOS/SV_V0395.DAT differ diff --git a/DATOS/SV_V0495.DAT b/DATOS/SV_V0495.DAT new file mode 100644 index 0000000..da496c8 Binary files /dev/null and b/DATOS/SV_V0495.DAT differ diff --git a/DATOS/SV_V0595.DAT b/DATOS/SV_V0595.DAT new file mode 100644 index 0000000..5d34ff6 Binary files /dev/null and b/DATOS/SV_V0595.DAT differ diff --git a/DATOS/SV_V0695.DAT b/DATOS/SV_V0695.DAT new file mode 100644 index 0000000..44db89a Binary files /dev/null and b/DATOS/SV_V0695.DAT differ diff --git a/DATOS/SV_V0795.DAT b/DATOS/SV_V0795.DAT new file mode 100644 index 0000000..098c199 Binary files /dev/null and b/DATOS/SV_V0795.DAT differ diff --git a/DATOS/SV_VEND.DAT b/DATOS/SV_VEND.DAT new file mode 100644 index 0000000..c699bfc Binary files /dev/null and b/DATOS/SV_VEND.DAT differ diff --git a/DATOS/SV__REF.DAT b/DATOS/SV__REF.DAT new file mode 100644 index 0000000..ceff958 Binary files /dev/null and b/DATOS/SV__REF.DAT differ diff --git a/DEL1.BAT b/DEL1.BAT new file mode 100644 index 0000000..5bd04f4 --- /dev/null +++ b/DEL1.BAT @@ -0,0 +1,3 @@ +del clientes.dat +del c_indice.dat +del sv_c0095.dat diff --git a/LITT.CHR b/LITT.CHR new file mode 100644 index 0000000..08c3067 Binary files /dev/null and b/LITT.CHR differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..b9249ff --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +#SV + + +*11/11/1991* + +ToDo: wwtcf? + + +![screenshot](/SV.png "Screenshot") diff --git a/RUN.BAT b/RUN.BAT new file mode 100644 index 0000000..4c6e5d2 --- /dev/null +++ b/RUN.BAT @@ -0,0 +1 @@ +..\..\out\sv diff --git a/RUN2.BAT b/RUN2.BAT new file mode 100644 index 0000000..8fbd6ab --- /dev/null +++ b/RUN2.BAT @@ -0,0 +1,6 @@ + +..\..\out\sv +rem cd datos +rem ..\..\..\out\sv +rem cd .. +exit diff --git a/SV.CPP b/SV.CPP new file mode 100644 index 0000000..58f424a --- /dev/null +++ b/SV.CPP @@ -0,0 +1,562 @@ +////////////////////////////////////////////////////////////////////////////// +/// Nombre: SV .CPP /// +/// Modulo: Grficos para programa original [SINTITULO] /// +/// Descripcin: /// +/// /// +/// Autor: Jos David Guilln Dominguez /// +/// Fecha: 13 - 01 - 1995 /// +/// /// +/// Comentario: /// +/// /// +/// /// +/// Compilador Borland C++ 3.0 /// +////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "..\libs\make_bot\make_bot.h" +#include "SV_graph.h" +#include "sv_util.h" + +extern int x_raton, y_raton; extern char raton; +extern int boton_izq, boton_der; +extern int dir_raton [32+32]; + +extern void Pantalla_Graficas_Compras(struct boton *PGC); +extern void Menu_Graficas_de_Compras(int Compras_Ventas); +extern void Menu_Graficas_de_Clientes(int Current_Date); +extern void Acerca_de(void); +extern void desactiva_raton(void); +extern void activa_raton(void); +extern void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py); +extern void Menu_de_Ventas(int Current_Date); +extern void Menu_de_Clientes(void); +extern void Menu_de_Vendedores(void); +extern void Menu_de_Referencias(void); +extern void Menu_de_Clientes_Comp(int Current_Date); +extern void Menu_de_Compras(void); +// extern void Dibuja_Pantalla_Stock(void); +extern void Menu_de_Stock(void); + + +extern void Menu_de_Facturas(void); +extern void Configuracion(void); +extern void textxy(int x, int y, char *text); +extern int Espera_Tecla_o_Raton(void); +void Mensaje(void); + +extern struct Make_Boton PP_S[5]; + +void redefine_cursor_raton(int r_e); +void BEEP(void); + + +void EditCursorMP(int Muestra_Oculta, int Columna, int Linea, int Menu_Desplegado); +void Contrae_Menu(int Columna); +void Despliega_Menu(int Columna); +void Menu_Principal(void); +int Menu(int Columna, int Linea); + +extern char PunteroRaton; + +int main(void){ + + int GD = 9, GM = 2; + + Initialize(GD, GM); + + inicializa_raton_grafico(0, 0, 624, 464, 320, 240); + if(raton!=0) desactiva_raton(); + +// Menu_de_Vendedores(); +// Menu_de_Referencias(); +// Menu_de_Compras(); +// Menu_de_Stock(); + +Menu_Principal(); + +// Dibuja_Pantalla_Pricipal(); +/* +Dibuja_Pantalla_Altas_Todos_los_Datos(); + getch(); + cleardevice(); + Dibuja_Pantalla_Altas_Rapida(); + getch(); + cleardevice(); + Dibuja_Pantalla_Vendedores(); + getch(); + cleardevice(); + Dibuja_Pantalla_Referencia(); + getch(); + cleardevice(); + Dibuja_Pantalla_Compras(); + getch(); + cleardevice(); + Dibuja_Pantalla_Stock(); + +*/ +// if (raton == 0) { cprintf("ERROR RATON NECESARIO"); return 1; } + + +// Espera_Tecla_o_Raton(); + +//getch(); + + + + restorecrtmode(); Mensaje(); return 0; +} + +void Mensaje(void){ + +clrscr(); +printf("JD_ FuTuRe ViSiOn\n\n"); + + +} + + + + +void BEEP(void){ + + sound(440); + delay(50); + nosound(); + +} + + + +void Menu_Principal(void){ + + int CurrCol_MP=1, CurrRow_MP=1, Menu_Desplegado=0, key; + char finished = 0; + + int N_Row[] = { 5, 3, 3, 5, 5}; + + + + + Dibuja_Pantalla_Pricipal(); + + do{ + + EditCursorMP(1, CurrCol_MP, CurrRow_MP, Menu_Desplegado); + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + EditCursorMP(0, CurrCol_MP, CurrRow_MP, Menu_Desplegado); + + if(kbhit()){ + key = getch(); + if(key==13 && Menu_Desplegado == 1) + { finished = Menu(CurrCol_MP, CurrRow_MP); Contrae_Menu(CurrCol_MP); Menu_Desplegado = 0; } else + if(key==13 && Menu_Desplegado == 0){ Menu_Desplegado = 1; Despliega_Menu(CurrCol_MP); CurrRow_MP = 1;} + if(key==27) { Contrae_Menu(CurrCol_MP); Menu_Desplegado = 0;} + if( key == 0 ) { + switch( (key=getch()) ){ + // Flecha Arriba + case 72: + if( Menu_Desplegado == 1 ) { + CurrRow_MP --; if(CurrRow_MP < 1) CurrRow_MP = N_Row[CurrCol_MP - 1]; + } + break; + // Flecha Izquierda + case 75: + case 15: + if( Menu_Desplegado == 1 ) Contrae_Menu(CurrCol_MP); + CurrCol_MP--; if ( CurrCol_MP < 1 ) CurrCol_MP=5; + if( Menu_Desplegado == 1 ) { Despliega_Menu(CurrCol_MP); CurrRow_MP = 1; } + break; + // Flecha Derecha + case 77: + case 9: + if( Menu_Desplegado == 1 ) Contrae_Menu(CurrCol_MP); + CurrCol_MP++; if ( CurrCol_MP > 5 ) CurrCol_MP=1; + if( Menu_Desplegado == 1 ) { Despliega_Menu(CurrCol_MP); CurrRow_MP = 1; } + break; + // Flecha Abajo + case 80: + if( Menu_Desplegado == 1 ) { + CurrRow_MP ++; if(CurrRow_MP > N_Row[CurrCol_MP - 1]) CurrRow_MP = 1; + } else { + Menu_Desplegado = 1; Despliega_Menu(CurrCol_MP); CurrRow_MP = 1; + } + break; + // INICIO + case 71: + if( Menu_Desplegado == 0 ) CurrCol_MP = 1; else CurrRow_MP = 1; + break; + // FIN + case 79: + if( Menu_Desplegado == 0 ) CurrCol_MP = 5; else CurrRow_MP = N_Row[CurrCol_MP - 1]; + break; + default: + break; + } + } + } + + /* else if(raton!=0 && ( boton_izq==1 || boton_der==1 ) ) + + if( (bpush = CheckButon( 9, Comunes))>0 ) { + EditCursorComp(1); + switch(bpush){ + } + } else CompruebaLineasComp(); + */ + + }while( !finished ); + + +} + + +void Despliega_Menu(int Columna){ + +int x, n; struct Make_Boton Tmp; +char Texto[10][25]; + + switch(Columna) { + case 1: x = 7; n = 5; + strcpy ( Texto[0], " Estado actual "); + strcpy ( Texto[1], " Enlazar con ->"); + strcpy ( Texto[2], " Configuracin "); + strcpy ( Texto[3], " MS-DOS Shell "); + strcpy ( Texto[4], " ( SALIR ) "); + break; + case 2: x = 91; n = 3; + strcpy ( Texto[0], " Mantenimiento "); + strcpy ( Texto[1], " Emision de Facturas -> "); + strcpy ( Texto[2], " Altas / Modificaciones "); + break; + case 3: x = 266; n = 3; + strcpy ( Texto[0], " Compras "); + strcpy ( Texto[1], " Vendedores "); + strcpy ( Texto[2], " Referencias "); + break; + case 4: x = 395; n = 5; + strcpy ( Texto[0], " Stock actual "); + strcpy ( Texto[1], " Informe de Ventas "); + strcpy ( Texto[2], " Graficas de Ganancias "); + strcpy ( Texto[3], " Graficas de Compras "); + strcpy ( Texto[4], " Graficas de Clientes "); + break; + case 5: x = 455; n = 5; + strcpy ( Texto[0], " Menus "); + strcpy ( Texto[1], " Pantallas de Edicin "); + strcpy ( Texto[2], " -------------------- "); + strcpy ( Texto[3], " Ayuda en Linea ( Off )"); + strcpy ( Texto[4], " Acerca de... "); + break; + } + + Tmp.Up = 43; Tmp.Down = 45 + (n*19) + 5; + Tmp.Left = x; Tmp.Right = x + textwidth( Texto[0] ); + Imprime_Boton2 (0, GRIS_C, BLANCO, GRIS_O, Tmp); + Tmp.Up = 43 + 2; Tmp.Down = 45 + (n*19) - 2 + 5; + Tmp.Left = x + 2; Tmp.Right = x + textwidth( Texto[0] ) - 2; + Imprime_Boton2 (0, GRIS_C, GRIS_O, BLANCO, Tmp); + +for(int i=0; i + #include + #include +#include + #include +#include + #include + #include +#include "..\libs\make_bot\make_bot.h" + + +#define Letra_Boton setcolor(1); +#define Azul 1 +#define Texto_Normal setcolor(63); +#define Texto_Negrita setcolor(0); + +extern int x_raton, y_raton, raton; +extern int boton_izq, boton_der; + +extern int InputCadenaG(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo); +extern void desactiva_raton(void); +extern void activa_raton(void); +// extern void Anclar_Raton(void); +extern void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py); +extern int Espera_Tecla_o_Raton(void); +extern void BEEP(void); +extern void textxy(int x, int y, char *text); + + +#define NEGRO 0 +#define AZUL 1 +#define ROJO 4 +#define VERDE 2 +#define BLANCO 63 +#define GRIS_O 56 +#define GRIS_C 7 +#define AMARILLO 62 + +extern void textxy(int x, int y, char *text); + + +void Dibuja_Pantalla_Configuracion(void); + +void Configuracion(void){ + + Dibuja_Pantalla_Configuracion(); + + getch(); + +} + +void Dibuja_Pantalla_Configuracion(void){ + + struct boton DBC[10]; + +DBC[0].up = /*140*/130; DBC[0].down = /*255*/400; +DBC[0].left= /*200*/150; DBC[0].right= /*370*/465; +ImprimeBoton (1, GRIS_C, GRIS_O, BLANCO, DBC[0]); +textxy(160+2, 145+2, "PANTALLA DE CONFIGURACION"); + +DBC[0].up = /*143*/135; DBC[0].down = /*252*/395; +DBC[0].left= /*203*/155; DBC[0].right= /*367*/460; +ImprimeBoton (0, GRIS_C, BLANCO, GRIS_O, DBC[0]); + +DBC[0].up = /*235*/370; DBC[0].down = /*250*/390; +DBC[0].left= /*210*/160; DBC[0].right= /*270*/230; +ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, DBC[0]); +textxy(162, 372, " Aceptar"); + textxy(162, 373, " _"); + +DBC[1].up = /*235*/370; DBC[1].down = /*250*/390; +DBC[1].left= /*300*/385; DBC[1].right= /*360*/455; +ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, DBC[1]); +textxy(387, 372, " Cancelar"); + textxy(387, 373, " _"); + +DBC[2].up = /*165*/180; DBC[2].down = /*185*/195; +DBC[2].left= 235; DBC[2].right= 300; +Fuente(SMALL_FONT, 4); +textxy(160+2, 175+2, "Ao para las"); +textxy(160+2, 185+2, "gestiones..."); + ImprimeBoton (1, NEGRO, BLANCO, GRIS_O, DBC[2]); +textxy(305+2, 185+2, "<--- ( no Backup )"); + + + + +} diff --git a/SV_CLIE2.CPP b/SV_CLIE2.CPP new file mode 100644 index 0000000..bbc1146 --- /dev/null +++ b/SV_CLIE2.CPP @@ -0,0 +1,2150 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "..\libs\make_bot\make_bot.h" +#include "sv_graph.h" + +#include "sv_util.h" +#include "sv_ref_x.h" + +#define Texto_Normal setcolor(63); +#define Letra_Boton setcolor(1); +#define Texto_Negrita setcolor(0); + +#define FINAL 1 +#define SOLO_ESTA 0 +#define TODAS 1 +#define DESDE_CONTRATO_ACTUAL 2 +#define Para_Cliente 1 +#define Para_Empresa 0 + + +#define NO_ENCONTRADO 0 +#define ENCONTRADO 1 + +extern int x_raton, y_raton, raton; +extern int boton_izq, boton_der; + +extern void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py); +extern void textxy(int x, int y, char *text); +extern int Espera_Tecla_o_Raton(void); +extern void desactiva_raton(void); +extern void activa_raton(void); +extern void Anclar_Raton(void); +extern void BEEP(void); + +extern int InputCadenaG(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo); +extern int InputCadenaG_l(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int Row); +extern int InputCadenaG_T4(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int Row); + + + +extern void Actualizar_Ventas(int Referencia, int Unidades, int Codigo); +extern void Abre_Ficha_Ventas(void); + +extern void Abre_Ficha_Clientes(void); +extern void Abre_Ficha_Stock(void); +extern void GetLineClientes(void); + +int Viable_Apertura(void); +void Acota_Contenido(void); +void AddRecordClientes_C(void); +void Imprimir_Clientes_C(void); +void Edit_Item_Clientes_C(void); +void Menu_de_Clientes_Comp(void); +void Mueve_Abajo_Clientes2(void); +void Mueve_Ariba_Clientes2(void); +void Mueve_Abajo_Clientes1(void); +void Mueve_Arriba_Clientes1(void); +void DeleteRecordClientes_C(void); +void PutLineClientes_Compras2(void); +void GetLineClientes_Compras2(void); +void CompruebaLineasClientes_C(void); +void PrintWholeScreenClientes2(void); +void PrintWholeScreenClientes1(void); +void Imprime_Factura_C(int Para_quien); +void EditCursorClientes_C(int ShowHide); +int Obten_Direccion_Compras(int which); +void Displayado_de_Datos(int Para_quien); +void Actualiza_Direccion_Compras(int which); +void Current_Struct_to_Zero_Clientes_C(void); +void PrintLineClientes_C(int Rapida_Completa); +void Imprime_Todas_Facturas(int Para_quien, int Current_Date); + +void Barra_buscar_CC(struct boton *Tmp); +void Buscar_Cliente_Seccion_Compras(void); +int Sigue_Buscando_CB(struct Clientes Clientes1_Buscar); +void Edit_Item_Clientes_CB(int Columna, struct boton *Tmp, struct Clientes *Clientes1_Buscar); +void EditCursorClientes_CB(int Columna, int ShowHide, struct boton *Tmp, struct Clientes Clientes1_Buscar); + +extern void PrintWholeScreenClientes(void); +extern void PrintLineClientes(int Rapida_Completa); + +extern int Comprueba_Impresora(void); +extern void Abre_Ficha_Vendedores(void); +extern void Coloca_Nombres_a_botones(void); +extern void Carga_Todos_los_Vendedores(void); +extern void Abre_Ficha_Clientes_Compras(void); +extern void Prepara_Porcentaje_Circular(void); +extern void Obten_Nombre_Vendedor( int Nvend ); +extern void Abre_Ficha_Clientes_Ncontrato(void); + +void Barra_buscar_CC(struct boton *Tmp); +void Buscar_Cliente_Seccion_Compras(void); + + +struct Clientes_inx_NContrato { + unsigned long Inicio; + unsigned int Records; + unsigned char Libre; + }; + +struct Clientes_inx { + char Ncontrato_ocupado_SN[10000]; + unsigned int Fin; + }; + +struct Clientes { + int Address; + + char Nombre[15+1]; char Apellido1[15+1]; char Apellido2[15+1]; + char DNI[15+1]; unsigned long Telefono1; + char Calle1[30+1]; char Num1[5+1]; + + char Local[30+1]; unsigned long Telefono2; + char Calle2[30+1]; char Num2[5+1]; + char Poblacion[18+1]; char Provincia[16+1]; unsigned long CP; + + unsigned char GC; unsigned char MR; unsigned char SP; + unsigned char DP; unsigned int MA; + + struct date Fecha; int Vend; int NContrato; + +}; + +// Se almacenan 1000 registros por archivo +// En un caso extremo son: 9 bit ---> Espacio por Dato +// 31 ---> Dias por mes +// 2 ---> Productos por da +// 12 ---> 12 meses +// 1000 ---> Clientes +// + +struct Clientes_compras { // C UU VEN REF + struct date Fecha; // 1 99 999 9999 + unsigned long Cod_Und_Vend_Ref; + }; + +struct Vend_inx { + unsigned int Fin; + }; + +struct Vendedores { + int Num_V; + char Nombre[15+1]; char Apellido1[15+1]; char Apellido2[15+1]; + char DNI[15+1]; unsigned long Telefono1; unsigned long Telefono2; + char Calle[30+1]; char Num[3+1]; char Piso[3+1]; + char Poblacion[18+1]; char Provincia[16+1]; unsigned long CP; + unsigned long CC; unsigned int PP; unsigned int Cr; +}; +/* +extern struct Stock_inx { unsigned int Fin; }; + +extern struct Stock_actual { int Ref; long Und_0; long Und_1; }; +*/ +extern struct Stock_actual Ventas1; +extern struct Stock_inx Ventas1_inx; + +extern void Actualizar_Stock(int Referencia, int Unidades, int Codigo); + + +extern struct JD cabecera; +extern struct Clientes Clientes1; +extern struct Clientes_inx Clientes1_inx; +extern struct Clientes_compras Clientes2; +extern struct Clientes_inx_NContrato Clientes1_inx_NContrato; + +struct Clientes Clientes1_Buscar; + +extern struct Vendedores Vend1; +extern struct Vend_inx Vend1_inx; + + struct boton *PAR; +extern struct boton Comunes[9]; + + +extern int oldCNI; +extern int *Vend_Dir; + +extern FILE *Vend; // Fichero Vendedores +extern FILE *Stock; +extern FILE *Ventas; +extern FILE *Clientes; // Fichero Clientes +extern FILE *Clientes_C; // Fichero Clientes con las Compras. +extern FILE *Clientes_NC; // Fichero Clientes con los nmeros de contrato activos. + +extern int CurrRow1_Clien, CurrRow2_Clien; +extern int CurrCol1_Clien, CurrCol2_Clien; +extern int CurrTopLine_Clien, CurrTopLine_Clien1; +extern int SWAP_CLIEN; + +int Start_Comp_Clien; +int Comp_Clien_Records; +int Fecha, Usa_Pc = 0; +int Comienzo_Busqueda = 0; +char Se_Puede_Buscar = 0; +int Buscador; + + + +void Menu_de_Clientes_Comp(int Current_Date) { + + Fecha = Current_Date; + int finished = 0, key, bpush; + char Buffer[80]; + + Buscador = 0; + + CurrRow1_Clien = 1; CurrCol1_Clien = 1; + CurrRow2_Clien = 1; CurrCol2_Clien = 1; + + oldCNI = -1; SWAP_CLIEN = 1; + + CurrTopLine_Clien = 1; + CurrTopLine_Clien1 = 1; + Se_Puede_Buscar = 0; + + if( ( PAR = (struct boton *) malloc( sizeof(struct boton)*13 ) ) == NULL ) + { + Confirma("Memoria insuficiente", "para crear tablas de", "posisin PAR."); +// farfree(Clientes1_inx_NContrato); + return ; + } + + if( ( Vend_Dir = (int *) malloc( sizeof(int)*1024 ) ) == NULL ) + { + Confirma("Memoria insuficiente", "para crear tablas para", "Vend_Dir"); + free(PAR); + return ; + } + + +// inicializa_raton_grafico(0, 0, 624, 464, 320, 240); +// if(raton!=0) desactiva_raton(); + + cleardevice(); + Dibuja_Pantalla_Altas_Rapida(PAR); + + Fuente(SMALL_FONT, 5); + Coloca_Nombres_a_botones(); + Fuente(SMALL_FONT, 5); + + if( !Viable_Apertura() ) return ; + + Abre_Ficha_Clientes(); + Abre_Ficha_Clientes_Ncontrato(); + + + Abre_Ficha_Referencias(); + Carga_Referencias(); + Abre_Ficha_Vendedores(); + Carga_Todos_los_Vendedores(); + Abre_Ficha_Stock(); + Abre_Ficha_Ventas(); +// PUNTO DE CONFLICTO + +PrintWholeScreenClientes1(); + + GetLineClientes(); + Abre_Ficha_Clientes_Compras(); + + +// GetLineClientes(); + Acota_Contenido(); + PrintWholeScreenClientes2(); + GetLineClientes_Compras2(); + + +// +{ + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PAR[11]); + setcolor(63); + sprintf(Buffer, "N de Contrato: % 4d Suma Total:", Clientes1.NContrato); + outtextxy(20, 431, Buffer); +} +// + +// PrintLineClientes_C(0); + + + int oldCR1=0, oldCR2=0, oldCC1=0, oldCC2=0; + +do{ + + +if(oldCR1!=CurrRow1_Clien || oldCC1!=CurrCol1_Clien || oldCR2!=CurrRow2_Clien || oldCC2!=CurrCol2_Clien ) + EditCursorClientes_C(0); + +oldCR1 = CurrRow1_Clien; oldCC1 = CurrCol1_Clien; +oldCR2 = CurrRow2_Clien; oldCC2 = CurrCol2_Clien; + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + + + if(kbhit()){ + EditCursorClientes_C(1); + key = getch(); + if( isprint(key) || isspace(key) ) { + EditCursorClientes_C(0); + if(key!=13) ungetch(key); + Edit_Item_Clientes_C(); + EditCursorClientes_C(0); + + } else if( key == 0 ) { + switch( (key=getch()) ){ + // Flecha Arriba + case 72: + if(!SWAP_CLIEN) Mueve_Ariba_Clientes2(); + else Mueve_Arriba_Clientes1(); + break; + // Flecha Izquierda + case 75: + case 15: + if(SWAP_CLIEN) { CurrCol1_Clien--; if ( CurrCol1_Clien<1 ) CurrCol1_Clien=3; } + else { CurrCol2_Clien--; if ( CurrCol2_Clien < 1 ) CurrCol2_Clien=7; } + break; + // Flecha Derecha + case 77: + case 9: + if(SWAP_CLIEN) { CurrCol1_Clien++; if ( CurrCol1_Clien>3 ) CurrCol1_Clien=1; } + else { CurrCol2_Clien++; if ( CurrCol2_Clien > 7 ) CurrCol2_Clien=1; } + break; + // Flecha Abajo + case 80: + if(!SWAP_CLIEN) Mueve_Abajo_Clientes2(); + else Mueve_Abajo_Clientes1(); + break; + // Buscar F2 + case 60: + Buscar_Cliente_Seccion_Compras(); + break; + // Buscar otra vez --> F3 + case 61: + + if(Se_Puede_Buscar) { + CurrTopLine_Clien1++; + Comienzo_Busqueda = 1; + if( Sigue_Buscando_CB(Clientes1_Buscar) == ENCONTRADO ) { + PrintWholeScreenClientes1(); + GetLineClientes(); + { + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } + Acota_Contenido(); + PrintWholeScreenClientes2(); + GetLineClientes_Compras2(); + } + // + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PAR[11]); + setcolor(63); + sprintf(Buffer, "N de Contrato: % 4d Suma Total:", Clientes1.NContrato); + outtextxy(20, 431, Buffer); + // + + } else { + CurrTopLine_Clien1--; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, Comunes[7]); + GetLineClientes(); + + } + } + break; + + // Imprimir Clientes (incluye men desplegable) F5 + case 63: + Imprimir_Clientes_C(); + break; + // SWAP_CLIEN (la parte de edicin) F6 + case 64: + if(SWAP_CLIEN) { EditCursorClientes_C(0); SWAP_CLIEN=0; } else SWAP_CLIEN=1; + EditCursorClientes_C(0); + break; + // F9 --> AADIR + case 67: + if(!SWAP_CLIEN) + /*if( Confirma(" Dar de ALTA a un", "nuevo CLIENTE ?", "") )*/ + { AddRecordClientes_C(); } + break; + // F10 -> BORRAR + case 68: + if(!SWAP_CLIEN) + if( Confirma("Desea eliminar la", "Compra Actual", "") ) + { Fuente(SMALL_FONT, 5); DeleteRecordClientes_C(); } + + break; + // INICIO + case 71: + if(SWAP_CLIEN) CurrCol1_Clien = 1; else CurrCol2_Clien = 1; + break; + // FIN + case 79: + if(SWAP_CLIEN) CurrCol1_Clien = 3; else CurrCol2_Clien = 7; + break; + // RePg + case 73: + // CurrRow = 1; + if(SWAP_CLIEN) { + CurrRow1_Clien = 1; + if( CurrTopLine_Clien1 > 11 ) { CurrTopLine_Clien1 -= 11; } else { CurrTopLine_Clien1 = 1; } + if( CurrTopLine_Clien1 < 1 ) { CurrTopLine_Clien1 = 1; } + PrintWholeScreenClientes1(); + GetLineClientes(); + + { + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } + Acota_Contenido(); + PrintWholeScreenClientes2(); + GetLineClientes_Compras2(); +// PrintLineClientes_C(1); + // + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PAR[11]); + setcolor(63); + sprintf(Buffer, "N de Contrato: % 4d Suma Total:", Clientes1.NContrato); + outtextxy(20, 431, Buffer); + // + + } + + } + break; + // AvPg + case 81: + // CurrRow = 1; + if(SWAP_CLIEN) { + CurrRow1_Clien = 1; + CurrTopLine_Clien1 += 11; + if ( (CurrTopLine_Clien1+CurrRow1_Clien - 2 ) > Clientes1_inx.Fin) { CurrTopLine_Clien1 = Clientes1_inx.Fin+1; CurrRow1_Clien = 1; } + if (CurrTopLine_Clien1==0) CurrTopLine_Clien1 = 1; + PrintWholeScreenClientes1(); + GetLineClientes(); + { + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } + Acota_Contenido(); + PrintWholeScreenClientes2(); + GetLineClientes_Compras2(); +// PrintLineClientes_C(1); + // + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PAR[11]); + setcolor(63); + sprintf(Buffer, "N de Contrato: % 4d Suma Total:", Clientes1.NContrato); + outtextxy(20, 431, Buffer); + // + + } + + } + break; + + // Salir F1 + case 59: + finished = 1; + break; + default: + break; + } + EditCursorClientes_C(0); + } + } + else if(raton!=0 && ( boton_izq==1 || boton_der==1 ) ) + if( (bpush = CheckButon( 9, Comunes))>0 ) { + EditCursorClientes_C(1); + switch(bpush){ + // Flecha Arriba + case 1: + if(!SWAP_CLIEN) Mueve_Ariba_Clientes2(); + else Mueve_Arriba_Clientes1(); + break; + // Buscar + case 2: + Buscar_Cliente_Seccion_Compras(); + break; + // Flecha Abajo + case 3: + if(!SWAP_CLIEN) Mueve_Abajo_Clientes2(); + else Mueve_Abajo_Clientes1(); + break; + case 4: + if(SWAP_CLIEN) { EditCursorClientes_C(0); SWAP_CLIEN=0; }else SWAP_CLIEN=1; + EditCursorClientes_C(0); + break; + // Imprimir + case 5: + Imprimir_Clientes_C(); + break; + // Aadir + case 6: + if(!SWAP_CLIEN) + /*if( Confirma(" Dar de ALTA a un", "nuevo CLIENTE ?", "") )*/ + { AddRecordClientes_C(); } + + break; + // Borrar + case 7: + if(!SWAP_CLIEN) + if( Confirma("Desea eliminar la", "Compra Actual", "") ) + { Fuente(SMALL_FONT, 5); DeleteRecordClientes_C(); } + break; + // Repite Busqueda... + case 8: + if(Se_Puede_Buscar){ + CurrTopLine_Clien1++; + Comienzo_Busqueda = 1; + if( Sigue_Buscando_CB(Clientes1_Buscar) == ENCONTRADO ) { + PrintWholeScreenClientes1(); + GetLineClientes(); + { + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } + Acota_Contenido(); + PrintWholeScreenClientes2(); + GetLineClientes_Compras2(); + } + // + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PAR[11]); + setcolor(63); + sprintf(Buffer, "N de Contrato: % 4d Suma Total:", Clientes1.NContrato); + outtextxy(20, 431, Buffer); + // + + } else { + CurrTopLine_Clien1--; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, Comunes[7]); + GetLineClientes(); + + } + } + break; + // Salir + case 9: + finished = 1; + break; + default: + break; + } + EditCursorClientes_C(0); + } else CompruebaLineasClientes_C(); + + +}while(!finished); + +// rewind(Clientes_NC); + +fclose(Clientes); // Fichero Clientes +fclose(Clientes_NC); // Fichero Clientes +fclose(Clientes_C); // Fichero Clientes +fclose(Stock); +fclose(Ventas); +fclose(Vend); // Fichero Clientes +fclose(Ref); // Fichero Vendedores + + +if(Memory_ok==1) farfree(Addr); else free(Ref_inx_addr); +free(Vend_Dir); +free(PAR); + + +} + +void Mueve_Abajo_Clientes2(void){ + + int CurrRecord = CurrTopLine_Clien + CurrRow2_Clien - 1; + + if (CurrRow2_Clien==/*12*/11) { + if ( (CurrRecord - 1) >= Comp_Clien_Records - 1) BEEP(); + else { CurrTopLine_Clien++; + PrintWholeScreenClientes2(); + // + // + // + GetLineClientes_Compras2(); + // PrintLineClientes_C(1); + } + + } else { + + if( (CurrRecord - 1) >= Comp_Clien_Records -1) BEEP(); + else { CurrRow2_Clien++; + GetLineClientes_Compras2(); +// PrintLineClientes_C(1); + } + } + +} + +void Mueve_Ariba_Clientes2(void){ + int CurrRecord = CurrTopLine_Clien + CurrRow2_Clien - 1; + + if (CurrRow2_Clien==1) { + if ((CurrRecord - 1) <= 0) BEEP(); + else { + CurrTopLine_Clien--; + PrintWholeScreenClientes2(); + // + // + // + GetLineClientes_Compras2(); +// PrintLineClientes_C(1); + } + + } else { + if( (CurrRecord - 1) <= 0) BEEP(); + else { CurrRow2_Clien--; + GetLineClientes_Compras2(); +// PrintLineClientes_C(1); + } + } + +} +// +// +void Mueve_Abajo_Clientes1(void){ + + int CurrRecord = CurrTopLine_Clien1 + CurrRow1_Clien - 1; + char Buffer[80]; + + if (CurrRow1_Clien==11) { + if ( (CurrRecord - 1) >= Clientes1_inx.Fin) { BEEP(); return; } + else { +// CurrTopLine_Clien1++; + CurrRow1_Clien=1; + CurrTopLine_Clien1 += 11; + if ( (CurrTopLine_Clien1+CurrRow1_Clien) > Clientes1_inx.Fin) { CurrTopLine_Clien = Clientes1_inx.Fin; CurrRow1_Clien = 1; } + if (CurrTopLine_Clien1==0) CurrTopLine_Clien1 = 1; + + PrintWholeScreenClientes1(); + GetLineClientes(); + +// + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PAR[11]); + setcolor(63); + sprintf(Buffer, "N de Contrato: % 4d Suma Total:", Clientes1.NContrato); + outtextxy(20, 431, Buffer); +// +// PrintLineClientes_C(0); + } + + } else { + if( (CurrRecord - 1) >= (Clientes1_inx.Fin) ) { BEEP(); return; } + else { CurrRow1_Clien++; + GetLineClientes(); +// + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PAR[11]); + setcolor(63); + sprintf(Buffer, "N de Contrato: % 4d Suma Total:", Clientes1.NContrato); + outtextxy(20, 431, Buffer); +// +// PrintLineClientes_C(0); + } + } + + { + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } + Acota_Contenido(); + CurrTopLine_Clien = 1; + CurrRow2_Clien = 1; + PrintWholeScreenClientes2(); + GetLineClientes_Compras2(); +// PrintLineClientes_C(1); + } +} + + + + + + +void Mueve_Arriba_Clientes1(void){ + int CurrRecord = CurrTopLine_Clien1 + CurrRow1_Clien - 1; + char Buffer[80]; + + if (CurrRow1_Clien==1) { + if ((CurrRecord - 1) <= 0){ BEEP(); return; } + else { + +// CurrTopLine_Clien1--; + + if( CurrTopLine_Clien1 > 11 ) { CurrTopLine_Clien1 -= 11; } else { CurrTopLine_Clien1 = 1; } + if( CurrTopLine_Clien1 < 1 ) { CurrTopLine_Clien1 = 1; } + CurrRow1_Clien = 11; + while(CurrTopLine_Clien1 + CurrRow1_Clien - 1 >= Clientes1_inx.Fin ) CurrRow1_Clien--; + + + PrintWholeScreenClientes1(); + // + // + // + GetLineClientes(); +// + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PAR[11]); + setcolor(63); + sprintf(Buffer, "N de Contrato: % 4d Suma Total:", Clientes1.NContrato); + outtextxy(20, 431, Buffer); +// + +// PrintLineClientes_C(0); + } + + } else { + if( (CurrRecord - 1) <= 0){ BEEP(); return; } + else { CurrRow1_Clien--; + GetLineClientes(); +// + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PAR[11]); + setcolor(63); + sprintf(Buffer, "N de Contrato: % 4d Suma Total:", Clientes1.NContrato); + outtextxy(20, 431, Buffer); +// + + // PrintLineClientes_C(0); + } + } + { + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } + Acota_Contenido(); + CurrTopLine_Clien = 1; + CurrRow2_Clien = 1; + PrintWholeScreenClientes2(); + GetLineClientes_Compras2(); +// PrintLineClientes_C(1); + } +} + +void EditCursorClientes_C(int ShowHide) { +char Buffer[80]; + + setcolor(GRIS_C); + setfillstyle(SOLID_FILL, GRIS_C); + bar(10, 455, 545, 473); + +if(SWAP_CLIEN==1) { + if (!ShowHide) { + setcolor(63); + setfillstyle(SOLID_FILL, 63); + + bar((PAR[CurrCol1_Clien].left+2), PAR[CurrCol1_Clien].up+4+(CurrRow1_Clien-1)*15+2, PAR[CurrCol1_Clien].right-2, PAR[CurrCol1_Clien].up+/*4*/+((CurrRow1_Clien)-1)*15+16); + + setcolor(0); + } else { +// ImprimeBoton (0, GRIS_C, GRIS_O, BLANCO, PAR[CurrCol1_Clien/*-1*/]); + setcolor(0); + setfillstyle(SOLID_FILL, 0); + + bar((PAR[CurrCol1_Clien].left+2), PAR[CurrCol1_Clien].up+4+(CurrRow1_Clien-1)*15+2, PAR[CurrCol1_Clien].right-2, PAR[CurrCol1_Clien].up+/*4*/+((CurrRow1_Clien)-1)*15+16); + + Texto_Normal + } + + + switch(CurrCol1_Clien) { + case 1: outtextxy( PAR[1].left+2, PAR[1].up+2+(CurrRow1_Clien-1)*/*9*//*14*/15, Clientes1.Local ); + outtextxy( 15, 455, "Nombre del Local."); + break; + case 2: sprintf(Buffer, "%s %s", Clientes1.Nombre, Clientes1.Apellido1); + Buffer[15] = '\0'; + outtextxy( PAR[2].left+2, PAR[2].up+2+(CurrRow1_Clien-1)*/*9*//*14*/15, Buffer ); + outtextxy( 15, 455, "Nombre del Propietario."); + break; + case 3: sprintf(Buffer, "%12ld", Clientes1.Telefono2); + outtextxy( PAR[3].left+2, PAR[3].up+2+(CurrRow1_Clien-1)*/*9*//*14*/15, Buffer ); + outtextxy( 15, 455, "Telfono del Local."); + } +} else { + if (!ShowHide) { + setcolor(63); + setfillstyle(SOLID_FILL, 63); + bar((PAR[CurrCol2_Clien + 3].left+2), PAR[(CurrCol2_Clien)/*-1*/+3].up+4+(CurrRow2_Clien-1)*15+2, PAR[(CurrCol2_Clien)/*-1*/+3].right-2, PAR[(CurrCol2_Clien)/*-1*/+3].up+/*3*//*4*/+((CurrRow2_Clien)-1)*15+16); + setcolor(0); + } else { + setcolor(0); + setfillstyle(SOLID_FILL, 0); + bar((PAR[CurrCol2_Clien + 3].left+2), PAR[(CurrCol2_Clien)/*-1*/+3].up+4+(CurrRow2_Clien-1)*15+2, PAR[(CurrCol2_Clien)/*-1*/+3].right-2, PAR[(CurrCol2_Clien)/*-1*/+3].up+/*3*//*4*/+((CurrRow2_Clien)-1)*15+16); + Texto_Normal + } + + int Ref; + switch(CurrCol2_Clien){ + + case 1: + int day, mon; + day= Clientes2.Fecha.da_day; + mon= Clientes2.Fecha.da_mon; + sprintf(Buffer, "%02d/%02d/%02d", day, mon, Clientes2.Fecha.da_year ); + outtextxy( PAR[4].left+2, (PAR[4].up+3)+(CurrRow2_Clien-1)*15, Buffer ); + outtextxy( 15, 455, "Fecha. 6 digitos mximo."); + break; + case 2: + // 1 99 999 XXXX + Ref = ( Clientes2.Cod_Und_Vend_Ref - ((Clientes2.Cod_Und_Vend_Ref/10000)*10000) ); + sprintf(Buffer, " %04d", Ref); + outtextxy( PAR[5].left+2, (PAR[5].up+2)+(CurrRow2_Clien-1)*15, Buffer ); + outtextxy( 15, 455, "Referencia del Producto. 4 digitos mximo."); + break; + case 3: + outtextxy( PAR[6].left+2, (PAR[6].up+2)+(CurrRow2_Clien-1)*15, Ref1.Concepto ); + outtextxy( 15, 455, "Concepto. 15 digitos mximo."); + break; + case 4: + // 1 XX 999 9999 + Ref = ( ( Clientes2.Cod_Und_Vend_Ref/10000000L ) - ( ( (Clientes2.Cod_Und_Vend_Ref/10000000L)/100)*100 ) ); + sprintf(Buffer, "% 2d", Ref); + outtextxy( PAR[7].left+2, (PAR[7].up+2)+(CurrRow2_Clien-1)*15,Buffer ); + outtextxy( 15, 455, "Unidades. 2 digitos mximo."); + break; + case 5: + // 1 99 XXX 9999 + Ref = ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) - ( ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) / 1000) * 1000 ) ); + sprintf(Buffer, "% 2d", Ref); + outtextxy( PAR[8].left+2, (PAR[8].up+2)+(CurrRow2_Clien-1)*15,Buffer ); + outtextxy( 15, 455, "Vendedor. 3 digitos mximo."); + break; + case 6: + // X 99 999 9999 + Ref = ( Clientes2.Cod_Und_Vend_Ref/1000000000L ); + sprintf(Buffer, "% 2d", Ref); + outtextxy( PAR[9].left+2, (PAR[9].up+2)+(CurrRow2_Clien-1)*15,Buffer ); + outtextxy( 15, 455, "Cdigo. 1 digitos mximo."); + break; + case 7: + // TOTAL + long Total = ( ( Clientes2.Cod_Und_Vend_Ref/10000000L ) - ( ( (Clientes2.Cod_Und_Vend_Ref/10000000L)/100)*100 ) ); + sprintf(Buffer, "% 7ld", ( (Total*Ref1.PVP) + ( (Total*Ref1.PVP*Ref1.P2)/100) ) ); + outtextxy( PAR[10].left+2, (PAR[10].up+2)+(CurrRow2_Clien-1)*15,Buffer ); + outtextxy( 15, 455, "TOTAL A PAGAR + I.V.A. "); + break; + } + +} + +} + + + +void PrintLineClientes_C(int Rapida_Completa){ + +char Buffer[80]; + + if(!Rapida_Completa) { + // Completa + + setcolor(0); + setfillstyle(SOLID_FILL, 0); //// //// //// //// + for(int i=1; i<4; i++) + bar((PAR[i].left+2), PAR[i].up+4+(CurrRow1_Clien-1)*15+2, PAR[i].right-2, PAR[i].up+4+((CurrRow1_Clien)-1)*15+16); + + + Texto_Normal + outtextxy( PAR[1].left+2, PAR[1].up+2+(CurrRow1_Clien-1)*15, Clientes1.Local ); + sprintf(Buffer, "%s %s", Clientes1.Nombre, Clientes1.Apellido1); + Buffer[15] = '\0'; + outtextxy( PAR[2].left+2, PAR[2].up+2+(CurrRow1_Clien-1)*15, Buffer ); + sprintf(Buffer, "%12ld", Clientes1.Telefono2); + outtextxy( PAR[3].left+2, PAR[3].up+2+(CurrRow1_Clien-1)*15, Buffer ); + + } else { + setcolor(0); + setfillstyle(SOLID_FILL, 0); //// //// //// //// + for(int i=4; i<11; i++) + bar((PAR[i].left+2), PAR[i].up+4+(CurrRow2_Clien-1)*15+2, PAR[i].right-2, PAR[i].up+4+((CurrRow2_Clien)-1)*15+16); + + Texto_Normal + int day, mon; + day= Clientes2.Fecha.da_day; + mon= Clientes2.Fecha.da_mon; + sprintf(Buffer, "%02d/%02d/%02d", day, mon, Clientes2.Fecha.da_year ); + outtextxy( PAR[4].left+2, (PAR[4].up+3)+(CurrRow2_Clien-1)*15, Buffer ); + // 1 99 999 XXXX + int Ref = ( Clientes2.Cod_Und_Vend_Ref - ((Clientes2.Cod_Und_Vend_Ref/10000)*10000) ); + sprintf(Buffer, " %04d", Ref); + outtextxy( PAR[5].left+2, (PAR[5].up+2)+(CurrRow2_Clien-1)*15, Buffer ); + outtextxy( PAR[6].left+2, (PAR[6].up+2)+(CurrRow2_Clien-1)*15, Ref1.Concepto ); + // 1 XX 999 9999 + Ref = ( ( Clientes2.Cod_Und_Vend_Ref/10000000L ) - ( ( (Clientes2.Cod_Und_Vend_Ref/10000000L)/100)*100 ) ); + sprintf(Buffer, "% 2d", Ref); + outtextxy( PAR[7].left+2, (PAR[7].up+2)+(CurrRow2_Clien-1)*15,Buffer ); + // 1 99 XXX 9999 + Ref = ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) - ( ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) / 1000) * 1000 ) ); + sprintf(Buffer, "% 2d", Ref); + outtextxy( PAR[8].left+2, (PAR[8].up+2)+(CurrRow2_Clien-1)*15,Buffer ); + // X 99 999 9999 + Ref = ( Clientes2.Cod_Und_Vend_Ref/1000000000L ); + sprintf(Buffer, "% 2d", Ref); + outtextxy( PAR[9].left+2, (PAR[9].up+2)+(CurrRow2_Clien-1)*15,Buffer ); + long Total = ( ( Clientes2.Cod_Und_Vend_Ref/10000000L ) - ( ( (Clientes2.Cod_Und_Vend_Ref/10000000L)/100)*100 ) ); + sprintf(Buffer, "% 7ld", ( (Total*Ref1.PVP) + ( (Total*Ref1.PVP*Ref1.P2)/100) ) ); + outtextxy( PAR[10].left+2, (PAR[10].up+2)+(CurrRow2_Clien-1)*15,Buffer); + + } + + +} + +void PrintWholeScreenClientes2(void){ + +int tmp = CurrRow2_Clien; + +for(int i=4; i<=10; i++) + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PAR[i]); + + + for(CurrRow2_Clien = 1; CurrRow2_Clien < 11+1; CurrRow2_Clien++) +// + if ( (/*Start_Comp_Clien + */CurrTopLine_Clien + CurrRow2_Clien - 1 /*- 1*/) <= Comp_Clien_Records ){ + GetLineClientes_Compras2(); +// + PrintLineClientes_C(1); + } + + + +CurrRow2_Clien = tmp; + +} + +void PrintWholeScreenClientes1(void){ + +int tmp = CurrRow1_Clien; + +for(int i=1; i<4; i++) + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PAR[i]); + + + for(CurrRow1_Clien = 1; CurrRow1_Clien < (/*12*/11+1); CurrRow1_Clien++) + + if ( (CurrTopLine_Clien1 + CurrRow1_Clien - 1 - 1) <= Clientes1_inx.Fin){ + GetLineClientes(); + PrintLineClientes_C(0); + } + +CurrRow1_Clien = tmp; + +} + +void Edit_Item_Clientes_C(void){ +char Buffer[80]; +long Fcha; +int Cod_b, Ref_b, Und_b, Vend_b; + +if(SWAP_CLIEN){ + while( kbhit() ) getch(); +} else { + switch (CurrCol2_Clien) { + case 1: + int day/*, mon*/; + day= Clientes2.Fecha.da_day; +// mon= Clientes2.Fecha.da_mon; +// sprintf(Buffer, "%02d%02d%02d", day, mon, Clientes2.Fecha.da_year ); + sprintf(Buffer, "%d", day ); + do{ + InputCadenaG_l( Buffer, 1, 2/*6*/, 63, 57, PAR[4], CurrRow2_Clien-1); + Fcha = atol(Buffer); + Clientes2.Fecha.da_day =Fcha; +// Clientes2.Fecha.da_day = (Fcha/10000); +// Clientes2.Fecha.da_mon = (Fcha/100) - ((Clientes2.Fecha.da_day) * 100); +// Clientes2.Fecha.da_year = Fcha - ( (Clientes2.Fecha.da_day*10000) + (Clientes2.Fecha.da_mon*100) ); + }while( ( Clientes2.Fecha.da_day<1 || Clientes2.Fecha.da_day>31 ) ); +// }while( ( Clientes2.Fecha.da_day<1 || Clientes2.Fecha.da_day>31 ) || (Clientes2.Fecha.da_mon!=Fecha ) || strlen(Buffer)!=6 ); + + break; + case 2: + // 1 99 999 XXXX + int Ref = ( Clientes2.Cod_Und_Vend_Ref - ((Clientes2.Cod_Und_Vend_Ref/10000)*10000) ); + sprintf(Buffer, "%d", Ref); + do{ + InputCadenaG_l( Buffer, 1, 4, 63, 57, PAR[5], CurrRow2_Clien-1); + + Ref_b = atoi(Buffer); + }while( ( !Existe_Referencia( Ref_b ) || Ref_b == 0 ) && Ref_b != Ref ); + // Este que viene ahora es un proceso crtico, la + // unin de los distintos registros en uno solo. + Cod_b = ( Clientes2.Cod_Und_Vend_Ref/1000000000 ); +// Ref_b = atoi(Buffer); + Und_b = ( ( Clientes2.Cod_Und_Vend_Ref/10000000 ) - ( ( (Clientes2.Cod_Und_Vend_Ref/10000000)/100)*100 ) ); + Vend_b = ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) - ( ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) / 1000) * 1000 ) ); + + Clientes2.Cod_Und_Vend_Ref = ( Cod_b * 1000000000 ) + + ( Und_b * 10000000 ) + + ( Vend_b * 10000 ) + + ( Ref_b ) ; + + if(Ref != Ref_b) { + /*if(!Ref_no_valid)*/ Actualizar_Stock( Ref, Und_b, Cod_b ); + /*if(!Ref_no_valid)*/ Actualizar_Stock( Ref_b, (-1)*Und_b, Cod_b ); + + Actualizar_Ventas( Ref, (-1)*Und_b, Cod_b ); + Actualizar_Ventas( Ref_b, Und_b, Cod_b ); + + } + break; + case 3: +/* + outtextxy( PAR[2].left+2, (PAR[2].up+2)+(CurrRow2_Clien-1)*12, Ref1.Concepto ); + outtextxy( 15, 455, "Concepto. 15 digitos mximo."); +*/ while( kbhit() ) getch(); + break; + case 4: + // 1 XX 999 9999 + int Und = ( ( Clientes2.Cod_Und_Vend_Ref/10000000 ) - ( ( (Clientes2.Cod_Und_Vend_Ref/10000000)/100)*100 ) ); + sprintf(Buffer, "%d", Und); + InputCadenaG_l( Buffer, 1, 2, 63, 57, PAR[7], CurrRow2_Clien-1); + // Este que viene ahora es un proceso crtico, la + // unin de los distintos registros en uno solo. + Cod_b = ( Clientes2.Cod_Und_Vend_Ref/1000000000 ); + Ref_b = ( Clientes2.Cod_Und_Vend_Ref - ((Clientes2.Cod_Und_Vend_Ref/10000)*10000) ); + Und_b = atoi(Buffer); + Vend_b = ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) - ( ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) / 1000) * 1000 ) ); + Clientes2.Cod_Und_Vend_Ref = ( Cod_b * 1000000000 ) + + ( Und_b * 10000000 ) + + ( Vend_b * 10000 ) + + ( Ref_b ) ; + if(Und != Und_b) { + Actualizar_Stock( Ref_b, (-1)*( Und_b - Und), Cod_b ); + + Actualizar_Ventas( Ref_b, ( Und_b - Und), Cod_b ); + } + + + break; + case 5: + int Vend = ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) - ( ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) / 1000) * 1000 ) ); + sprintf(Buffer, "%d", Vend); + do{ + InputCadenaG_l( Buffer, 1, 3, 63, 57, PAR[8], CurrRow2_Clien-1); + }while( Vend_Dir[atoi(Buffer)]==-1 ); + + Cod_b = ( Clientes2.Cod_Und_Vend_Ref/1000000000 ); + Ref_b = ( Clientes2.Cod_Und_Vend_Ref - ((Clientes2.Cod_Und_Vend_Ref/10000)*10000) ); + Und_b = ( ( Clientes2.Cod_Und_Vend_Ref/10000000 ) - ( ( (Clientes2.Cod_Und_Vend_Ref/10000000)/100)*100 ) ); + Vend_b = atoi(Buffer); + Clientes2.Cod_Und_Vend_Ref = ( Cod_b * 1000000000 ) + + ( Und_b * 10000000 ) + + ( Vend_b * 10000 ) + + ( Ref_b ) ; + break; + case 6: + // X 99 999 9999 + int Cod = ( Clientes2.Cod_Und_Vend_Ref/1000000000 ); + sprintf( Buffer, "%d", Cod); + ungetch(8); + InputCadenaG_l( Buffer, 1, 1, 63, 57, PAR[9], CurrRow2_Clien-1); + + Cod_b = (char)atoi(Buffer); + Ref_b = ( Clientes2.Cod_Und_Vend_Ref - ((Clientes2.Cod_Und_Vend_Ref/10000)*10000) ); + Und_b = ( ( Clientes2.Cod_Und_Vend_Ref/10000000 ) - ( ( (Clientes2.Cod_Und_Vend_Ref/10000000)/100)*100 ) ); + Vend_b = ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) - ( ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) / 1000) * 1000 ) ); + Clientes2.Cod_Und_Vend_Ref = ( Cod_b * 1000000000 ) + + ( Und_b * 10000000 ) + + ( Vend_b * 10000 ) + + ( Ref_b ) ; + + if(Cod != Cod_b) { + Actualizar_Stock( Ref_b, (Und_b), Cod); + Actualizar_Stock( Ref_b, (-1)*Und_b, Cod_b); + + Actualizar_Ventas( Ref_b, (-1)*(Und_b), Cod); + Actualizar_Ventas( Ref_b, Und_b, Cod_b); + + } + break; + default: while( kbhit() ) getch(); return; + } + + PutLineClientes_Compras2(); + /**/ + /**/ GetLineClientes_Compras2(); /**/ + /**/ + PrintLineClientes_C(1); + +} + +} + +void Actualiza_Direccion_Compras(int which){ + + int i, LSC =sizeof(struct Clientes_inx_NContrato); + + if ( which == SOLO_ESTA ) { + + fseek(Clientes_NC, (long)LSC*(Clientes1.Address), SEEK_SET); + fwrite(&Clientes1_inx_NContrato, LSC,1, Clientes_NC); + + } + + if ( which == DESDE_CONTRATO_ACTUAL ) { + + for ( i = (Clientes1.Address+1); i <= (Clientes1.Address/100)+99; i++ ){ + + fseek(Clientes_NC, (long)LSC*( i ), SEEK_SET); + fread(&Clientes1_inx_NContrato, LSC, 1, Clientes_NC); + + Clientes1_inx_NContrato.Inicio++ ; + + fseek(Clientes_NC, (long)LSC*( i ), SEEK_SET); + fwrite(&Clientes1_inx_NContrato, LSC, 1, Clientes_NC); + + + } + + + } + // Restauramos las direcciones. + fseek(Clientes_NC, (long)sizeof(struct Clientes_inx_NContrato)*(Clientes1.Address), SEEK_SET); + fread(&Clientes1_inx_NContrato, sizeof(struct Clientes_inx_NContrato),1, Clientes_NC); + + + +} + +int Obten_Direccion_Compras(int which){ + + int devolver = -1; + + if ( which == FINAL ) { + + fseek(Clientes_NC, (long)sizeof(struct Clientes_inx_NContrato)*( (Clientes1.Address/100)+99 ), SEEK_SET); + fread(&Clientes1_inx_NContrato, sizeof(struct Clientes_inx_NContrato),1, Clientes_NC); + + devolver = Clientes1_inx_NContrato.Inicio + Clientes1_inx_NContrato.Records - 1; + + } + + // Restauramos las direcciones. + fseek(Clientes_NC, (long)sizeof(struct Clientes_inx_NContrato)*(Clientes1.Address), SEEK_SET); + fread(&Clientes1_inx_NContrato, sizeof(struct Clientes_inx_NContrato),1, Clientes_NC); + + return devolver; + +} +//۲۲۲۲۲۲۲۲۲۲ + +void DeleteRecordClientes_C(void) { + +unsigned int CurrRecord; + + int LSC = sizeof(struct Clientes_compras); + +CurrRecord = CurrTopLine_Clien + CurrRow2_Clien - 1; + + if ( Comp_Clien_Records == 1 ) BEEP(); else { + + Clientes1_inx_NContrato.Records -= 1; + Comp_Clien_Records--; + + Actualiza_Direccion_Compras(SOLO_ESTA); + + int Ref = ( Clientes2.Cod_Und_Vend_Ref - ((Clientes2.Cod_Und_Vend_Ref/10000)*10000) ); + int Cod = ( Clientes2.Cod_Und_Vend_Ref/1000000000 ); + int Und = ( ( Clientes2.Cod_Und_Vend_Ref/10000000 ) - ( ( (Clientes2.Cod_Und_Vend_Ref/10000000)/100)*100 ) ); +// int Vend = ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) - ( ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) / 1000) * 1000 ) ); + + Actualizar_Ventas( Ref, (-1)*Und, Cod ); + Actualizar_Stock( Ref, Und, Cod ); + + unsigned int p = + CurrRecord + + Clientes1_inx_NContrato.Inicio + + Start_Comp_Clien - 1; + + while( p <= ( Clientes1_inx_NContrato.Inicio + Clientes1_inx_NContrato.Records - 1) ) { + + fseek(Clientes_C, (long)( LSC * ( p + 1 ) ), SEEK_SET); + fread(&Clientes2, LSC, 1, Clientes_C); + + fseek(Clientes_C, (long)( LSC * p ), SEEK_SET); + fwrite(&Clientes2, LSC, 1, Clientes_C); + + p++; + }; + + PrintWholeScreenClientes2(); + if ( (CurrRecord - 1) == Comp_Clien_Records) CurrRow2_Clien--; + GetLineClientes_Compras2(); + // PrintLineClientes_C(0); + } +} + + + +void AddRecordClientes_C(void){ + + int LSC = sizeof(struct Clientes_compras); + + int CurrRecord = CurrTopLine_Clien + CurrRow2_Clien - 1; + +if(CurrRecord < 80 ) { + + long avance = Obten_Direccion_Compras(FINAL) + 1; + + while( avance >= (CurrRecord + + Clientes1_inx_NContrato.Inicio + + Start_Comp_Clien ) ) + { + + fseek(Clientes_C, (long)( LSC * avance ), SEEK_SET); + fread(&Clientes2, LSC, 1, Clientes_C); + + fseek(Clientes_C, (long)( LSC * (avance + 1) ), SEEK_SET); + fwrite(&Clientes2, LSC, 1, Clientes_C); + + avance--; + }; + + Clientes1_inx_NContrato.Records ++; + Comp_Clien_Records++; + Actualiza_Direccion_Compras(SOLO_ESTA); + Actualiza_Direccion_Compras(DESDE_CONTRATO_ACTUAL); + + Clientes2.Fecha.da_day = 0; + Clientes2.Fecha.da_mon = Fecha; + Clientes2.Cod_Und_Vend_Ref = 1000000000; + + fseek(Clientes_C, (long)( LSC * ( CurrTopLine_Clien + CurrRow2_Clien + Start_Comp_Clien + + Clientes1_inx_NContrato.Inicio - 1) ), SEEK_SET); + fwrite(&Clientes2, LSC, 1, Clientes_C); + + CurrRow2_Clien++; + if (CurrRow2_Clien>15) { CurrTopLine_Clien++; CurrRow2_Clien--; } + PrintWholeScreenClientes2(); + GetLineClientes_Compras2(); + //PrintLineClientes_C(0); + + } + +} + + + +void GetLineClientes_Compras2(void){ + + int LSC = sizeof(struct Clientes_compras); + +long CurrRecord = + CurrTopLine_Clien + + CurrRow2_Clien - 1 + + Clientes1_inx_NContrato.Inicio + + Start_Comp_Clien; + +fseek(Clientes_C, (long)( LSC * CurrRecord ) - LSC, SEEK_SET); // Se coloca +fread(&Clientes2, LSC, 1, Clientes_C); // Y lee + +BuscaReferencia(( Clientes2.Cod_Und_Vend_Ref - ((Clientes2.Cod_Und_Vend_Ref/10000)*10000) )); + +} + + +void PutLineClientes_Compras2(void){ + + int LSC = sizeof(struct Clientes_compras); + +long CurrRecord = + CurrTopLine_Clien + + CurrRow2_Clien - 1 + + Clientes1_inx_NContrato.Inicio + + Start_Comp_Clien; + +fseek(Clientes_C, (long)( LSC * CurrRecord ) - LSC, SEEK_SET); // Se coloca +fwrite(&Clientes2, LSC, 1, Clientes_C); // Y lee + +} + + + +void Imprimir_Clientes_C(void){ + +int Where_Ask = 1; +int fins_print= 0, key_print, bpush; + +void far *ptr; +unsigned size; +struct boton pregunta[3]; + +size = imagesize(198, 138, 372, 257); + +/* get byte size of image */ + +if ( (ptr = farmalloc(size)) != NULL) { + getimage(198, 138, 372, 257, ptr); + + pregunta[0].up = 140; pregunta[0].down = 255; + pregunta[0].left= 200; pregunta[0].right= 370; + ImprimeBoton (1, ROJO, GRIS_C, BLANCO, pregunta[0]); + pregunta[0].up = 150; pregunta[0].down = 175; + pregunta[0].left= 210; pregunta[0].right= 360; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[0]); + pregunta[1].up = 185; pregunta[1].down = 210; + pregunta[1].left= 210; pregunta[1].right= 360; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[1]); + pregunta[2].up = 220; pregunta[2].down = 245; + pregunta[2].left= 210; pregunta[2].right= 360; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[2]); + Fuente(SMALL_FONT, 4); +} else { + Where_Ask = 0; + pregunta[0].up = 450; pregunta[0].down = 475; + pregunta[0].left= 5; pregunta[0].right= 152; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[0]); + pregunta[1].up = 450; pregunta[1].down = 475; + pregunta[1].left= 155; pregunta[1].right= 309; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[1]); + pregunta[2].up = 450; pregunta[2].down = 475; + pregunta[2].left= 312; pregunta[2].right= 549; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[2]); + Fuente(SMALL_FONT, 4); +} + +Letra_Boton +outtextxy(pregunta[0].left+2, pregunta[0].up+2, "F3 Factura Cliente"); +outtextxy(pregunta[1].left+2, pregunta[1].up+2, "F2 Factura Empresa"); +outtextxy(pregunta[2].left+2, pregunta[2].up+2, "F1 CANCELAR IMPRESION"); + +// +do{ + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + if(kbhit()){ + key_print = getch(); + if( key_print == 0 ) { + switch( (key_print=getch()) ){ + // F1 Cancelar + case 59: + fins_print = 1; + break; + // F3 Imprimir Ficha + case 61: + if(Where_Ask){ + pregunta[0].up = 140; pregunta[0].down = 255; + pregunta[0].left= 200; pregunta[0].right= 370; + } else { + pregunta[0].up = 450; pregunta[0].down = 475; + pregunta[0].left= 5; pregunta[0].right= 549; + } + ImprimeBoton (1, GRIS_O, GRIS_C, BLANCO, pregunta[0]); + + // + if(Comprueba_Impresora()) { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Imprimiendo."); + outtextxy(210,170, "Por Favor, espere..."); + } else outtextxy(10,452, "Imprimiendo. Por Favor, espere..."); + Imprime_Factura_C(Para_Cliente); + } else { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Impresora no preparada."); + outtextxy(210,170, "Impresion Cancelada"); + } else { outtextxy(10,452, "Impresora no preparada. Impresin Cancelada."); } + Espera_Tecla_o_Raton(); + } + fins_print = 1; + + // + break; + // F2 Imprimir lista rpida + case 60: + if(Where_Ask){ + pregunta[0].up = 140; pregunta[0].down = 255; + pregunta[0].left= 200; pregunta[0].right= 370; + } else { + pregunta[0].up = 450; pregunta[0].down = 475; + pregunta[0].left= 5; pregunta[0].right= 549; + } + ImprimeBoton (1, GRIS_O, GRIS_C, BLANCO, pregunta[0]); + + // + if(Comprueba_Impresora()) { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Imprimiendo."); + outtextxy(210,170, "Por Favor, espere..."); + } else outtextxy(10,452, "Imprimiendo. Por Favor, espere..."); + Imprime_Factura_C(Para_Empresa); + } else { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Impresora no preparada."); + outtextxy(210,170, "Impresion Cancelada"); + } else { outtextxy(10,452, "Impresora no preparada. Impresin Cancelada."); } + Espera_Tecla_o_Raton(); + } + fins_print = 1; + + // + break; + default: + fins_print = 1; + } + } + } else + if(raton!=0 && boton_izq==1 || boton_der==1) { + if( (bpush = CheckButon( 3, pregunta))>0 ) { + + if(Where_Ask){ + pregunta[0].up = 140; pregunta[0].down = 255; + pregunta[0].left= 200; pregunta[0].right= 370; + } else { + pregunta[0].up = 450; pregunta[0].down = 475; + pregunta[0].left= 5; pregunta[0].right= 549; + } + ImprimeBoton (1, GRIS_O, GRIS_C, BLANCO, pregunta[0]); + + switch(bpush){ + // Imprimir Ficha + case 1: + // + if(Comprueba_Impresora()) { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Imprimiendo."); + outtextxy(210,170, "Por Favor, espere..."); + } else outtextxy(10,452, "Imprimiendo. Por Favor, espere..."); + Imprime_Factura_C(Para_Cliente); + } else { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Impresora no preparada."); + outtextxy(210,170, "Impresion Cancelada"); + } else { outtextxy(10,452, "Impresora no preparada. Impresin Cancelada."); } + Espera_Tecla_o_Raton(); + } + fins_print = 1; + // + + break; + // Imprime Lista Rpida + case 2: + // + if(Comprueba_Impresora()) { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Imprimiendo."); + outtextxy(210,170, "Por Favor, espere..."); + } else outtextxy(10,452, "Imprimiendo. Por Favor, espere..."); + Imprime_Factura_C(Para_Empresa); + } else { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Impresora no preparada."); + outtextxy(210,170, "Impresion Cancelada"); + } else { outtextxy(10,452, "Impresora no preparada. Impresin Cancelada."); } + Espera_Tecla_o_Raton(); + } + fins_print = 1; + + // + break; + // Cancelar + case 3: + fins_print=1; + break; + default: + fins_print = 1; + } + } + } + + +}while(!fins_print); + +// + + if(Where_Ask == 1) { + putimage(198, 138, ptr, COPY_PUT); + farfree(ptr); + } else { + struct boton help; + help.up = 450; help.down = 475; + help.left = 5; help.right = 549; + ImprimeBoton (1, GRIS_C, GRIS_O, BLANCO, help); + } + + Fuente(SMALL_FONT, 5); +} + +void Imprime_Factura_C(int Para_quien){ + char Buffer[80]; + int old_CurrRow2, old_CurrTopLine; + int day, mon, Ref, Und, Cod, Vend; + unsigned long Suma_Total = 0, Suma_IVA = 0, Total; + + old_CurrRow2 = CurrRow2_Clien; + old_CurrTopLine = CurrTopLine_Clien; + CurrTopLine_Clien = 1; + + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "FACTURA PROTOTIPO N1JD(SV0001)\n\r"); + fprintf( stdprn, "MENSAJE 001\n\r"); + fprintf( stdprn, "DIRECCIN 001\n\r"); + fprintf( stdprn, "TELFONO 001, 002\n\r"); + fprintf( stdprn, "MENSAJE 002\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, " Cliente: %03d", (Clientes1.CP-((Clientes1.CP/1000)*1000)) ); + fprintf( stdprn, "."); + fprintf( stdprn, "%04d\n\r", Clientes1.NContrato); + fprintf( stdprn, " %s\n\r",Clientes1.Local); + fprintf( stdprn, " %s %s, %s\n\r", Clientes1.Apellido1, Clientes1.Apellido2, Clientes1.Nombre); + fprintf( stdprn, " %s, n %s\n\r", Clientes1.Calle2, Clientes1.Num2); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "Ŀ\n\r"); + fprintf( stdprn, " Fecha Ref/C Producto IVA Und P.V.P Total | Vend \n\r"); + + for(CurrRow2_Clien = 1; (CurrTopLine_Clien + CurrRow2_Clien - 1) <= Comp_Clien_Records; CurrRow2_Clien++) { + + GetLineClientes_Compras2(); + + // fprintf( stdprn, " | \n\r"); + + // X 99 999 9999 + Cod = ( Clientes2.Cod_Und_Vend_Ref/1000000000L ); + + day= Clientes2.Fecha.da_day; + mon= Clientes2.Fecha.da_mon; + sprintf(Buffer, "%02d/%02d/%02d", day, mon, Clientes2.Fecha.da_year ); + // 1 99 999 XXXX + Ref = ( Clientes2.Cod_Und_Vend_Ref - ((Clientes2.Cod_Und_Vend_Ref/10000)*10000) ); + // 1 XX 999 9999 + Und = ( ( Clientes2.Cod_Und_Vend_Ref/10000000L ) - ( ( (Clientes2.Cod_Und_Vend_Ref/10000000L)/100)*100 ) ); + // 1 99 XXX 9999 + Vend = ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) - ( ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) / 1000) * 1000 ) ); + + Total = Und * Ref1.PVP; + + if( Cod == 0 && Para_quien == Para_Empresa ) { + fprintf( stdprn, "Ĵ\n\r"); +// fprintf( stdprn, " % 6s % 4d%1d %-20s % 3d % 2d % 5d % 7ld | % 3d \n\r", Buffer, Ref, Cod, Ref1.Concepto, Ref1.P2, Und, Ref1.PVP, Total, Vend); + fprintf( stdprn, " % 6s % 4d%1d %-20s % 3d % 2d % 5d ", Buffer, Ref, Cod, Ref1.Concepto, Ref1.P2, Und, Ref1.PVP); + fprintf( stdprn, " % 7ld | % 3d \n\r", Total, Vend); + Suma_Total += Total; + Suma_IVA += ( (Total * Ref1.P2) / 100 ); + + } + if( Cod != 0 ) { + fprintf( stdprn, "Ĵ\n\r"); +// fprintf( stdprn, " % 6s % 4d%1d %-20s % 3d % 2d % 5d % 7ld | % 3d \n\r", Buffer, Ref, Cod, Ref1.Concepto, Ref1.P2, Und, Ref1.PVP, Total, Vend); + fprintf( stdprn, " % 6s % 4d%1d %-20s % 3d % 2d % 5d ", Buffer, Ref, Cod, Ref1.Concepto, Ref1.P2, Und, Ref1.PVP); + fprintf( stdprn, " % 7ld | % 3d \n\r", Total, Vend); + + Suma_Total += Total; + Suma_IVA += ( (Total * Ref1.P2) / 100 ); + } + + if (Usa_Pc == 1) + pieslice(400, 265, (( ( 360 * ( ( CurrRow2_Clien * 100 ) / Comp_Clien_Records ) ) / 100 ) - 1), 0, 38); + + + } + + fprintf( stdprn, "Ĵ\n\r"); + fprintf( stdprn, " Suma Total %13ld \n\r", Suma_Total ) ; + fprintf( stdprn, " + I.V.A. %13ld \n\r", Suma_IVA ) ; + fprintf( stdprn, " Ĵ\n\r") ; + fprintf( stdprn, " TOTAL %13ld \n\r", (Suma_Total + Suma_IVA) ) ; + fprintf( stdprn, " \n\r") ; + + + fputc(12, stdprn); + + CurrRow2_Clien = old_CurrRow2; + CurrTopLine_Clien = old_CurrTopLine; + GetLineClientes_Compras2(); + Fuente(SMALL_FONT, 5); + +} + + +void CompruebaLineasClientes_C(void){ +/* // Check una pulsacion sobre un campo, y se situa, si es posible + int inc=0; + + if( (inc = CheckButon_S(10, 4, PAR))>0 && (inc <=23) ) { EditCursorClientes_C(1); CurrCol1_Clien = (inc); } +*/ +} + +// +// +// Esta funcin, que debe ser llamada antes de cada obtencin de datos +// de Compras, devolvera las acotaciones necesarias, para el mes actual +// dentro de la ficha respectiva. Si no existe ese mes en cuestin se +// aadir, ya indexado al fichero. +// +// Reestructuracin de la gestin interna del archivo de compras para +// una mayor facilidad en su gestin... +// +// +void Acota_Contenido(void){ + +int Avance = 0, ok = 0; +int LSC = sizeof(struct Clientes_compras); long CurrRecord; + +//Start_Comp_Clien = -1; +Comp_Clien_Records = 0; +// Ahora se buscar que el mes, coincida con el mes elegido para la +// transaccin, guardando la direccin del mes mas cercano. + + fseek(Clientes_NC, (long)sizeof(struct Clientes_inx_NContrato)*(Clientes1.Address), SEEK_SET); + fread(&Clientes1_inx_NContrato, sizeof(struct Clientes_inx_NContrato),1, Clientes_NC); +/* +if(Clientes1_inx_NContrato.Records < 12){ + fseek(Clientes_NC, (long)sizeof(struct Clientes_inx_NContrato)*(Clientes1.Address), SEEK_SET); + fwrite(&Clientes1_inx_NContrato, sizeof(struct Clientes_inx_NContrato),1, Clientes_NC); +} +*/ + while(Avance < Clientes1_inx_NContrato.Records ){ + + CurrRecord = Clientes1_inx_NContrato.Inicio + Avance + 1; + + fseek(Clientes_C, (long)( LSC * CurrRecord ) - LSC, SEEK_SET); // Se coloca + fread(&Clientes2, LSC, 1, Clientes_C); // Y lee + + if( Clientes2.Fecha.da_mon == Fecha ) + { + if( ok == 0) Start_Comp_Clien = Avance; + Comp_Clien_Records++; + ok = 1; + } + Avance++; + } + + // Si no se encuentra el mes buscado, + + if( ok == 1 ) return; else + { + Confirma("Error en direccionamiento","el archivo COMPRAS","debe estar corrupto."); + restorecrtmode(); + exit(2); + } + +} + + +int Viable_Apertura(void){ + + + if( !file_exists("Clientes.DAT") || !file_exists("C_INDICE.DAT") ){ + Confirma("Antes de iniciar el", "mantenimiento debe", "existir algun cliente" ); + return (0); + } + + return (1); +} + + +void Imprime_Todas_Facturas(int Para_quien, int Current_Date){ + + Fecha = Current_Date; + + int tmp = CurrRow1_Clien, Ptotal; + Usa_Pc = 1; + + oldCNI = -1; + + setcolor(4); + setfillstyle(SOLID_FILL, 60); + + if( !Viable_Apertura() ) return ; + + Abre_Ficha_Clientes(); + Abre_Ficha_Clientes_Ncontrato(); + + Abre_Ficha_Referencias(); + Carga_Referencias(); + + if( ( Vend_Dir = (int *) malloc( sizeof(int)*1024 ) ) == NULL ) + { + Confirma("Memoria insuficiente", "para crear tablas para", "Vend_Dir"); + return ; + } + Abre_Ficha_Vendedores(); + Carga_Todos_los_Vendedores(); + + + CurrRow1_Clien = 1; + CurrTopLine_Clien1 = 1; + GetLineClientes(); + Abre_Ficha_Clientes_Compras(); + + for(CurrRow1_Clien = 1; CurrRow1_Clien <= ( Clientes1_inx.Fin + 1); CurrRow1_Clien++){ + + GetLineClientes(); + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } + Acota_Contenido(); + +// Porcentaje(); + + Displayado_de_Datos(Para_quien); + + setcolor(4); + setfillstyle(SOLID_FILL, 60); + Imprime_Factura_C(Para_quien); +// Calculamos el porcentaje total realizado +// Si todo es el: ( Clientes1_inx.Fin + 1 ) es decir 100 % +// CurrRow1_Clien el el X % +// X = ( CurrRow1_Clien * 100 ) / ( Clientes1_inx.Fin + 1 ) + +// Si 285 es el 100 % +// x es el X anterior +// x = ( 285 * X ) / 100 + Ptotal = ( ( 283 * ( ( CurrRow1_Clien * 100 ) / ( Clientes1_inx.Fin + 1 ) ) ) / 100 ); + bar(167, 172, 167 + Ptotal, 182 ); + + Prepara_Porcentaje_Circular(); + + } + +CurrRow1_Clien = tmp; + +fclose(Clientes); // Fichero Clientes +fclose(Clientes_NC); // Fichero Clientes +fclose(Clientes_C); // Fichero Clientes +fclose(Ref); // Fichero Vendedores + + +if(Memory_ok==1) farfree(Addr); else free(Ref_inx_addr); +free(Vend_Dir); + +Usa_Pc = 0; +} + +void Displayado_de_Datos(int Para_quien){ + char Buffer[80]; + char mes[][11] = { " Enero", "Febrero", " Marzo", + " Abril", " Mayo", " Junio", + " Julio", " Agosto", "Septiemb", + "Octubre", "Noviemb", "Diciemb" + }; +struct boton TMP; +TMP.up = 320; TMP.down = 380; +TMP.left = 165; TMP.right = 450; + + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, TMP); + +// Check[4].up = 290; Check[4].down = 310; +// Check[4].left = 260; Check[4].right = 350; +setcolor(4); +if(Para_quien==Para_Cliente) + sprintf( Buffer, "Imprimiendo mes: %s, para Cliente", mes[Fecha-1] ); +else if(Para_quien==Para_Empresa) + sprintf( Buffer, "Imprimiendo mes: %s, para Empresa", mes[Fecha-1] ); +else if(Para_quien==5) + sprintf( Buffer, "Buscando en %s, Los 12 mejores Clientes", mes[Fecha-1] ); + + + outtextxy(167, 322, Buffer); + + sprintf( Buffer, "Contrato n % 4d, y % 2d compras." , Clientes1.NContrato, Comp_Clien_Records); + outtextxy(167, 337, Buffer); + + sprintf( Buffer, "> %s" , Clientes1.Local); + outtextxy(/*262*/167, 352, Buffer); + +} + + +void Buscar_Cliente_Seccion_Compras(void){ + +struct boton *b_cc; +char Buffer[80]; + + int TFuente, f_busqueda = 0, Columna=1, key; + struct textsettingstype textinfo; + gettextsettings(&textinfo); + TFuente = textinfo.charsize; + void far *ptr; + unsigned size; + int Encontrado = 0; + + size = imagesize(47, 224, 593, 271); + + + Clientes1_Buscar.NContrato = -1; + strcpy(Clientes1_Buscar.Local, "\0"); + strcpy(Clientes1_Buscar.Nombre, "\0"); strcpy(Clientes1_Buscar.Apellido1, "\0"); + Clientes1_Buscar.Telefono2 = -1; + + + if( (b_cc = (struct boton *)calloc( 10, sizeof( struct boton ) ) ) == NULL ) { + Confirma( "Imposible iniciar", "busqueda...", "MEMORIA INSUFICIENTE" ); + return; + } + + /* get byte size of image */ + + if ( (ptr = farmalloc(size)) == NULL) { + Confirma( "Imposible iniciar", "busqueda.._.", "MEMORIA INSUFICIENTE" ); + free(b_cc); + return; + } + + getimage(47, 224, 593, 271, ptr); + + + Barra_buscar_CC( b_cc ); + + +// Prueba inicial... +do{ + + EditCursorClientes_CB(Columna, 0, b_cc, Clientes1_Buscar); + Espera_Tecla_o_Raton(); + if(kbhit()){ + EditCursorClientes_CB(Columna, 1, b_cc, Clientes1_Buscar); + key = getch(); + if( key == 27 ) f_busqueda = 1; + if( isprint(key) || isspace(key) ) { + EditCursorClientes_CB(Columna, 0, b_cc, Clientes1_Buscar); + if(key!=13) ungetch(key); + Edit_Item_Clientes_CB(Columna, b_cc, &Clientes1_Buscar); + EditCursorClientes_CB(Columna, 0, b_cc, Clientes1_Buscar); + + } else if( key == 0 ) { + switch( (key=getch()) ){ + // Flecha Izquierda + + case 75: + case 15: + { Columna--; if ( Columna<1 ) Columna=4; } + break; + // Flecha Derecha + case 77: + case 9: + { Columna++; if ( Columna>4 ) Columna=1; } + break; + // INICIO + case 71: + Columna = 1; + break; + // FIN + case 79: + Columna = 4; + break; + // Salir F1 + case 59: + f_busqueda = 1; + break; + default: + break; + } + EditCursorClientes_CB(Columna, 0, b_cc, Clientes1_Buscar); + } + } + +}while(!f_busqueda); + +struct boton Temp; + +if( strlen(Clientes1_Buscar.Local)!=0 || + strlen(Clientes1_Buscar.Nombre)!=0 || + Clientes1_Buscar.Telefono2 != -1 || + Clientes1_Buscar.NContrato != -1 ) + { Comienzo_Busqueda = 0; + Encontrado = Sigue_Buscando_CB( Clientes1_Buscar ); + } else { + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, Comunes[7]); + } + + putimage(47, 224, ptr, 0); + farfree(ptr); + free(b_cc); + + +Fuente(SMALL_FONT, TFuente); + +if( Encontrado ) { + + Temp.up = Comunes[7].up+4; Temp.down = Comunes[7].down-4; + Temp.left = Comunes[7].left+4; Temp.right = Comunes[7].right-4; + ImprimeBoton (1, ROJO, GRIS_O, BLANCO, Temp); + + textxy( Temp.left + 2, Temp.up /*+ 2*/, " Buscar"); + textxy( Temp.left + 2, Temp.up /*+ 2*/+10, " otra "); + textxy( Temp.left + 2, Temp.up /*+ 2*/+20, " F3 "); + +if(Buscador==0) + PrintWholeScreenClientes1(); + GetLineClientes(); + + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } +if(Buscador==0){ + Acota_Contenido(); + PrintWholeScreenClientes2(); + GetLineClientes_Compras2(); + + // + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PAR[11]); + setcolor(63); + sprintf(Buffer, "N de Contrato: % 4d Suma Total:", Clientes1.NContrato); + outtextxy(20, 431, Buffer); + // + } else { + Fuente(SMALL_FONT, 4); + PrintWholeScreenClientes(); + Fuente(SMALL_FONT, 5); + PrintLineClientes(0); + } + + } else { + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, Comunes[7]); + GetLineClientes(); + } + +} + +void Barra_buscar_CC(struct boton *Tmp){ + +Fuente(SMALL_FONT, 4); + +// BARRA DE BUSQUEDA... +Tmp[0].up = 225; Tmp[0].down = 270; +Tmp[0].left = 48; Tmp[0].right = 592; +ImprimeBoton (1, GRIS_C, GRIS_O, BLANCO, Tmp[0]); + +Tmp[1].up = 228; Tmp[1].down = 268; +Tmp[1].left = 50; Tmp[1].right = 590; +ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, Tmp[1]); + +Tmp[0].up = 248; Tmp[0].down = 263; +Tmp[0].left = 54; Tmp[0].right = 126; +ImprimeBoton (1, NEGRO, BLANCO, GRIS_O, Tmp[0]); + +Tmp[1].up = 248; Tmp[1].down = 263; +Tmp[1].left = 130; Tmp[1].right = 325; +ImprimeBoton (1, NEGRO, BLANCO, GRIS_O, Tmp[1]); + +Tmp[2].up = 248; Tmp[2].down = 263; +Tmp[2].left = 329; Tmp[2].right = 440; +ImprimeBoton (1, NEGRO, BLANCO, GRIS_O, Tmp[2]); + +Tmp[3].up = 248; Tmp[3].down = 263; +Tmp[3].left = 444; Tmp[3].right = 586; +ImprimeBoton (1, NEGRO, BLANCO, GRIS_O, Tmp[3]); + + +textxy( 52, 230, " N Contrato | Local | Nombre | Telfono" ); + + +} + + +void EditCursorClientes_CB(int Columna, int ShowHide, struct boton *Tmp, struct Clientes Clientes1_Buscar) { +char Buffer[80]; + + setcolor(GRIS_C); + setfillstyle(SOLID_FILL, GRIS_C); + bar(10, 455, 545, 473); + +if(SWAP_CLIEN==1) { + if (!ShowHide) { + setcolor(63); + setfillstyle(SOLID_FILL, 63); + bar((Tmp[Columna-1].left+2), Tmp[Columna-1].up+2, Tmp[Columna-1].right-2, Tmp[Columna-1].down - 2); + setcolor(0); + } else { + setcolor(0); + setfillstyle(SOLID_FILL, 0); + bar((Tmp[Columna-1].left+2), Tmp[Columna-1].up+2, Tmp[Columna-1].right-2, Tmp[Columna-1].down - 2); + Texto_Normal + } + + + switch(Columna) { + case 1: sprintf(Buffer, "%d", Clientes1_Buscar.NContrato); + outtextxy( Tmp[0].left+2, Tmp[0].up+2, Buffer); + outtextxy( 15, 455, "Buscar --> n Contrato xxxx."); + break; + case 2: outtextxy( Tmp[1].left+2, Tmp[1].up+2, Clientes1_Buscar.Local ); + outtextxy( 15, 455, "Buscar --> Nombre del Local."); + break; + case 3: sprintf(Buffer, "%s %s", Clientes1_Buscar.Nombre, Clientes1_Buscar.Apellido1); + Buffer[15] = '\0'; + outtextxy( Tmp[2].left+2, Tmp[2].up+2, Buffer ); + outtextxy( 15, 455, "Buscar --> Nombre del Propietario."); + break; + case 4: sprintf(Buffer, "%12ld", Clientes1_Buscar.Telefono2); + outtextxy( Tmp[3].left+2, Tmp[3].up+2, Buffer ); + outtextxy( 15, 455, "Buscar --> Telfono del Local."); + } + +} + +} + +void Edit_Item_Clientes_CB(int Columna, struct boton *Tmp, struct Clientes *Clientes1_Buscar){ +char Buffer[80]; + + setcolor(0); + setfillstyle(SOLID_FILL, 0); + bar((Tmp[0].left+2), Tmp[0].up+2, Tmp[0].right-2, Tmp[0].down - 2); + bar((Tmp[1].left+2), Tmp[1].up+2, Tmp[1].right-2, Tmp[1].down - 2); + bar((Tmp[2].left+2), Tmp[2].up+2, Tmp[2].right-2, Tmp[2].down - 2); + bar((Tmp[3].left+2), Tmp[3].up+2, Tmp[3].right-2, Tmp[3].down - 2); + + switch(Columna) { + case 1: // N de Contrato + sprintf(Buffer, "%d", Clientes1_Buscar -> NContrato); + do{ + InputCadenaG( Buffer, 1, 4, 63, 57, Tmp[0]); + }while( Clientes1_inx.Ncontrato_ocupado_SN[atoi(Buffer)]!=1); + Clientes1_Buscar -> NContrato = atoi(Buffer); + strcpy( Clientes1_Buscar -> Local, "\0" ); + strcpy( Clientes1_Buscar -> Nombre, "\0" ); + Clientes1_Buscar -> Telefono2 = -1; + break; + case 2: // Local + InputCadenaG( Clientes1_Buscar -> Local, 0, 30, 63, 57, Tmp[1]); + Clientes1_Buscar -> NContrato = -1; + strcpy( Clientes1_Buscar -> Nombre, "\0" ); + Clientes1_Buscar -> Telefono2 = -1; + + break; + case 3: // Nombre + InputCadenaG( Clientes1_Buscar -> Nombre, 0, 15, 63, 57, Tmp[2]); + Clientes1_Buscar -> NContrato = -1; + strcpy( Clientes1_Buscar -> Local, "\0" ); + Clientes1_Buscar -> Telefono2 = -1; + break; + case 4: // Telfono + sprintf(Buffer, "%ld", Clientes1_Buscar -> Telefono2); + InputCadenaG( Buffer, 1, 9, 63, 57, Tmp[3]); + Clientes1_Buscar -> Telefono2 = atol(Buffer); + Clientes1_Buscar -> NContrato = -1; + strcpy( Clientes1_Buscar -> Local, "\0" ); + strcpy( Clientes1_Buscar -> Nombre, "\0" ); + break; + } + +} + +int Sigue_Buscando_CB(struct Clientes Clientes1_Buscar){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Clientes_inx); + int LSC = sizeof(struct Clientes); + int ok = 0, CurrRecord; + char Buffer[80], Buffer2[80], Buffer3[80]; + int oldCTL= CurrTopLine_Clien1; + int oldCR= CurrRow1_Clien; + + if( Comienzo_Busqueda == 0 ) { + CurrTopLine_Clien1 = 1; + CurrRow1_Clien = 1; + } + + +do{ + + CurrRecord = CurrTopLine_Clien1 + CurrRow1_Clien - 1; + + fseek(Clientes, (long)LSJ + LSI + ( LSC * CurrRecord ) - LSC, SEEK_SET); + fread(&Clientes1, LSC, 1, Clientes); + +// + if ( Clientes1_Buscar.NContrato != -1 ) { + // Compara el n de contrato + if ( Clientes1_Buscar.NContrato == Clientes1.NContrato ) ok = 1; + CurrCol1_Clien = 1; + + } else + if ( strlen(Clientes1_Buscar.Local) != 0 ) { + // Compara la cadena de Local ( MAYUSCULAS = minusculas ) + strncpy( Buffer, Clientes1.Local, strlen(Clientes1_Buscar.Local) ); + Buffer[strlen(Clientes1_Buscar.Local)] = '\0'; + if ( strcmpi(Clientes1_Buscar.Local, Buffer ) == 0 ) ok = 1; + CurrCol1_Clien = 1; + + } else + if ( strlen(Clientes1_Buscar.Nombre) != 0 ) { + // Compara la cadena de Nombre ( MAYUSCULAS = minusculas ) + strncpy( Buffer, Clientes1.Nombre, strlen(Clientes1_Buscar.Nombre) ); + Buffer[strlen(Clientes1_Buscar.Nombre)] = '\0'; + if ( strcmpi(Clientes1_Buscar.Nombre, Buffer ) == 0 ) ok = 1; + CurrCol1_Clien = 2; + + } else + if ( Clientes1_Buscar.Telefono2 != -1 ) { + // Compara el telfono + sprintf(Buffer2, "%ld", Clientes1_Buscar.Telefono2); + sprintf(Buffer3, "%ld", Clientes1.Telefono2); + + strncpy( Buffer, Buffer3, strlen(Buffer2) ); + Buffer[strlen(Buffer2)] = '\0'; + if ( strcmpi(Buffer2, Buffer ) == 0 ) ok = 1; + CurrCol1_Clien = 3; + + } +// + if( ok != 1 ) CurrTopLine_Clien1++ ; +}while(!ok && (CurrRecord-1)<= Clientes1_inx.Fin ); + + +if ( ok == 0 ) { + + CurrTopLine_Clien1 = oldCTL; + CurrRow1_Clien = oldCR; + + Se_Puede_Buscar = 0; + Confirma("No se encontr", "equivalencia...", ""); + Comienzo_Busqueda = 0; + return NO_ENCONTRADO; +} else { + Se_Puede_Buscar = 1; + return ENCONTRADO; +} + + +} + + + + + + + + + + + + diff --git a/SV_CLIEN.CPP b/SV_CLIEN.CPP new file mode 100644 index 0000000..76346a9 --- /dev/null +++ b/SV_CLIEN.CPP @@ -0,0 +1,2257 @@ +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "..\libs\make_bot\make_bot.h" +#include "sv_graph.h" + +#include "sv_util.h" +#include "sv_ref_x.h" + +#define Texto_Normal setcolor(63); +#define Letra_Boton setcolor(1); +#define Texto_Negrita setcolor(0); + + +#define LIBRE 1 +#define OCUPADO 0 + +#define NO_ENCONTRADO 0 +#define ENCONTRADO 1 + + +extern int x_raton, y_raton, raton; +extern int boton_izq, boton_der; + +extern void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py); +extern void textxy(int x, int y, char *text); +extern int Espera_Tecla_o_Raton(void); +extern void desactiva_raton(void); +extern void activa_raton(void); +extern void Anclar_Raton(void); +extern void BEEP(void); + +extern int InputCadenaG(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo); +extern int InputCadenaG_l(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int Row); +extern int InputCadenaG_T4(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int Row); + +void PutLineClientes(void); +void GetLineClientes(void); +void AddRecordClientes(void); +void Menu_de_Clientes (void); +void Imprimir_Clientes(void); +void Edit_Item_Clientes(void); +void Abre_Ficha_Clientes(void); +void DeleteRecordClientes(void); +void Mueva_Abajo_CClientes(void); +void Mueva_Ariba_CClientes(void); +void Anula_Compras_Cliente(void); +// +void Imprime_Ficha_Clientes(void); +void Imprime_Extracto_Anual(void); +// +void GetLineClientes_Compras(void); +void CompruebaLineasClientes(void); +void Coloca_Nombres_a_botones(void); +void PrintWholeScreenClientes(void); +void EditCursorClientes(int ShowHide); +void Carga_Todos_los_Vendedores(void); +void Abre_Ficha_Clientes_Compras(void); +void Obten_Nombre_Vendedor( int Nvend ); +void Abre_Ficha_Clientes_Ncontrato(void); +void Current_Struct_to_Zero_Clientes(void); +void PrintLineClientes(int Rapida_Completa); +void Suma_Contrato_Activo_Vendedor( int Nvend ); +void Borra_Contrato_Activo_Vendedor( int Nvend ); + +extern void Buscar_Cliente_Seccion_Compras(void); +extern int Sigue_Buscando_CB(struct Clientes Clientes1_Buscar); + +extern int Comprueba_Impresora(void); +extern void Abre_Ficha_Vendedores(void); +extern void Abre_Ficha_Stock(void); + +struct Clientes_inx_NContrato { + unsigned long Inicio; + unsigned int Records; + unsigned char Libre; + }; + +struct Clientes_inx { + char Ncontrato_ocupado_SN[10000]; + unsigned int Fin; + }; + +struct Clientes { + int Address; + + char Nombre[15+1]; char Apellido1[15+1]; char Apellido2[15+1]; + char DNI[15+1]; unsigned long Telefono1; + char Calle1[30+1]; char Num1[5+1]; + + char Local[30+1]; unsigned long Telefono2; + char Calle2[30+1]; char Num2[5+1]; + char Poblacion[18+1]; char Provincia[16+1]; unsigned long CP; + + unsigned char GC; unsigned char MR; unsigned char SP; + unsigned char DP; unsigned int MA; + + struct date Fecha; int Vend; int NContrato; + +}; + +// Se almacenan 1000 registros por archivo +// En un caso extremo son: 9 bit ---> Espacio por Dato +// 31 ---> Dias por mes +// 2 ---> Productos por da +// 12 ---> 12 meses +// 1000 ---> Clientes +// + +struct Clientes_compras { // C UU VEN REF + struct date Fecha; // 1 99 999 9999 + unsigned long Cod_Und_Vend_Ref; + }; + +/*extern*/ struct Vend_inx { + unsigned int Fin; + }; + +/*extern*/ struct Vendedores { + int Num_V; + char Nombre[15+1]; char Apellido1[15+1]; char Apellido2[15+1]; + char DNI[15+1]; unsigned long Telefono1; unsigned long Telefono2; + char Calle[30+1]; char Num[3+1]; char Piso[3+1]; + char Poblacion[18+1]; char Provincia[16+1]; unsigned long CP; + unsigned long CC; unsigned int PP; unsigned int Cr; +}; + +extern struct JD cabecera; +struct Clientes Clientes1; +extern struct Clientes Clientes1_Buscar; +struct Clientes_inx Clientes1_inx; +struct Clientes_compras Clientes2; + // // // // +struct Clientes_inx_NContrato Clientes1_inx_NContrato; + // // // // + +extern struct Vendedores Vend1; +extern struct Vend_inx Vend1_inx; + + struct boton *PATLD; + struct boton *PATLD_c; +extern struct boton Comunes[9]; + + +int oldCNI = -1; +int *Vend_Dir; + +extern FILE *Vend; // Fichero Vendedores +extern FILE *Stock; +FILE *Clientes; // Fichero Clientes +FILE *Clientes_C; // Fichero Clientes con las Compras. +FILE *Clientes_NC; // Fichero Clientes con los nmeros de contrato activos. + +int CurrRow1_Clien, CurrRow2_Clien; +int CurrCol1_Clien, CurrCol2_Clien; +int CurrTopLine_Clien, CurrTopLine_Clien1; +int SWAP_CLIEN = 1; + +extern int Comienzo_Busqueda; +extern char Se_Puede_Buscar; +extern int Buscador; + + +// +// +// +// +// +// +// +// + + +void Menu_de_Clientes (void) { + + + int finished = 0, key, bpush; + CurrRow1_Clien = 1; CurrCol1_Clien = 1; + CurrRow2_Clien = 1; CurrCol2_Clien = 1; + + CurrTopLine_Clien = 1; + CurrTopLine_Clien1 = 1; + + Buscador = 1; + + if( ( Vend_Dir = (int *) malloc( sizeof(int)*1024 ) ) == NULL ) + { + Confirma("Memoria insuficiente", "para crear tablas para", "Vend_Dir"); + return ; + } + + + if( ( PATLD = (struct boton *) malloc( sizeof(struct boton)*24 ) ) == NULL ) + { + Confirma("Memoria insuficiente", "para crear tablas de", "posisin PATLD."); + free(Vend_Dir); + return ; + } + + if( ( PATLD_c = (struct boton *) malloc( sizeof(struct boton)*7 ) ) == NULL ) + { + Confirma("Memoria insuficiente", "para crear tablas de", "posisin PATLD_c."); + free(PATLD); + free(Vend_Dir); + return ; + } + +// inicializa_raton_grafico(0, 0, 624, 464, 320, 240); +// if(raton!=0) desactiva_raton(); + + cleardevice(); + Dibuja_Pantalla_Altas_Todos_los_Datos(PATLD, PATLD_c); + + Fuente(SMALL_FONT, 5); + Coloca_Nombres_a_botones(); + +Abre_Ficha_Clientes_Ncontrato(); +Abre_Ficha_Clientes(); + + Abre_Ficha_Referencias(); + Carga_Referencias(); + Abre_Ficha_Vendedores(); + Carga_Todos_los_Vendedores(); + Abre_Ficha_Stock(); + +GetLineClientes(); + Abre_Ficha_Clientes_Compras(); + + + + PrintLineClientes(0); + Fuente(SMALL_FONT, 4); + PrintWholeScreenClientes(); + Fuente(SMALL_FONT, 5); + + int oldCR1=0, oldCR2=0, oldCC1=0, oldCC2=0; + +do{ + + +if(oldCR1!=CurrRow1_Clien || oldCC1!=CurrCol1_Clien || oldCR2!=CurrRow2_Clien || oldCC2!=CurrCol2_Clien ) + EditCursorClientes(0); + +oldCR1 = CurrRow1_Clien; oldCC1 = CurrCol1_Clien; +oldCR2 = CurrRow2_Clien; oldCC2 = CurrCol2_Clien; + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + + + if(kbhit()){ + EditCursorClientes(1); + key = getch(); + if( isprint(key) || isspace(key) ) { + EditCursorClientes(0); + if(key!=13) ungetch(key); + Edit_Item_Clientes(); + EditCursorClientes(0); + + } else if( key == 0 ) { + switch( (key=getch()) ){ + // Flecha Arriba + case 72: + if(!SWAP_CLIEN) Mueva_Ariba_CClientes(); + else { if ( CurrTopLine_Clien1 + CurrRow1_Clien - 1 > 1 ){CurrRow1_Clien--; + GetLineClientes(); + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } + Fuente(SMALL_FONT, 4); + PrintWholeScreenClientes(); + Fuente(SMALL_FONT, 5); + PrintLineClientes(0); + } + } + break; + // Flecha Izquierda + case 75: + case 15: + if(SWAP_CLIEN) { CurrCol1_Clien--; if ( CurrCol1_Clien<1 ) CurrCol1_Clien=22; } + else { CurrCol2_Clien--; if ( CurrCol2_Clien < 1 ) CurrCol2_Clien=6; } + break; + // Flecha Derecha + case 77: + case 9: + if(SWAP_CLIEN) { CurrCol1_Clien++; if ( CurrCol1_Clien>22 ) CurrCol1_Clien=1; } + else { CurrCol2_Clien++; if ( CurrCol2_Clien > 6 ) CurrCol2_Clien=1; } + break; + // Flecha Abajo + case 80: + if(!SWAP_CLIEN) { Mueva_Abajo_CClientes(); } + else { + if ( CurrTopLine_Clien1 + CurrRow1_Clien - 2 < Clientes1_inx.Fin ){ + CurrRow1_Clien++; + GetLineClientes(); + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } + Fuente(SMALL_FONT, 4); + PrintWholeScreenClientes(); + Fuente(SMALL_FONT, 5); + PrintLineClientes(0); + } + } + break; + // Buscar F2 + case 60: + Buscar_Cliente_Seccion_Compras(); + //BuscarClientes(); + break; + // Buscar otra vez --> F3 + case 61: + + if(Se_Puede_Buscar) { + CurrTopLine_Clien1++; + Comienzo_Busqueda = 1; + if( Sigue_Buscando_CB(Clientes1_Buscar) == ENCONTRADO ) { + GetLineClientes(); + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } + Fuente(SMALL_FONT, 4); + PrintWholeScreenClientes(); + Fuente(SMALL_FONT, 5); + PrintLineClientes(0); + + } else { + CurrTopLine_Clien1--; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, Comunes[7]); + GetLineClientes(); + + } + } + break; + + + // Imprimir Clientes (incluye men desplegable) F5 + case 63: + Imprimir_Clientes(); + break; + // SWAP_CLIEN (la parte de edicin) F6 + case 64: + if(SWAP_CLIEN){ SWAP_CLIEN=0; Fuente(SMALL_FONT, 4); GetLineClientes_Compras(); } + else { SWAP_CLIEN=1; Fuente(SMALL_FONT, 5); } + EditCursorClientes(0); + break; + // F9 --> AADIR + case 67: + if(SWAP_CLIEN) + if( Confirma(" Dar de ALTA a un", "nuevo CLIENTE ?", "") ){ AddRecordClientes(); + for(int i=0; i<6; i++) + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PATLD_c[i]); + PrintLineClientes(0); } + + + break; + // F10 -> BORRAR + case 68: + if(SWAP_CLIEN) + if( Confirma("Desea eliminar al", "Cliente Actual", "") ) + { DeleteRecordClientes(); + PrintLineClientes(0); + for(int i=0; i<6; i++) + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PATLD_c[i]); + } + + break; + // INICIO + case 71: + if(SWAP_CLIEN) CurrCol1_Clien = 1; else CurrCol2_Clien = 1; + break; + // FIN + case 79: + if(SWAP_CLIEN) CurrCol1_Clien = 4; else CurrCol2_Clien = 14; + break; + // RePg + case 73: + // CurrRow = 1; + if(SWAP_CLIEN) { + if( CurrTopLine_Clien1 + CurrRow1_Clien > 11 ) { CurrTopLine_Clien1 -= 11; } else { CurrTopLine_Clien1 = 1; CurrRow1_Clien = 1;} + if( CurrTopLine_Clien1 + CurrRow1_Clien< 1 ) { CurrTopLine_Clien1 = 1; CurrRow1_Clien = 1;} + PrintWholeScreenClientes(); + GetLineClientes(); + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } + Fuente(SMALL_FONT, 4); + PrintWholeScreenClientes(); + Fuente(SMALL_FONT, 5); + PrintLineClientes(0); + + } + break; + // AvPg + case 81: + // CurrRow = 1; + if(SWAP_CLIEN) { + CurrTopLine_Clien1 += 11; + if ( (CurrTopLine_Clien1+CurrRow1_Clien-1) > Clientes1_inx.Fin) { CurrTopLine_Clien1 = Clientes1_inx.Fin; CurrRow1_Clien = 1; } + if (CurrTopLine_Clien1==0) CurrTopLine_Clien1 = 1; + PrintWholeScreenClientes(); + GetLineClientes(); + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } + Fuente(SMALL_FONT, 4); + PrintWholeScreenClientes(); + Fuente(SMALL_FONT, 5); + PrintLineClientes(0); + + } + break; + + // Salir F1 + case 59: + finished = 1; + break; + default: + break; + } + EditCursorClientes(0); + } + } + else if(raton!=0 && ( boton_izq==1 || boton_der==1 ) ) + if( (bpush = CheckButon( 9, Comunes))>0 ) { + EditCursorClientes(1); + switch(bpush){ + // Flecha Arriba + case 1: + if(!SWAP_CLIEN) Mueva_Ariba_CClientes(); + else { + if ( CurrTopLine_Clien1 + CurrRow1_Clien > 1 ){CurrRow1_Clien--; + GetLineClientes(); + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } + Fuente(SMALL_FONT, 4); + PrintWholeScreenClientes(); + Fuente(SMALL_FONT, 5); + PrintLineClientes(0); + } + } + break; + // Buscar + case 2: + Buscar_Cliente_Seccion_Compras(); + //BuscarClientes(); + break; + // Flecha Abajo + case 3: + if(!SWAP_CLIEN) Mueva_Abajo_CClientes(); + else { + if ( CurrTopLine_Clien1 + CurrRow1_Clien - 1 < Clientes1_inx.Fin ){ + CurrRow1_Clien++; + GetLineClientes(); + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } + Fuente(SMALL_FONT, 4); + PrintWholeScreenClientes(); + Fuente(SMALL_FONT, 5); + PrintLineClientes(0); + } + } + break; + case 4: + if(SWAP_CLIEN){ SWAP_CLIEN=0; Fuente(SMALL_FONT, 4); GetLineClientes_Compras();} + else { SWAP_CLIEN=1; Fuente(SMALL_FONT, 5); } + EditCursorClientes(0); + break; + // Imprimir + case 5: + Imprimir_Clientes(); + break; + // Aadir + case 6: + if(SWAP_CLIEN) + if( Confirma(" Dar de ALTA a un", "nuevo CLIENTE ?", "") ) + { AddRecordClientes(); + for(int i=0; i<6; i++) + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PATLD_c[i]); + PrintLineClientes(0); } + + break; + // Borrar + case 7: + if(SWAP_CLIEN) + if( Confirma("Desea eliminar al", "Cliente Actual", "") ) + { DeleteRecordClientes(); + for(int i=0; i<6; i++) + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PATLD_c[i]); + PrintLineClientes(0); + } + break; + // Buscar otra vez --> F3 + case 8: + + if(Se_Puede_Buscar) { + CurrTopLine_Clien1++; + Comienzo_Busqueda = 1; + if( Sigue_Buscando_CB(Clientes1_Buscar) == ENCONTRADO ) { + GetLineClientes(); + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } + Fuente(SMALL_FONT, 4); + PrintWholeScreenClientes(); + Fuente(SMALL_FONT, 5); + PrintLineClientes(0); + + } else { + CurrTopLine_Clien1--; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, Comunes[7]); + GetLineClientes(); + + } + } + break; + + + // Salir + case 9: + finished = 1; + break; + default: + break; + } + EditCursorClientes(0); + } else CompruebaLineasClientes(); + + +}while(!finished); + + +rewind(Clientes); + +fseek(Clientes, (long)sizeof(struct JD), SEEK_SET); +fwrite(&Clientes1_inx, sizeof(struct Clientes_inx), 1, Clientes); // Acualiza n de registros + + fclose(Clientes); // Fichero Clientes + fclose(Clientes_NC); // Fichero Clientes Indice + fclose(Clientes_C); // Fichero Clientes Compras + + fclose(Stock); +/*//*/ fclose(Vend); // Fichero Clientes + fclose(Ref); // Fichero Vendedores + + +if(Memory_ok==1) farfree(Addr); else free(Ref_inx_addr); +free(PATLD); +free(PATLD_c); +free(Vend_Dir); + +} + +// +// +// +// +// +// +// +// + +void Mueva_Abajo_CClientes(void){ + + int CurrRecord = CurrTopLine_Clien + CurrRow2_Clien - 1; + + if (CurrRow2_Clien==15) { + if ( (CurrRecord - 1) >= Clientes1_inx_NContrato/*[Clientes1.NContrato]*/.Records - 1) BEEP(); + else { CurrTopLine_Clien++; + PrintWholeScreenClientes(); + GetLineClientes_Compras(); + PrintLineClientes(1); + } + + } else { + if( (CurrRecord - 1) >= Clientes1_inx_NContrato/*[Clientes1.NContrato]*/.Records-1) BEEP(); + else { CurrRow2_Clien++; + GetLineClientes_Compras(); + PrintLineClientes(1); + } + } + +} + +void Mueva_Ariba_CClientes(void){ + int CurrRecord = CurrTopLine_Clien + CurrRow2_Clien - 1; + + if (CurrRow2_Clien==1) { + if ((CurrRecord - 1) <= 0) BEEP(); + else { + CurrTopLine_Clien--; + PrintWholeScreenClientes(); + GetLineClientes_Compras(); + PrintLineClientes(1); + } + + } else { + if( (CurrRecord - 1) <= 0) BEEP(); + else { CurrRow2_Clien--; + GetLineClientes_Compras(); + PrintLineClientes(1); + } + } + +} + +void EditCursorClientes(int ShowHide) { + +char Buffer[80]; +int MR; + + setcolor(GRIS_C); + setfillstyle(SOLID_FILL, GRIS_C); + bar(10, 455, 545, 473); + +if(SWAP_CLIEN==1) { + if (!ShowHide) { + ImprimeBoton (0, GRIS_C, ROJO, ROJO, PATLD[CurrCol1_Clien-1]); + setcolor(63); + setfillstyle(SOLID_FILL, 63); + bar(PATLD[CurrCol1_Clien-1].left+2, PATLD[CurrCol1_Clien-1].up+2, PATLD[CurrCol1_Clien-1].right-2, PATLD[CurrCol1_Clien-1].down-2); + setcolor(0); + } else { + ImprimeBoton (0, GRIS_C, GRIS_O, BLANCO, PATLD[CurrCol1_Clien-1]); + setcolor(0); + setfillstyle(SOLID_FILL, 0); + bar(PATLD[CurrCol1_Clien-1].left+2, PATLD[CurrCol1_Clien-1].up+2, PATLD[CurrCol1_Clien-1].right-2, PATLD[CurrCol1_Clien-1].down-2); + Texto_Normal + } + Fuente(SMALL_FONT, 5); + + switch(CurrCol1_Clien) { + case 1: outtextxy( PATLD[0].left+2, PATLD[0].up+2, Clientes1.Nombre ); + outtextxy( 15, 455, "Nombre del Cliente. 15 digitos maximo."); + break; + case 2: outtextxy( PATLD[1].left+2, PATLD[1].up+2, Clientes1.Apellido1 ); + outtextxy( 15, 455, "1er. Apellido. 15 digitos mximo."); + break; + case 3: outtextxy( PATLD[2].left+2, PATLD[2].up+2, Clientes1.Apellido2 ); + outtextxy( 15, 455, "2 Apellido. 15 digitos mximo."); + break; + case 4: outtextxy( PATLD[3].left+2, PATLD[3].up+2, Clientes1.DNI ); + outtextxy( 15, 455, "D.N.I. del Cliente. 15 digitos mximo."); + break; + case 5: sprintf(Buffer, "%ld", Clientes1.Telefono1); + outtextxy( PATLD[4].left+2, PATLD[4].up+2, Buffer ); + outtextxy( 15, 455, "Telefono Particular. 12 digitos mximo."); + break; + case 6: outtextxy( PATLD[5].left+2, PATLD[5].up+2, Clientes1.Calle1 ); + outtextxy( 15, 455, "Calle. (del Cliente). 30 digitos mximo."); + break; + case 7: outtextxy( PATLD[6].left+2, PATLD[6].up+2, Clientes1.Num1 ); + outtextxy( 15, 455, "Nmero. 5 digitos mximo."); + break; + case 8: outtextxy( PATLD[7].left+2, PATLD[7].up+2, Clientes1.Local ); + outtextxy( 15, 455, "Nombre del Local. 30 digitos mximo."); + break; + case 9: sprintf(Buffer, "%ld", Clientes1.Telefono2); + outtextxy( PATLD[8].left+2, PATLD[8].up+2, Buffer ); + outtextxy( 15, 455, "Telfono del Local. 12 digitos mximo."); + break; + case 10:outtextxy( PATLD[9].left+2, PATLD[9].up+2, Clientes1.Calle2 ); + outtextxy( 15, 455, "Calle del Local. 30 digitos mximo."); + break; + case 11:outtextxy( PATLD[10].left+2, PATLD[10].up+2, Clientes1.Num2 ); + outtextxy( 15, 455, "Nmero. 5 digitos mximo."); + break; + case 12:outtextxy( PATLD[11].left+2, PATLD[11].up+2, Clientes1.Poblacion); + outtextxy( 15, 455, "Poblacin. 18 digitos mximo."); + break; + case 13:outtextxy( PATLD[12].left+2, PATLD[12].up+2, Clientes1.Provincia); + outtextxy( 15, 455, "Provincia. 16 digitos mximo."); + break; + case 14:sprintf(Buffer, "%lu", Clientes1.CP); +// +// sprintf(Buffer, "%d", Clientes1.Address); +// int Libre = Clientes1_inx_NContrato.Libre; +// sprintf(Buffer, "%d", Libre); +// + outtextxy( PATLD[13].left+2, PATLD[13].up+2, Buffer ); + outtextxy( 15, 455, "Cdigo Postal. 5 digitos maximo."); + break; + + case 15:int GC = Clientes1.GC; Fuente(SMALL_FONT, 4); + sprintf(Buffer, "% 2d", GC); + outtextxy( PATLD[14].left+2, PATLD[14].up+2, Buffer ); + Fuente(SMALL_FONT, 5); + outtextxy( 15, 455, "Grifos / Columnas. 2 digitos maximo."); + break; + case 16: MR = Clientes1.MR; Fuente(SMALL_FONT, 4); + sprintf(Buffer, "% 2d", MR); + outtextxy( PATLD[15].left+2, PATLD[15].up+2, Buffer ); + Fuente(SMALL_FONT, 5); + outtextxy( 15, 455, "Manoreductor/es. 2 digitos maximo."); + break; + case 17: MR = Clientes1.SP; Fuente(SMALL_FONT, 4); + sprintf(Buffer, "% 2d", MR); + outtextxy( PATLD[16].left+2, PATLD[16].up+2, Buffer ); + Fuente(SMALL_FONT, 5); + outtextxy( 15, 455, "Serpentn/es. 2 digitos maximo."); + break; + case 18: MR = Clientes1.DP; Fuente(SMALL_FONT, 4); + sprintf(Buffer, "% 2d", MR); + outtextxy( PATLD[17].left+2, PATLD[17].up+2, Buffer ); + Fuente(SMALL_FONT, 5); + outtextxy( 15, 455, "Dispensadores. 2 digitos maximo."); + break; + case 19: MR = Clientes1.MA; Fuente(SMALL_FONT, 4); + sprintf(Buffer, "% 5d", MR); + outtextxy( PATLD[18].left+2, PATLD[18].up+2, Buffer ); + Fuente(SMALL_FONT, 5); + outtextxy( 15, 455, "Material Auxiliar. 5 digitos maximo."); + break; + case 20:int day, mon; Fuente(SMALL_FONT, 4); + day= Clientes1.Fecha.da_day; + mon= Clientes1.Fecha.da_mon; + sprintf(Buffer, "%02d/%02d/%02d", day, mon, Clientes1.Fecha.da_year ); + outtextxy( PATLD[19].left+2, PATLD[19].up+2, Buffer ); + Fuente(SMALL_FONT, 5); + outtextxy( 15, 455, "Fecha 6 digitos maximo."); + break; + case 21:sprintf(Buffer, "% 3d", Clientes1.NContrato); + outtextxy( PATLD[20].left+2, PATLD[20].up+2, Buffer ); + outtextxy( 15, 455, "Nmero de Contrato. 4 digitos maximo."); + break; + + case 22:sprintf(Buffer, "% 3d", Clientes1.Vend); Fuente(SMALL_FONT, 4); + outtextxy( PATLD[21].left+2, PATLD[21].up+2, Buffer ); + Fuente(SMALL_FONT, 5); + outtextxy( 15, 455, "Nmero de Vendedor. 3 digitos maximo."); + break; + + } +} else { + if (!ShowHide) { + setcolor(63); + setfillstyle(SOLID_FILL, 63); + if( Clientes2.Fecha.da_day == 0 ) CurrCol2_Clien = 1; + bar((PATLD_c[(CurrCol2_Clien)-1].left+2), PATLD_c[(CurrCol2_Clien)-1].up+(CurrRow2_Clien-1)*12+2, PATLD_c[(CurrCol2_Clien)-1].right-2, PATLD_c[(CurrCol2_Clien)-1].up+4+((CurrRow2_Clien)-1)*12+10); + setcolor(0); + } else { + setcolor(0); + setfillstyle(SOLID_FILL, 0); + if( Clientes2.Fecha.da_day == 0 ) CurrCol2_Clien = 1; + bar((PATLD_c[(CurrCol2_Clien)-1].left+2), PATLD_c[(CurrCol2_Clien)-1].up+(CurrRow2_Clien-1)*12+2, PATLD_c[(CurrCol2_Clien)-1].right-2, PATLD_c[(CurrCol2_Clien)-1].up+4+((CurrRow2_Clien)-1)*12+10); + Texto_Normal + } + Fuente(SMALL_FONT, 4); + int Ref; +if( Clientes2.Fecha.da_day != 0 ){ + switch(CurrCol2_Clien){ + case 1: + int day, mon; + day= Clientes2.Fecha.da_day; + mon= Clientes2.Fecha.da_mon; + sprintf(Buffer, "%02d/%02d/%02d", day, mon, Clientes2.Fecha.da_year ); + outtextxy( PATLD_c[0].left+2, (PATLD_c[0].up+3)+(CurrRow2_Clien-1)*12, Buffer ); + outtextxy( 15, 455, "Fecha. 6 digitos mximo."); + break; + case 2: + // 1 99 999 XXXX + Ref = ( Clientes2.Cod_Und_Vend_Ref - ((Clientes2.Cod_Und_Vend_Ref/10000)*10000) ); + sprintf(Buffer, " %04d", Ref); + outtextxy( PATLD_c[1].left+2, (PATLD_c[1].up+2)+(CurrRow2_Clien-1)*12, Buffer ); + outtextxy( 15, 455, "Referencia del Producto. 4 digitos mximo."); + break; + case 3: + outtextxy( PATLD_c[2].left+2, (PATLD_c[2].up+2)+(CurrRow2_Clien-1)*12, Ref1.Concepto ); + outtextxy( 15, 455, "Concepto. 15 digitos mximo."); + break; + case 4: + // 1 XX 999 9999 + Ref = ( ( Clientes2.Cod_Und_Vend_Ref/10000000L ) - ( ( (Clientes2.Cod_Und_Vend_Ref/10000000L)/100)*100 ) ); + sprintf(Buffer, "% 2d", Ref); + outtextxy( PATLD_c[3].left+2, (PATLD_c[3].up+2)+(CurrRow2_Clien-1)*12,Buffer ); + outtextxy( 15, 455, "Unidades. 2 digitos mximo."); + break; + case 5: + // 1 99 XXX 9999 + Ref = ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) - ( ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) / 1000) * 1000 ) ); + sprintf(Buffer, "% 2d", Ref); + outtextxy( PATLD_c[4].left+2, (PATLD_c[4].up+2)+(CurrRow2_Clien-1)*12,Buffer ); + outtextxy( 15, 455, "Vendedor. 3 digitos mximo."); + break; + case 6: + // X 99 999 9999 + Ref = ( Clientes2.Cod_Und_Vend_Ref/1000000000L ); + sprintf(Buffer, "% 2d", Ref); + outtextxy( PATLD_c[5].left+2, (PATLD_c[5].up+2)+(CurrRow2_Clien-1)*12,Buffer ); + outtextxy( 15, 455, "Cdigo. 1 digitos mximo."); + break; + + } +} else { + if (ShowHide) setcolor(EGA_YELLOW); + int mon; + mon= Clientes2.Fecha.da_mon; + sprintf(Buffer, "%02d -- %02d", mon, Clientes2.Fecha.da_year ); + outtextxy( PATLD_c[0].left+2, (PATLD_c[0].up+3)+(CurrRow2_Clien-1)*12, Buffer ); + + +} + +} + + +} + + + +void PrintLineClientes(int Rapida_Completa){ + +char Buffer[80]; + + if(!Rapida_Completa) { + + // Completa + + for(int i=0; i<23; i++) + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PATLD[i]); + + Texto_Normal + Fuente(SMALL_FONT, 5); + + outtextxy( PATLD[0].left+2, PATLD[0].up+2, Clientes1.Nombre ); + outtextxy( PATLD[1].left+2, PATLD[1].up+2, Clientes1.Apellido1 ); + outtextxy( PATLD[2].left+2, PATLD[2].up+2, Clientes1.Apellido2 ); + outtextxy( PATLD[3].left+2, PATLD[3].up+2, Clientes1.DNI ); + sprintf(Buffer, "%ld", Clientes1.Telefono1); + outtextxy( PATLD[4].left+2, PATLD[4].up+2, Buffer ); + outtextxy( PATLD[5].left+2, PATLD[5].up+2, Clientes1.Calle1 ); + outtextxy( PATLD[6].left+2, PATLD[6].up+2, Clientes1.Num1 ); + outtextxy( PATLD[7].left+2, PATLD[7].up+2, Clientes1.Local ); + sprintf(Buffer, "%ld", Clientes1.Telefono2); + outtextxy( PATLD[8].left+2, PATLD[8].up+2, Buffer ); + outtextxy( PATLD[9].left+2, PATLD[9].up+2, Clientes1.Calle2 ); + outtextxy( PATLD[10].left+2, PATLD[10].up+2, Clientes1.Num2 ); + outtextxy( PATLD[11].left+2, PATLD[11].up+2, Clientes1.Poblacion); + outtextxy( PATLD[12].left+2, PATLD[12].up+2, Clientes1.Provincia); +// +// sprintf(Buffer, "%d", Clientes1.Address); +// int Libre = Clientes1_inx_NContrato.Libre; +// sprintf(Buffer, "%d", Libre); +// + sprintf(Buffer, "%lu", Clientes1.CP); + outtextxy( PATLD[13].left+2, PATLD[13].up+2, Buffer ); + Fuente(SMALL_FONT, 4); + int GC = Clientes1.GC; + sprintf(Buffer, "% 2d", GC); + outtextxy( PATLD[14].left+2, PATLD[14].up+2, Buffer ); + int MR = Clientes1.MR; + sprintf(Buffer, "% 2d", MR); + outtextxy( PATLD[15].left+2, PATLD[15].up+2, Buffer ); + MR = Clientes1.SP; + sprintf(Buffer, "% 2d", MR); + outtextxy( PATLD[16].left+2, PATLD[16].up+2, Buffer ); + MR = Clientes1.DP; + sprintf(Buffer, "% 2d", MR); + outtextxy( PATLD[17].left+2, PATLD[17].up+2, Buffer ); + MR = Clientes1.MA; + sprintf(Buffer, "% 5d", MR); + outtextxy( PATLD[18].left+2, PATLD[18].up+2, Buffer ); + int day, mon; + day= Clientes1.Fecha.da_day; + mon= Clientes1.Fecha.da_mon; + sprintf(Buffer, "%02d/%02d/%02d", day, mon, Clientes1.Fecha.da_year ); + outtextxy( PATLD[19].left+2, PATLD[19].up+2, Buffer ); + sprintf(Buffer, "% 3d", Clientes1.Vend); + outtextxy( PATLD[21].left+2, PATLD[21].up+2, Buffer ); + sprintf(Buffer, " %15s", Vend1.Nombre); + outtextxy( PATLD[22].left+2, PATLD[22].up+2, Buffer ); + Fuente(SMALL_FONT, 5); + sprintf(Buffer, "% 3d", Clientes1.NContrato); + outtextxy( PATLD[20].left+2, PATLD[20].up+2, Buffer ); + + } else { +// Rapida + + Texto_Normal + Fuente(SMALL_FONT, 4); + if( Clientes2.Fecha.da_day != 0 ){ + int day, mon; + day= Clientes2.Fecha.da_day; + mon= Clientes2.Fecha.da_mon; + sprintf(Buffer, "%02d/%02d/%02d", day, mon, Clientes2.Fecha.da_year ); + outtextxy( PATLD_c[0].left+2, (PATLD_c[0].up+3)+(CurrRow2_Clien-1)*12, Buffer ); + // 1 99 999 XXXX + int Ref = ( Clientes2.Cod_Und_Vend_Ref - ((Clientes2.Cod_Und_Vend_Ref/10000)*10000) ); + sprintf(Buffer, " %04d", Ref); + outtextxy( PATLD_c[1].left+2, (PATLD_c[1].up+2)+(CurrRow2_Clien-1)*12, Buffer ); + outtextxy( PATLD_c[2].left+2, (PATLD_c[2].up+2)+(CurrRow2_Clien-1)*12, Ref1.Concepto ); + // 1 XX 999 9999 + Ref = ( ( Clientes2.Cod_Und_Vend_Ref/10000000L ) - ( ( (Clientes2.Cod_Und_Vend_Ref/10000000L)/100)*100 ) ); + sprintf(Buffer, "% 2d", Ref); + outtextxy( PATLD_c[3].left+2, (PATLD_c[3].up+2)+(CurrRow2_Clien-1)*12,Buffer ); + // 1 99 XXX 9999 + Ref = ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) - ( ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) / 1000) * 1000 ) ); + sprintf(Buffer, "% 2d", Ref); + outtextxy( PATLD_c[4].left+2, (PATLD_c[4].up+2)+(CurrRow2_Clien-1)*12,Buffer ); + // X 99 999 9999 + Ref = ( Clientes2.Cod_Und_Vend_Ref/1000000000L ); + sprintf(Buffer, "% 2d", Ref); + outtextxy( PATLD_c[5].left+2, (PATLD_c[5].up+2)+(CurrRow2_Clien-1)*12,Buffer ); + }else{ + setcolor(EGA_YELLOW); + int mon; + mon= Clientes2.Fecha.da_mon; + sprintf(Buffer, "%02d -- %02d", mon, Clientes2.Fecha.da_year ); + outtextxy( PATLD_c[0].left+2, (PATLD_c[0].up+3)+(CurrRow2_Clien-1)*12, Buffer ); + } + } + + +} + +void PrintWholeScreenClientes(void){ + +int tmp = CurrRow2_Clien; + +for(int i=0; i<6; i++) + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PATLD_c[i]); + + + for(CurrRow2_Clien = 1; CurrRow2_Clien < (15+1); CurrRow2_Clien++) + + if ( (CurrTopLine_Clien + CurrRow2_Clien - 1) <= Clientes1_inx_NContrato.Records){ + GetLineClientes_Compras(); + PrintLineClientes(1); + } + +CurrRow2_Clien = tmp; + +} + +void Edit_Item_Clientes(void){ +char Buffer[80]; int MR; +long Fecha; +if(SWAP_CLIEN){ + Fuente(SMALL_FONT, 5); + switch (CurrCol1_Clien) { + case 1: InputCadenaG( Clientes1.Nombre, 0, 15, 63, 57, PATLD[0]/*, CurrRow1_Clien-1*/); + break; + case 2: InputCadenaG( Clientes1.Apellido1, 0, 15, 63, 57, PATLD[1]/*, CurrRow1_Clien-1*/); + break; + case 3: InputCadenaG( Clientes1.Apellido2, 0, 15, 63, 57, PATLD[2]/*, CurrRow1_Clien-1*/); + break; + case 4: InputCadenaG( Clientes1.DNI, 0, 15, 63, 57, PATLD[3]/*, CurrRow1_Clien-1*/); + break; + case 5: sprintf(Buffer, "%ld", Clientes1.Telefono1); + InputCadenaG( Buffer, 1, 9, 63, 57, PATLD[4]/*, CurrRow1_Clien-1*/); + Clientes1.Telefono1 = atol(Buffer); + break; + case 6: InputCadenaG( Clientes1.Calle1, 0, 30, 63, 57, PATLD[5]/*, CurrRow1_Clien-1*/); + break; + case 7: InputCadenaG( Clientes1.Num1, 0, 5, 63, 57, PATLD[6]/*, CurrRow1_Clien-1*/); + break; + case 8: InputCadenaG( Clientes1.Local, 0, 30, 63, 57, PATLD[7]/*, CurrRow1_Clien-1*/); + break; + case 9: sprintf(Buffer, "%ld", Clientes1.Telefono2); + InputCadenaG( Buffer, 1, 9, 63, 57, PATLD[8]/*, CurrRow1_Clien-1*/); + Clientes1.Telefono2 = atol(Buffer); + break; + case 10:InputCadenaG( Clientes1.Calle2, 0, 30, 63, 57, PATLD[9]/*, CurrRow1_Clien-1*/); + break; + case 11:InputCadenaG( Clientes1.Num2, 0, 5, 63, 57, PATLD[10]/*, CurrRow1_Clien-1*/); + break; + case 12:InputCadenaG( Clientes1.Poblacion, 0, 18, 63, 57, PATLD[11]/*, CurrRow1_Clien-1*/); + break; + case 13:InputCadenaG( Clientes1.Provincia, 0, 16, 63, 57, PATLD[12]/*, CurrRow1_Clien-1*/); + break; + case 14: +// +// sprintf(Buffer, "%d", Clientes1.Address); +// int Libre = Clientes1_inx_NContrato.Libre; +// sprintf(Buffer, "%d", Libre); +// + sprintf(Buffer, "%lu", Clientes1.CP); + InputCadenaG( Buffer, 1, 5, 63, 57, PATLD[13]/*, CurrRow1_Clien-1*/); + Clientes1.CP = atol(Buffer); +// Clientes1.Address = atol(Buffer); +// Libre =atol(Buffer); +// Clientes1_inx_NContrato.Libre = Libre; +// fseek(Clientes_NC, (long)sizeof(struct Clientes_inx_NContrato)*(Clientes1.Address), SEEK_SET); +// fwrite( &Clientes1_inx_NContrato, sizeof(struct Clientes_inx_NContrato), 1, Clientes_NC); + + break; + case 15:int GC = Clientes1.GC; Fuente(SMALL_FONT, 4); + sprintf(Buffer, "%d", GC); + InputCadenaG( Buffer, 1, 2, 63, 57, PATLD[14]/*, 0*/); + Clientes1.GC = atoi(Buffer); + if(GC != Clientes1.GC) + Actualizar_Stock( 9996, (-1)*((Clientes1.GC)-GC), 1); + Fuente(SMALL_FONT, 5); + break; + case 16:MR = Clientes1.MR; Fuente(SMALL_FONT, 4); + sprintf(Buffer, "%d", MR); + InputCadenaG( Buffer, 1, 2, 63, 57, PATLD[15]/*, CurrRow1_Clien-1*/); + Clientes1.MR = atoi(Buffer); + if(MR != Clientes1.MR) + Actualizar_Stock( 9997, (-1)*((Clientes1.MR)-MR), 1); + Fuente(SMALL_FONT, 5); + break; + case 17:MR = Clientes1.SP;Fuente(SMALL_FONT, 4); + sprintf(Buffer, "%d", MR); + InputCadenaG( Buffer, 1, 2, 63, 57, PATLD[16]/*, CurrRow1_Clien-1*/); + Clientes1.SP = atoi(Buffer); + if(MR != Clientes1.SP) + Actualizar_Stock( 9998, (-1)*((Clientes1.SP)-MR), 1); + Fuente(SMALL_FONT, 5); + break; + case 18:MR = Clientes1.DP;Fuente(SMALL_FONT, 4); + sprintf(Buffer, "%d", MR); + InputCadenaG( Buffer, 1, 2, 63, 57, PATLD[17]/*, CurrRow1_Clien-1*/); + Clientes1.DP = atoi(Buffer); + if(MR != Clientes1.SP) + Actualizar_Stock( 9999, (-1)*((Clientes1.DP)-MR), 1); + Fuente(SMALL_FONT, 5); + break; + case 19:MR = Clientes1.MA;Fuente(SMALL_FONT, 4); + sprintf(Buffer, "%d", MR); + InputCadenaG( Buffer, 1, 4, 63, 57, PATLD[18]/*, CurrRow1_Clien-1*/); + Clientes1.MA = atoi(Buffer); + Fuente(SMALL_FONT, 5); + break; + case 20:int day, mon; Fuente(SMALL_FONT, 4); + day= Clientes1.Fecha.da_day; + mon= Clientes1.Fecha.da_mon; + sprintf(Buffer, "%02d%02d%02d", day, mon, Clientes1.Fecha.da_year ); + do{ + InputCadenaG( Buffer, 1, 6, 63, 57, PATLD[19]/*, CurrRow1_Clien-1*/); + Fecha = atol(Buffer); + Clientes1.Fecha.da_day = (Fecha/10000); + Clientes1.Fecha.da_mon = (Fecha/100) - ((Clientes1.Fecha.da_day) * 100); + Clientes1.Fecha.da_year = Fecha - ( (Clientes1.Fecha.da_day*10000) + (Clientes1.Fecha.da_mon*100) ); + }while( ( Clientes1.Fecha.da_day<1 || Clientes1.Fecha.da_day>31 ) || (Clientes1.Fecha.da_mon<1 || Clientes1.Fecha.da_mon > 12) || strlen(Buffer)!=6 ); + Fuente(SMALL_FONT, 5); + break; + case 21:sprintf(Buffer, "%d", Clientes1.NContrato); + Clientes1_inx.Ncontrato_ocupado_SN[atoi(Buffer)]=0; + do{ + InputCadenaG( Buffer, 1, 4, 63, 57, PATLD[20]/*, CurrRow1_Clien-1*/); + }while( Clientes1_inx.Ncontrato_ocupado_SN[atoi(Buffer)]==1 || atoi(Buffer) == 0); + Clientes1_inx.Ncontrato_ocupado_SN[atoi(Buffer)]=1; + Clientes1.NContrato = atoi(Buffer); + break; + case 22:int old_Vend = Clientes1.Vend; Fuente(SMALL_FONT, 4); + sprintf(Buffer, "%d", Clientes1.Vend); + do{ + InputCadenaG( Buffer, 1, 3, 63, 57, PATLD[21]/*, CurrRow1_Clien-1*/); + }while( Vend_Dir[atoi(Buffer)]==-1 ); + Clientes1.Vend = atoi(Buffer); + if( Clientes1.Vend != old_Vend ) { + Borra_Contrato_Activo_Vendedor( old_Vend ); + Suma_Contrato_Activo_Vendedor( Clientes1.Vend ); + Obten_Nombre_Vendedor( Clientes1.Vend ); + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PATLD[22]); + setcolor(BLANCO); + sprintf(Buffer, " %15s", Vend1.Nombre/*, Vend1.Apellido1*/); + outtextxy( PATLD[22].left+2, PATLD[22].up+2, Buffer ); + + } + Fuente(SMALL_FONT, 5); + break; + default: + return; + } + + PutLineClientes(); + /**/ + /**/ GetLineClientes(); /**/ + /**/ + +} else { + switch (CurrCol2_Clien) { + case 1: + while( kbhit() ) getch(); + break; + case 2: + while( kbhit() ) getch(); + break; + case 3: + while( kbhit() ) getch(); + break; + case 4: + while( kbhit() ) getch(); + break; + case 5: + while( kbhit() ) getch(); + break; + case 6: + while( kbhit() ) getch(); + break; + + default: while( kbhit() ) getch(); return; + } + + PutLineClientes(); + /**/ + /**/ GetLineClientes(); /**/ + /**/ + PrintLineClientes(1); + +} + +} + +// +// +// +// +// +// +// +// + +void Abre_Ficha_Clientes(void){ + +char ArchivoDatos[]="Clientes.DAT"; + +//// +// Comprueba apertura correcta de Indice, y Datos y creacin... // +//// + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Clientes_inx); + int LSC = sizeof(struct Clientes); + + if ( (Clientes = fopen( ArchivoDatos, "r+b"))==NULL) { + + FILE *fa; int i; + + if ( (fa = fopen( ArchivoDatos, "wb" ) )!=NULL ) { + + Current_Struct_to_Zero_Clientes(); + Clientes1.Address = 0; + Clientes1_inx.Fin = 0; + for(i = 0; i<10000; i++) + Clientes1_inx.Ncontrato_ocupado_SN[i] = 0; + +///////////////////////////////////// +///////////////////////////////////// +/*****/ Clientes1.Address = 0; +/*****/ Clientes1_inx_NContrato.Libre = OCUPADO; /* 0 */ +/*****/ fseek( Clientes_NC, (long)sizeof(struct Clientes_inx_NContrato)*0, SEEK_SET); +/*****/ fwrite( &Clientes1_inx_NContrato, sizeof(struct Clientes_inx_NContrato), 1, Clientes_NC); +///////////////////////////////////// +///////////////////////////////////// + rewind(fa); + + fwrite(&cabecera, LSJ, 1, fa); fseek(fa, (long)LSJ, SEEK_SET); + fwrite(&Clientes1_inx, LSI, 1, fa); fseek(fa, (long)LSJ+LSI, SEEK_SET); + fwrite(&Clientes1, LSC, 1, fa); + + if (fclose(fa) == EOF ) exit(1); + } + + if ( (Clientes = fopen( ArchivoDatos, "r+b"))==NULL) { + restorecrtmode(); + printf("NO SE PUDO ABRIR EL FICHERO INDICE EN LA 2 PASADA"); + printf("Clientes.dat"); + exit(1); + } + } + + fseek(Clientes, (long)LSJ, SEEK_SET); + if ( fread(&Clientes1_inx, LSI, 1, Clientes) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: INDICE"); + exit(1); + } + fseek(Clientes, (long)LSJ+LSI, SEEK_SET); + if ( fread(&Clientes1, LSC, 1, Clientes) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: DATOS"); + exit(1); + } + +} + + +//// +// Aqui es donde se guardan los contratos lgicos: 1,0 Ocupado, Libre // +//// +void Abre_Ficha_Clientes_Ncontrato(void){ + +char ArchivoDatos[]="C_INDICE.DAT"; + +//// +// Comprueba apertura correcta de Indice, y Datos y creacin... // +//// + + int LSC = sizeof(struct Clientes_inx_NContrato), i; + + if ( (Clientes_NC = fopen( ArchivoDatos, "r+b"))==NULL) { + + FILE *fa; + + if ( (fa = fopen( ArchivoDatos, "wb" ) )!=NULL ) { + + rewind(fa); + int Td; + + Clientes1_inx_NContrato.Records = 12; + + for( Td = 0; Td < 100/*0*/; Td++) + for(i = 0; i<100/*0*/; i++) { + Clientes1_inx_NContrato.Inicio = i*12; + Clientes1_inx_NContrato.Libre = LIBRE; /*1*/ + fseek(fa, (long)LSC*(i+(100*Td)), SEEK_SET); + fwrite(&Clientes1_inx_NContrato, LSC, 1, fa); + } + + if (fclose(fa) == EOF ) exit(1); + } + + if ( (Clientes_NC = fopen( ArchivoDatos, "r+b"))==NULL) { + restorecrtmode(); + printf("NO SE PUDO ABRIR EL FICHERO INDICE EN LA 2 PASADA"); + printf("C_indice.dat"); + exit(1); + } + } + + rewind(Clientes_NC); + + if (fread(&Clientes1_inx_NContrato, LSC, 1, Clientes_NC) !=1 ){ + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: DATOS"); + exit(1); + } + +} + +//// +// Aqui es donde estarn las compras realizadas por los clientes. // +//// +void Abre_Ficha_Clientes_Compras(void){ + +char ArchivoDatos[]="12345678.1237"; +struct date Fecha; +int mes; +getdate(&Fecha); + +// He decidido modificar el nmero de clientes soportados +// en un solo archivo de 1000 a 100, para acelerar el +// proceso de actualizaciones... +sprintf( ArchivoDatos, "SV_C%02d%02d.dat", ( (Clientes1.Address) / 100/*0*/ ), (Fecha.da_year - (Fecha.da_year/100)*100) ); + + + +//// +// Comprueba apertura correcta de Indice, y Datos y creacin... // +//// + + int LSC = sizeof(struct Clientes_compras), i; + + if ( (Clientes_C = fopen( ArchivoDatos, "r+b"))==NULL) { + + FILE *fa; + + if ( (fa = fopen( ArchivoDatos, "wb" ) )!=NULL ) { + + Clientes2.Fecha.da_day = 0; + Clientes2.Fecha.da_mon = 0; + Clientes2.Fecha.da_year = (Fecha.da_year - (Fecha.da_year/100)*100); + Clientes2.Cod_Und_Vend_Ref = 0; + auto int suma = 0; +// + for(i = 0; i<100/*0*/; i++) + for(mes = 1; mes <= 12; mes++) { + Clientes2.Fecha.da_mon = mes; + fseek(fa, (long)LSC * suma, SEEK_SET); + fwrite(&Clientes2, LSC, 1, fa); + suma++; + } + + + if (fclose(fa) == EOF ) exit(1); + } + + if ( (Clientes_C = fopen( ArchivoDatos, "r+b"))==NULL) { + restorecrtmode(); + printf("NO SE PUDO ABRIR EL FICHERO INDICE EN LA 2 PASADA"); + printf("%s", ArchivoDatos); + exit(1); + } + } + + rewind(Clientes_C); + if ( fread(&Clientes2, LSC, 1, Clientes_C) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: DATOS"); + exit(1); + } + +} + +// +// +// +// +// +// +// +// + +void DeleteRecordClientes(void) { + +unsigned int CurrRecord; + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Clientes_inx); + int LSC = sizeof(struct Clientes); + +CurrRecord = CurrTopLine_Clien1 + CurrRow1_Clien - 1; + + if ( Clientes1_inx.Fin == 0 ) { + + Clientes1_inx.Ncontrato_ocupado_SN[Clientes1.NContrato] = 0; + fseek(Clientes, (long)LSJ + LSI + ( LSC * ( CurrTopLine_Clien1 + CurrRow1_Clien - 1) ), SEEK_SET); // Se coloca + fwrite(&Clientes1, LSC, 1, Clientes); // Y escribe + + Clientes1_inx_NContrato.Records = 12; + Clientes1_inx_NContrato.Libre = OCUPADO;/*1*/ + fseek( Clientes_NC, (long)sizeof(struct Clientes_inx_NContrato)*Clientes1.Address, SEEK_SET); + fwrite(&Clientes1_inx_NContrato, sizeof(struct Clientes_inx_NContrato), 1, Clientes_NC); + Anula_Compras_Cliente(); + Borra_Contrato_Activo_Vendedor( Clientes1.Vend ); + Actualizar_Stock( 9996, (1)*(Clientes1.GC), 1); + Actualizar_Stock( 9997, (1)*(Clientes1.MR), 1); + Actualizar_Stock( 9998, (1)*(Clientes1.SP), 1); + Actualizar_Stock( 9999, (1)*(Clientes1.DP), 1); + Current_Struct_to_Zero_Clientes(); + PutLineClientes(); + PrintLineClientes(1); + BEEP(); + } else { + Clientes1_inx.Fin -= 1; + Clientes1_inx_NContrato.Records = 12; + Clientes1_inx_NContrato.Libre = LIBRE;/*1*/ + + fseek( Clientes_NC, (long)sizeof(struct Clientes_inx_NContrato)*Clientes1.Address, SEEK_SET); + fwrite( &Clientes1_inx_NContrato, sizeof(struct Clientes_inx_NContrato), 1, Clientes_NC); + + Clientes1_inx.Ncontrato_ocupado_SN[Clientes1.NContrato] = 0; + fseek(Clientes, (long)LSJ, SEEK_SET); // Se coloca + fwrite(&Clientes1, LSI, 1, Clientes); // Y escribe + Anula_Compras_Cliente(); + Borra_Contrato_Activo_Vendedor( Clientes1.Vend ); + Actualizar_Stock( 9996, (1)*(Clientes1.GC), 1); + Actualizar_Stock( 9997, (1)*(Clientes1.MR), 1); + Actualizar_Stock( 9998, (1)*(Clientes1.SP), 1); + Actualizar_Stock( 9999, (1)*(Clientes1.DP), 1); + +CurrRecord = CurrTopLine_Clien1 + CurrRow1_Clien - 1; + + unsigned int p = CurrRecord - 1; + + while( p <= Clientes1_inx.Fin ) { + + fseek(Clientes, (long)LSJ + LSI + ( LSC * ( p + 1 ) ), SEEK_SET); // Se coloca + fread(&Clientes1, LSC, 1, Clientes); // Y lee + + fseek(Clientes, (long)LSJ + LSI + ( LSC * p ), SEEK_SET); // Se coloca + fwrite(&Clientes1, LSC, 1, Clientes); // Y escribe + + p++; + }; + + fseek(Clientes, (long)LSJ, SEEK_SET); + fwrite(&Clientes1_inx, LSI, 1, Clientes); // Acualiza n de registros + +// PrintWholeScreenClientes(); +/* if ((CurrRecord - 1) == Clientes1_inx.Fin + 1)*/ CurrRow1_Clien--; + if( Clientes1_inx.Fin == 0 ) CurrRow1_Clien = 1; + while( CurrRow1_Clien + CurrTopLine_Clien1 < 1 ) CurrRow1_Clien ++; + GetLineClientes(); + PrintLineClientes(1); + } +} + + + +void AddRecordClientes(void){ + +unsigned int CurrRecord= CurrTopLine_Clien1 + CurrRow1_Clien - 1; + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Clientes_inx); + int LSC = sizeof(struct Clientes); + int ok = 0, i=0; + +if(CurrRecord < 10000 ) { + + long avance = Clientes1_inx.Fin; + + while( avance >= (CurrRecord-1) ) { + + fseek(Clientes, (long)LSJ + LSI + ( LSC * avance ), SEEK_SET); + fread(&Clientes1, LSC, 1, Clientes); + + fseek(Clientes, (long)LSJ + LSI + ( LSC * (avance + 1) ), SEEK_SET); // Se coloca + fwrite(&Clientes1, LSC, 1, Clientes); // Y escribe + + avance--; + }; + + Clientes1_inx.Fin++; + + fseek(Clientes, (long)LSJ, SEEK_SET); + fwrite(&Clientes1_inx, LSI, 1, Clientes); // Acualiza n de registros + + Current_Struct_to_Zero_Clientes(); + +avance = 0; +ok =0; + do{ + fseek( Clientes_NC, (long)sizeof(struct Clientes_inx_NContrato)*avance, SEEK_SET); + fread( &Clientes1_inx_NContrato, sizeof(struct Clientes_inx_NContrato), 1, Clientes_NC); + if( Clientes1_inx_NContrato.Libre == LIBRE) + { + ok = 1; + Clientes1.Address = avance; + Clientes1_inx_NContrato.Libre = OCUPADO; /* 0 */ + fseek( Clientes_NC, (long)sizeof(struct Clientes_inx_NContrato)*avance, SEEK_SET); + fwrite( &Clientes1_inx_NContrato, sizeof(struct Clientes_inx_NContrato), 1, Clientes_NC); + } + avance++; + }while( (avance<10000) && !ok); + + if( ok==0 ) + Confirma("Error buscando un", "hueco para indexar la", "posisin de COMPRAS."); + + +ok = 0; + do{ + i++; + if( Clientes1_inx.Ncontrato_ocupado_SN[i]==0 ) { Clientes1.NContrato = i; Clientes1_inx.Ncontrato_ocupado_SN[i]=1; ok = 1; } + } while(!ok && i < 10000); + + fseek(Clientes, (long)LSJ, SEEK_SET); + fwrite(&Clientes1_inx, LSI, 1, Clientes); // Acualiza n de registros + + + fseek(Clientes, (long)LSJ + LSI + ( LSC * ( CurrTopLine_Clien1 + CurrRow1_Clien - 1) ), SEEK_SET); // Se coloca + fwrite(&Clientes1, LSC, 1, Clientes); // Y escribe + + CurrRow1_Clien++; +// if (CurrRow1_Clien>11) { CurrTopLine_Clien1++; CurrRow1_Clien--; } +// PrintWholeScreenClientes(); + GetLineClientes(); + PrintLineClientes(1); + } + +} + + +void PutLineClientes(void){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Clientes_inx); + int LSC = sizeof(struct Clientes); + + int CurrRecord = CurrTopLine_Clien1 + CurrRow1_Clien - 1; + +fseek(Clientes, (long)LSJ + LSI + ( LSC * CurrRecord ) - LSC, SEEK_SET); +fwrite(&Clientes1, LSC, 1, Clientes); + +} + +void GetLineClientes(void){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Clientes_inx); + int LSC = sizeof(struct Clientes); + + int CurrRecord = CurrTopLine_Clien1 + CurrRow1_Clien - 1; + +fseek(Clientes, (long)LSJ + LSI + ( LSC * CurrRecord ) - LSC, SEEK_SET); +fread(&Clientes1, LSC, 1, Clientes); + + fseek(Clientes_NC, (long)sizeof(struct Clientes_inx_NContrato)*(Clientes1.Address), SEEK_SET); + fread(&Clientes1_inx_NContrato, sizeof(struct Clientes_inx_NContrato),1, Clientes_NC); + + Obten_Nombre_Vendedor( Clientes1.Vend ); + + +} + +void GetLineClientes_Compras(void){ + + int LSC = sizeof(struct Clientes_compras); + + long CurrRecord = CurrTopLine_Clien + CurrRow2_Clien - 1 + Clientes1_inx_NContrato.Inicio; + +fseek(Clientes_C, (long)( LSC * CurrRecord ) - LSC, SEEK_SET); // Se coloca +fread(&Clientes2, LSC, 1, Clientes_C); // Y lee + + BuscaReferencia(( Clientes2.Cod_Und_Vend_Ref - ((Clientes2.Cod_Und_Vend_Ref/10000)*10000) )); + +} + +// +// +// +// +// +// +// +// + + +void Current_Struct_to_Zero_Clientes(void){ + + cabecera.esc = 27; strcpy(cabecera.color, "[31;40m"); + strcpy(cabecera.prog, "Jos David Guilln Dominguez"); + cabecera.nl = 13; cabecera.rt = 10; + strcpy(cabecera.autor, " 31 / Abril / 1995 "); + cabecera.pt = 7; cabecera.ef = 26; + + strcpy(Clientes1.Nombre, "\0"); strcpy(Clientes1.Apellido1, "\0"); strcpy(Clientes1.Apellido2, "\0"); + strcpy(Clientes1.DNI, "\0"); Clientes1.Telefono1 = 0; + strcpy(Clientes1.Calle1, "\0"); strcpy(Clientes1.Num1, "\0"); + + strcpy(Clientes1.Local, "\0"); Clientes1.Telefono2 = 0; + strcpy(Clientes1.Calle2, "\0"); strcpy(Clientes1.Num2, "\0"); + strcpy(Clientes1.Poblacion, "\0"); strcpy(Clientes1.Provincia, "\0"); + Clientes1.CP =41; + Clientes1.GC = 0; Clientes1.MR = 0; + Clientes1.SP = 0; Clientes1.DP = 0; Clientes1.MA = 0; + + getdate(&Clientes1.Fecha); + Clientes1.Fecha.da_year = ( Clientes1.Fecha.da_year - ( Clientes1.Fecha.da_year / 100 )* 100 ) ; + Clientes1.Vend = 0; Clientes1.NContrato = 0; + +} + + + + +void CompruebaLineasClientes(void){ + // Check una pulsacion sobre un campo, y se situa, si es posible + int inc=0; + if( (inc = CheckButon_S( 23, 4, PATLD))>0 && (inc <=23) ) { EditCursorClientes(1); CurrCol1_Clien = (inc); } +} + + +// +// +// Esta Funcin cargar todas las direcciones de los Vendedores. +// + +void Carga_Todos_los_Vendedores(void){ + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Vend_inx); + int LSC = sizeof(struct Vendedores); + + int i, Curr_Vend = 0; + for (i=0; i<1000; i++) Vend_Dir[i]=-1; + + while(Curr_Vend <= Vend1_inx.Fin ){ + fseek(Vend, (long)LSJ + LSI + ( LSC * Curr_Vend ), SEEK_SET); + fread(&Vend1, LSC, 1, Vend); + if(Vend1.Num_V>999) { Confirma("Error.", "Archivo Vendedores CORRUPTO", "Error."); exit(1); } + Vend_Dir[Vend1.Num_V] = Curr_Vend; + Curr_Vend++; + } + } + + +void Borra_Contrato_Activo_Vendedor( int Nvend ){ + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Vend_inx); + int LSC = sizeof(struct Vendedores); + +if( Vend_Dir[Nvend] != -1 ) { + fseek(Vend, (long)LSJ + LSI + ( LSC * Vend_Dir[Nvend] ), SEEK_SET); // Se coloca + fread(&Vend1, LSC, 1, Vend); + Vend1.Cr--; + fseek(Vend, (long)LSJ + LSI + ( LSC * Vend_Dir[Nvend] ), SEEK_SET); // Se coloca + fwrite(&Vend1, LSC, 1, Vend); +} + +} + +void Suma_Contrato_Activo_Vendedor( int Nvend ){ + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Vend_inx); + int LSC = sizeof(struct Vendedores); + +if( Vend_Dir[Nvend] != -1 ) { + fseek(Vend, (long)LSJ + LSI + ( LSC * Vend_Dir[Nvend] ), SEEK_SET); // Se coloca + fread(&Vend1, LSC, 1, Vend); + Vend1.Cr++; + fseek(Vend, (long)LSJ + LSI + ( LSC * Vend_Dir[Nvend] ), SEEK_SET); // Se coloca + fwrite(&Vend1, LSC, 1, Vend); +} + +} + +void Obten_Nombre_Vendedor( int Nvend ){ + + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Vend_inx); + int LSC = sizeof(struct Vendedores); + +if( Vend_Dir[Nvend] != -1 ) { + fseek(Vend, (long)LSJ + LSI + ( LSC * Vend_Dir[Nvend] ), SEEK_SET); // Se coloca + fread(&Vend1, LSC, 1, Vend); +} + + +} + + +// +// +// +// +// +// +// +// + +void Imprimir_Clientes(void){ + +int Where_Ask = 1; +int fins_print= 0, key_print, bpush; + +void far *ptr; +unsigned size; +struct boton pregunta[3]; + +size = imagesize(198, 138, 372, 257); + +/* get byte size of image */ + +if ( (ptr = farmalloc(size)) != NULL) { + getimage(198, 138, 372, 257, ptr); + + pregunta[0].up = 140; pregunta[0].down = 255; + pregunta[0].left= 200; pregunta[0].right= 370; + ImprimeBoton (1, ROJO, GRIS_C, BLANCO, pregunta[0]); + pregunta[0].up = 150; pregunta[0].down = 175; + pregunta[0].left= 210; pregunta[0].right= 360; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[0]); + pregunta[1].up = 185; pregunta[1].down = 210; + pregunta[1].left= 210; pregunta[1].right= 360; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[1]); + pregunta[2].up = 220; pregunta[2].down = 245; + pregunta[2].left= 210; pregunta[2].right= 360; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[2]); + Fuente(SMALL_FONT, 4); +} else { + Where_Ask = 0; + pregunta[0].up = 450; pregunta[0].down = 475; + pregunta[0].left= 5; pregunta[0].right= 152; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[0]); + pregunta[1].up = 450; pregunta[1].down = 475; + pregunta[1].left= 155; pregunta[1].right= 309; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[1]); + pregunta[2].up = 450; pregunta[2].down = 475; + pregunta[2].left= 312; pregunta[2].right= 549; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[2]); + Fuente(SMALL_FONT, 4); +} + +Letra_Boton +outtextxy(pregunta[0].left+2, pregunta[0].up+2, "F3 Imprimir Ficha Actual"); +outtextxy(pregunta[1].left+2, pregunta[1].up+2, "F2 Informe hasta la Fecha"); +outtextxy(pregunta[2].left+2, pregunta[2].up+2, "F1 CANCELAR IMPRESION"); + +// +do{ + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + if(kbhit()){ + key_print = getch(); + if( key_print == 0 ) { + switch( (key_print=getch()) ){ + // F1 Cancelar + case 59: + fins_print = 1; + break; + // F3 Imprimir Ficha + case 61: + if(Where_Ask){ + pregunta[0].up = 140; pregunta[0].down = 255; + pregunta[0].left= 200; pregunta[0].right= 370; + } else { + pregunta[0].up = 450; pregunta[0].down = 475; + pregunta[0].left= 5; pregunta[0].right= 549; + } + ImprimeBoton (1, GRIS_O, GRIS_C, BLANCO, pregunta[0]); + + // + if( Comprueba_Impresora() ) { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Imprimiendo."); + outtextxy(210,170, "Por Favor, espere..."); + } else outtextxy(10,452, "Imprimiendo. Por Favor, espere..."); + Imprime_Ficha_Clientes(); + } else { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Impresora no preparada."); + outtextxy(210,170, "Impresion Cancelada"); + } else { outtextxy(10,452, "Impresora no preparada. Impresin Cancelada."); } + Espera_Tecla_o_Raton(); + } + fins_print = 1; + + // + break; + // F2 Imprimir lista rpida + case 60: + if(Where_Ask){ + pregunta[0].up = 140; pregunta[0].down = 255; + pregunta[0].left= 200; pregunta[0].right= 370; + } else { + pregunta[0].up = 450; pregunta[0].down = 475; + pregunta[0].left= 5; pregunta[0].right= 549; + } + ImprimeBoton (1, GRIS_O, GRIS_C, BLANCO, pregunta[0]); + + // + if(Comprueba_Impresora()) { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Imprimiendo."); + outtextxy(210,170, "Por Favor, espere..."); + } else outtextxy(10,452, "Imprimiendo. Por Favor, espere..."); +// Imprime_Lista_Rapida(); + } else { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Impresora no preparada."); + outtextxy(210,170, "Impresion Cancelada"); + } else { outtextxy(10,452, "Impresora no preparada. Impresin Cancelada."); } + Espera_Tecla_o_Raton(); + } + fins_print = 1; + + // + break; + default: + fins_print = 1; + } + } + } else + if(raton!=0 && boton_izq==1 || boton_der==1) { + if( (bpush = CheckButon( 3, pregunta))>0 ) { + + if(Where_Ask){ + pregunta[0].up = 140; pregunta[0].down = 255; + pregunta[0].left= 200; pregunta[0].right= 370; + } else { + pregunta[0].up = 450; pregunta[0].down = 475; + pregunta[0].left= 5; pregunta[0].right= 549; + } + ImprimeBoton (1, GRIS_O, GRIS_C, BLANCO, pregunta[0]); + + switch(bpush){ + // Imprimir Ficha + case 1: + // + if(Comprueba_Impresora()) { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Imprimiendo."); + outtextxy(210,170, "Por Favor, espere..."); + } else outtextxy(10,452, "Imprimiendo. Por Favor, espere..."); + Imprime_Ficha_Clientes(); + } else { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Impresora no preparada."); + outtextxy(210,170, "Impresion Cancelada"); + } else { outtextxy(10,452, "Impresora no preparada. Impresin Cancelada."); } + Espera_Tecla_o_Raton(); + } + fins_print = 1; + // + + break; + // Imprime Lista Rpida + case 2: + // + if(Comprueba_Impresora()) { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Imprimiendo."); + outtextxy(210,170, "Por Favor, espere..."); + } else outtextxy(10,452, "Imprimiendo. Por Favor, espere..."); +// Imprime_Lista_Rapida(); + } else { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Impresora no preparada."); + outtextxy(210,170, "Impresion Cancelada"); + } else { outtextxy(10,452, "Impresora no preparada. Impresin Cancelada."); } + Espera_Tecla_o_Raton(); + } + fins_print = 1; + + // + break; + // Cancelar + case 3: + fins_print=1; + break; + default: + fins_print = 1; + } + } + } + + +}while(!fins_print); + +// + + if(Where_Ask == 1) { + putimage(198, 138, ptr, COPY_PUT); + farfree(ptr); + } else { + struct boton help; + help.up = 450; help.down = 475; + help.left = 5; help.right = 549; + ImprimeBoton (1, GRIS_C, GRIS_O, BLANCO, help); + } + +} + + +void Imprime_Ficha_Clientes(void){ + +int Buff; + + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "Ŀ\n\r"); + fprintf( stdprn, " Nmero de Contrato: % 4d \n\r", Clientes1.NContrato); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "Establecimiento: %-30s, Tlf. % 12ld\n\r", Clientes1.Local, Clientes1.Telefono2); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "Calle, %s, %s\n\r", Clientes1.Calle2, Clientes1.Num2); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "Poblacion: %18s Provincia: %16s C.P.: %ld\n\r", Clientes1.Poblacion, Clientes1.Provincia, Clientes1.CP); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "Cliente: %s %s, %s \n\r", Clientes1.Apellido1, Clientes1.Apellido2, Clientes1.Nombre); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "Tlf.: %12ld D.N.I: %15s \n\r", Clientes1.Telefono1, Clientes1.DNI); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "Calle: %s, %s\n\r", Clientes1.Calle1, Clientes1.Num1); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + int Dia, Mes; + Dia = Clientes1.Fecha.da_day; Mes = Clientes1.Fecha.da_mon; + fprintf( stdprn, "Ŀ Contrato Realizado el %2d/%2d/%2d \n\r", Dia, Mes, Clientes1.Fecha.da_year); + fprintf( stdprn, " Materiales \n\r"); + fprintf( stdprn, "Ĵ por el Vendedor n % 3d\n\r", Clientes1.Vend); + fprintf( stdprn, " \n\r"); + Buff = Clientes1.GC ; + fprintf( stdprn, " Grifo(s) / Columna(s) %02d %s %s\n\r", Buff, Vend1.Nombre, Vend1.Apellido1); + fprintf( stdprn, " \n\r"); + Buff = Clientes1.MR; + fprintf( stdprn, " Manoreductor(es) %02d \n\r", Buff); + fprintf( stdprn, " \n\r"); + Buff = Clientes1.SP; + fprintf( stdprn, " Serpentn(es) %02d \n\r", Buff); + fprintf( stdprn, " \n\r"); + Buff = Clientes1.DP; + fprintf( stdprn, " Dispensador(es) %02d \n\r", Buff); + fprintf( stdprn, " \n\r"); + fprintf( stdprn, " \n\r"); + fprintf( stdprn, " \n\r"); + fprintf( stdprn, " MATERIAL AUXILIAR % 5d \n\r", Clientes1.MA); + fprintf( stdprn, " \n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "Notas: _______________________________________________________________________________\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "________________________________________________________________________________________\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "________________________________________________________________________________________\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "________________________________________________________________________________________\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "________________________________________________________________________________________\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "________________________________________________________________________________________\n\r"); + fputc(12, stdprn); +} + + +/* +void Imprime_Lista_Rapida(void){ + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Clientes_inx); + int LSC = sizeof(struct Clientes); + int lprint = 3; + +// 1 2 3 4 5 6 7 8 +// 123456789123456789123456789123456789123456789123456789123456789123456789 +int Curr_Clientes = 0; + fprintf( stdprn, "\n\r"); + fprintf( stdprn, " Num_V Nombre Apellido Telfono Contratos Activos\n\r"); + fprintf( stdprn, "\n\r"); + + while(Curr_Clientes <= Clientes1_inx.Fin ){ + + fseek(Clientes, (long)LSJ + LSI + ( LSC * Curr_Clientes ), SEEK_SET); // Se coloca + fread(&Clientes1, LSC, 1, Clientes); // Y lee + + fprintf( stdprn, " %03d %-15s %-15s % 12ld % 12ld %04d\n\r", Clientes1.Vend, Clientes1.Nombre, Clientes1.Apellido1, Clientes1.Telefono1, Clientes1.Telefono2, Clientes1.CR); + + lprint++; + if (lprint==55) { lprint = 3; + fputc(12, stdprn); + fprintf( stdprn, " Num_V Nombre Apellido Telfono Contratos Activos\n\r"); + fprintf( stdprn, "\n\r"); + } + Curr_Clientes++; + } + + + fputc(12, stdprn); +} +*/ + +void Anula_Compras_Cliente(void){ + + int LSC = sizeof(struct Clientes_compras); +struct date Fecha; + +getdate(&Fecha); + +long CurrRecord; + + Clientes2.Fecha.da_day = 0; + Clientes2.Fecha.da_mon = 0; + Clientes2.Fecha.da_year = (Fecha.da_year - (Fecha.da_year/100)*100); + Clientes2.Cod_Und_Vend_Ref = 0; +// + +for ( int i=0; i<12; i++ ){ + CurrRecord = 1 + Clientes1_inx_NContrato.Inicio + i; + Clientes2.Fecha.da_mon = i+1; + + fseek(Clientes_C, (long)( LSC * CurrRecord ) - LSC, SEEK_SET); // Se coloca + fwrite(&Clientes2, LSC, 1, Clientes_C); // Y lee +} + +} + + + +/* +void Menu_Buscar_Clientes(void){ + + Clientes1_Buscar = Clientes1; + Current_Struct_to_Zero_Clientes(); + + do{ + EditCursorClientes(0); + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + + + if(kbhit()){ + EditCursorClientes(1); + key = getch(); + if(key!=27) finished = 1; else + if( isprint(key) || isspace(key) ) { + EditCursorClientes(0); + if(key!=13) ungetch(key); + Edit_Item_Clientes_B(); + EditCursorClientes(0); + + } else if( key == 0 ) { + switch( (key=getch()) ){ + // Flecha Izquierda + case 75: + case 15: + { CurrCol1_Clien--; if ( CurrCol1_Clien<1 ) CurrCol1_Clien=22; } + break; + // Flecha Derecha + case 77: + case 9: + { CurrCol1_Clien++; if ( CurrCol1_Clien>22 ) CurrCol1_Clien=1; } + break; + // INICIO + case 71: + CurrCol1_Clien = 1; else CurrCol2_Clien = 1; + break; + // FIN + case 79: + CurrCol1_Clien = 4; else CurrCol2_Clien = 14; + break; + // Salir F1 + case 59: + finished = 1; + break; + default: + break; + } + EditCursorClientes(0); + } + } + else if(raton!=0 && ( boton_izq==1 || boton_der==1 ) ) + if( (bpush = CheckButon( 9, Comunes))>0 ) { + EditCursorClientes(1); + switch(bpush){ + // Salir + case 9: + finished = 1; + break; + default: + break; + } + EditCursorClientes(0); + } + + +}while(!finished); + +Clientes1_Buscar = Clientes1; +Comienzo_Busqueda = 0; + +if( !Sigue_Buscando_Ficha() ) GetLineClientes(); + + +} + +int Sigue_Buscando_Ficha(void){ + +///////// + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Clientes_inx); + int LSC = sizeof(struct Clientes); + int ok = 0, CurrRecord; + char Buffer[80], Buffer2[80], Buffer3[80]; + int oldCTL= CurrTopLine_Clien1; + int oldCR= CurrRow1_Clien; + + if( Comienzo_Busqueda == 0 ) { + CurrTopLine_Clien1 = 1; + CurrRow1_Clien = 1; + } + + +do{ + + CurrRecord = CurrTopLine_Clien1 + CurrRow1_Clien - 1; + + fseek(Clientes, (long)LSJ + LSI + ( LSC * CurrRecord ) - LSC, SEEK_SET); + fread(&Clientes1, LSC, 1, Clientes); + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + if ( Clientes1_Buscar.NContrato != -1 ) { + // Compara el n de contrato + if ( Clientes1_Buscar.NContrato == Clientes1.NContrato ) ok = 1; + CurrCol1_Clien = 1; + + } else + if ( strlen(Clientes1_Buscar.Local) != 0 ) { + // Compara la cadena de Local ( MAYUSCULAS = minusculas ) + strncpy( Buffer, Clientes1.Local, strlen(Clientes1_Buscar.Local) ); + Buffer[strlen(Clientes1_Buscar.Local)] = '\0'; + if ( strcmpi(Clientes1_Buscar.Local, Buffer ) == 0 ) ok = 1; + CurrCol1_Clien = 1; + + } else + if ( strlen(Clientes1_Buscar.Nombre) != 0 ) { + // Compara la cadena de Nombre ( MAYUSCULAS = minusculas ) + strncpy( Buffer, Clientes1.Nombre, strlen(Clientes1_Buscar.Nombre) ); + Buffer[strlen(Clientes1_Buscar.Nombre)] = '\0'; + if ( strcmpi(Clientes1_Buscar.Nombre, Buffer ) == 0 ) ok = 1; + CurrCol1_Clien = 2; + + } else + if ( Clientes1_Buscar.Telefono2 != -1 ) { + // Compara el telfono + sprintf(Buffer2, "%ld", Clientes1_Buscar.Telefono2); + sprintf(Buffer3, "%ld", Clientes1.Telefono2); + + strncpy( Buffer, Buffer3, strlen(Buffer2) ); + Buffer[strlen(Buffer2)] = '\0'; + if ( strcmpi(Buffer2, Buffer ) == 0 ) ok = 1; + CurrCol1_Clien = 3; + + } +////////////////////////////////////////////////////////////////////////////// + +if( Clientes1_Buscar.NContrato!=-1) { + +} else { + + if( strlen(Clientes1_Buscar.Nombre)!=0) + if( strlen(Clientes1_Buscar.Apellido1)!=0) + if( strlen(Clientes1_Buscar.Apellido2)!=0) + if( strlen(Clientes1_Buscar.DNI)!=0) + if( Clientes1_Buscar.Telefono1!=0) + if( strlen(Clientes1_Buscar.Calle1)!=0) + if( strlen(Clientes1_Buscar.Num1)!=0) + if( strlen(Clientes1_Buscar.Local)!=0) + if( Clientes1_Buscar.Telefono2!=0) + if( strlen(Clientes1_Buscar.Calle2)!=0) + if( strlen(Clientes1_Buscar.Num2)!=0) + if( strlen(Clientes1_Buscar.Poblacion)!=0) + if( strlen(Clientes1_Buscar.Provincia)!=0) + if( Clientes1_Buscar.Vend!=0) + +} + +////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + if( ok != 1 ) CurrTopLine_Clien1++ ; +}while(!ok && (CurrRecord-1)<= Clientes1_inx.Fin ); + + +if ( ok == 0 ) { + + CurrTopLine_Clien1 = oldCTL; + CurrRow1_Clien = oldCR; + + Se_Puede_Buscar = 0; + Confirma("No se encontr", "equivalencia...", ""); + Comienzo_Busqueda = 0; + return NO_ENCONTRADO; +} else { + Se_Puede_Buscar = 1; + return ENCONTRADO; +} + +///////// + +} +void Edit_Item_Clientes_B(void){ +char Buffer[80]; int MR; +long Fecha; +Clientes1.NContrato = -1; + + switch (CurrCol1_Clien) { + case 1: InputCadenaG( Clientes1.Nombre, 0, 15, 63, 57, PATLD[0]); + break; + case 2: InputCadenaG( Clientes1.Apellido1, 0, 15, 63, 57, PATLD[1]); + break; + case 3: InputCadenaG( Clientes1.Apellido2, 0, 15, 63, 57, PATLD[2]); + break; + case 4: InputCadenaG( Clientes1.DNI, 0, 15, 63, 57, PATLD[3]); + break; + case 5: sprintf(Buffer, "%ld", Clientes1.Telefono1); + InputCadenaG( Buffer, 1, 9, 63, 57, PATLD[4]); + Clientes1.Telefono1 = atol(Buffer); + break; + case 6: InputCadenaG( Clientes1.Calle1, 0, 30, 63, 57, PATLD[5]); + break; + case 7: InputCadenaG( Clientes1.Num1, 0, 5, 63, 57, PATLD[6]); + break; + case 8: InputCadenaG( Clientes1.Local, 0, 30, 63, 57, PATLD[7]); + break; + case 9: sprintf(Buffer, "%ld", Clientes1.Telefono2); + InputCadenaG( Buffer, 1, 9, 63, 57, PATLD[8]); + Clientes1.Telefono2 = atol(Buffer); + break; + case 10:InputCadenaG( Clientes1.Calle2, 0, 30, 63, 57, PATLD[9]); + break; + case 11:InputCadenaG( Clientes1.Num2, 0, 5, 63, 57, PATLD[10]); + break; + case 12:InputCadenaG( Clientes1.Poblacion, 0, 18, 63, 57, PATLD[11]); + break; + case 13:InputCadenaG( Clientes1.Provincia, 0, 16, 63, 57, PATLD[12]); + break; + case 14: + while( kbhit() ) getch(); + break; + case 15: + while( kbhit() ) getch(); + break; + case 16: + while( kbhit() ) getch(); + break; + case 17: + while( kbhit() ) getch(); + break; + case 18: + while( kbhit() ) getch(); + break; + case 19: + while( kbhit() ) getch(); + break; + case 20: + while( kbhit() ) getch(); + break; + case 21:sprintf(Buffer, "%d", Clientes1.NContrato); + InputCadenaG( Buffer, 1, 4, 63, 57, PATLD[20]); + Clientes1.NContrato = atoi(Buffer); + break; + case 22:int old_Vend = Clientes1.Vend; Fuente(SMALL_FONT, 4); + sprintf(Buffer, "%d", Clientes1.Vend); + do{ + InputCadenaG( Buffer, 1, 3, 63, 57, PATLD[21]); + }while( Vend_Dir[atoi(Buffer)]==-1 ); + Clientes1.Vend = atoi(Buffer); + if( Clientes1.Vend != old_Vend ) { + Obten_Nombre_Vendedor( Clientes1.Vend ); + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PATLD[22]); + setcolor(BLANCO); + sprintf(Buffer, " %15s", Vend1.Nombre); + outtextxy( PATLD[22].left+2, PATLD[22].up+2, Buffer ); + } + Fuente(SMALL_FONT, 5); + break; + default: + return; + } + + +} +*/ diff --git a/SV_COMP.CPP b/SV_COMP.CPP new file mode 100644 index 0000000..13eb388 --- /dev/null +++ b/SV_COMP.CPP @@ -0,0 +1,1137 @@ +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "..\libs\make_bot\make_bot.h" +#include "sv_util.h" +#include "sv_graph.h" +#include "sv_ref_x.h" + + +#define Letra_Boton setcolor(1); +#define Azul 1 +#define Texto_Normal setcolor(63); +#define Texto_Negrita setcolor(0); + +extern int x_raton, y_raton, raton; +extern int boton_izq, boton_der; + +extern void desactiva_raton(void); +extern void activa_raton(void); +extern void Anclar_Raton(void); +extern void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py); +extern int Espera_Tecla_o_Raton(void); +extern void BEEP(void); + +extern int InputCadenaG(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo); +extern int InputCadenaG_l(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int Row); + +void Menu_de_Compras(void); +void Mueve_Arriba_Comp(void); +void Mueve_Abajo_Comp(void); +void EditCursorComp(int ShowHide); +void PrintLineComp(void); +void PrintWholeScreenComp(void); +void Edit_Item_Comp(void); +void Abre_Ficha_Compras(void); +void DeleteRecordComp(void); +void AddRecordComp(void); +void PutLineComp(void); +void GetLineComp(void); +void Current_Struct_to_Zero_Compras(void); +extern void Coloca_Nombres_a_botones(void); +void Imprimir_Compras(int desde, int hasta, int codigos); +void Imprimir_Compras_Menu(void); + + +// void Llena_con_Comp_basicas(void); + +void CompruebaLineasComp(void); + + + + +// extern int Confirma(char *f1, char *f2, char *f3); +extern int Comprueba_Impresora(void); + +extern void Abre_Ficha_Stock(void); + + + + +struct Comp_inx { unsigned int Fin; }; + + +struct Compras { + struct date Fecha; + int Ref; + int Und; + char Cod; +}; + +struct Compras Comp1; +struct Comp_inx Comp1_inx; + + +struct boton *PC;//[7] +extern struct boton Comunes[9]; + +FILE *Comp; // Fichero de Compras +extern FILE *Stock; // Fichero de Stock + +int CurrRowComp1; +int CurrColComp1; +int CurrTopLineComp; + + + + + +void Menu_de_Compras(void) { + + int finished = 0, key, bpush; + CurrRowComp1 = 1; CurrColComp1 = 1; + + CurrTopLineComp = 1; + +// inicializa_raton_grafico(0, 0, 624, 464, 320, 240); +// if(raton!=0) desactiva_raton(); + + if( ( PC = (struct boton *) malloc( sizeof(struct boton)*7 ) ) == NULL ) + { + Confirma("Memoria insuficiente", "para crear tablas de", "posisin PC."); + return ; + } + + cleardevice(); + Dibuja_Pantalla_Compras(PC); + Fuente(SMALL_FONT, 5); + Coloca_Nombres_a_botones(); + setcolor(GRIS_C); + outtextxy(Comunes[3].left, Comunes[3].up, " SWAP" ); + outtextxy(Comunes[3].left, Comunes[3].up+18, " F6 " ); + + + Fuente(SMALL_FONT, 6); + + Abre_Ficha_Compras(); + Abre_Ficha_Referencias(); + Abre_Ficha_Stock(); + + Carga_Referencias(); + + // Realiza el clculo para situarse en el ltimo registro \\ +// \\ + CurrTopLineComp = Comp1_inx.Fin-2; +// if(CurrTopLineComp + CurrRowComp1 - 2 >= Comp1_inx.Fin ) CurrRowComp1 = 1; + if ( CurrTopLineComp < 1 ){ CurrTopLineComp = 1; CurrRowComp1 = 1; } +CurrRowComp1 = 26; +while( (CurrTopLineComp + CurrRowComp1 - 1) != ( Comp1_inx.Fin + 1 ) ) CurrRowComp1--; +// + PrintWholeScreenComp(); + GetLineComp(); + int oldCR1=0, oldCC1=0; + +do{ + +if(oldCR1!=CurrRowComp1 || oldCC1!=CurrColComp1 ) + EditCursorComp(0); + +oldCR1 = CurrRowComp1; oldCC1 = CurrColComp1; + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + if(kbhit()){ + EditCursorComp(1); + key = getch(); + if( isprint(key) || isspace(key) ) { + EditCursorComp(0); + if(key!=13) ungetch(key); + Edit_Item_Comp(); + EditCursorComp(0); + } else if( key == 0 ) { + switch( (key=getch()) ){ + // Flecha Arriba + case 72: + Mueve_Arriba_Comp(); + break; + // Flecha Izquierda + case 75: + case 15: + CurrColComp1--; + if ( CurrColComp1<1 ) CurrColComp1=4; + break; + // Flecha Derecha + case 77: + case 9: + CurrColComp1++; + if ( CurrColComp1>4 ) CurrColComp1=1; + break; + // Flecha Abajo + case 80: + Mueve_Abajo_Comp(); + break; + // Buscar F2 + case 60: +// BuscarComp(); + break; + // Imprimir Compras F5 + case 63: + Imprimir_Compras_Menu(); + Fuente(SMALL_FONT, 6); + break; + // F9 --> AADIR + case 67: + AddRecordComp(); + break; + // F10 -> BORRAR + case 68: + if( Confirma("Desea eliminar la", "Compra Actual", "") ) DeleteRecordComp(); + break; + // INICIO + case 71: + CurrColComp1 = 1; + break; + // FIN + case 79: + CurrColComp1 = 4; + break; + // RePg + case 73: + // CurrRow = 1; + if( CurrTopLineComp > /*28*/26 ) { CurrTopLineComp -= /*28*/26; } else { CurrTopLineComp = 1; } + if( CurrTopLineComp < 1 ) { CurrTopLineComp = 1; } + PrintWholeScreenComp(); + GetLineComp(); + EditCursorComp(0); + break; + // AvPg + case 81: + // CurrRow = 1; + CurrTopLineComp += /*28*/26; + if ( (CurrTopLineComp+CurrRowComp1) > Comp1_inx.Fin) { CurrTopLineComp = Comp1_inx.Fin; CurrRowComp1 = 1; } + if (CurrTopLineComp==0) CurrTopLineComp = 1; + PrintWholeScreenComp(); + GetLineComp(); + EditCursorComp(0); + break; + // Salir F1 + case 59: + finished = 1; + break; + default: + break; + } + EditCursorComp(0); + } + } else if(raton!=0 && ( boton_izq==1 || boton_der==1 ) ) + if( (bpush = CheckButon( 9, Comunes))>0 ) { + EditCursorComp(1); + switch(bpush){ + // Flecha Arriba + case 1: + Mueve_Arriba_Comp(); + break; + // Buscar + case 2: +// BuscarVend(); + break; + // Flecha Abajo + case 3: + Mueve_Abajo_Comp(); + break; + case 4: + break; + // Imprimir + case 5: + Imprimir_Compras_Menu(); + Fuente(SMALL_FONT, 6); + break; + // Aadir + case 6: + AddRecordComp(); + break; + // Borrar + case 7: + if( Confirma("Desea eliminar la", "Compra Actual", "") ) DeleteRecordComp(); + break; + // Salir + case 9: + finished = 1; + break; + + + default: + break; + } + EditCursorComp(0); + } else CompruebaLineasComp(); + + +}while(!finished); + +fclose(Comp); // Fichero Vendedores +fclose(Ref); // Fichero Vendedores +fclose(Stock); // Fichero Vendedores +if(Memory_ok==1) farfree(Addr); else free(Ref_inx_addr); +free(PC); // Libera la memoria + + +} + +void Mueve_Abajo_Comp(void){ + + int CurrRecord = CurrTopLineComp + CurrRowComp1 - 1; + + if (CurrRowComp1==/*28*/26) { + if ( (CurrRecord - 1) >= Comp1_inx.Fin) { BEEP(); EditCursorComp(0); } + else { +/////////// +/*///////*/ +/*///////*/ CurrRowComp1 = 1; +/*///////*/ CurrTopLineComp += /*28*/26; +/*///////*/ if ( (CurrTopLineComp+CurrRowComp1) > Comp1_inx.Fin) { CurrTopLineComp = Comp1_inx.Fin; CurrRowComp1 = 1; } +/*///////*/ if (CurrTopLineComp==0) CurrTopLineComp = 1; +/*///////*/ PrintWholeScreenComp(); +/*///////*/ GetLineComp(); +/*///////*/ EditCursorComp(0); + + +/////////// CurrTopLineComp++; +/////////// PrintWholeScreenComp(); + // + // + // +/////////// GetLineComp(); +// PrintLineComp(); + } + } else { + if( (CurrRecord - 1) >= Comp1_inx.Fin) { BEEP(); EditCursorComp(0); } + else { CurrRowComp1++; + GetLineComp(); +// PrintLineComp(); + } + } + +} + +void Mueve_Arriba_Comp(void){ + int CurrRecord = CurrTopLineComp + CurrRowComp1 - 1; + + if (CurrRowComp1==1) { + if ((CurrRecord - 1) <= 0) { BEEP(); EditCursorComp(0); } + else { +//////////// +/*////////*/ +/*////////*/ if( CurrTopLineComp > /*28*/26 ) { CurrTopLineComp -= /*28*/26; } else { CurrTopLineComp = 1; } +/*////////*/ if( CurrTopLineComp < 1 ) { CurrTopLineComp = 1; } +/*////////*/ +/*////////*/ CurrRowComp1 = 26; +/*////////*/ while(CurrTopLineComp + CurrRowComp1 - 2 >= Comp1_inx.Fin ) CurrRowComp1--; + +/*////////*/ PrintWholeScreenComp(); +/*////////*/ +/*////////*/ GetLineComp(); +/*////////*/ EditCursorComp(0); + +//////////// CurrTopLineComp--; +//////////// PrintWholeScreenComp(); + // + // + // +//////////// GetLineComp(); +// PrintLineComp(); + } + + } else { + if( (CurrRecord - 1) <= 0) BEEP(); + else { CurrRowComp1--; + + GetLineComp(); +// PrintLineComp(); + } + } + +} + +void EditCursorComp(int ShowHide) { + +char Buffer[80]; + + setcolor(GRIS_C); + setfillstyle(SOLID_FILL, GRIS_C); + bar(10, 455, 545, 473); +int bar_p; +switch(CurrColComp1){ + case 1: + bar_p=0; + break; + case 2: + bar_p=1; + break; + case 3: + bar_p=3; + break; + case 4: + bar_p=4; + break; +} + + + if (!ShowHide) { + setcolor(63); + setfillstyle(SOLID_FILL, 63); //// //// //// //// + bar((PC[bar_p].left+2), PC[bar_p].up+4+(CurrRowComp1-1)*/*9*//*14*/15+2, PC[bar_p].right-2, PC[bar_p].up+/*3*/4+((CurrRowComp1)-1)*/*9*//*14*/15+/*9*/16); + setcolor(0); + } else { + setcolor(0); + setfillstyle(SOLID_FILL, 0); //// //// //// //// + bar((PC[bar_p].left+2), PC[bar_p].up+4+(CurrRowComp1-1)*/*9*//*14*/15+2, PC[bar_p].right-2, PC[bar_p].up+/*3*/4+((CurrRowComp1)-1)*/*9*//*14*/15+/*9*/16); + Texto_Normal + } + + if(Ref_no_valid) setcolor(ROJO); + + switch(CurrColComp1){ + case 1: + int day, mon; + day= Comp1.Fecha.da_day; + mon= Comp1.Fecha.da_mon; + sprintf(Buffer, "%02d/%02d/%02d", day, mon, Comp1.Fecha.da_year ); + outtextxy( PC[0].left+2, (PC[0].up+2)+(CurrRowComp1-1)*/*9*//*14*/15, Buffer ); + outtextxy( 15, 455, "Fecha de Compra. . 4 digitos mximo."); + break; + case 2: + sprintf(Buffer, "%04d", Comp1.Ref); // 4 + outtextxy( PC[1].left+2, (PC[1].up+2)+(CurrRowComp1-1)*/*9*//*14*/15, Buffer); + outtextxy( 15, 455, "Referencia de Compra. 20 digitos mximo."); + + break; + case 3: + sprintf(Buffer, "%4d", Comp1.Und); // 4 + outtextxy( PC[3].left+2, (PC[3].up+2)+(CurrRowComp1-1)*/*9*//*14*/15, Buffer ); + outtextxy( 15, 455, "Unidades Compradas. 5 digitos mximo."); + break; + case 4: + int num = Comp1.Cod; + sprintf(Buffer, "%1d", num); // 4 + outtextxy( PC[4].left+2, (PC[4].up+2)+(CurrRowComp1-1)*/*9*//*14*/15, Buffer ); + outtextxy( 15, 455, "Cdigo de Registro. 1 digito mximo."); + break; + + } + +} + + + +void PrintLineComp(void){ + + char Buffer[80]; + long total; + + setcolor(0); + setfillstyle(SOLID_FILL, 0); //// //// //// //// + bar((PC[2].left+2), PC[2].up+4+(CurrRowComp1-1)*/*9*//*14*/15+2, PC[2].right-2, PC[2].up+/*3*/4+((CurrRowComp1)-1)*/*9*//*14*/15+/*9*/16); + bar((PC[4].left+2), PC[4].up+4+(CurrRowComp1-1)*/*9*//*14*/15+2, PC[4].right-2, PC[4].up+/*3*/4+((CurrRowComp1)-1)*/*9*//*14*/15+/*9*/16); + bar((PC[5].left+2), PC[5].up+4+(CurrRowComp1-1)*/*9*//*14*/15+2, PC[5].right-2, PC[5].up+/*3*/4+((CurrRowComp1)-1)*/*9*//*14*/15+/*9*/16); + bar((PC[6].left+2), PC[6].up+4+(CurrRowComp1-1)*/*9*//*14*/15+2, PC[6].right-2, PC[6].up+/*3*/4+((CurrRowComp1)-1)*/*9*//*14*/15+/*9*/16); + + Texto_Normal + + if(Ref_no_valid) setcolor(ROJO); + + int day, mon; + day= Comp1.Fecha.da_day; + mon= Comp1.Fecha.da_mon; + sprintf(Buffer, "%02d/%02d/%02d", day, mon, Comp1.Fecha.da_year ); + outtextxy( PC[0].left+2, (PC[0].up+2)+(CurrRowComp1-1)*/*9*//*14*/15, Buffer ); + + sprintf(Buffer, "%04d", Comp1.Ref); // 4 + outtextxy( PC[1].left+2, (PC[1].up+2)+(CurrRowComp1-1)*/*9*//*14*/15, Buffer); + + outtextxy( PC[2].left+2, (PC[2].up+2)+(CurrRowComp1-1)*/*9*//*14*/15,Ref1.Concepto ); + + sprintf(Buffer, "%4d", Comp1.Und); // 4 + outtextxy( PC[3].left+2, (PC[3].up+2)+(CurrRowComp1-1)*/*9*//*14*/15, Buffer ); + + day = Comp1.Cod; + sprintf(Buffer, "%1d", day); // 1 + outtextxy( PC[4].left+2, (PC[4].up+2)+(CurrRowComp1-1)*/*9*//*14*/15, Buffer ); + + if(day==1) + total = (((Ref1.P_und * Ref1.P1)/100) + Ref1.P_und); + else + total = ( Ref1.P_und ); + + sprintf(Buffer, "% 7ld", total ); + outtextxy( PC[5].left/*+2*/-10, (PC[5].up+2)+(CurrRowComp1-1)*/*9*//*14*/15, Buffer ); + + sprintf(Buffer, "% 11lu", ( Comp1.Und * total ) ); + outtextxy( PC[6].left/*+2*/-19, (PC[6].up+2)+(CurrRowComp1-1)*/*9*//*14*/15,Buffer ); + +} + + +void PrintWholeScreenComp(void){ + +int tmp = CurrRowComp1; + +for(int i=0; i<7; i++) + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PC[i]); + + + for(CurrRowComp1 = 1; CurrRowComp1 < (/*28*/26+1); CurrRowComp1++) + + if ( (CurrTopLineComp + CurrRowComp1 - 1) <= (Comp1_inx.Fin + 1) ) { + GetLineComp(); + PrintLineComp(); + } + + +CurrRowComp1 = tmp; + +} + +void Edit_Item_Comp(void){ + + char buffer[80]; + long Fecha; + + switch (CurrColComp1) { + case 1: + int day, mon; + day= Comp1.Fecha.da_day; + mon= Comp1.Fecha.da_mon; + sprintf(buffer, "%02d%02d%02d", day, mon, Comp1.Fecha.da_year ); + do{ + InputCadenaG_l( buffer, 1, 6, 63, 57, PC[0], CurrRowComp1-1); + Fecha = atol(buffer); + Comp1.Fecha.da_day = (Fecha/10000); + Comp1.Fecha.da_mon = (Fecha/100) - ((Comp1.Fecha.da_day) * 100); + Comp1.Fecha.da_year = Fecha - ( (Comp1.Fecha.da_day*10000) + (Comp1.Fecha.da_mon*100) ); + + }while( ( Comp1.Fecha.da_day<1 || Comp1.Fecha.da_day>31 ) || (Comp1.Fecha.da_mon<1 || Comp1.Fecha.da_mon > 12) || strlen(buffer)!=6 ); + + PutLineComp(); + break; + + case 2: int old_ref = Comp1.Ref; + sprintf( buffer, "%d", Comp1.Ref); + InputCadenaG_l( buffer, 1, 4, 63, 57, PC[1], CurrRowComp1-1); + Comp1.Ref = atoi(buffer); + PutLineComp(); + /**/ + /**/ GetLineComp(); /**/ + /**/ + if(old_ref != Comp1.Ref) { + /*if(!Ref_no_valid)*/ Actualizar_Stock( old_ref, (Comp1.Und)*(-1), Comp1.Cod); + /*if(!Ref_no_valid)*/ Actualizar_Stock( Comp1.Ref, Comp1.Und, Comp1.Cod); + } + break; + case 3: int old_und = Comp1.Und; + sprintf( buffer, "%d", Comp1.Und); + InputCadenaG_l( buffer, 1, 4, 63, 57, PC[3], CurrRowComp1-1); + Comp1.Und = atol(buffer); + PutLineComp(); + if(old_und != Comp1.Und) + Actualizar_Stock( Comp1.Ref, ((Comp1.Und)-old_und), Comp1.Cod); + break; + case 4: int Cod = Comp1.Cod; + sprintf( buffer, "%d", Cod); + ungetch(8); + InputCadenaG_l( buffer, 1, 1, 63, 57, PC[4], CurrRowComp1-1); + Comp1.Cod = (char)atoi(buffer); + PutLineComp(); + if(Cod != atoi(buffer)) { + Actualizar_Stock( Comp1.Ref, (Comp1.Und)*(-1), Cod); + Actualizar_Stock( Comp1.Ref, Comp1.Und, atoi(buffer)); + } + + break; + + default: + return; + } + + PrintLineComp(); + +} + +void Abre_Ficha_Compras(void){ + +char ArchivoDatos[]="SV_Comp.DAT"; + +//// +// Comprueba apertura correcta de Indice, y Datos y creacin... // +//// + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Comp_inx); + int LSC = sizeof(struct Compras); + + if ( (Comp = fopen( ArchivoDatos, "r+b"))==NULL) { + + FILE *fa; + + if ( (fa = fopen( ArchivoDatos, "wb" ) )!=NULL ) { + + Current_Struct_to_Zero_Compras(); + Comp1_inx.Fin = 0; + rewind(fa); + + fwrite(&cabecera, LSJ, 1, fa); fseek(fa, (long)LSJ, SEEK_SET); + fwrite(&Comp1_inx, LSI, 1, fa); fseek(fa, (long)LSJ+LSI, SEEK_SET); + fwrite(&Comp1, LSC, 1, fa); + + if (fclose(fa) == EOF ) exit(1); + } + + if ( (Comp = fopen( ArchivoDatos, "r+b"))==NULL) { + restorecrtmode(); + printf("NO SE PUDO ABRIR EL FICHERO INDICE EN LA 2 PASADA"); + exit(1); + } + } + + fseek(Comp, (long)LSJ, SEEK_SET); + if ( fread(&Comp1_inx, LSI, 1, Comp) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: INDICE"); + exit(1); + } + fseek(Comp, (long)LSJ+LSI, SEEK_SET); + if ( fread(&Comp1, LSC, 1, Comp) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: DATOS"); + exit(1); + } + + +} + +void DeleteRecordComp(void) { + +unsigned int CurrRecord; + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Comp_inx); + int LSC = sizeof(struct Compras); + +CurrRecord = CurrTopLineComp + CurrRowComp1 - 1; + + if ( (Comp1_inx.Fin == 0) ) { BEEP(); + + Actualizar_Stock( Comp1.Ref, (Comp1.Und)*(-1), Comp1.Cod); + + Current_Struct_to_Zero_Compras(); + + fseek(Comp, (long)LSJ + LSI + ( LSC * ( 0 ) ), SEEK_SET); // Se coloca + fwrite(&Comp1, LSC, 1, Comp); // Y escribe +/* */ PrintWholeScreenComp(); +/* */ GetLineComp(); + EditCursorComp(0); + + + }else { + + + + Comp1_inx.Fin -= 1; + + unsigned int p = CurrRecord - 1; + + while( p <= Comp1_inx.Fin ) { + + fseek(Comp, (long)LSJ + LSI + ( LSC * ( p + 1 ) ), SEEK_SET); // Se coloca + fread(&Comp1, LSC, 1, Comp); // Y lee + + fseek(Comp, (long)LSJ + LSI + ( LSC * p ), SEEK_SET); // Se coloca + fwrite(&Comp1, LSC, 1, Comp); // Y escribe + + p++; + }; + + fseek(Comp, (long)LSJ, SEEK_SET); + fwrite(&Comp1_inx, LSI, 1, Comp); // Acualiza n de registros + +/* */ if ((CurrRecord - 1) == Comp1_inx.Fin + 1) CurrRowComp1--; +/* */ +/* */ PrintWholeScreenComp(); +/* */ GetLineComp(); + EditCursorComp(0); + +// PrintLineComp(); + } +} + + + +void AddRecordComp(void){ + +unsigned int CurrRecord= CurrTopLineComp + CurrRowComp1 - 1; + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Comp_inx); + int LSC = sizeof(struct Compras); + +if(CurrRecord < 10000 ) { + + long avance = Comp1_inx.Fin /*+ 1*/; + + while( avance >= (CurrRecord-1) ) { + + fseek(Comp, (long)LSJ + LSI + ( LSC * avance ), SEEK_SET); // Se coloca + fread(&Comp1, LSC, 1, Comp); // Y lee + + fseek(Comp, (long)LSJ + LSI + ( LSC * (avance + 1) ), SEEK_SET); // Se coloca + fwrite(&Comp1, LSC, 1, Comp); // Y escribe + + avance--; + }; + +// Comp1_inx.Fin = Comp1_inx.Fin + 1; + Comp1_inx.Fin++; + + fseek(Comp, (long)LSJ, SEEK_SET); + fwrite(&Comp1_inx, LSI, 1, Comp); // Acualiza n de registros + + Current_Struct_to_Zero_Compras(); + + fseek(Comp, (long)LSJ + LSI + ( LSC * ( CurrTopLineComp + CurrRowComp1 - 1) ), SEEK_SET); // Se coloca + fwrite(&Comp1, LSC, 1, Comp); // Y escribe + + CurrRowComp1++; + if (CurrRowComp1>/*28*/26) { CurrTopLineComp++; CurrRowComp1--; } + PrintWholeScreenComp(); + GetLineComp(); + EditCursorComp(0); +// PrintLineComp(); + + } + +} + + +void PutLineComp(void){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Comp_inx); + int LSC = sizeof(struct Compras); + + int CurrRecord = CurrTopLineComp + CurrRowComp1 - 1; + +fseek(Comp, (long)LSJ + LSI + ( LSC * CurrRecord ) - LSC, SEEK_SET); // Se coloca +fwrite(&Comp1, LSC, 1, Comp); // Y escribe + +} + +void GetLineComp(void){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Comp_inx); + int LSC = sizeof(struct Compras); + + int CurrRecord = CurrTopLineComp + CurrRowComp1 - 1; + +fseek(Comp, (long)LSJ + LSI + ( LSC * CurrRecord ) - LSC, SEEK_SET); // Se coloca +fread(&Comp1, LSC, 1, Comp); // Y lee + + BuscaReferencia(Comp1.Ref); + +} + + + + + +void Current_Struct_to_Zero_Compras(void){ + + cabecera.esc = 27; strcpy(cabecera.color, "[31;40m"); + strcpy(cabecera.prog, "Jos David Guilln Dominguez"); + cabecera.nl = 13; cabecera.rt = 10; + strcpy(cabecera.autor, " 6 / Mayo / 1995 "); + cabecera.pt = 7; cabecera.ef = 26; + + getdate( &Comp1.Fecha ); + Comp1.Fecha.da_year = Comp1.Fecha.da_year - ( ( Comp1.Fecha.da_year / 100 ) * 100 ); + Comp1.Ref=0; + Comp1.Und=0; + Comp1.Cod=1; + + +} + +void Imprimir_Compras_Menu(void){ + +int Where_Ask = 1; +int fins_print= 0, key_print, bpush; +int Desde, Hasta; + +void far *ptr; +unsigned size; +struct boton pregunta[3]; + +size = imagesize(198, 138, 372, 257); + +/* get byte size of image */ + +if ( (ptr = farmalloc(size)) != NULL) { + getimage(198, 138, 372, 257, ptr); + + pregunta[0].up = 140; pregunta[0].down = 255; + pregunta[0].left= 200; pregunta[0].right= 370; + ImprimeBoton (1, ROJO, GRIS_C, BLANCO, pregunta[0]); + pregunta[0].up = 150; pregunta[0].down = 175; + pregunta[0].left= 210; pregunta[0].right= 360; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[0]); + pregunta[1].up = 185; pregunta[1].down = 210; + pregunta[1].left= 210; pregunta[1].right= 360; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[1]); + pregunta[2].up = 220; pregunta[2].down = 245; + pregunta[2].left= 210; pregunta[2].right= 360; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[2]); + Fuente(SMALL_FONT, 4); +} else { + Where_Ask = 0; + pregunta[0].up = 450; pregunta[0].down = 475; + pregunta[0].left= 5; pregunta[0].right= 152; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[0]); + pregunta[1].up = 450; pregunta[1].down = 475; + pregunta[1].left= 155; pregunta[1].right= 309; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[1]); + pregunta[2].up = 450; pregunta[2].down = 475; + pregunta[2].left= 312; pregunta[2].right= 549; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[2]); + Fuente(SMALL_FONT, 4); +} + +Letra_Boton +outtextxy(pregunta[0].left+2, pregunta[0].up+2, "F3 Codigos 1"); +outtextxy(pregunta[1].left+2, pregunta[1].up+2, "F2 Codigos 0"); +outtextxy(pregunta[2].left+2, pregunta[2].up+2, "F1 CANCELAR IMPRESION"); + +// +do{ + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + if(kbhit()){ + key_print = getch(); + if( key_print == 0 ) { + switch( (key_print=getch()) ){ + // F1 Cancelar + case 59: + fins_print = 1; + break; + // F3 Imprimir Ficha + case 61: + if(Where_Ask){ + pregunta[0].up = 140; pregunta[0].down = 255; + pregunta[0].left= 200; pregunta[0].right= 370; + } else { + pregunta[0].up = 450; pregunta[0].down = 475; + pregunta[0].left= 5; pregunta[0].right= 549; + } + ImprimeBoton (1, GRIS_O, GRIS_C, BLANCO, pregunta[0]); + + // + if(Comprueba_Impresora()) { + Letra_Boton + if( Desde_Hasta( &Desde, &Hasta) != -1 ) { + if(Where_Ask){ outtextxy(210,150, "Imprimiendo."); + outtextxy(210,170, "Por Favor, espere..."); + } else outtextxy(10,452, "Imprimiendo. Por Favor, espere..."); + Imprimir_Compras(Desde, Hasta, 1); + } + } else { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Impresora no preparada."); + outtextxy(210,170, "Impresion Cancelada"); + } else { outtextxy(10,452, "Impresora no preparada. Impresin Cancelada."); } + Espera_Tecla_o_Raton(); + } + fins_print = 1; + + // + break; + // F2 Imprimir lista rpida + case 60: + if(Where_Ask){ + pregunta[0].up = 140; pregunta[0].down = 255; + pregunta[0].left= 200; pregunta[0].right= 370; + } else { + pregunta[0].up = 450; pregunta[0].down = 475; + pregunta[0].left= 5; pregunta[0].right= 549; + } + ImprimeBoton (1, GRIS_O, GRIS_C, BLANCO, pregunta[0]); + + // + if(Comprueba_Impresora()) { + Letra_Boton + if( Desde_Hasta( &Desde, &Hasta) != -1 ) { + if(Where_Ask){ outtextxy(210,150, "Imprimiendo."); + outtextxy(210,170, "Por Favor, espere..."); + } else outtextxy(10,452, "Imprimiendo. Por Favor, espere..."); + Imprimir_Compras(Desde, Hasta, 0); + } + } else { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Impresora no preparada."); + outtextxy(210,170, "Impresion Cancelada"); + } else { outtextxy(10,452, "Impresora no preparada. Impresin Cancelada."); } + Espera_Tecla_o_Raton(); + } + fins_print = 1; + + // + break; + default: + fins_print = 1; + } + } + } else + if(raton!=0 && boton_izq==1 || boton_der==1) { + if( (bpush = CheckButon( 3, pregunta))>0 ) { + + if(Where_Ask){ + pregunta[0].up = 140; pregunta[0].down = 255; + pregunta[0].left= 200; pregunta[0].right= 370; + } else { + pregunta[0].up = 450; pregunta[0].down = 475; + pregunta[0].left= 5; pregunta[0].right= 549; + } + ImprimeBoton (1, GRIS_O, GRIS_C, BLANCO, pregunta[0]); + + switch(bpush){ + // Imprimir Ficha + case 1: + // + if(Comprueba_Impresora()) { + Letra_Boton + if( Desde_Hasta( &Desde, &Hasta) != -1 ) { + if(Where_Ask){ outtextxy(210,150, "Imprimiendo."); + outtextxy(210,170, "Por Favor, espere..."); + } else outtextxy(10,452, "Imprimiendo. Por Favor, espere..."); + Imprimir_Compras(Desde, Hasta, 1); + } + } else { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Impresora no preparada."); + outtextxy(210,170, "Impresion Cancelada"); + } else { outtextxy(10,452, "Impresora no preparada. Impresin Cancelada."); } + Espera_Tecla_o_Raton(); + } + fins_print = 1; + // + + break; + // Imprime Lista Rpida + case 2: + // + if(Comprueba_Impresora()) { + Letra_Boton + if( Desde_Hasta( &Desde, &Hasta) != -1 ) { + if(Where_Ask){ outtextxy(210,150, "Imprimiendo."); + outtextxy(210,170, "Por Favor, espere..."); + } else outtextxy(10,452, "Imprimiendo. Por Favor, espere..."); + Imprimir_Compras(Desde, Hasta, 0); + } + } else { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Impresora no preparada."); + outtextxy(210,170, "Impresion Cancelada"); + } else { outtextxy(10,452, "Impresora no preparada. Impresin Cancelada."); } + Espera_Tecla_o_Raton(); + } + fins_print = 1; + + // + break; + // Cancelar + case 3: + fins_print=1; + break; + default: + fins_print = 1; + } + } + } + + +}while(!fins_print); + +// + + if(Where_Ask == 1) { + putimage(198, 138, ptr, COPY_PUT); + farfree(ptr); + } else { + struct boton help; + help.up = 450; help.down = 475; + help.left = 5; help.right = 549; + ImprimeBoton (1, GRIS_C, GRIS_O, BLANCO, help); + } + + Fuente(SMALL_FONT, 5); +} + + + +void Imprimir_Compras(int desde, int hasta, int codigos){ + +int LSJ = sizeof(struct JD); +int LSI = sizeof(struct Comp_inx); +int LSC = sizeof(struct Compras); +int lprint = 3, day, mon, cod, Curr_Comp = 0; +long total; +float Total_Compras = 0; + + + + +char mes[][12] = {"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", + "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"}; + +if ( Comprueba_Impresora() == 0 ) { +Confirma("Error Imprimiendo.", "Impresora Fuera de", "Servicio."); +return; +} + + +fprintf( stdprn, "\n\r"); +fprintf( stdprn, "Informe de compras\n\r"); + + fprintf( stdprn, " Fecha Ref Concepto Cod Unds. P_Und. TOTAL\n\r"); + fprintf( stdprn, "\n\r"); + + while( (Curr_Comp <= Comp1_inx.Fin) ){ + + fseek(Comp, (long)LSJ + LSI + ( LSC * Curr_Comp ), SEEK_SET); // Se coloca + fread(&Comp1, LSC, 1, Comp); // Y lee + + + mon = Comp1.Fecha.da_mon; + + if( mon>=desde && mon<=hasta ){ + + BuscaReferencia(Comp1.Ref); + day= Comp1.Fecha.da_day; + cod = Comp1.Cod; + + + if(cod==1) + total = ( ((Ref1.P_und * Ref1.P1)/100) + Ref1.P_und ); + else + total = ( Ref1.P_und ); + + if(codigos==2) { + fprintf( stdprn, "%02d/%02d%02d", day, mon, Comp1.Fecha.da_year ); + fprintf( stdprn, " % 4d %-20s % 1d % 4d % 7ld % 11lu\n\r", + Comp1.Ref, Ref1.Concepto, cod, Comp1.Und, total, ( Comp1.Und * total ) ); + Total_Compras += ( Comp1.Und * total ); + } + + if(codigos==1 && cod==1) { + fprintf( stdprn, "%02d/%02d/%02d", day, mon, Comp1.Fecha.da_year ); + fprintf( stdprn, " % 4d %-20s %1d % 4d % 7ld % 11lu\n\r", + Comp1.Ref, Ref1.Concepto, cod, Comp1.Und, total, ( Comp1.Und * total ) ); + Total_Compras += ( Comp1.Und * total ); + } + + if(codigos==0 && cod==0) { + fprintf( stdprn, "%02d/%02d/%02d", day, mon, Comp1.Fecha.da_year ); + fprintf( stdprn, " % 4d %-20s %1d % 4d % 7ld % 11lu\n\r", + Comp1.Ref, Ref1.Concepto, cod, Comp1.Und, total, ( Comp1.Und * total ) ); + Total_Compras += ( Comp1.Und * total ); + } + + + lprint++; + if (lprint==55) { lprint = 3; + fputc(12, stdprn); + fprintf( stdprn, " Fecha Ref Concepto Cod Unds. P_Und. TOTAL\n\r"); + fprintf( stdprn, "\n\r"); + } + } + Curr_Comp++; + } + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, " Total de las compras entre los meses %s a %s\n\r", mes[desde-1], mes[hasta-1]); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "--------------> %e <--------------\n\r", Total_Compras); + fputc(12, stdprn); + +} + + +void CompruebaLineasComp(void){ + // Check una pulsacion sobre un campo, y se situa, si es posible + int ok_p=0, inc=0, md=0; + int oldr, oldc; +// Anclar_Raton(); + + do{ + inc++; + if(x_raton >= (PC[(inc)-1].left+2) && x_raton <= (PC[inc-1].right-2) ) { ok_p=1; md = 1; + oldc=inc; } + if(inc==5) ok_p=1; + }while(!ok_p); + if(md==1){ + inc=0; ok_p=0; md = 0; + do{ + inc++; + if( (y_raton >= (PC[(oldc)-1].up+4+(inc-1)*15+2)) && (y_raton <= (PC[oldc-1].up+4+(inc-1)*15+16)) ) { ok_p=1; oldr=inc; md = 1;} + if(inc==26) ok_p=1; + }while(!ok_p); + } + int newc; + + switch(oldc){ + case 1: + case 2: newc = oldc; break; + case 4: + case 5: newc = (oldc - 1); break; + default: + break; + } + + + if( (md==1) && ((CurrColComp1!=newc) || (CurrRowComp1!=oldr)) ) + { + + if( (CurrTopLineComp + oldr - 2 )<= Comp1_inx.Fin ){ + EditCursorComp(1); + switch(oldc){ + case 1: + case 2: + CurrColComp1 = oldc; + CurrRowComp1 = oldr; + break; + case 4: + case 5: + CurrColComp1 = (oldc-1); + CurrRowComp1 = oldr; + break; + default: + EditCursorComp(0); + break; + } + GetLineComp(); + } + } + + } + + diff --git a/SV_DATOS.H b/SV_DATOS.H new file mode 100644 index 0000000..f302b46 --- /dev/null +++ b/SV_DATOS.H @@ -0,0 +1,25 @@ +////////////////////////////////////////////////////////////////////////////// +/// Nombre: SV_DATOS.H /// +/// Modulo: Cabecera comn a todos los mdulos /// +/// Descripcin: /// +/// /// +/// Autor: Jos David Guilln Dominguez /// +/// Fecha: 21 - 05 - 1995 /// +/// /// +/// Comentario: /// +/// /// +/// /// +/// Compilador Borland C++ 3.0 /// +////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif + + + + + +#ifdef __cplusplus +} +#endif diff --git a/SV_FACT.CPP b/SV_FACT.CPP new file mode 100644 index 0000000..bafea5b --- /dev/null +++ b/SV_FACT.CPP @@ -0,0 +1,147 @@ +#include "..\libs\make_bot\make_bot.h" +#include "SV_graph.h" +#include +#include +#include "sv_util.h" + +#define Para_Cliente 1 +#define Para_Empresa 0 + +extern struct boton Check[5]; +extern int x_raton, y_raton, raton; +extern int boton_izq, boton_der; + +extern void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py); +extern void textxy(int x, int y, char *text); +extern int Espera_Tecla_o_Raton(void); +extern void desactiva_raton(void); +extern void activa_raton(void); +extern void Anclar_Raton(void); +extern void BEEP(void); + + +void Menu_de_Facturas(void); +void Prepara_Porcentaje_Circular(void); +extern void Imprime_Todas_Facturas(int Para_quien, int Current_Date); + +void Menu_de_Facturas(void){ + + int Devuelve, finished=0, bpush; + char Select[2] = {0, 1}; + + if ( ( Devuelve = Pide_Fecha_Actual( ) ) == -1 ) return; + Pantalla_de_Facturas(); + Prepara_Porcentaje_Circular(); + + ImprimeBoton (1, ROJO, BLANCO, GRIS_O, Check[1]); +do{ + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + if(kbhit()) + switch( getch() ){ + case 0: getch(); break; + // EMPRESA + case 101: + case 69: + if( Select[0] == 1 ) { + Select[0] = 0; + ImprimeBoton (1, NEGRO, BLANCO, GRIS_O, Check[0]); + } else { + Select[0] = 1; + ImprimeBoton (1, ROJO, BLANCO, GRIS_O, Check[0]); + } + break; + // CLIENTE + case 67: + case 99: + if( Select[1] == 1 ) { + Select[1] = 0; + ImprimeBoton (1, NEGRO, BLANCO, GRIS_O, Check[1]); + } else { + Select[1] = 1; + ImprimeBoton (1, ROJO, BLANCO, GRIS_O, Check[1]); + } + break; + // COMENZAR + case 79: + case 111: + if(Select[0]==1) Imprime_Todas_Facturas(Para_Empresa, Devuelve); + if(Select[1]==1) Imprime_Todas_Facturas(Para_Cliente, Devuelve); + finished = 1; + break; + // DETENER + case 27: + case 68: + case 100: + finished = 1; + break; + default: break; + } else if(raton!=0 && ( boton_izq==1 || boton_der==1 ) ) + if( (bpush = CheckButon( 4, Check))>0 ) { + switch(bpush){ + // EMPRESA + case 1: + if( Select[0] == 1 ) { + Select[0] = 0; + ImprimeBoton (1, NEGRO, BLANCO, GRIS_O, Check[0]); + } else { + Select[0] = 1; + ImprimeBoton (1, ROJO, BLANCO, GRIS_O, Check[0]); + } + break; + // CLIENTE + case 2: + if( Select[1] == 1 ) { + Select[1] = 0; + ImprimeBoton (1, NEGRO, BLANCO, GRIS_O, Check[1]); + } else { + Select[1] = 1; + ImprimeBoton (1, ROJO, BLANCO, GRIS_O, Check[1]); + } + break; + // COMENZAR + case 3: + if(Select[0]==1) Imprime_Todas_Facturas(Para_Empresa, Devuelve); + if(Select[1]==1) Imprime_Todas_Facturas(Para_Cliente, Devuelve); + finished = 1; + break; + // DETENER + case 4: + finished = 1; + break; + default: + break; + } + + } + + +}while(!finished); + +} + +void Prepara_Porcentaje_Circular(void) { + setcolor(NEGRO); + setfillstyle(SOLID_FILL, NEGRO); + pieslice(400, 265, 0, 359, 38); + + setcolor(GRIS_O); + arc(400, 265, 300, 110, 40); + arc(400, 265, 302, 112, 39); + setcolor(BLANCO); + arc(400, 265, 110, 300, 40); + arc(400, 265, 112, 302, 39); + setcolor(GRIS_O); + arc(400, 265, 290, 100, 7); + arc(400, 265, 291, 101, 6); + setcolor(BLANCO); + arc(400, 265, 100, 290, 7); + arc(400, 265, 101, 291, 6); + setcolor(NEGRO); + setfillstyle(SOLID_FILL, GRIS_C); + pieslice(400, 265, 0, 360, 5); +} + diff --git a/SV_GCLIE.CPP b/SV_GCLIE.CPP new file mode 100644 index 0000000..dd2f39d --- /dev/null +++ b/SV_GCLIE.CPP @@ -0,0 +1,692 @@ +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "..\libs\make_bot\make_bot.h" +#include "sv_util.h" +#include "sv_graph.h" +#include "sv_ref_x.h" + + +#define Letra_Boton setcolor(1); +#define Azul 1 +#define Texto_Normal setcolor(63); +#define Texto_Negrita setcolor(0); + +extern int x_raton, y_raton, raton; +extern int boton_izq, boton_der; + +extern void desactiva_raton(void); +extern void activa_raton(void); +extern void Anclar_Raton(void); +extern void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py); +extern int Espera_Tecla_o_Raton(void); +extern void BEEP(void); +extern void textxy(int x, int y, char *text); + + +extern void Abre_Ficha_Compras(void); +extern void GetLineComp(void); + +// extern int Confirma(char *f1, char *f2, char *f3); +extern int Comprueba_Impresora(void); + +extern void Abre_Ficha_Stock(void); + +extern void Lee_Datos_Ganancias(unsigned long *Compras_mes); + +void Imprimir_Gra_Compras_C(unsigned long *Compras_mes); + +void Prepara_Pantalla_GC2(void); + +void Lee_Datos_C(unsigned long *Compras_mes); +void Muestra_Datos_C(unsigned long *Compras_mes, int Cod); +extern void Calcula_Porcentaje_C(unsigned long *Compras_mes); + +struct Comp_inx { unsigned int Fin; }; + + +struct Compras { + struct date Fecha; + int Ref; + int Und; + char Cod; +}; + +//////////// +extern void Prepara_Porcentaje_Circular(void); +extern void GetLineClientes_Compras2(void); +extern void Displayado_de_Datos(int Para_quien); +extern void Acota_Contenido(void); +extern int Viable_Apertura(void); +extern void Abre_Ficha_Clientes(void); +extern void Abre_Ficha_Clientes_Ncontrato(void); +extern void Abre_Ficha_Vendedores(void); +extern void Carga_Todos_los_Vendedores(void); +extern int CurrRow1_Clien, CurrRow2_Clien; +extern int CurrCol1_Clien, CurrCol2_Clien; +extern int CurrTopLine_Clien, CurrTopLine_Clien1; +extern void GetLineClientes(void); +extern void Abre_Ficha_Clientes_Compras(void); + +extern int *Vend_Dir; + +struct Clientes_inx_NContrato { + unsigned long Inicio; + unsigned int Records; + unsigned char Libre; + }; + +struct Clientes_inx { + char Ncontrato_ocupado_SN[10000]; + unsigned int Fin; + }; + +struct Clientes { + int Address; + + char Nombre[15+1]; char Apellido1[15+1]; char Apellido2[15+1]; + char DNI[15+1]; unsigned long Telefono1; + char Calle1[30+1]; char Num1[5+1]; + + char Local[30+1]; unsigned long Telefono2; + char Calle2[30+1]; char Num2[5+1]; + char Poblacion[18+1]; char Provincia[16+1]; unsigned long CP; + + unsigned char GC; unsigned char MR; unsigned char SP; + unsigned char DP; unsigned int MA; + + struct date Fecha; int Vend; int NContrato; + +}; + +// Se almacenan 1000 registros por archivo +// En un caso extremo son: 9 bit ---> Espacio por Dato +// 31 ---> Dias por mes +// 2 ---> Productos por da +// 12 ---> 12 meses +// 1000 ---> Clientes +// + +struct Clientes_compras { // C UU VEN REF + struct date Fecha; // 1 99 999 9999 + unsigned long Cod_Und_Vend_Ref; + }; + +struct Vend_inx { + unsigned int Fin; + }; + +struct Vendedores { + int Num_V; + char Nombre[15+1]; char Apellido1[15+1]; char Apellido2[15+1]; + char DNI[15+1]; unsigned long Telefono1; unsigned long Telefono2; + char Calle[30+1]; char Num[3+1]; char Piso[3+1]; + char Poblacion[18+1]; char Provincia[16+1]; unsigned long CP; + unsigned long CC; unsigned int PP; unsigned int Cr; +}; +/* +extern struct Stock_inx { unsigned int Fin; }; + +extern struct Stock_actual { int Ref; long Und_0; long Und_1; }; +*/ +extern struct Stock_actual Ventas1; +extern struct Stock_inx Ventas1_inx; + +extern void Actualizar_Stock(int Referencia, int Unidades, int Codigo); + + +extern struct JD cabecera; +extern struct Clientes Clientes1; +extern struct Clientes_inx Clientes1_inx; +extern struct Clientes_compras Clientes2; +extern struct Clientes_inx_NContrato Clientes1_inx_NContrato; + +// struct Clientes Clientes1_Buscar; + +extern struct Vendedores Vend1; +extern struct Vend_inx Vend1_inx; + +extern FILE *Vend; // Fichero Vendedores +extern FILE *Stock; +extern FILE *Ventas; +extern FILE *Clientes; // Fichero Clientes +extern FILE *Clientes_C; // Fichero Clientes con las Compras. +extern FILE *Clientes_NC; // Fichero Clientes con los nmeros de contrato activos. + +extern int Usa_Pc; + +extern int Start_Comp_Clien; +extern int Comp_Clien_Records; +extern int oldCNI; + + +char Buffer_Clien[15][80]; + +//////////// + +extern struct Compras Comp1; +extern struct Comp_inx Comp1_inx; + +struct boton *PGC2;//[7] +extern struct boton Comunes[9]; + +extern int CurrRowComp1; +extern int CurrColComp1; +extern int CurrTopLineComp; + +extern unsigned long TOTAL, TOTAL1, TOTAL0; +extern int Fecha; +int Dir_Pers[15]; +int Buff_Contr[15]; + +void Menu_Graficas_de_Clientes(int Current_Date); + + +void Menu_Graficas_de_Clientes(int Current_Date){ + + Fecha = Current_Date; + int i; + +for( i=0; i<15; i++) { + Dir_Pers[i] = 0; + Buff_Contr[i] = 0; + strcpy( Buffer_Clien[i], "\0"); +} + + int finished = 0, bpush; + unsigned long *Compras_mes; + + if( ( PGC2 = (struct boton *) malloc( sizeof(struct boton)*20 ) ) == NULL ) + { + Confirma("Memoria insuficiente", "para crear tablas de", "posisin PGC."); + return ; + } + + if( ( Compras_mes = (unsigned long *) malloc( sizeof(long)*24 ) ) == NULL ) + { + Confirma("Memoria insuficiente", "para crear tablas de", "Compras_mes."); + free(PGC2); + return ; + } + + for(bpush=0; bpush<24; bpush++) + Compras_mes[bpush]=0; + + +////////////////// + if( !Viable_Apertura() ) return ; + + Abre_Ficha_Clientes(); + Abre_Ficha_Clientes_Ncontrato(); + + Abre_Ficha_Referencias(); + Carga_Referencias(); + + if( ( Vend_Dir = (int *) malloc( sizeof(int)*1024 ) ) == NULL ) + { + Confirma("Memoria insuficiente", "para crear tablas para", "Vend_Dir"); + return ; + } + Abre_Ficha_Vendedores(); + Carga_Todos_los_Vendedores(); + + + CurrRow1_Clien = 1; + CurrTopLine_Clien1 = 1; + GetLineClientes(); + Abre_Ficha_Clientes_Compras(); + +////////////////// + + Lee_Datos_C(Compras_mes); + + Prepara_Pantalla_GC2(); + + Calcula_Porcentaje_C(Compras_mes); + Muestra_Datos_C(Compras_mes, 1); + +do{ + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + if(kbhit()){ + if( getch()==0 ) { + switch( (getch()) ){ + // Flecha Arriba + case 72: + break; + // Flecha Izquierda + case 75: + case 15: + break; + // Flecha Derecha + case 77: + case 9: + break; + // Flecha Abajo + case 80: + break; + // Codigo 1 F2 + case 60: +// Muestra_Datos_C(Compras_mes, 1); + break; + // Codigo 0 F3 + case 61: +// Muestra_Datos_C(Compras_mes, 0); + break; + // Codigo 1y0 F4 + case 62: +// Muestra_Datos_C(Compras_mes, 2); + break; + // Imprimir Compras F5 + case 63: + Imprimir_Gra_Compras_C(Compras_mes); + break; + // F9 --> AADIR + case 67: + break; + // F10 -> BORRAR + case 68: + break; + // INICIO + case 71: + break; + // FIN + case 79: + break; + // RePg + case 73: + // CurrRow = 1; + break; + // AvPg + case 81: + break; + // Salir F1 + case 59: + finished = 1; + break; + default: + break; + } + } + } else if(raton!=0 && ( boton_izq==1 || boton_der==1 ) ) + if( (bpush = CheckButon( 9, Comunes))>0 ) { + switch(bpush){ + // Flecha Arriba + case 1: + break; + // Buscar + case 2: + break; + // Flecha Abajo + case 3: + break; + case 4: + break; + // Imprimir + case 5: + Imprimir_Gra_Compras_C(Compras_mes); + break; + // Aadir + case 6: + break; + // Borrar + case 7: + break; + // Salir + case 9: + finished = 1; + break; + default: + break; + } + } + + +}while(!finished); + +fclose(Clientes); // Fichero Clientes +fclose(Clientes_NC); // Fichero Clientes +fclose(Clientes_C); // Fichero Clientes +fclose(Ref); // Fichero Vendedores + + +if(Memory_ok==1) farfree(Addr); else free(Ref_inx_addr); +free(PGC2); +free(Vend_Dir); +free(Compras_mes); + + +} + + +void Lee_Datos_C(unsigned long *Compras_mes){ + + setcolor(ROJO); + setfillstyle( SOLID_FILL, ROJO ); + Pantalla_de_Facturas(); + /* char Buffer[80]; */ + int /*day, mon, Ref,*/ Und,/* Cod, Vend,*/ ok, Compara, sustf; + unsigned long Suma_Total = 0, /*Suma_IVA = 0,*/ Total; + + int tmp = CurrRow1_Clien, Ptotal; + CurrTopLine_Clien1 = 1; + Usa_Pc = 1; + + CurrTopLine_Clien = 1; + Prepara_Porcentaje_Circular(); + +setcolor(4); +setfillstyle(SOLID_FILL, 60); + + + for(CurrRow1_Clien = 1; CurrRow1_Clien <= ( Clientes1_inx.Fin + 1); CurrRow1_Clien++){ + + GetLineClientes(); + if( ( (Clientes1.Address)/100/*0*/ ) != oldCNI ){ + oldCNI = ( (Clientes1.Address) / 100/*0*/ ); + fclose(Clientes_C); + Abre_Ficha_Clientes_Compras(); + } + Acota_Contenido(); + +// Porcentaje(); + + Displayado_de_Datos(5); + + setcolor(4); + setfillstyle(SOLID_FILL, 60); + +////////////////////////////////////////////////////// + Suma_Total = 0; + + for(CurrRow2_Clien = 1; (CurrTopLine_Clien + CurrRow2_Clien - 1) <= Comp_Clien_Records; CurrRow2_Clien++) { + + GetLineClientes_Compras2(); + + // X 99 999 9999 +/// Cod = ( Clientes2.Cod_Und_Vend_Ref/1000000000L ); + +// day= Clientes2.Fecha.da_day; +// mon= Clientes2.Fecha.da_mon; +// sprintf(Buffer, "%02d/%02d/%02d", day, mon, Clientes2.Fecha.da_year ); + // 1 99 999 XXXX +/// Ref = ( Clientes2.Cod_Und_Vend_Ref - ((Clientes2.Cod_Und_Vend_Ref/10000)*10000) ); + // 1 XX 999 9999 + Und = ( ( Clientes2.Cod_Und_Vend_Ref/10000000L ) - ( ( (Clientes2.Cod_Und_Vend_Ref/10000000L)/100)*100 ) ); + // 1 99 XXX 9999 +/// Vend = ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) - ( ( ( Clientes2.Cod_Und_Vend_Ref/10000 ) / 1000) * 1000 ) ); + + Total = ( (Und * Ref1.PVP) + ( ( Und * Ref1.PVP*Ref1.P2)/100) ); + + Suma_Total += Total; + + if (Usa_Pc == 1) + pieslice(400, 265, (( ( 360 * ( ( CurrRow2_Clien * 100 ) / Comp_Clien_Records ) ) / 100 ) - 1), 0, 38); + } + + // + + // +ok = 0; + +for( Compara=0; Compara<12 && !ok ; Compara++ ) { + if( Compras_mes[Compara] < Suma_Total ) { + for( sustf = 11; sustf >= Compara; sustf-- ) { + + Compras_mes[sustf] = Compras_mes[sustf-1]; + + Dir_Pers[sustf] = Dir_Pers[sustf-1]; + + strcpy( Buffer_Clien[sustf], Buffer_Clien[sustf-1]); + + Buff_Contr[sustf] = Buff_Contr[sustf-1]; + + } + Compras_mes[Compara] = Suma_Total; + Dir_Pers[Compara] = CurrRow1_Clien; + sprintf( Buffer_Clien[Compara], "%-21s", Clientes1.Local); + Buff_Contr[Compara] = Clientes1.NContrato; + ok = 1; + } +} + // + +// fprintf( stdprn, "%04d\n\r", Clientes1.NContrato); +// fprintf( stdprn, " %s\n\r",Clientes1.Local); +// fprintf( stdprn, " %s %s, %s\n\r", Clientes1.Apellido1, Clientes1.Apellido2, Clientes1.Nombre); + + // + + +////////////////////////////////////////////////////// + +// Calculamos el porcentaje total realizado +// Si todo es el: ( Clientes1_inx.Fin + 1 ) es decir 100 % +// CurrRow1_Clien el el X % +// X = ( CurrRow1_Clien * 100 ) / ( Clientes1_inx.Fin + 1 ) + +// Si 285 es el 100 % +// x es el X anterior +// x = ( 285 * X ) / 100 + Ptotal = ( ( 283 * ( ( CurrRow1_Clien * 100 ) / ( Clientes1_inx.Fin + 1 ) ) ) / 100 ); + bar(167, 172, 167 + Ptotal, 182 ); + + Prepara_Porcentaje_Circular(); + + } + +CurrRow1_Clien = tmp; + + +Usa_Pc = 0; + +} + +void Muestra_Datos_C(unsigned long *Compras_mes, int Cod){ + +char Buffer[80]; + +setcolor(ROJO); + + for(int i=0; i<12; i++){ + ImprimeBoton (1, NEGRO, BLANCO, GRIS_O, PGC2[i]); + +/// if(Cod == 1){ +/// setcolor(EGA_LIGHTBLUE); +/// sprintf(Buffer, "%18ld", Compras_mes[i*2 + 1] ); +/// } else if(Cod == 0){ +/// sprintf(Buffer, "%18ld", Compras_mes[i*2] ); +/// setcolor(ROJO); +/// } else if(Cod == 2){ + setcolor(EGA_YELLOW); + sprintf(Buffer, "%13ld", Compras_mes[i /* *2 + 1 */]/* + Compras_mes[i*2]*/ ); +/// } + outtextxy(PGC2[i].left+2, PGC2[i].up+2, Buffer); + } + + Fuente(SMALL_FONT, 4); + for(i=0; i<12; i++) + textxy( PGC2[i].left - 78 - 40 - 5, PGC2[i].up+2, Buffer_Clien[i] ); + + Fuente(SMALL_FONT, 6); +// ImprimeBoton (1, NEGRO, BLANCO, GRIS_O, PGC2[12]); +// setcolor(BLANCO); +/// if(Cod == 1) sprintf(Buffer, "%46ld", TOTAL1 ); +/// else if(Cod == 0) sprintf(Buffer, "%46ld", TOTAL0 ); +/// else if(Cod == 2) sprintf(Buffer, "%46ld", TOTAL ); + + +/// outtextxy(PGC2[12].left+2, PGC2[12].up+2, Buffer); + +// bar(152,372, ( 152 + 245 ), 388); + +} + +void Calcula_Porcentaje_C(unsigned long *Compras_mes){ + +/* long double */ TOTAL = 0; +/* long double */ TOTAL1 = 0; +/* long double */ TOTAL0 = 0; + + char Buffer[80]; + int i, ADD = 15; + long P1tmp, P0tmp, Ltmp; + + + for(i=0; i<12; i++) { + TOTAL0 += Compras_mes[ i/* *2 */ ]; +// TOTAL1 += Compras_mes[ i*2 + 1 ]; + } + TOTAL1 = 0; + + TOTAL = /* TOTAL1 + */ TOTAL0 ; + + setcolor(BLANCO); + +// sprintf(Buffer, "%46ld", TOTAL1 ); +// outtextxy(PGC2[12].left+2, PGC2[12].up+2, Buffer); + + ImprimeBoton (1, NEGRO, BLANCO, GRIS_O, PGC2[13]); + +// PGC2[13].up = 195; PGC2[13].down = 440; +// PGC2[13].left = 5; PGC2[13].right = 549; + +Fuente(SMALL_FONT, 4); + +setcolor(BLANCO); +outtextxy( 10, 350 + 15+ 5 - 150, "100 %"); + +outtextxy( 10, 350 + 15+ 5 - 75, " 50 %"); + +outtextxy( 10, 350 + 15+ 5, " 0 %"); + +setcolor(ROJO); +outtextxy( 10, 350 + 15+ 5 - 75 - 37, " 75 %"); + +outtextxy( 10, 350 + 15+ 5 - 37, " 25 %"); + +for(i=0; i<12; i++){ + + //bar3d( (ADD + 45 + (i*35 + 2 + i*5) ), 215, (ADD + 45 + (i*35 + 2 + i*5) + 35 ), 350, 10, 1); +if ( (Compras_mes[ i /* * 2 + 1 */ ] /* + Compras_mes[ i * 2 ] */ ) != 0 ) { + // Porcentaje de las compras 1 en un mes +/// P1tmp = (Compras_mes[ i /* * 2 + 1 */ ] * 100)/(Compras_mes[ i /* * 2 + 1 */ ]/* + Compras_mes[ i * 2 ]*/); +/// P0tmp = (Compras_mes[ i * 2 ] * 100)/(Compras_mes[ i * 2 + 1 ] + Compras_mes[ i * 2 ]); + P0tmp = 0; + P1tmp = 100; + + Ltmp = ( ( 150 * ( ( (Compras_mes[ i /* * 2 + 1 */ ] /*+ Compras_mes[ i * 2 ]*/) * 100 ) / TOTAL ) ) / 100 ); + +if( P1tmp != 0 && P0tmp == 0 ){ + setcolor(AZUL); + setfillstyle( i, AZUL ); + bar3d( (ADD + 45 + (i*35 + 2 + i*5) ) - 15 - 5, + 350 + 15+ 5 - ( (Ltmp * P1tmp) / 100), + (ADD + 45 + (i*35 + 2 + i*5) + 35 ) - 15 - 5, 350 + 15+5, 30, 1); +} +if( P1tmp != 0 && P0tmp != 0 ){ + setcolor(AZUL); + setfillstyle( i, AZUL ); + bar3d( (ADD + 45 + (i*35 + 2 + i*5) ) - 15 - 5, + 350 + 15+ 5 - ( (Ltmp * P1tmp) / 100), + (ADD + 45 + (i*35 + 2 + i*5) + 35 ) - 15 - 5, 350 + 15+5, 30, 0); +} +if( P0tmp != 0 ){ + setcolor(ROJO); + setfillstyle( i, ROJO ); + bar3d( (ADD + 45 + (i*35 + 2 + i*5) ) - 15 - 5, + (350 + 15+ 5 - ( (Ltmp * P1tmp) / 100) ) - ( (Ltmp * P0tmp) / 100), + (ADD + 45 + (i*35 + 2 + i*5) + 35 ) - 15 - 5, + (350 + 15+5 - ( (Ltmp * P1tmp) / 100) ), 30, 1); +} + +setcolor(EGA_YELLOW); +sprintf(Buffer, " %04d", Buff_Contr[i] ); +outtextxy( (ADD + 45 + (i*35 + 2 + i*5) ) - 15 - 5 - 5 - 1, 380 - 5, Buffer); +} +} + + + + Fuente(SMALL_FONT, 6); +} + + + +void Prepara_Pantalla_GC2(void) { + cleardevice(); + Pantalla_Graficas_Compras_C(PGC2); + + Fuente(SMALL_FONT, 5); + +// Coloca_Nombres_a_botones(); +/* + textxy(Comunes[0].left+2, Comunes[0].up, "Cdigos" ); + textxy(Comunes[0].left+2, Comunes[0].up+18, " F2" ); + + textxy(Comunes[1].left+2, Comunes[1].up, "Cdigos 0" ); + textxy(Comunes[1].left+2, Comunes[1].up+18, " F3" ); + + textxy(Comunes[2].left+2, Comunes[2].up, "Totales" ); + textxy(Comunes[2].left+2, Comunes[2].up+18, " F4" ); +*/ + + textxy(Comunes[4].left+2, Comunes[4].up, " Imprimir" ); + textxy(Comunes[4].left+2, Comunes[4].up+18, " F5" ); + + textxy(Comunes[8].left+2, Comunes[8].up, " Salir" ); + textxy(Comunes[8].left+2, Comunes[8].up+18, " F1" ); + + + Fuente(SMALL_FONT, 6); + +} + +void Imprimir_Gra_Compras_C(unsigned long *Compras_mes){ + +char mes[][12] = {"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", + "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"}; + + +if ( Comprueba_Impresora() == 0 ) { +Confirma("Error Imprimiendo.", "Impresora Fuera de", "Servicio."); +return; +} + +fprintf( stdprn, "\n\r"); + +for(int i=0; i<12; i++) { + + + CurrRow1_Clien = Dir_Pers[i]; + GetLineClientes(); + + fprintf( stdprn, "N de Contrato: %04d Local: %s\n\r", Clientes1.NContrato, Clientes1.Local); + fprintf( stdprn, "Propietario: %s %s %s ", Clientes1.Nombre, Clientes1.Apellido1, Clientes1.Apellido2); + fprintf( stdprn, "Tlf: %lu\n\r", Clientes1.Telefono2); + fprintf( stdprn, "Valor de las Compras: %10ld\n\r", Compras_mes[i]); + fprintf( stdprn, "\n\r"); + +} + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "Indice de ventas referente al mes de %s\n\r", mes[Fecha-1]); + + fputc(12, stdprn); + +} + + + + + diff --git a/SV_GCOMP.CPP b/SV_GCOMP.CPP new file mode 100644 index 0000000..a5481fc --- /dev/null +++ b/SV_GCOMP.CPP @@ -0,0 +1,440 @@ +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "..\libs\make_bot\make_bot.h" +#include "sv_util.h" +#include "sv_graph.h" +#include "sv_ref_x.h" + + +#define Letra_Boton setcolor(1); +#define Azul 1 +#define Texto_Normal setcolor(63); +#define Texto_Negrita setcolor(0); + +extern int x_raton, y_raton, raton; +extern int boton_izq, boton_der; + +extern void desactiva_raton(void); +extern void activa_raton(void); +extern void Anclar_Raton(void); +extern void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py); +extern int Espera_Tecla_o_Raton(void); +extern void BEEP(void); +extern void textxy(int x, int y, char *text); + + +extern void Abre_Ficha_Compras(void); +extern void GetLineComp(void); + +// extern int Confirma(char *f1, char *f2, char *f3); +extern int Comprueba_Impresora(void); + +extern void Abre_Ficha_Stock(void); + +extern void Lee_Datos_Ganancias(unsigned long *Compras_mes); + +void Imprimir_Gra_Compras(unsigned long *Compras_mes); +void Prepara_Pantalla_GC(void); +void Lee_Datos(unsigned long *Compras_mes); +void Muestra_Datos(unsigned long *Compras_mes, int Cod); +void Calcula_Porcentaje(unsigned long *Compras_mes); +struct Comp_inx { unsigned int Fin; }; + + +struct Compras { + struct date Fecha; + int Ref; + int Und; + char Cod; +}; + +extern struct Compras Comp1; +extern struct Comp_inx Comp1_inx; + + +struct boton *PGC;//[7] +extern struct boton Comunes[9]; + +extern FILE *Comp; // Fichero de Compras + +extern int CurrRowComp1; +extern int CurrColComp1; +extern int CurrTopLineComp; + + unsigned long TOTAL = 0, TOTAL1 = 0, TOTAL0 = 0; + + +void Menu_Graficas_de_Compras(int Compras_Ventas); +/////////////// Voy a readactar el men para que la inicializacin se pueda +/////////////// hacer desde varios puntos, y un mismo mdulo sirva para dos +/////////////// o tres cosas... + +void Menu_Graficas_de_Compras(int Compras_Ventas) { + + int finished = 0, bpush; + unsigned long *Compras_mes; + + if( ( PGC = (struct boton *) malloc( sizeof(struct boton)*20 ) ) == NULL ) + { + Confirma("Memoria insuficiente", "para crear tablas de", "posisin PGC."); + return ; + } + + if( ( Compras_mes = (unsigned long *) malloc( sizeof(long)*24 ) ) == NULL ) + { + Confirma("Memoria insuficiente", "para crear tablas de", "Compras_mes."); + free(PGC); + return ; + } + for(bpush=0; bpush<24; bpush++) + Compras_mes[bpush]=0; + + + Prepara_Pantalla_GC(); +if ( Compras_Ventas == 0 ) + Abre_Ficha_Compras(); + Abre_Ficha_Referencias(); + + Carga_Referencias(); +if ( Compras_Ventas == 0 ) + Lee_Datos(Compras_mes); +else if ( Compras_Ventas == 1 ) + Lee_Datos_Ganancias(Compras_mes); +else + Lee_Datos_Ganancias(Compras_mes); + + Calcula_Porcentaje(Compras_mes); + Muestra_Datos(Compras_mes, 1); + +do{ + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + if(kbhit()){ + if( getch()==0 ) { + switch( (getch()) ){ + // Flecha Arriba + case 72: + break; + // Flecha Izquierda + case 75: + case 15: + break; + // Flecha Derecha + case 77: + case 9: + break; + // Flecha Abajo + case 80: + break; + // Codigo 1 F2 + case 60: + Muestra_Datos(Compras_mes, 1); + break; + // Codigo 0 F3 + case 61: + Muestra_Datos(Compras_mes, 0); + break; + // Codigo 1y0 F4 + case 62: + Muestra_Datos(Compras_mes, 2); + break; + // Imprimir Compras F5 + case 63: + Imprimir_Gra_Compras(Compras_mes); + break; + // F9 --> AADIR + case 67: + break; + // F10 -> BORRAR + case 68: + break; + // INICIO + case 71: + break; + // FIN + case 79: + break; + // RePg + case 73: + // CurrRow = 1; + break; + // AvPg + case 81: + break; + // Salir F1 + case 59: + finished = 1; + break; + default: + break; + } + } + } else if(raton!=0 && ( boton_izq==1 || boton_der==1 ) ) + if( (bpush = CheckButon( 9, Comunes))>0 ) { + switch(bpush){ + // Flecha Arriba + case 1: + break; + // Buscar + case 2: + break; + // Flecha Abajo + case 3: + break; + case 4: + break; + // Imprimir + case 5: + Imprimir_Gra_Compras(Compras_mes); + break; + // Aadir + case 6: + break; + // Borrar + case 7: + break; + // Salir + case 9: + finished = 1; + break; + default: + break; + } + } + + +}while(!finished); + +if ( Compras_Ventas == 0 ) fclose(Comp); // Fichero Vendedores +fclose(Ref); // Fichero Vendedores +if(Memory_ok==1) farfree(Addr); else free(Ref_inx_addr); +free(PGC); // Libera la memoria +free(Compras_mes); + +} + + +void Lee_Datos(unsigned long *Compras_mes){ + + setcolor(ROJO); + setfillstyle( SOLID_FILL, ROJO ); + CurrTopLineComp=1; + for(CurrRowComp1 = 1; CurrRowComp1 <= (Comp1_inx.Fin + 1); CurrRowComp1++){ + + GetLineComp(); + Compras_mes[ (Comp1.Fecha.da_mon - 1)*2 + (Comp1.Cod ? 1 : 0 ) ] + += ( Comp1.Cod + ? + (((Ref1.P_und * Ref1.P1)/100) + Ref1.P_und) + : + ( Ref1.P_und ) + )*Comp1.Und; + + bar(152,372, 152 + ( (240*(CurrRowComp1*100)/(Comp1_inx.Fin + 1)) / 100 ), 388); + + } + +} + +void Muestra_Datos(unsigned long *Compras_mes, int Cod){ + +char Buffer[80]; + +setcolor(ROJO); + + for(int i=0; i<12; i++){ + ImprimeBoton (1, NEGRO, BLANCO, GRIS_O, PGC[i]); + + if(Cod == 1){ + setcolor(EGA_LIGHTBLUE); + sprintf(Buffer, "%18ld", Compras_mes[i*2 + 1] ); + } else if(Cod == 0){ + sprintf(Buffer, "%18ld", Compras_mes[i*2] ); + setcolor(ROJO); + } else if(Cod == 2){ + setcolor(EGA_YELLOW); + sprintf(Buffer, "%18ld", Compras_mes[i*2 + 1] + Compras_mes[i*2] ); + } + outtextxy(PGC[i].left+2, PGC[i].up+2, Buffer); + + } + + ImprimeBoton (1, NEGRO, BLANCO, GRIS_O, PGC[12]); + setcolor(BLANCO); + if(Cod == 1) sprintf(Buffer, "%46ld", TOTAL1 ); + else if(Cod == 0) sprintf(Buffer, "%46ld", TOTAL0 ); + else if(Cod == 2) sprintf(Buffer, "%46ld", TOTAL ); + + + outtextxy(PGC[12].left+2, PGC[12].up+2, Buffer); + +// bar(152,372, ( 152 + 245 ), 388); + +} + +void Calcula_Porcentaje(unsigned long *Compras_mes){ + + char mes[][11] = { " Enero", "Febrero", " Marzo", + " Abril", " Mayo", " Junio", + " Julio", "Agosto", "Sept.", + "Octub.", "Nov.", "Diciemb." + }; + +/* long double */ TOTAL = 0; +/* long double */ TOTAL1 = 0; +/* long double */ TOTAL0 = 0; + +// char Buffer[80]; + int i, ADD = 15; + long P1tmp, P0tmp, Ltmp; + + + for(i=0; i<12; i++) { + TOTAL0 += Compras_mes[ i*2 ]; + TOTAL1 += Compras_mes[ i*2 + 1 ]; + } + + TOTAL = TOTAL1 + TOTAL0 ; + + setcolor(BLANCO); + +// sprintf(Buffer, "%46ld", TOTAL1 ); +// outtextxy(PGC[12].left+2, PGC[12].up+2, Buffer); + + ImprimeBoton (1, NEGRO, BLANCO, GRIS_O, PGC[13]); + + + +// PGC[13].up = 195; PGC[13].down = 440; +// PGC[13].left = 5; PGC[13].right = 549; + +Fuente(SMALL_FONT, 4); + +setcolor(BLANCO); +outtextxy( 10, 350 + 15+ 5 - 150, "100 %"); + +outtextxy( 10, 350 + 15+ 5 - 75, " 50 %"); + +outtextxy( 10, 350 + 15+ 5, " 0 %"); + +setcolor(ROJO); +outtextxy( 10, 350 + 15+ 5 - 75 - 37, " 75 %"); + +outtextxy( 10, 350 + 15+ 5 - 37, " 25 %"); + +for(i=0; i<12; i++){ + + //bar3d( (ADD + 45 + (i*35 + 2 + i*5) ), 215, (ADD + 45 + (i*35 + 2 + i*5) + 35 ), 350, 10, 1); +if ( (Compras_mes[ i * 2 + 1] + Compras_mes[ i * 2 ]) != 0 ) { + // Porcentaje de las compras 1 en un mes + P1tmp = (Compras_mes[ i * 2 + 1 ] * 100)/(Compras_mes[ i * 2 + 1] + Compras_mes[ i * 2 ]); + P0tmp = (Compras_mes[ i * 2 ] * 100)/(Compras_mes[ i * 2 + 1 ] + Compras_mes[ i * 2 ]); + + Ltmp = ( ( 150 * ( ( (Compras_mes[ i * 2 + 1] + Compras_mes[ i * 2 ]) * 100 ) / TOTAL ) ) / 100 ); + +if( P1tmp != 0 && P0tmp == 0 ){ + setcolor(AZUL); + setfillstyle( i, AZUL ); + bar3d( (ADD + 45 + (i*35 + 2 + i*5) ) - 15 - 5, + 350 + 15+ 5 - ( (Ltmp * P1tmp) / 100), + (ADD + 45 + (i*35 + 2 + i*5) + 35 ) - 15 - 5, 350 + 15+5, 30, 1); +} +if( P1tmp != 0 && P0tmp != 0 ){ + setcolor(AZUL); + setfillstyle( i, AZUL ); + bar3d( (ADD + 45 + (i*35 + 2 + i*5) ) - 15 - 5, + 350 + 15+ 5 - ( (Ltmp * P1tmp) / 100), + (ADD + 45 + (i*35 + 2 + i*5) + 35 ) - 15 - 5, 350 + 15+5, 30, 0); +} +if( P0tmp != 0 ){ + setcolor(ROJO); + setfillstyle( i, ROJO ); + bar3d( (ADD + 45 + (i*35 + 2 + i*5) ) - 15 - 5, + (350 + 15+ 5 - ( (Ltmp * P1tmp) / 100) ) - ( (Ltmp * P0tmp) / 100), + (ADD + 45 + (i*35 + 2 + i*5) + 35 ) - 15 - 5, + (350 + 15+5 - ( (Ltmp * P1tmp) / 100) ), 30, 1); +} + setcolor(BLANCO); + outtextxy( (ADD + 45 + (i*35 + 2 + i*5) ) - 15 - 5 - 5 - 1, 380 - 5, mes[i]); +} +} + + + + Fuente(SMALL_FONT, 6); +} + + + +void Prepara_Pantalla_GC(void) { + cleardevice(); + Pantalla_Graficas_Compras(PGC); + Fuente(SMALL_FONT, 4); + +// Coloca_Nombres_a_botones(); + + textxy(Comunes[0].left+2, Comunes[0].up, "Cdigos 1" ); + textxy(Comunes[0].left+2, Comunes[0].up+18, " F2" ); + + textxy(Comunes[1].left+2, Comunes[1].up, "Cdigos 0" ); + textxy(Comunes[1].left+2, Comunes[1].up+18, " F3" ); + + textxy(Comunes[2].left+2, Comunes[2].up, "Totales" ); + textxy(Comunes[2].left+2, Comunes[2].up+18, " F4" ); + + + textxy(Comunes[4].left+2, Comunes[4].up, " Imprimir" ); + textxy(Comunes[4].left+2, Comunes[4].up+18, " F5" ); + + textxy(Comunes[8].left+2, Comunes[8].up, " Salir" ); + textxy(Comunes[8].left+2, Comunes[8].up+18, " F1" ); + + + Fuente(SMALL_FONT, 6); + +} + +void Imprimir_Gra_Compras(unsigned long *Compras_mes){ + + +char mes[][12] = {"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", + "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"}; + +if ( Comprueba_Impresora() == 0 ) { +Confirma("Error Imprimiendo.", "Impresora Fuera de", "Servicio."); +return; +} + +fprintf( stdprn, "\n\r"); + +for(int i=0; i<12; i++) + fprintf( stdprn, "%-10s ->> Cod.1: %10ld Cod.0: %10ld Total: %15ld\n\r", mes[i], Compras_mes[i*2 + 1], Compras_mes[i*2], Compras_mes[i*2 + 1]+Compras_mes[i*2]); + + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "TOTAL 1: %20ld\n\r", TOTAL1); + fprintf( stdprn, "TOTAL 0: %20ld\n\r", TOTAL0); + fprintf( stdprn, "TOTAL : %20ld\n\r", (TOTAL1 + TOTAL0) ); + fprintf( stdprn, "\n\r"); + + fputc(12, stdprn); + +} + + + + + diff --git a/SV_GRAPH.CPP b/SV_GRAPH.CPP new file mode 100644 index 0000000..d9621cf --- /dev/null +++ b/SV_GRAPH.CPP @@ -0,0 +1,1387 @@ +#include +#include + +#include + + + +#include "..\libs\make_bot\make_bot.h" +#include "sv_graph.h" + +void Fuente(int Fuente, int Size ); + +void textxy(int x, int y, char *text); +void Dibuja_Botones_Comunes(void); + +extern struct Make_Boton Check[5]; + +extern struct Make_Boton PP_S[5]; + +extern struct Make_Boton Comunes[9]; + + + +void Dibuja_Pantalla_Altas_Todos_los_Datos(struct Make_Boton *PATLD, struct Make_Boton *PATLD_c){ + + int A_H = 5 /*22*/; + int A_V_P = 15 /*50*/; + int A_V_P_P = -35 /*0*/; + + + Fuente(SMALL_FONT, 6); + +// char buffer[50]; + + ////////////////////////////// Calcula los botones ///////////////////////// +// Toda la pantalla + PATLD[0].Up = 0; PATLD[0].Down = 480; + PATLD[0].Left = 0; PATLD[0].Right = 640; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PATLD[0]); + +// Barra de ayuda + PATLD[0].Up = 450; PATLD[0].Down = 475; + PATLD[0].Left = 5; PATLD[0].Right = 549; + Imprime_Boton2 (1, GRIS_C, GRIS_O, BLANCO, PATLD[0]); + + + setcolor(NEGRO); + + textxy(10+A_H,50+A_V_P_P, "Nombre"); + + PATLD[0].Up = 50+A_V_P_P; PATLD[0].Down = 70+A_V_P_P; + PATLD[0].Left = 82+A_H; PATLD[0].Right = 232+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[0]); + + PATLD[1].Up = 50+A_V_P_P; PATLD[1].Down = 70+A_V_P_P; + PATLD[1].Left = 238+A_H; PATLD[1].Right = 388+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[1]); + + PATLD[2].Up = 50+A_V_P_P; PATLD[2].Down = 70+A_V_P_P; + PATLD[2].Left = 394+A_H; PATLD[2].Right = 544+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[2]); + + textxy(10+A_H,75+A_V_P_P, "D.N.I."); // 15 d + PATLD[3].Up = 75+A_V_P_P; PATLD[3].Down = 95+A_V_P_P; + PATLD[3].Left = 82+A_H; PATLD[3].Right = 232+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[3]); + + + textxy(242+A_H,75+A_V_P_P, "Telfono"); // 12 d + + PATLD[4].Up = 75+A_V_P_P; PATLD[4].Down = 95+A_V_P_P; + PATLD[4].Left = 332+A_H; PATLD[4].Right = 544+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[4]); + + textxy(10+A_H,100+A_V_P_P, "Calle"); // 30 d + PATLD[5].Up = 100+A_V_P_P; PATLD[5].Down = 120+A_V_P_P; + PATLD[5].Left = 82+A_H; PATLD[5].Right = 382+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[5]); + + textxy(392+A_H,100+A_V_P_P, "n"); + PATLD[6].Up = 100+A_V_P_P; PATLD[6].Down = 120+A_V_P_P; + PATLD[6].Left = 422+A_H; PATLD[6].Right = 544+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[6]); + + + textxy(10+A_H,150+A_V_P_P, "Local"); // 30 digitos + PATLD[7].Up = 150+A_V_P_P; PATLD[7].Down = 170+A_V_P_P; + PATLD[7].Left = 82+A_H; PATLD[7].Right = 382+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[7]); + + textxy(390+A_H,150+A_V_P_P, "Tlf."); // 12 digitos + PATLD[8].Up = 150+A_V_P_P; PATLD[8].Down = 170+A_V_P_P; + PATLD[8].Left = 422+A_H; PATLD[8].Right = 544+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[8]); + + + textxy(10+A_H,175+A_V_P_P, "Calle"); // 30 d + PATLD[9].Up = 175+A_V_P_P; PATLD[9].Down = 195+A_V_P_P; + PATLD[9].Left = 82+A_H; PATLD[9].Right = 382+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[9]); + + textxy(392+A_H,175+A_V_P_P, "n"); // 10 d + PATLD[10].Up = 175+A_V_P_P; PATLD[10].Down = 195+A_V_P_P; + PATLD[10].Left = 422+A_H; PATLD[10].Right = 544+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[10]); + + textxy(10+A_H,200+A_V_P_P, "Poblacin"); // 18 + PATLD[11].Up = 200+A_V_P_P; PATLD[11].Down = 220+A_V_P_P; + PATLD[11].Left = 100+A_H; PATLD[11].Right = 285+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[11]); + + textxy(290+A_H,200+A_V_P_P, "Provincia"); // 16 + PATLD[12].Up = 200+A_V_P_P; PATLD[12].Down = 220+A_V_P_P; + PATLD[12].Left = 380+A_H; PATLD[12].Right = 544+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[12]); + + textxy(10+A_H,225+A_V_P_P, "C.P."); + PATLD[13].Up = 225+A_V_P_P; PATLD[13].Down = 245+A_V_P_P; + PATLD[13].Left = 82+A_H; PATLD[13].Right = 135+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[13]); + + + + Fuente(SMALL_FONT, 4); + PATLD[14].Up = 220+A_V_P; PATLD[14].Down = 235+A_V_P; + PATLD[14].Left = 10+A_H; PATLD[14].Right = 45+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[14]); + textxy(55+A_H,220+A_V_P, "Grifo-columna/s."); + PATLD[15].Up = 220+A_V_P; PATLD[15].Down = 235+A_V_P; + PATLD[15].Left = 155+A_H; PATLD[15].Right = 195+A_H; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PATLD[15]); + setcolor(0); + textxy(200+A_H,220+A_V_P, "Ptas."); + + PATLD[15].Up = 240+A_V_P; PATLD[15].Down = 255+A_V_P; + PATLD[15].Left = 10+A_H; PATLD[15].Right = 45+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[15]); + textxy(55+A_H,240+A_V_P, "Manoreductor/es."); + PATLD[16].Up = 240+A_V_P; PATLD[16].Down = 255+A_V_P; + PATLD[16].Left = 155+A_H; PATLD[16].Right = 195+A_H; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PATLD[16]); + setcolor(0); + textxy(200+A_H,240+A_V_P, "Ptas."); + + PATLD[16].Up = 260+A_V_P; PATLD[16].Down = 275+A_V_P; + PATLD[16].Left = 10+A_H; PATLD[16].Right = 45+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[16]); + textxy(55+A_H,260+A_V_P, "Serpentn/es."); + PATLD[17].Up = 260+A_V_P; PATLD[17].Down = 275+A_V_P; + PATLD[17].Left = 155+A_H; PATLD[17].Right = 195+A_H; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PATLD[17]); + setcolor(0); + textxy(200+A_H,260+A_V_P, "Ptas."); + + PATLD[17].Up = 280+A_V_P; PATLD[17].Down = 295+A_V_P; + PATLD[17].Left = 10+A_H; PATLD[17].Right = 45+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[17]); + textxy(55+A_H,280+A_V_P, "Dispensador/es."); + PATLD[18].Up = 280+A_V_P; PATLD[18].Down = 295+A_V_P; + PATLD[18].Left = 155+A_H; PATLD[18].Right = 195+A_H; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PATLD[18]); + setcolor(0); + textxy(200+A_H,280+A_V_P, "Ptas."); + + textxy(10+A_H,300+A_V_P, "Material auxiliar de"); + textxy(10+A_H,310+A_V_P, "tuberas y accesorios."); + PATLD[18].Up = 300+A_V_P; PATLD[18].Down = 315+A_V_P; + PATLD[18].Left = 155+A_H; PATLD[18].Right = 195+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[18]); + setcolor(0); + textxy(200+A_H,300+A_V_P, "Ptas."); + + textxy(10+A_H,340+A_V_P, "FECHA DE INSTALACION:"); + PATLD[19].Up = 340+A_V_P; PATLD[19].Down = 355+A_V_P; + PATLD[19].Left = 138+A_H; PATLD[19].Right = 223+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[19]); +/* + setcolor(BLANCO); + outtextxy(144+A_H,342+A_V_P, " / / "); + setcolor(ROJO); + outtextxy(144-1+A_H,342-1+A_V_P, " / / "); +*/ + + Fuente(SMALL_FONT, 6); + setcolor(0); + textxy(10+A_H,370+A_V_P, "N Contrato:"); + PATLD[20].Up = 370+A_V_P; PATLD[20].Down = 390+A_V_P; + PATLD[20].Left = 130+A_H; PATLD[20].Right = 223+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[20]); + + Fuente(SMALL_FONT, 4); +/**/ PATLD[22].Up = 400+A_V_P; PATLD[22].Down = 415+A_V_P; /**/ +/**/ PATLD[22].Left = 115+A_H; PATLD[22].Right = 223+A_H; /**/ +/**/ Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[22]); /**/ + + textxy(10+A_H,400+A_V_P, "Distribuidor"); + PATLD[21].Up = 400+A_V_P; PATLD[21].Down = 415+A_V_P; + PATLD[21].Left = 80+A_H; PATLD[21].Right = 110+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD[21]); + + + + +// Parte del men de compras... + + + PATLD_c[0].Up = 200+A_V_P; PATLD_c[0].Down = 215+A_V_P; + PATLD_c[0].Left = 240+A_H; PATLD_c[0].Right = 544+A_H; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PATLD_c[0]); + Fuente(SMALL_FONT, 4); + setcolor(0); + textxy(246+A_H, 202+A_V_P, "FECHA REF. CONCEPTO UND. VEND."); + textxy(524+A_H,202+A_V_P,"COD."); + + PATLD_c[0].Up = 220+A_V_P; PATLD_c[0].Down = 415+A_V_P; + PATLD_c[0].Left = 240+A_H; PATLD_c[0].Right = 544+A_H; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PATLD_c[0]); + +// Para Fecha 6 + 2 '/' digitos + PATLD_c[0].Up = 224+A_V_P; PATLD_c[0].Down = 411+A_V_P; + PATLD_c[0].Left = 244+A_H; PATLD_c[0].Right = 295+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD_c[0]); +// Para Ref. 5 + 1 '.' digitos + PATLD_c[1].Up = 224+A_V_P; PATLD_c[1].Down = 411+A_V_P; + PATLD_c[1].Left = 300+A_H; PATLD_c[1].Right = 335+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD_c[1]); +// Para Concepto 20 digitos + PATLD_c[2].Up = 224+A_V_P; PATLD_c[2].Down = 411+A_V_P; + PATLD_c[2].Left = 340+A_H; PATLD_c[2].Right = 464+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD_c[2]); +// Para Unidades 3 digitos + PATLD_c[3].Up = 224+A_V_P; PATLD_c[3].Down = 411+A_V_P; + PATLD_c[3].Left = 469+A_H; PATLD_c[3].Right = 489+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD_c[3]); +// Para Vendedor 3 digitos (solo cdigo de registro) + PATLD_c[4].Up = 224+A_V_P; PATLD_c[4].Down = 411+A_V_P; + PATLD_c[4].Left = 494+A_H; PATLD_c[4].Right = 513+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD_c[4]); +// Para Cdigo 1 digito + PATLD_c[5].Up = 224+A_V_P; PATLD_c[5].Down = 411+A_V_P; + PATLD_c[5].Left = 524+A_H; PATLD_c[5].Right = 540+A_H; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PATLD_c[5]); + + + + + +/* +char csm[80]; Fuente(SMALL_FONT, 5); +sprintf(csm, "Altura %d, Ancho %d", textheight("M"), textwidth("M") ); +textxy(2,2, csm); +*/ +/* +// Barra de ayuda + Boton.Up = 450; Boton.Down = 475; + Boton.Left = 5; Boton.Right = 549; + +for(int n=0; n<16; n++) { + Imprime_Boton2 (1, n, GRIS_O, BLANCO, Boton); + getch(); } +*/ + Dibuja_Botones_Comunes(); +} + + +void Dibuja_Pantalla_Altas_Rapida(struct Make_Boton *PAR){ + + // struct boton PAR[12]; + Fuente(SMALL_FONT, /*6*/5); + +// char buffer[50]; + + + ////////////////////////////// Calcula los botones ///////////////////////// +// Toda la pantalla + PAR[0].Up = 0; PAR[0].Down = 480; + PAR[0].Left = 0; PAR[0].Right = 640; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PAR[0]); + +// Barra de ayuda + PAR[0].Up = 450; PAR[0].Down = 475; + PAR[0].Left = 5; PAR[0].Right = 549; + Imprime_Boton2 (1, GRIS_C, GRIS_O, BLANCO, PAR[0]); + + + PAR[0].Up = 15; PAR[0].Down = 35; + PAR[0].Left = 15; PAR[0].Right = 490; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PAR[0]); + setcolor(0); + textxy(20,15, "Local Nombre Telf."); + + + PAR[1].Up = 45; PAR[1].Down = 225; + PAR[1].Left = 15; PAR[1].Right = 259; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PAR[1]); + + + PAR[2].Up = 45; PAR[2].Down = 225; + PAR[2].Left = 264; PAR[2].Right = 388; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PAR[2]); + + PAR[3].Up = 45; PAR[3].Down = 225; + PAR[3].Left = 393; PAR[3].Right = 490; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PAR[3]); + + +// Barra de Men rapido 2, - FECHA - + PAR[4].Up = 232; PAR[4].Down = 247; + PAR[4].Left = 15; PAR[4].Right = 490; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PAR[4]); + + setcolor(0); + Fuente(SMALL_FONT, 5); + textxy( 20, 231, "Fecha Ref. Concepto Und Vend Cod"); + textxy(425, 231, "TOTAL"); + Fuente(SMALL_FONT, 2); + textxy(464, 235, "+ I.V.A."); + Fuente(SMALL_FONT, 5); + +//Fecha 8 d + PAR[4].Up = 254; PAR[4].Down = 425; + PAR[4].Left = 15; PAR[4].Right = 80; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PAR[4]); +// Ref. 5 d + PAR[5].Up = 254; PAR[5].Down = 425; + PAR[5].Left = 92; PAR[5].Right = 134; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PAR[5]); +// Concepto 20 d + PAR[6].Up = 254; PAR[6].Down = 425; + PAR[6].Left = 146; PAR[6].Right = 308; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PAR[6]); +// Unidades 3 d + PAR[7].Up = 254; PAR[7].Down = 425; + PAR[7].Left = 320; PAR[7].Right = 347; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PAR[7]); +// Vendedor 3 d + PAR[8].Up = 254; PAR[8].Down = 425; + PAR[8].Left = 359; PAR[8].Right = 386; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PAR[8]); +// Cdigo 1 d + PAR[9].Up = 254; PAR[9].Down = 425; + PAR[9].Left = 398; PAR[9].Right = 415; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PAR[9]); +// TOTAL 8 d + PAR[10].Up = 254; PAR[10].Down = 425; + PAR[10].Left = 424; PAR[10].Right = 490; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PAR[10]); + + +// BARRA TOTAL TOTAL 8 d + PAR[11].Up = 430; PAR[11].Down = 445; + PAR[11].Left = 15; PAR[11].Right = 490; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PAR[11]); + setcolor(1); + outtextxy(20, 431, "N de Contrato: Suma Total:"); + + // Suma Total == 11 digitos. Long double float 'Lf' -> _atold() <- + // long double _strtold(const char *(s), char **(endptr)); + +/* +char csm[80]; Fuente(SMALL_FONT, 5); +sprintf(csm, "Altura %d, Ancho %d", textheight("M"), textwidth("M") ); +textxy(2,2, csm); +*/ + + Dibuja_Botones_Comunes(); +} + +void Dibuja_Pantalla_Vendedores(struct Make_Boton *PV){ + + Fuente(SMALL_FONT, 6); + +// char buffer[50]; + + ////////////////////////////// Calcula los botones ///////////////////////// +// Toda la pantalla + PV[0].Up = 0; PV[0].Down = 480; + PV[0].Left = 0; PV[0].Right = 640; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PV[0]); + +// Barra de ayuda + PV[0].Up = 450; PV[0].Down = 475; + PV[0].Left = 5; PV[0].Right = 549; + Imprime_Boton2 (1, GRIS_C, GRIS_O, BLANCO, PV[0]); + + + PV[0].Up = 15; PV[0].Down = 35; + PV[0].Left = 15; PV[0].Right = 490; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PV[0]); + setcolor(0); + textxy(20,15, "N Nombre 1er. Apellido Telf."); + + // N 3 d + PV[0].Up = 45; PV[0].Down = 225; + PV[0].Left = 15; PV[0].Right = 45; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[0]); + + // Nombre 15 + PV[1].Up = 45; PV[1].Down = 225; + PV[1].Left = 52; PV[1].Right = 203; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[1]); + // 1er. Apellido 15 + PV[2].Up = 45; PV[2].Down = 225; + PV[2].Left = 210; PV[2].Right = 358; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[2]); + // Tlf. 12 + PV[3].Up = 45; PV[3].Down = 225; + PV[3].Left = 365; PV[3].Right = 490; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[3]); +// Datos completos +Fuente(SMALL_FONT, 5); +textxy(15, 235, "Nombre"); // 15, 15, 15 d + PV[4].Up =235; PV[4].Down = 255; + PV[4].Left = 85; PV[4].Right = 205; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[4]); + + PV[5].Up =235; PV[5].Down = 255; + PV[5].Left =225; PV[5].Right = 345; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[5]); + + PV[6].Up =235; PV[6].Down = 255; + PV[6].Left =365; PV[6].Right = 490; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[6]); + +textxy(15, 260, "D.N.I"); // 15 d + PV[7].Up =260; PV[7].Down = 280; + PV[7].Left = 85; PV[7].Right = 205; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[7]); + +textxy(225, 260, "Telfono"); // 12 + 12 d + PV[8].Up =260; PV[8].Down = 280; + PV[8].Left =289; PV[8].Right = 385; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[8]); + + PV[9].Up =260; PV[9].Down = 280; + PV[9].Left =394; PV[9].Right = 490; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[9]); + +textxy(15, 285, "Calle");// 30 d + PV[10].Up =285; PV[10].Down = 305; + PV[10].Left = 85; PV[10].Right = 327; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[10]); + +textxy(347, 285, "N");// 3 d + PV[11].Up =285; PV[11].Down = 305; + PV[11].Left =376; PV[11].Right = 400; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[11]); + +textxy(424, 285, "Piso"); // 3 d + PV[12].Up =285; PV[12].Down = 305; + PV[12].Left =465; PV[12].Right = 490; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[12]); + +textxy(15, 310, "Poblacin");// 18 d + PV[13].Up =310; PV[13].Down = 330; + PV[13].Left = 85; PV[13].Right = 230; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[13]); + +textxy(275, 310, "Provincia");// 16 d + PV[14].Up =310; PV[14].Down = 330; + PV[14].Left =357; PV[14].Right = 490; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[14]); + +textxy(15, 335, "C.P."); // 5 + 1 d + PV[15].Up =335; PV[15].Down = 355; + PV[15].Left = 85; PV[15].Right = 133; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[15]); + + +textxy(15, 370, "C.C."); // 5 + 1 d + PV[16].Up =370; PV[16].Down = 390; + PV[16].Left = 85; PV[16].Right = 133; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[16]); + +textxy(140, 370, " P. Producto %"); // 3 d + PV[17].Up =370; PV[17].Down = 390; + PV[17].Left =236; PV[17].Right = 263; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[17]); + +setcolor(1); +Fuente(SMALL_FONT, 4); +textxy(305, 375, "Contratos realizados"); // 3 d + setcolor(BLANCO); + outtextxy(305, 384, "( y aun activos )"); + setcolor(ROJO); + outtextxy(305-1, 384-1, "( y aun activos )"); + + PV[18].Up =370; PV[18].Down = 390; + PV[18].Left =430; PV[18].Right = 490; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PV[18]); +// Fuente(SMALL_FONT, 5); + +/* + + PV[xx].Up = 430; PV[xx].Down = 445; + PV[xx].Left = 15; PV[xx].Right = 490; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PV[xx]); + setcolor(1); + textxy(20, 431, "N de Contrato: Suma Total:"); +*/ +/* +char csm[80]; Fuente(SMALL_FONT, 5); +sprintf(csm, "Altura %d, Ancho %d", textheight("M"), textwidth("M") ); +textxy(2,2, csm); +*/ + + Dibuja_Botones_Comunes(); +} + +void Dibuja_Pantalla_Referencia(struct Make_Boton *PR){ + + Fuente(SMALL_FONT, 6); + +// char buffer[50]; + + ////////////////////////////// Calcula los botones ///////////////////////// +// Toda la pantalla + PR[0].Up = 0; PR[0].Down = 480; + PR[0].Left = 0; PR[0].Right = 640; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PR[0]); + +// Barra de ayuda + PR[0].Up = 450; PR[0].Down = 475; + PR[0].Left = 5; PR[0].Right = 549; + Imprime_Boton2 (1, GRIS_C, GRIS_O, BLANCO, PR[0]); + + + PR[0].Up = 15; PR[0].Down = 35; + PR[0].Left = 15; PR[0].Right = 549; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PR[0]); + + // 5 + 1 2 5 2 + setcolor(0); // 12345 12345678901234567890 123456 123 123456 123 + textxy(20,15, "Ref Concepto P. Und % P.V.P. %"); + + +// Ref + PR[0].Up = 40; PR[0].Down = 440; + PR[0].Left = 15; PR[0].Right = 70; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PR[0]); +// Concepto + PR[1].Up = 40; PR[1].Down = 440; + PR[1].Left = 85; PR[1].Right = 285; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PR[1]); +// P. Und + PR[2].Up = 40; PR[2].Down = 440; + PR[2].Left = 298; PR[2].Right = 373; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PR[2]); +// P. Producto + PR[3].Up = 40; PR[3].Down = 440; + PR[3].Left = 386; PR[3].Right = 416; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PR[3]); +// P. V. P. + PR[4].Up = 40; PR[4].Down = 440; + PR[4].Left = 429; PR[4].Right = 504; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PR[4]); +// P. P. Pblico + PR[5].Up = 40; PR[5].Down = 440; + PR[5].Left = 517; PR[5].Right = 549; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PR[5]); + + Dibuja_Botones_Comunes(); + +} + + +void Dibuja_Pantalla_Compras(struct Make_Boton *PC){ + + Fuente(SMALL_FONT, 6); + +// char buffer[50]; + + ////////////////////////////// Calcula los botones ///////////////////////// +// Toda la pantalla + PC[0].Up = 0; PC[0].Down = 480; + PC[0].Left = 0; PC[0].Right = 640; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PC[0]); + +// Barra de ayuda + PC[0].Up = 450; PC[0].Down = 475; + PC[0].Left = 5; PC[0].Right = 549; + Imprime_Boton2 (1, GRIS_C, GRIS_O, BLANCO, PC[0]); + + + PC[0].Up = 15; PC[0].Down = 35; + PC[0].Left = 5; PC[0].Right = 549; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PC[0]); + + // 4 + 1 5 + 1 9 + 2 + setcolor(0); // 12-12-12123451234567890123456789012345123456123456789-- + textxy(10, 15, "Fecha Ref Concepto Und. C P.Und P. Total"); + + +// Fecha 7 + 2 + PC[0].Up = 40; PC[0].Down = 440; + PC[0].Left = 5; PC[0].Right = 85; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PC[0]); +// Ref 4 + PC[1].Up = 40; PC[1].Down = 440; + PC[1].Left = 88; PC[1].Right = 128; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PC[1]); +// Concepto 20 + PC[2].Up = 40; PC[2].Down = 440; + PC[2].Left = 131; PC[2].Right = 331; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PC[2]); +// Unidades 4 + PC[3].Up = 40; PC[3].Down = 440; + PC[3].Left = 334; PC[3].Right = 377; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PC[3]); + +// Codigo 1 + PC[4].Up = 40; PC[4].Down = 440; + PC[4].Left = 380; PC[4].Right = 392; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PC[4]); + + +// P. Unidad 5 + PC[5].Up = 40; PC[5].Down = 440; + PC[5].Left = 395; PC[5].Right = 455; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PC[5]); +// TOTAL --- 9 + 2 --- + PC[6].Up = 40; PC[6].Down = 440; + PC[6].Left = 458; PC[6].Right = 549; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PC[6]); + + Dibuja_Botones_Comunes(); + +} + + +void Dibuja_Pantalla_Stock(struct Make_Boton *PS){ + + Fuente(SMALL_FONT, 5); + +// char buffer[50]; +/* + int ok, ok1; + setcolor(63); + Fuente(SMALL_FONT, 6); + ok = textheight("M"); + ok1 = textwidth("M"); + sprintf(buffer, "Altura: % 2d Anchura: % 2d Tamao: 6", ok, ok1); + textxy(10,10, buffer); + Fuente(SMALL_FONT, 5); + ok = textheight("M"); + ok1 = textwidth("M"); + sprintf(buffer, "Altura: % 2d Anchura: % 2d Tamao: 5", ok, ok1); + textxy(10,30, buffer); + Fuente(SMALL_FONT, 4); + ok = textheight("M"); + ok1 = textwidth("M"); + sprintf(buffer, "Altura: % 2d Anchura: % 2d Tamao: 4", ok, ok1); + textxy(10,45, buffer); + Fuente(SMALL_FONT, 3); + ok = textheight("M"); + ok1 = textwidth("M"); + sprintf(buffer, "Altura: % 2d Anchura: % 2d Tamao: 3", ok, ok1); + textxy(10,60, buffer); + Fuente(SMALL_FONT, 2); + ok = textheight("M"); + ok1 = textwidth("M"); + sprintf(buffer, "Altura: % 2d Anchura: % 2d Tamao: 2", ok, ok1); + textxy(10,70, buffer); +*/ +// getch(); + + + Fuente(SMALL_FONT, 4); + ////////////////////////////// Calcula los botones ///////////////////////// +// Toda la pantalla + PS[0].Up = 0; PS[0].Down = 480; + PS[0].Left = 0; PS[0].Right = 640; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PS[0]); + +// Barra de ayuda + PS[0].Up = 450; PS[0].Down = 475; + PS[0].Left = 5; PS[0].Right = 549; + Imprime_Boton2 (1, GRIS_C, GRIS_O, BLANCO, PS[0]); + + + PS[0].Up = 15; PS[0].Down = 35; + PS[0].Left = 5; PS[0].Right = 325; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PS[0]); + + + // 1234 123456789-123456789- 1234567 1234567 1234567890 + textxy(10, 17, "Ref Concepto Und. 1 Und. 0 Unds Total"); + + +// Ref 4 + 1 + PS[0].Up = 40; PS[0].Down = 440; + PS[0].Left = 5; PS[0].Right = 40; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PS[0]); +// Concepto 20 + PS[1].Up = 40; PS[1].Down = 440; + PS[1].Left = 45; PS[1].Right = 165; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PS[1]); +// Unidades 1 7 + PS[2].Up = 40; PS[2].Down = 440; + PS[2].Left = 170; PS[2].Right = 210; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PS[2]); +// Unidades 2 7 + PS[3].Up = 40; PS[3].Down = 440; + PS[3].Left = 215; PS[3].Right = 254; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PS[3]); + +// Unidades T. 7 + PS[4].Up = 40; PS[4].Down = 440; + PS[4].Left = 259; PS[4].Right = 325; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PS[4]); + + + +struct Make_Boton Ptmp; +// Pantalla de grficas. + Ptmp.Up = 15; Ptmp.Down = 213; + Ptmp.Left = 349; Ptmp.Right = 549; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, Ptmp); + + Ptmp.Up = 242; Ptmp.Down = 440; + Ptmp.Left = 349; Ptmp.Right = 549; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, Ptmp); + + Dibuja_Botones_Comunes(); + +} + + + + +void Dibuja_Botones_Comunes(void){ + + + + Comunes[0].Up = 15; Comunes[0].Down = 57; + + Comunes[1].Up = 67; Comunes[1].Down =109; + + Comunes[2].Up =119; Comunes[2].Down =161; + + Comunes[3].Up =171; Comunes[3].Down =213; + + Comunes[4].Up =223; Comunes[4].Down =265; + + Comunes[5].Up =275; Comunes[5].Down =317; + + Comunes[6].Up =327; Comunes[6].Down =369; + + Comunes[7].Up =379; Comunes[7].Down =421; + + Comunes[8].Up =431; Comunes[8].Down =473; + + for(int i=0; i<9; i++) { + Comunes[i].Left =559; Comunes[i].Right =630; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, Comunes[i]); + } + + +} + +/* +void Dibuja_Pantalla_Altas_Todos_los_Datos(void); +void Dibuja_Pantalla_Altas_Rapida(void); +void Dibuja_Pantalla_Vendedores(void); + +void Dibuja_Pantalla_Referencia(void); +void Dibuja_Pantalla_Compras(void); +void Dibuja_Pantalla_Stock(void); +*/ +void Dibuja_Pantalla_Pricipal(void){ + + Fuente(SMALL_FONT, 5); + +// char buffer[50]; + + Fuente(SMALL_FONT, 5); + ////////////////////////////// Calcula los botones ///////////////////////// +// Toda la pantalla + PP_S[0].Up = 0; PP_S[0].Down = 480; + PP_S[0].Left = 0; PP_S[0].Right = 640; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PP_S[0]); + +// Barra de ayuda + PP_S[0].Up = 450; PP_S[0].Down = 475; + PP_S[0].Left = 5; PP_S[0].Right = /*554*/635; + Imprime_Boton2 (1, GRIS_C, GRIS_O, BLANCO, PP_S[0]); + + + PP_S[0].Up = 15; PP_S[0].Down = 40; + PP_S[0].Left = 5; PP_S[0].Right = /*554*/635; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PP_S[0]); + + +// 123456789-123456789-123456789-123456789-123456789-123456789-123456789-123456789- + textxy(10, 19, " Archivo Gestion de Clientes Mantenimiento Balances Ayuda"); + + +// Archivo Estatico + PP_S[0].Up = 17; PP_S[0].Down = 38; + PP_S[0].Left = 7; PP_S[0].Right = 84; + // Imprime_Boton2 (0, NEGRO, GRIS_O, BLANCO, PP_S[0]); +// Gestion Estatico + PP_S[1].Up = 17; PP_S[1].Down = 38; + PP_S[1].Left = 91; PP_S[1].Right = 259; + // Imprime_Boton2 (0, NEGRO, GRIS_O, BLANCO, PP_S[1]); +// Mantenimiento Estatico + PP_S[2].Up = 17; PP_S[2].Down = 38; + PP_S[2].Left = 266; PP_S[2].Right = 388; + // Imprime_Boton2 (0, NEGRO, GRIS_O, BLANCO, PP_S[2]); +// Balance Estatico + PP_S[3].Up = 17; PP_S[3].Down = 38; + PP_S[3].Left = 395; PP_S[3].Right = 483; + // Imprime_Boton2 (0, NEGRO, GRIS_O, BLANCO, PP_S[3]); +// Ayuda Estatico + PP_S[4].Up = 17; PP_S[4].Down = 38; + PP_S[4].Left = 570/*490*/; PP_S[4].Right = /*552*/633; + // Imprime_Boton2 (0, NEGRO, GRIS_O, BLANCO, PP_S[4]); + + + +} + +void textxy(int x, int y, char *text){ + + setcolor(BLANCO); + outtextxy(x, y, text); + setcolor(NEGRO); + outtextxy(x-1, y-1, text); + +} + +void Pantalla_de_Facturas(void){ + struct Make_Boton Tmp; + +Tmp.Up = 130; Tmp.Down = 400; +Tmp.Left = 150; Tmp.Right = 465; +Imprime_Boton2 (1, GRIS_C, GRIS_O, BLANCO, Tmp); + +Tmp.Up = 135; Tmp.Down = 395; +Tmp.Left = 155; Tmp.Right = 460; +Imprime_Boton2 (0, GRIS_C, BLANCO, GRIS_O, Tmp); + +// Imprime_Todas_Facturas( Para_quien, Devuelve ); +textxy( 165, 140, "Porcentaje realizado:"); +Tmp.Up = 170; Tmp.Down = 185; +Tmp.Left = 165; Tmp.Right = 450; +Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, Tmp); + +textxy( 165, 200, "Imprimiendo Contrato "); +Tmp.Up = 197; Tmp.Down = 217; +Tmp.Left = 350; Tmp.Right = 450; +Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, Tmp); + +textxy( 165, 220, "Fatura para"); +textxy( 165, 240, " Empresa"); + textxy( 165, 242, " _"); +textxy( 165, 265, " Cliente"); + textxy( 165, 267, " _"); + + +Check[0].Up = 240; Check[0].Down = 255; +Check[0].Left = 145+90; Check[0].Right = 160+90; +Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, Check[0]); + +Check[1].Up = 265; Check[1].Down = 280; +Check[1].Left = 145+90; Check[1].Right = 160+90; +Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, Check[1]); + +Check[2].Up = 320; Check[2].Down = 380; +Check[2].Left = 165; Check[2].Right = 450; +Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, Check[2]); + +Check[3].Up = 290; Check[3].Down = 310; +Check[3].Left = 165; Check[3].Right = 255; +Imprime_Boton2 (0, NEGRO, GRIS_O, BLANCO, Check[3]); + +Check[4].Up = 290; Check[4].Down = 310; +Check[4].Left = 260; Check[4].Right = 350; +Imprime_Boton2 (0, NEGRO, GRIS_O, BLANCO, Check[4]); + +textxy(170, 292, " COMENZAR DETENER"); + textxy(170, 294, " _ _ "); + + +} + +void Pantalla_Graficas_Compras(struct Make_Boton *PGC){ + + Fuente(SMALL_FONT, 5); + +// char buffer[50]; + + ////////////////////////////// Calcula los botones ///////////////////////// +// Toda la pantalla + PGC[0].Up = 0; PGC[0].Down = 480; + PGC[0].Left = 0; PGC[0].Right = 640; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PGC[0]); + +// Barra de ayuda + PGC[0].Up = 450; PGC[0].Down = 475; + PGC[0].Left = 5; PGC[0].Right = 549; + Imprime_Boton2 (1, GRIS_C, GRIS_O, BLANCO, PGC[0]); + + + PGC[0].Up = 15; PGC[0].Down = 35; + PGC[6].Up = 15; PGC[6].Down = 35; + + PGC[0].Left = 85; PGC[0].Right = 275; + PGC[6].Left =360; PGC[6].Right = 549; + + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[0]); + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[6]); + + textxy( 7, 17, "Enero" ); + textxy( 282, 17, "Julio" ); + + PGC[1].Up = 40; PGC[1].Down = 60; + PGC[7].Up = 40; PGC[7].Down = 60; + + PGC[1].Left = 85; PGC[1].Right = 275; + PGC[7].Left =360; PGC[7].Right = 549; + + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[1]); + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[7]); + + textxy( 7, 42, "Febrero" ); + textxy( 282, 42, "Agosto" ); + + PGC[2].Up = 65; PGC[2].Down = 85; + PGC[8].Up = 65; PGC[8].Down = 85; + + PGC[2].Left = 85; PGC[2].Right = 275; + PGC[8].Left =360; PGC[8].Right = 549; + + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[2]); + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[8]); + + textxy( 7, 67, "Marzo" ); + textxy( 282, 67, "Septiembre" ); + + PGC[3].Up = 90; PGC[3].Down = 110; + PGC[9].Up = 90; PGC[9].Down = 110; + + PGC[3].Left = 85; PGC[3].Right = 275; + PGC[9].Left =360; PGC[9].Right = 549; + + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[3]); + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[9]); + + textxy( 7, 92, "Abril" ); + textxy( 282, 92, "Octubre" ); + + PGC[4].Up = 115; PGC[4].Down = 135; + PGC[10].Up = 115; PGC[10].Down = 135; + + PGC[4].Left = 85; PGC[4].Right = 275; + PGC[10].Left = 360; PGC[10].Right = 549; + + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[4]); + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[10]); + + textxy( 7, 117, "Mayo" ); + textxy( 282, 117, "Noviembre" ); + + PGC[5].Up = 140; PGC[5].Down = 160; + PGC[11].Up = 140; PGC[11].Down = 160; + + PGC[5].Left = 85; PGC[5].Right = 275; + PGC[11].Left =360; PGC[11].Right = 549; + + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[5]); + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[11]); + + textxy( 7, 142, "Junio" ); + textxy( 282, 142, "Diciembre" ); + + PGC[12].Up = 165; PGC[12].Down = 185; + PGC[12].Left = 85; PGC[12].Right =549; + + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[12]); + + textxy( 7, 167, "Total Anual" ); + + PGC[13].Up = 195; PGC[13].Down = 440; + PGC[13].Left = 5; PGC[13].Right = 549; + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[13]); + + Fuente(SMALL_FONT, 10); + setcolor(ROJO); + outtextxy( 148, 310, "CALCULANDO..." ); + setcolor(BLANCO); + outtextxy( 149, 311, "CALCULANDO..." ); + + PGC[14].Up = 368; PGC[14].Down = 392; + PGC[14].Left = 148; PGC[14].Right = 402; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PGC[14]); + + PGC[14].Up = 370; PGC[14].Down = 390; + PGC[14].Left = 150; PGC[14].Right = 400; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PGC[14]); + + + + +/* + Ŀ ĿĿ + Enero Julio + ٳ + Ŀ Ŀ + Febrero Agosto + + Ŀ ĿĿ + Marzo Septiembre + ٳ + Ŀ Ŀ + Abril Octubre + + Ŀ ĿĿ + Mayo Noviembre + ٳ + Ŀ Ŀ + Junio Diciembre + + ĿĿ + + + + + + Ŀ + + + + + + Ŀ + +*/ + + + + Dibuja_Botones_Comunes(); + +} + +void Pantalla_Graficas_Compras_C(struct Make_Boton *PGC){ + + Fuente(SMALL_FONT, 5); + +// char buffer[50]; + + ////////////////////////////// Calcula los botones ///////////////////////// +// Toda la pantalla + PGC[0].Up = 0; PGC[0].Down = 480; + PGC[0].Left = 0; PGC[0].Right = 640; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PGC[0]); + +// Barra de ayuda + PGC[0].Up = 450; PGC[0].Down = 475; + PGC[0].Left = 5; PGC[0].Right = 549; + Imprime_Boton2 (1, GRIS_C, GRIS_O, BLANCO, PGC[0]); + + + PGC[0].Up = 15; PGC[0].Down = 35; + PGC[6].Up = 15; PGC[6].Down = 35; + + PGC[0].Left = 85+ 50; PGC[0].Right = 275; + PGC[6].Left =360+ 50; PGC[6].Right = 549; + + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[0]); + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[6]); +/* + textxy( 7, 17, "Enero" ); + textxy( 282, 17, "Julio" ); +*/ + + PGC[1].Up = 40; PGC[1].Down = 60; + PGC[7].Up = 40; PGC[7].Down = 60; + + PGC[1].Left = 85 + 50; PGC[1].Right = 275; + PGC[7].Left =360+ 50; PGC[7].Right = 549; + + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[1]); + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[7]); +/* + textxy( 7, 42, "Febrero" ); + textxy( 282, 42, "Agosto" ); +*/ + PGC[2].Up = 65; PGC[2].Down = 85; + PGC[8].Up = 65; PGC[8].Down = 85; + + PGC[2].Left = 85+ 50; PGC[2].Right = 275; + PGC[8].Left =360+ 50; PGC[8].Right = 549; + + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[2]); + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[8]); +/* + textxy( 7, 67, "Marzo" ); + textxy( 282, 67, "Septiembre" ); +*/ + PGC[3].Up = 90; PGC[3].Down = 110; + PGC[9].Up = 90; PGC[9].Down = 110; + + PGC[3].Left = 85+ 50; PGC[3].Right = 275; + PGC[9].Left =360+ 50; PGC[9].Right = 549; + + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[3]); + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[9]); +/* + textxy( 7, 92, "Abril" ); + textxy( 282, 92, "Octubre" ); +*/ + PGC[4].Up = 115; PGC[4].Down = 135; + PGC[10].Up = 115; PGC[10].Down = 135; + + PGC[4].Left = 85+ 50; PGC[4].Right = 275; + PGC[10].Left = 360+ 50; PGC[10].Right = 549; + + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[4]); + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[10]); +/* + textxy( 7, 117, "Mayo" ); + textxy( 282, 117, "Noviembre" ); +*/ + PGC[5].Up = 140; PGC[5].Down = 160; + PGC[11].Up = 140; PGC[11].Down = 160; + + PGC[5].Left = 85+ 50; PGC[5].Right = 275; + PGC[11].Left =360+ 50; PGC[11].Right = 549; + + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[5]); + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[11]); +/* + textxy( 7, 142, "Junio" ); + textxy( 282, 142, "Diciembre" ); +*/ +/// PGC[12].Up = 165; PGC[12].Down = 185; +/// PGC[12].Left = 85; PGC[12].Right =549; + +/// Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[12]); + +// textxy( 7, 167, "Total Anual" ); + + PGC[13].Up = 195; PGC[13].Down = 440; + PGC[13].Left = 5; PGC[13].Right = 549; + Imprime_Boton2 (1, NEGRO, BLANCO, GRIS_O, PGC[13]); + + Fuente(SMALL_FONT, 10); + setcolor(ROJO); + outtextxy( 148, 310, "CALCULANDO..." ); + setcolor(BLANCO); + outtextxy( 149, 311, "CALCULANDO..." ); + + PGC[14].Up = 368; PGC[14].Down = 392; + PGC[14].Left = 148; PGC[14].Right = 402; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PGC[14]); + + PGC[14].Up = 370; PGC[14].Down = 390; + PGC[14].Left = 150; PGC[14].Right = 400; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PGC[14]); + + + + +/* + Ŀ ĿĿ + Enero Julio + ٳ + Ŀ Ŀ + Febrero Agosto + + Ŀ ĿĿ + Marzo Septiembre + ٳ + Ŀ Ŀ + Abril Octubre + + Ŀ ĿĿ + Mayo Noviembre + ٳ + Ŀ Ŀ + Junio Diciembre + + ĿĿ + + + + + + Ŀ + + + + + + Ŀ + +*/ + + + + Dibuja_Botones_Comunes(); + +} + +void Dibuja_Pantalla_Ventas(struct Make_Boton *PVent){ + + Fuente(SMALL_FONT, 5); + + Fuente(SMALL_FONT, 4); + ////////////////////////////// Calcula los botones ///////////////////////// +// Toda la pantalla + PVent[0].Up = 0; PVent[0].Down = 480; + PVent[0].Left = 0; PVent[0].Right = 640; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PVent[0]); + +// Barra de ayuda + PVent[0].Up = 450; PVent[0].Down = 475; + PVent[0].Left = 5; PVent[0].Right = 549; + Imprime_Boton2 (1, GRIS_C, GRIS_O, BLANCO, PVent[0]); + + + PVent[0].Up = 15; PVent[0].Down = 35; + PVent[0].Left = 5; PVent[0].Right = /*325*/549; + Imprime_Boton2 (1, GRIS_C, BLANCO, GRIS_O, PVent[0]); + + + // 1234 123456789-123456789- 1234567 1234567890 1234567 1234567890 1234567890 123456789123 + textxy(10, 17, "Ref Concepto Und. 1 V. Bruto 1 Und. 0 V. Bruto 0 Unds Total T. V. Bruto"); + + +// Ref 4 + 1 + PVent[0].Up = 40; PVent[0].Down = 440; + PVent[0].Left = 5; PVent[0].Right = 40; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PVent[0]); +// Concepto 20 + PVent[1].Up = 40; PVent[1].Down = 440; + PVent[1].Left = 45; PVent[1].Right = 165; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PVent[1]); +// Unidades 1 7 + PVent[2].Up = 40; PVent[2].Down = 440; + PVent[2].Left = 170; PVent[2].Right = 210; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PVent[2]); +// Ventas Bruto 1 10 + PVent[3].Up = 40; PVent[3].Down = 440; + PVent[3].Left = 215; PVent[3].Right = 305-25; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PVent[3]); +// Unidades 0 7 + PVent[4].Up = 40; PVent[4].Down = 440; + PVent[4].Left = 310-25; PVent[4].Right = 350-25; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PVent[4]); +// Ventas Bruto 1 10 + PVent[5].Up = 40; PVent[5].Down = 440; + PVent[5].Left = 355-25; PVent[5].Right = 445-25-25; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PVent[5]); +// Unidades Total 7 + PVent[6].Up = 40; PVent[6].Down = 440; + PVent[6].Left = 450-25-25; PVent[6].Right = 500-25-20; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PVent[6]); +// Total Ventas Bruto 1 10 + PVent[7].Up = 40; PVent[7].Down = 440; + PVent[7].Left = 505-25-20; PVent[7].Right = 549; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, PVent[7]); + + + +// struct boton Ptmp; +// Pantalla de grficas. +/* + Ptmp.Up = 15; Ptmp.Down = 213; + Ptmp.Left = 349; Ptmp.Right = 549; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, Ptmp); + + Ptmp.Up = 242; Ptmp.Down = 440; + Ptmp.Left = 349; Ptmp.Right = 549; + Imprime_Boton2 (1, NEGRO, GRIS_O, BLANCO, Ptmp); +*/ + + Dibuja_Botones_Comunes(); + +} + +void Imprime_Boton2(int D_Bord, char Cf, int Cb1, int Cb2, struct Make_Boton Bot_Imp){ + + int puntos[14]; + unsigned char Ab = D_Bord; + +if ( Bot_Imp.Down < 0 ) + { + if(Bot_Imp.Pb > 0) + { + puntos[1] = 120; + puntos[2] = 300; + } else { + puntos[1] = 60; + puntos[2] = 240; + } + setlinestyle(0, 1, NORM_WIDTH); + setcolor(Cb1); + setfillstyle(SOLID_FILL, Cb1); + for ( puntos[0] = 0; puntos[0] < Ab; puntos[0]++ ) + arc( Bot_Imp.Left, Bot_Imp.Up, puntos[1]+puntos[0], puntos[2]+puntos[0], Bot_Imp.Right - puntos[0]); + setcolor(Cb2); + setfillstyle(SOLID_FILL, Cb2); + for ( puntos[0] = 0; puntos[0] < Ab; puntos[0]++ ) + arc( Bot_Imp.Left, Bot_Imp.Up, puntos[2]+puntos[0], puntos[1]+puntos[0], Bot_Imp.Right - puntos[0]); + + if(D_Bord) { + setcolor(Cf); + setfillstyle(SOLID_FILL, Cf); + pieslice( Bot_Imp.Left, Bot_Imp.Up, 0, 360, Bot_Imp.Right - Ab); + } + + if( Ab >= 2 ) { + setcolor( NEGRO ); + setfillstyle(EMPTY_FILL, Cf); + circle( Bot_Imp.Left, Bot_Imp.Up, Bot_Imp.Right); + } + + } else { + + if(Bot_Imp.Pb == 2) { + puntos[0] = Bot_Imp.Left; puntos[1] = Bot_Imp.Up; + puntos[2] = Bot_Imp.Right; puntos[3] = Bot_Imp.Up; + puntos[4] = Bot_Imp.Right; puntos[5] = Bot_Imp.Down; + puntos[6] = (Bot_Imp.Right-Ab); puntos[7] = (Bot_Imp.Down-Ab); + puntos[8] = (Bot_Imp.Right-Ab); puntos[9] = (Bot_Imp.Up+Ab); + puntos[10] = (Bot_Imp.Left+Ab); puntos[11] = (Bot_Imp.Up+Ab); + puntos[12] = Bot_Imp.Left; puntos[13] = Bot_Imp.Up; + } else { + puntos[0] = Bot_Imp.Left; puntos[1] = Bot_Imp.Up; + puntos[2] = Bot_Imp.Right; puntos[3] = Bot_Imp.Up; + puntos[4] = Bot_Imp.Right - Ab; puntos[5] = Bot_Imp.Up + Ab; + puntos[6] = Bot_Imp.Left + Ab; puntos[7] = Bot_Imp.Up + Ab; + puntos[8] = Bot_Imp.Left + Ab; puntos[9] = Bot_Imp.Down - Ab; + puntos[10] = Bot_Imp.Left; puntos[11] = Bot_Imp.Down; + puntos[12] = Bot_Imp.Left; puntos[13] = Bot_Imp.Up; + } + + setcolor(Cb1); + setfillstyle(SOLID_FILL, Cb1); + setlinestyle(0, 1, NORM_WIDTH); + fillpoly(7, puntos); + + if(Bot_Imp.Pb == 2) { + puntos[0] = Bot_Imp.Left+Ab; puntos[1] = Bot_Imp.Up+Ab; + puntos[2] = Bot_Imp.Left+Ab; puntos[3] = Bot_Imp.Down-Ab; + puntos[4] = Bot_Imp.Right-Ab; puntos[5] = Bot_Imp.Down-Ab; + puntos[6] = Bot_Imp.Right; puntos[7] = Bot_Imp.Down; + puntos[8] = Bot_Imp.Left; puntos[9] = Bot_Imp.Down; + puntos[10] = Bot_Imp.Left; puntos[11] = Bot_Imp.Up; + puntos[12] = Bot_Imp.Left+Ab; puntos[13] = Bot_Imp.Up+Ab; + } else { + puntos[0] = Bot_Imp.Right; puntos[1] = Bot_Imp.Up; + puntos[2] = Bot_Imp.Right; puntos[3] = Bot_Imp.Down; + puntos[4] = Bot_Imp.Left; puntos[5] = Bot_Imp.Down; + puntos[6] = Bot_Imp.Left+Ab; puntos[7] = Bot_Imp.Down-Ab; + puntos[8] = Bot_Imp.Right-Ab; puntos[9] = Bot_Imp.Down-Ab; + puntos[10] = Bot_Imp.Right-Ab; puntos[11] = Bot_Imp.Up+Ab; + puntos[12] = Bot_Imp.Right; puntos[13] = Bot_Imp.Up; + } + + setcolor(Cb2); + setfillstyle(SOLID_FILL, Cb2); + setlinestyle(0, 1, NORM_WIDTH); + fillpoly(7, puntos); + + if(D_Bord) { + setcolor(Cf); + setfillstyle(SOLID_FILL, Cf); + bar(Bot_Imp.Left+Ab+1, Bot_Imp.Up+Ab+1, Bot_Imp.Right-Ab-1, Bot_Imp.Down-Ab-1); + } + + if( Ab >= 2 ) { + setcolor( NEGRO ); + setfillstyle(EMPTY_FILL, Cf); + rectangle(Bot_Imp.Left, Bot_Imp.Up, Bot_Imp.Right, Bot_Imp.Down); + } +} + +} + +void Fuente(int Fuente, int Size ) +{ + /* select the registered font */ + settextstyle( Fuente, HORIZ_DIR, Size); +}; diff --git a/SV_GRAPH.H b/SV_GRAPH.H new file mode 100644 index 0000000..9bbf5d4 --- /dev/null +++ b/SV_GRAPH.H @@ -0,0 +1,35 @@ +#define NEGRO 0 +#define AZUL 1 +#define ROJO 4 +#define VERDE 2 +#define BLANCO 63 +#define GRIS_O 56 +#define GRIS_C 7 +#define AMARILLO 62 + +void Imprime_Boton2(int D_Bord, char Cf, int Cb1, int Cb2, struct Make_Boton Bot_Imp); +void Fuente(int Fuente, int Size ); + + +void Dibuja_Pantalla_Altas_Rapida(struct Make_Boton *PAR); +void Dibuja_Pantalla_Pricipal(void); + +void Dibuja_Pantalla_Altas_Todos_los_Datos(struct Make_Boton *PATLD, struct Make_Boton *PATLD_c); +void Dibuja_Pantalla_Vendedores(struct Make_Boton *PV); +void Dibuja_Pantalla_Referencia(struct Make_Boton *PR); +void Dibuja_Pantalla_Compras(struct Make_Boton *PC); +void Dibuja_Pantalla_Stock(struct Make_Boton *PS); +void Pantalla_de_Facturas(void); + +void Pantalla_Graficas_Compras(struct Make_Boton *PGC); +void Pantalla_Graficas_Compras_C(struct Make_Boton *PGC); +void Imprime_Boton2(int D_Bord, char Cf, int Cb1, int Cb2, struct Make_Boton Bot_Imp); +void Dibuja_Pantalla_Ventas(struct Make_Boton *PVent); + struct Make_Boton { + /* unsigned */ int Up, Left, Down, Right; + unsigned char Cdf, Cb1, Cb2; + unsigned char Ab, Pb; + unsigned char Isc, Sc; + }; + +int CheckButon(int nb, struct boton menu[]); \ No newline at end of file diff --git a/SV_REF.CPP b/SV_REF.CPP new file mode 100644 index 0000000..bd713a1 --- /dev/null +++ b/SV_REF.CPP @@ -0,0 +1,723 @@ +#include +#include +#include +#include +#include +#include +#include + + +#include "..\libs\make_bot\make_bot.h" +#include "sv_graph.h" +#include "sv_util.h" + +/*///////*/ + #include "sv_ref_x.h" + +#define Letra_Boton setcolor(1); +#define Azul 1 +#define Texto_Normal setcolor(63); +#define Texto_Negrita setcolor(0); + +extern int x_raton, y_raton, raton; +extern int boton_izq, boton_der; + +extern void desactiva_raton(void); +extern void activa_raton(void); +extern void Anclar_Raton(void); +extern void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py); +extern int Espera_Tecla_o_Raton(void); +extern void BEEP(void); + +extern int InputCadenaG(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo); +extern int InputCadenaG_l(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int Row); + +void Menu_de_Referencias(void); +void Mueve_Arriba_Ref(void); +void Mueve_Abajo_Ref(void); +void EditCursorRef(int ShowHide); +void PrintLineRef(void); +void PrintWholeScreenRef(void); +void Edit_Item_Ref(void); +void Abre_Ficha_Referencias(void); +void DeleteRecordRef(void); +void AddRecordRef(int Imprime); +void PutLineRef(void); +void GetLineRef(void); +void Poner_a_cero_estructura_actual_Ref(void); +extern void Coloca_Nombres_a_botones(void); +void Imprimir_Referencias(void); +void Llena_con_ref_basicas(void); +void CompruebaLineasRef(void); + +// extern int Confirma(char *f1, char *f2, char *f3); +extern int Comprueba_Impresora(void); + +struct Referencias Ref1; +struct Ref_inx Ref1_inx; +extern struct JD cabecera; + +struct boton *PR;//[6] +extern struct boton Comunes[9]; + +FILE *Ref; // Fichero Vendedores + +int CurrRowRef1; +int CurrColRef1; +int CurrTopLineRef; + +void Menu_de_Referencias(void) { + + int finished = 0, key, bpush; + CurrRowRef1 = 6; CurrColRef1 = 1; + + CurrTopLineRef = 1; + + inicializa_raton_grafico(0, 0, 624, 464, 320, 240); + if(raton!=0) desactiva_raton(); + + if( ( PR = (struct boton *) malloc( sizeof(struct boton)*6 ) ) == NULL ) + { + Confirma("Memoria insuficiente", "para crear tablas de", "posisin PR."); + return ; + } + + cleardevice(); + Dibuja_Pantalla_Referencia(PR); + Fuente(SMALL_FONT, 5); + Coloca_Nombres_a_botones(); + setcolor(GRIS_C); + outtextxy(Comunes[3].left, Comunes[3].up, " SWAP" ); + outtextxy(Comunes[3].left, Comunes[3].up+18, " F6 " ); + + + Fuente(SMALL_FONT, 6); + Abre_Ficha_Referencias(); +/*/////////*/ Carga_Referencias(); + PrintWholeScreenRef(); + GetLineRef(); + int oldCR1=0, oldCC1=0; + +do{ + +if(oldCR1!=CurrRowRef1 || oldCC1!=CurrColRef1 ) + EditCursorRef(0); + +oldCR1 = CurrRowRef1; oldCC1 = CurrColRef1; + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + if(kbhit()){ + EditCursorRef(1); + key = getch(); + if( isprint(key) || isspace(key) ) { + EditCursorRef(0); + if(key!=13) ungetch(key); + Edit_Item_Ref(); + EditCursorRef(0); + } else if( key == 0 ) { + switch( (key=getch()) ){ + // Flecha Arriba + case 72: + Mueve_Arriba_Ref(); + break; + // Flecha Izquierda + case 75: + case 15: + CurrColRef1--; + if ( CurrColRef1<1 ) CurrColRef1=6; + break; + // Flecha Derecha + case 77: + case 9: + CurrColRef1++; + if ( CurrColRef1>6 ) CurrColRef1=1; + break; + // Flecha Abajo + case 80: + Mueve_Abajo_Ref(); + break; + // Buscar F2 + case 60: +// BuscarRef(); + break; + // Imprimir Referencias F5 + case 63: + Imprimir_Referencias(); + break; + // F9 --> AADIR + case 67: + AddRecordRef(1); + break; + // F10 -> BORRAR + case 68: + if( Confirma("Desea eliminar la", "Referencia Actual", "") ) DeleteRecordRef(); + break; + // INICIO + case 71: + CurrColRef1 = 1; + break; + // FIN + case 79: + CurrColRef1 = 5; + break; + // RePg + case 73: + // CurrRow = 1; + if( CurrTopLineRef > /*28*/26 ) { CurrTopLineRef -= /*28*/26; } else { CurrTopLineRef = 1; } + if( CurrTopLineRef < 1 ) { CurrTopLineRef = 1; } + if( (CurrTopLineRef + CurrRowRef1 - 1) == 5 ) CurrRowRef1 = 2; + PrintWholeScreenRef(); + GetLineRef(); + break; + // AvPg + case 81: + // CurrRow = 1; + CurrTopLineRef += /*28*/26; + if ( (CurrTopLineRef+CurrRowRef1) > Ref1_inx.Fin) { CurrTopLineRef = Ref1_inx.Fin; CurrRowRef1 = 1; } + if (CurrTopLineRef==0) CurrTopLineRef = 1; + if( (CurrTopLineRef + CurrRowRef1 - 1) == 5 ) CurrRowRef1 = 2; + PrintWholeScreenRef(); + GetLineRef(); + break; + // Salir F1 + case 59: + finished = 1; + break; + default: + break; + } + EditCursorRef(0); + } + } else if(raton!=0 && ( boton_izq==1 || boton_der==1 ) ) + if( (bpush = CheckButon( 9, Comunes))>0 ) { + EditCursorRef(1); + switch(bpush){ + // Flecha Arriba + case 1: + Mueve_Arriba_Ref(); + break; + // Buscar + case 2: +// BuscarVend(); + break; + // Flecha Abajo + case 3: + Mueve_Abajo_Ref(); + break; + case 4: + break; + // Imprimir + case 5: + Imprimir_Referencias(); + break; + // Aadir + case 6: + AddRecordRef(1); + break; + // Borrar + case 7: + if( Confirma("Desea eliminar la", "Referencia Actual", "") ) DeleteRecordRef(); + break; + // Salir + case 9: + finished = 1; + break; + + + default: + break; + } + EditCursorRef(0); + } else CompruebaLineasRef(); + +}while(!finished); + +fclose(Ref); // Fichero Vendedores +free(PR); + +} + +void Mueve_Abajo_Ref(void){ + + int CurrRecord = CurrTopLineRef + CurrRowRef1 - 1; + + if (CurrRowRef1==/*28*/26) { + if ( (CurrRecord - 1) >= Ref1_inx.Fin) BEEP(); + else { CurrTopLineRef++; + PrintWholeScreenRef(); + // + // + // + GetLineRef(); +// PrintLineRef(); + } + } else { + if( (CurrRecord - 1) >= Ref1_inx.Fin) BEEP(); + else { CurrRowRef1++; + if( (CurrTopLineRef + CurrRowRef1 - 1) == 5 ) CurrRowRef1++; + GetLineRef(); +// PrintLineRef(); + } + } + +} + +void Mueve_Arriba_Ref(void){ + int CurrRecord = CurrTopLineRef + CurrRowRef1 - 1; + + if (CurrRowRef1==1) { + if ((CurrRecord - 1) <= 0) BEEP(); + else { + CurrTopLineRef--; + PrintWholeScreenRef(); + // + // + // + GetLineRef(); +// PrintLineRef(); + } + + } else { + if( (CurrRecord - 1) <= 0) BEEP(); + else { CurrRowRef1--; + if( (CurrTopLineRef + CurrRowRef1 - 1) == 5 ){ CurrRowRef1--; + if(CurrRowRef1 < 1) { CurrRowRef1=1; + CurrTopLineRef --; + PrintWholeScreenRef(); + } + } + GetLineRef(); +// PrintLineRef(); + } + } + +} + +void EditCursorRef(int ShowHide) { + +if( (CurrTopLineRef + CurrRowRef1 - 1) != 5 ) { + +char Buffer[80]; + + setcolor(GRIS_C); + setfillstyle(SOLID_FILL, GRIS_C); + bar(10, 455, 545, 473); + + if (!ShowHide) { + setcolor(63); + setfillstyle(SOLID_FILL, 63); //// //// //// //// + bar((PR[(CurrColRef1)-1].left+2), PR[(CurrColRef1)-1].up+4+(CurrRowRef1-1)*/*9*//*14*/15+2, PR[(CurrColRef1)-1].right-2, PR[(CurrColRef1)-1].up+/*3*/4+((CurrRowRef1)-1)*/*9*//*14*/15+/*9*/16); + setcolor(0); + } else { + setcolor(0); + setfillstyle(SOLID_FILL, 0); //// //// //// //// + bar((PR[(CurrColRef1)-1].left+2), PR[(CurrColRef1)-1].up+4+(CurrRowRef1-1)*/*9*//*14*/15+2, PR[(CurrColRef1)-1].right-2, PR[(CurrColRef1)-1].up+/*3*/4+((CurrRowRef1)-1)*/*9*//*14*/15+/*9*/16); + Texto_Normal + } + switch(CurrColRef1){ + case 1: + sprintf(Buffer, " %04d", Ref1.Ref); + outtextxy( PR[0].left+2, (PR[0].up+2)+(CurrRowRef1-1)*/*9*//*14*/15, Buffer ); + outtextxy( 15, 455, "Nmero de Referencia. 4 digitos mximo."); + break; + case 2: + outtextxy( PR[1].left+2, (PR[1].up+2)+(CurrRowRef1-1)*/*9*//*14*/15,Ref1.Concepto ); + outtextxy( 15, 455, "Concepto para Ref. 20 digitos mximo."); + + break; + case 3: + sprintf(Buffer, " % 6ld", Ref1.P_und ); + outtextxy( PR[2].left+2, (PR[2].up+2)+(CurrRowRef1-1)*/*9*//*14*/15, Buffer ); + outtextxy( 15, 455, "Precio Costo Unidad. 5 digitos mximo."); + break; + case 4: + sprintf(Buffer, "%03d", Ref1.P1 ); + outtextxy( PR[3].left+2, (PR[3].up+2)+(CurrRowRef1-1)*/*9*//*14*/15,Buffer ); + outtextxy( 15, 455, "I.V.A. original. 2 digitos mximo."); + break; + case 5: + sprintf(Buffer, " % 6ld", Ref1.PVP ); + outtextxy( PR[4].left+2, (PR[4].up+2)+(CurrRowRef1-1)*/*9*//*14*/15,Buffer ); + outtextxy( 15, 455, "Precio Venta Publico. 5 digitos mximo."); + break; + case 6: + sprintf(Buffer, "%03d", Ref1.P2 ); + outtextxy( PR[5].left+2, (PR[5].up+2)+(CurrRowRef1-1)*/*9*//*14*/15,Buffer ); + outtextxy( 15, 455, "I.V.A. original. 2 digitos mximo."); + break; + } +} + +} + + + +void PrintLineRef(void){ + +if( (CurrTopLineRef + CurrRowRef1 - 1) != 5 ) { + char Buffer[80]; + + Texto_Normal + + sprintf(Buffer, " %04d", Ref1.Ref); + outtextxy( PR[0].left+2, (PR[0].up+2)+(CurrRowRef1-1)*/*9*//*14*/15, Buffer ); + outtextxy( PR[1].left+2, (PR[1].up+2)+(CurrRowRef1-1)*/*9*//*14*/15,Ref1.Concepto ); + sprintf(Buffer, " % 6ld", Ref1.P_und ); + outtextxy( PR[2].left+2, (PR[2].up+2)+(CurrRowRef1-1)*/*9*//*14*/15, Buffer ); + sprintf(Buffer, "%03d", Ref1.P1 ); + outtextxy( PR[3].left+2, (PR[3].up+2)+(CurrRowRef1-1)*/*9*//*14*/15,Buffer ); + sprintf(Buffer, " % 6ld", Ref1.PVP ); + outtextxy( PR[4].left+2, (PR[4].up+2)+(CurrRowRef1-1)*/*9*//*14*/15,Buffer ); + sprintf(Buffer, "%03d", Ref1.P2 ); + outtextxy( PR[5].left+2, (PR[5].up+2)+(CurrRowRef1-1)*/*9*//*14*/15,Buffer ); +} + +} + +void PrintWholeScreenRef(void){ + +int tmp = CurrRowRef1; + +for(int i=0; i<6; i++) + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PR[i]); + + + for(CurrRowRef1 = 1; CurrRowRef1 < (/*28*/26+1); CurrRowRef1++) + + if ( (CurrTopLineRef + CurrRowRef1 - 1) <= (Ref1_inx.Fin + 1) ) { + GetLineRef(); + PrintLineRef(); + } + + + +CurrRowRef1 = tmp; + +} + +void Edit_Item_Ref(void){ +char buffer[80]; int oldRef; +long CurrRecord = CurrTopLineRef + CurrRowRef1 - 1; + switch (CurrColRef1) { + case 1: + if ( (CurrRecord>5) ) { + oldRef = Ref1.Ref; + sprintf( buffer, "%d", Ref1.Ref); + do{ + InputCadenaG_l( buffer, 1, 4, 63, 57, PR[0], CurrRowRef1-1); + Ref1.Ref = atoi(buffer); + }while( ( (Existe_Referencia(Ref1.Ref)) || Ref1.Ref==0 ) && Ref1.Ref != oldRef ); + } else { + while( kbhit() ) getch(); + } + break; + case 2: if ( (CurrRecord>5) ) + InputCadenaG_l( Ref1.Concepto, 0, 20, 63, 57, PR[1], CurrRowRef1-1); + else { + while( kbhit() ) getch(); + } + break; + case 3: sprintf( buffer, "%ld", Ref1.P_und); + InputCadenaG_l( buffer, 1, 5, 63, 57, PR[2], CurrRowRef1-1); + Ref1.P_und = atol(buffer); + break; + case 4: sprintf( buffer, "%d", Ref1.P1 ); + InputCadenaG_l( buffer, 1, 2, 63, 57, PR[3], CurrRowRef1-1); + Ref1.P1= atoi( buffer ); + break; + case 5: sprintf( buffer, "%ld", Ref1.PVP ); + InputCadenaG_l( buffer, 1, 5, 63, 57, PR[4], CurrRowRef1-1); + Ref1.PVP = atol( buffer ); + break; + case 6: sprintf( buffer, "%d", Ref1.P2 ); + InputCadenaG_l( buffer, 1, 2, 63, 57, PR[5], CurrRowRef1-1); + Ref1.P2 = atoi( buffer ); + break; + + default: + return; + } + + PutLineRef(); + /**/ + /**/ GetLineRef(); /**/ + /**/ + PrintLineRef(); + +} + +void Abre_Ficha_Referencias(void){ + +char ArchivoDatos[]="SV__REF.DAT"; +int ok = 0; + +//// +// Comprueba apertura correcta de Indice, y Datos y creacin... // +//// + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Ref_inx); + int LSC = sizeof(struct Referencias); + + if ( (Ref = fopen( ArchivoDatos, "r+b"))==NULL) { + + FILE *fa; + + if ( (fa = fopen( ArchivoDatos, "wb" ) )!=NULL ) { + + Poner_a_cero_estructura_actual_Ref(); + Ref1_inx.Fin = 0; + ok = 1; + rewind(fa); + + fwrite(&cabecera, LSJ, 1, fa); fseek(fa, (long)LSJ, SEEK_SET); + fwrite(&Ref1_inx, LSI, 1, fa); fseek(fa, (long)LSJ+LSI, SEEK_SET); + fwrite(&Ref1, LSC, 1, fa); + + if (fclose(fa) == EOF ) exit(1); + } + + if ( (Ref = fopen( ArchivoDatos, "r+b"))==NULL) { + restorecrtmode(); + printf("NO SE PUDO ABRIR EL FICHERO INDICE EN LA 2 PASADA"); + exit(1); + } + } + + fseek(Ref, (long)LSJ, SEEK_SET); + if ( fread(&Ref1_inx, LSI, 1, Ref) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: INDICE"); + exit(1); + } + fseek(Ref, (long)LSJ+LSI, SEEK_SET); + if ( fread(&Ref1, LSC, 1, Ref) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: DATOS"); + exit(1); + } + + if(ok) Llena_con_ref_basicas(); + + + +} + +void DeleteRecordRef(void) { + +unsigned int CurrRecord; + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Ref_inx); + int LSC = sizeof(struct Referencias); + +CurrRecord = CurrTopLineRef + CurrRowRef1 - 1; + + if ( (Ref1_inx.Fin == 4) || (CurrRecord<=5) ) BEEP(); else { + + Ref1_inx.Fin -= 1; + + unsigned int p = CurrRecord - 1; + + while( p <= Ref1_inx.Fin ) { + + fseek(Ref, (long)LSJ + LSI + ( LSC * ( p + 1 ) ), SEEK_SET); // Se coloca + fread(&Ref1, LSC, 1, Ref); // Y lee + + fseek(Ref, (long)LSJ + LSI + ( LSC * p ), SEEK_SET); // Se coloca + fwrite(&Ref1, LSC, 1, Ref); // Y escribe + + p++; + }; + + fseek(Ref, (long)LSJ, SEEK_SET); + fwrite(&Ref1_inx, LSI, 1, Ref); // Acualiza n de registros + +/* */ if ((CurrRecord - 1) == Ref1_inx.Fin + 1) CurrRowRef1--; +/* */ if( Ref1_inx.Fin == 4 ) AddRecordRef(1); +/* */ +/* */ PrintWholeScreenRef(); +/* */ GetLineRef(); + +// PrintLineRef(); + } +} + + + +void AddRecordRef(int Imprime){ + +unsigned int CurrRecord= CurrTopLineRef + CurrRowRef1 - 1; + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Ref_inx); + int LSC = sizeof(struct Referencias); + +if(CurrRecord < 10000 ) { + + long avance = Ref1_inx.Fin /*+ 1*/; + + while( avance >= (CurrRecord-1) ) { + + fseek(Ref, (long)LSJ + LSI + ( LSC * avance ), SEEK_SET); // Se coloca + fread(&Ref1, LSC, 1, Ref); // Y lee + + fseek(Ref, (long)LSJ + LSI + ( LSC * (avance + 1) ), SEEK_SET); // Se coloca + fwrite(&Ref1, LSC, 1, Ref); // Y escribe + + avance--; + }; + +// Ref1_inx.Fin = Ref1_inx.Fin + 1; + Ref1_inx.Fin++; + + fseek(Ref, (long)LSJ, SEEK_SET); + fwrite(&Ref1_inx, LSI, 1, Ref); // Acualiza n de registros + + Poner_a_cero_estructura_actual_Ref(); + + fseek(Ref, (long)LSJ + LSI + ( LSC * ( CurrTopLineRef + CurrRowRef1 - 1) ), SEEK_SET); // Se coloca + fwrite(&Ref1, LSC, 1, Ref); // Y escribe + + CurrRowRef1++; + if (CurrRowRef1>/*28*/26) { CurrTopLineRef++; CurrRowRef1--; } + if(Imprime) PrintWholeScreenRef(); + GetLineRef(); +// PrintLineRef(); + + } + +} + + +void PutLineRef(void){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Ref_inx); + int LSC = sizeof(struct Referencias); + + int CurrRecord = CurrTopLineRef + CurrRowRef1 - 1; + +fseek(Ref, (long)LSJ + LSI + ( LSC * CurrRecord ) - LSC, SEEK_SET); // Se coloca +fwrite(&Ref1, LSC, 1, Ref); // Y escribe + +} + +void GetLineRef(void){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Ref_inx); + int LSC = sizeof(struct Referencias); + + int CurrRecord = CurrTopLineRef + CurrRowRef1 - 1; + +fseek(Ref, (long)LSJ + LSI + ( LSC * CurrRecord ) - LSC, SEEK_SET); // Se coloca +fread(&Ref1, LSC, 1, Ref); // Y lee + +} + + + + + +void Poner_a_cero_estructura_actual_Ref(void){ + + cabecera.esc = 27; strcpy(cabecera.color, "[31;40m"); + strcpy(cabecera.prog, "Jos David Guilln Dominguez"); + cabecera.nl = 13; cabecera.rt = 10; + strcpy(cabecera.autor, " 6 / Mayo / 1995 "); + cabecera.pt = 7; cabecera.ef = 26; + + Ref1.Ref = 0; strcpy(Ref1.Concepto, "\0"); Ref1.P_und = 0; + Ref1.P1 = 0; Ref1.PVP = 0; Ref1.P2 = 0; +} + +void Llena_con_ref_basicas(void){ + CurrRowRef1=1; + Ref1.Ref = 9996; strcpy(Ref1.Concepto, "Grifo-Columna/s."); + PutLineRef(); + AddRecordRef(0); + Ref1.Ref = 9997; strcpy(Ref1.Concepto, "Manoreductor/es."); + PutLineRef(); + AddRecordRef(0); + Ref1.Ref = 9998; strcpy(Ref1.Concepto, "Serpentn/es."); + PutLineRef(); + AddRecordRef(0); + Ref1.Ref = 9999; strcpy(Ref1.Concepto, "Dispensador/es."); + PutLineRef(); + AddRecordRef(0); + Poner_a_cero_estructura_actual_Ref(); + AddRecordRef(0); +} + +void Imprimir_Referencias(void){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Ref_inx); + int LSC = sizeof(struct Referencias); + int lprint = 3; + +if ( Comprueba_Impresora() == 0 ) { +Confirma("Error Imprimiendo.", "Impresora Fuera de", "Servicio."); +return; +} + +int Curr_Ref = 0; +fprintf( stdprn, "\n\r"); +// 1 2 3 4 5 6 7 8 +// 123456789123456789123456789123456789123456789123456789123456789123456789 + fprintf( stdprn, " Refer. Concepto P.C. I.V.A P.V.P. I.V.A \n\r"); + fprintf( stdprn, "\n\r"); + while(Curr_Ref <= Ref1_inx.Fin ){ + + fseek(Ref, (long)LSJ + LSI + ( LSC * Curr_Ref ), SEEK_SET); // Se coloca + fread(&Ref1, LSC, 1, Ref); // Y lee + fprintf( stdprn, " %04d %-20s % 6ld %03d % 6ld %03d \n\r", Ref1.Ref, Ref1.Concepto, Ref1.P_und, Ref1.P1, Ref1.PVP, Ref1.P2); + lprint++; + if (lprint==55) { lprint = 3; + fputc(12, stdprn); + fprintf( stdprn, " Refer. Concepto P.C. I.V.A P.V.P. I.V.A \n\r"); + fprintf( stdprn, "\n\r"); + } + Curr_Ref++; + } + + + fputc(12, stdprn); +} + + +void CompruebaLineasRef(void){ + // Check una pulsacion sobre un campo, y se situa, si es posible + int ok_p=0, inc=0, md=0; + int oldr, oldc; +// Anclar_Raton(); + + do{ + inc++; + if(x_raton >= (PR[(inc)-1].left+2) && x_raton <= (PR[inc-1].right-2) ) { ok_p=1; md = 1; + oldc=inc; } + if(inc==6) ok_p=1; + }while(!ok_p); + if(md==1){ + inc=0; ok_p=0; md = 0; + do{ + inc++; + if( (y_raton >= (PR[(oldc)-1].up+4+(inc-1)*15+2)) && (y_raton <= (PR[oldc-1].up+4+(inc-1)*15+16)) ) { ok_p=1; oldr=inc; md = 1;} + if(inc==26) ok_p=1; + }while(!ok_p); + } + if( (md==1) && ((CurrTopLineRef + oldr - 1) != 5) && ((CurrColRef1!=oldc) || (CurrRowRef1!=oldr)) ) + { + if( (CurrTopLineRef + oldr - 2 )<= Ref1_inx.Fin ){ + EditCursorRef(1); + CurrColRef1 = oldc; + CurrRowRef1 = oldr; + GetLineRef(); + + } + } + + } diff --git a/SV_REF_X.CPP b/SV_REF_X.CPP new file mode 100644 index 0000000..c8acacf --- /dev/null +++ b/SV_REF_X.CPP @@ -0,0 +1,134 @@ +#include +#include +#include +#include +#include +#include "sv_ref_x.h" + + +struct direccion far *Addr; + +int *Ref_inx_addr; +int Ref_no_valid; +char Memory_ok; +char Uso_de_la_Memoria; + + +void BuscaReferencia(int Referencia){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Ref_inx); + int LSC = sizeof(struct Referencias); + + + if( Uso_de_la_Memoria == 1 ) { + + Ref_no_valid = 0; + int ok=0; + int i, Direccion; + + for(i=0; i<(Ref1_inx.Fin+1) && ok==0; i++) + + if ( Addr[i].Ref_inx_Ref == Referencia ) { ok=1; Direccion = i; } + + if ( ok == 0 ) { + strcpy(Ref1.Concepto, "REFERENCIA NO VALIDA"); + Ref1.P_und = 0; + Ref_no_valid = 1; + } else { + fseek(Ref, (long)LSJ + LSI + ( LSC * ( Addr[Direccion].Ref_inx_Addr - 1) ), SEEK_SET); // Se coloca + fread(&Ref1, LSC, 1, Ref); // Y lee + } + + } else { + + if(Ref_inx_addr[Referencia] == 0){ + strcpy(Ref1.Concepto, "REFERENCIA NO VALIDA"); + Ref1.P_und = 0; + Ref_no_valid = 1; + } else { + + fseek(Ref, (long)LSJ + LSI + ( LSC * (Ref_inx_addr[Referencia]-1) ), SEEK_SET); // Se coloca + fread(&Ref1, LSC, 1, Ref); // Y lee + } + + } + + +} + + +void Carga_Referencias(void){ + + int i; + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Ref_inx); + int LSC = sizeof(struct Referencias); + + +if( Ref1_inx.Fin >= 5000 ) Uso_de_la_Memoria = 0; else Uso_de_la_Memoria = 1; + + +if( Uso_de_la_Memoria == 1 ) { + // Comienza proceso de carga de las Referencias. + // 1 Comprobamos la memoria disponible, y si hay, asignamos suficiente. + if( (Addr = (struct direccion far *)farmalloc( (sizeof(struct direccion) * (Ref1_inx.Fin+1) ) ) ) == NULL ) { + Memory_ok = 0; + restorecrtmode(); + exit(1); + } else { + + i = 0; + // Cargamos las posiciones de las referencias en el archivo. + + while(i <= Ref1_inx.Fin ){ + + fseek(Ref, (long)LSJ + LSI + ( LSC * i ), SEEK_SET); // Se coloca + fread(&Ref1, LSC, 1, Ref); // Y lee + Addr[i].Ref_inx_Ref = Ref1.Ref; + Addr[i].Ref_inx_Addr = (i+1); + i++; + } + } +} else { + if( (Ref_inx_addr = (int *)malloc( (sizeof(int) * (10001) ) ) ) == NULL ) { + Memory_ok = 0; + restorecrtmode(); + exit(1); + } else { + + for(i=0; i<10000; i++) Ref_inx_addr[i] = 0; + + i = 0; + // Cargamos las posiciones de las referencias en el archivo. + + while(i <= Ref1_inx.Fin ){ + fseek(Ref, (long)LSJ + LSI + ( LSC * i ), SEEK_SET); // Se coloca + fread(&Ref1, LSC, 1, Ref); // Y lee + Ref_inx_addr[Ref1.Ref]=(i+1); + i++; + } + } +} +} + +int Existe_Referencia(int Referencia){ + + if( Uso_de_la_Memoria == 1 ) { + + Ref_no_valid = 0; + int ok=0; + int i; + + for(i=0; i<(Ref1_inx.Fin+1) && ok==0; i++) + if ( Addr[i].Ref_inx_Ref == Referencia ) ok=1; + + if ( ok == 0 ) return 0; else return 1; + + } else { + + if(Ref_inx_addr[Referencia] == 0) return 0; else return 1; + } + + +} diff --git a/SV_REF_X.H b/SV_REF_X.H new file mode 100644 index 0000000..205d588 --- /dev/null +++ b/SV_REF_X.H @@ -0,0 +1,82 @@ +/////////////////////////////////////////// +/**/ /**/// +/**/// Referencias [enlace global] /**/// +/**/ /**/// +////////////////////////////////////////////////////////////////////////////// +/**/ /**/// // +/**/ extern void Abre_Ficha_Referencias(void); +/**/ +/**/ int Existe_Referencia(int Referencia); +/**/ void BuscaReferencia(int Referencia); +/**/ void Carga_Referencias(void); /**/// // +/**/ /**/// // +////////////////////////////////////////////////////////////////////////////// +/**/ /**/// // +/**/ /*extern*/ struct Ref_inx { /**/// // +/**/ unsigned int Fin; /**/// // +/**/ }; /**/// // +/**/ /**/// // +/**/ /*extern*/ struct Referencias { /**/// // +/**/ int Ref; char Concepto[20+1]; /**/// // +/**/ long P_und; int P1; long PVP; /**/// Estructuras de Datos. // +/**/ int P2; /**/// // +/**/ }; /**/// // +/**/ /**/// // +/**/ extern struct Ref_inx Ref1_inx; /**/// // +/**/ extern struct Referencias Ref1; /**/// // +/**/ /**/// // +////////////////////////////////////////////////////////////////////////////// +/**/ /**/// // +/**/ /*extern*/ struct direccion { /**/// <- Para Memoria = 1 // +/**/ int Ref_inx_Ref; /**/// // +/**/ int Ref_inx_Addr; /**/// // +/**/ }; /**/// // +/**/ extern /**/// +/**/ struct direccion far *Addr; /**/// +/**/ /**/// // +/**/ extern int *Ref_inx_addr; /**/// <- Para Memoria = 0 // +/**/ /**/// // +////////////////////////////////////////////////////////////////////////////// +/**/ /**/// // +/**/ extern int Ref_no_valid; /**/// Si nos quedamos sin memoria, // +/**/ extern char Memory_ok; /**/// usaremos un segundo enlaze que // +/**/ extern char Uso_de_la_Memoria; /**/// consume menos memoria a grandes // +/**/ /**/// cantidades de registros, que no // +/**/ /**/// es recomendable usar por debajo // +/**/ /**/// de los 5000 registros de 4 bytes// +/**/ /**/// // +/**/ extern FILE *Ref; /**/// Fichero Referencias // +////////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////// +/**/ /**/// +/**/// Cabecera /**/// +/**/ /**/// +////////////////////////////////////////////////////////////////////////////// +/**/ /**/// // +/**/ /*extern*/ struct JD { /**/// Estructura para la cabecera // +/**/ char esc; char color[8]; /**/// de todos los ficheros definida // +/**/ char prog[40]; char nl; /**/// en alguna parte. // +/**/ char rt; char autor[36]; /**/// // +/**/ char pt; char ef; /**/// // +/**/ }; /**/// // +/**/ /**/// // +/**/ extern struct JD cabecera; /**/// // +/**/ /**/// // +////////////////////////////////////////////////////////////////////////////// + + +#ifndef SV_REF_X + + +/*extern*/ struct Stock_inx { unsigned int Fin; }; + +/*extern*/ struct Stock_actual { int Ref; long Und_0; long Und_1; }; + +extern struct Stock_actual Stock1; +extern struct Stock_inx Stock1_inx; + +extern void Actualizar_Stock(int Referencia, int Unidades, int Codigo); + +#endif diff --git a/SV_STOCK.CPP b/SV_STOCK.CPP new file mode 100644 index 0000000..f1fbdd1 --- /dev/null +++ b/SV_STOCK.CPP @@ -0,0 +1,883 @@ +#define SV_REF_X + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "..\libs\make_bot\make_bot.h" +#include "sv_util.h" +#include "sv_graph.h" +#include "sv_ref_x.h" + + +#define Letra_Boton setcolor(1); +#define Azul 1 +#define Texto_Normal setcolor(63); +#define Texto_Negrita setcolor(0); + +extern int x_raton, y_raton, raton; +extern int boton_izq, boton_der; + +extern void desactiva_raton(void); +extern void activa_raton(void); +extern void Anclar_Raton(void); +extern void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py); +extern int Espera_Tecla_o_Raton(void); +extern void BEEP(void); + +extern int InputCadenaG(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo); +extern int InputCadenaG_l(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int Row); +extern int InputCadenaG_T4(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int RoW); + +void PutLineStock(void); +void GetLineStock(void); +void Menu_de_Stock(void); +void AddRecordStock(void); +void PrintLineStock(void); +void Edit_Item_Stock(void); +void Abre_Ficha_Stock(void); +void DeleteRecordStock(void); +void Mueve_Abajo_Stock(void); +void Mueve_Arriba_Stock(void); +void CompruebaLineasStock(void); +void PrintWholeScreenStock(void); +void EditCursorStock(int ShowHide); +void Imprimir_Stock(); +void Poner_a_cero_estructura_actual_Stock(void); +void Recalcula_Porcentaje(int Individual_Seleccionado); + +// void Llena_con_Stock_basicas(void); +extern void Coloca_Nombres_a_botones(void); + + + + + + +// extern int Confirma(char *f1, char *f2, char *f3); +extern int Comprueba_Impresora(void); + + + + + +struct Stock_inx { unsigned int Fin; }; + + +struct Stock_actual { int Ref; long Und_0; long Und_1; }; + +struct Stock_actual Stock1; +struct Stock_actual Stock1_Graficas[10]; +struct Stock_inx Stock1_inx; + +struct boton *PS;//[5] +extern struct boton Comunes[9]; + +FILE *Stock; // Fichero de Stock + + +int CurrRowStock1; +int CurrColStock1; +int CurrTopLineStock; + + + + + +void Menu_de_Stock(void) { + + int finished = 0, key, bpush; + CurrRowStock1 = 1; CurrColStock1 = 1; + + CurrTopLineStock = 1; + + inicializa_raton_grafico(0, 0, 624, 464, 320, 240); + if(raton!=0) desactiva_raton(); + + if( ( PS = (struct boton *) malloc( sizeof(struct boton)*5 ) ) == NULL ) + { + Confirma("Memoria insuficiente", "para crear tablas de", "posisin PS."); + return ; + } + + + cleardevice(); + Dibuja_Pantalla_Stock(PS); + Fuente(SMALL_FONT, 5); + setcolor(NEGRO); + Coloca_Nombres_a_botones(); + setcolor(GRIS_C); + outtextxy(Comunes[3].left, Comunes[3].up, " SWAP" ); + outtextxy(Comunes[3].left, Comunes[3].up+18, " F6 " ); + + + Fuente(SMALL_FONT, 4); + Abre_Ficha_Stock(); + Abre_Ficha_Referencias(); + Carga_Referencias(); + + PrintWholeScreenStock(); + GetLineStock(); + int oldCR1=0, oldCC1=0; + +do{ + +if(oldCR1!=CurrRowStock1 || oldCC1!=CurrColStock1 ) + EditCursorStock(0); + +oldCR1 = CurrRowStock1; oldCC1 = CurrColStock1; + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + if(kbhit()){ + EditCursorStock(1); + key = getch(); + if( isprint(key) || isspace(key) ) { + EditCursorStock(0); + if(key!=13) ungetch(key); + Edit_Item_Stock(); + Recalcula_Porcentaje(1); + EditCursorStock(0); + } else if( key == 0 ) { + switch( (key=getch()) ){ + // Flecha Arriba + case 72: + Mueve_Arriba_Stock(); + Recalcula_Porcentaje(1); + break; + // Flecha Izquierda + case 75: + case 15: + CurrColStock1--; + if ( CurrColStock1<1 ) CurrColStock1=5; + break; + // Flecha Derecha + case 77: + case 9: + CurrColStock1++; + if ( CurrColStock1>5 ) CurrColStock1=1; + break; + // Flecha Abajo + case 80: + Mueve_Abajo_Stock(); + Recalcula_Porcentaje(1); + break; + // Buscar F2 + case 60: +// BuscarStock(); + break; + // Imprimir Stock F5 + case 63: + Imprimir_Stock(); + break; + + // F9 --> AADIR + case 67: +// if( Confirma("AADIR NUEVO STOCK", "INICIAL", "") ) +// if ( Pide_Codigo(SV_CFG.COD_Stock) ) +// AddRecordStock(); + break; + // F10 -> BORRAR + case 68: + if( Confirma("ELIMINAR TOTALMENTE", "STOCK ACTUAL", "") ) +// if ( Pide_Codigo(SV_CFG.COD_Stock) ) + DeleteRecordStock(); + Recalcula_Porcentaje(1); + break; + + // INICIO + case 71: + CurrColStock1 = 1; + break; + // FIN + case 79: + CurrColStock1 = 5; + break; + // RePg + case 73: + // CurrRow = 1; +// + if( CurrTopLineStock > /*28*/26 ) { CurrTopLineStock -= /*28*/26; } else { CurrTopLineStock = 1; } + if( CurrTopLineStock < 1 ) { CurrTopLineStock = 1; } + PrintWholeScreenStock(); + GetLineStock(); + EditCursorStock(0); + Recalcula_Porcentaje(1); + break; +// + // AvPg + case 81: + // CurrRow = 1; +// + CurrTopLineStock += /*28*/26; + if ( (CurrTopLineStock+CurrRowStock1) > Stock1_inx.Fin) { CurrTopLineStock = Stock1_inx.Fin; CurrRowStock1 = 1; } + if (CurrTopLineStock==0) CurrTopLineStock = 1; + PrintWholeScreenStock(); + GetLineStock(); + EditCursorStock(0); + Recalcula_Porcentaje(1); +// + break; + // Salir F1 + case 59: + finished = 1; + break; + default: + break; + } + EditCursorStock(0); + } + } else if(raton!=0 && ( boton_izq==1 || boton_der==1 ) ) + if( (bpush = CheckButon( 9, Comunes))>0 ) { + EditCursorStock(1); + switch(bpush){ + // Flecha Arriba + case 1: + Mueve_Arriba_Stock(); + Recalcula_Porcentaje(1); + break; + // Buscar + case 2: +// BuscarVend(); + break; + // Flecha Abajo + case 3: + Mueve_Abajo_Stock(); + Recalcula_Porcentaje(1); + break; + case 4: + break; + // Imprimir + case 5: + Imprimir_Stock(); + break; + // Aadir + case 6: +// if( Confirma("AADIR NUEVO STOCK", "INICIAL", "") ) +// if ( Pide_Codigo(SV_CFG.COD_Stock) ) +// AddRecordStock(); + break; + // Borrar + case 7: + if( Confirma("ELIMINAR TOTALMENTE", "STOCK ACTUAL", "") ) +// if ( Pide_Codigo(SV_CFG.COD_Stock) ) + DeleteRecordStock(); + Recalcula_Porcentaje(1); + break; + // Salir + case 9: + finished = 1; + break; + default: + break; + } + EditCursorStock(0); + } else CompruebaLineasStock(); + +}while(!finished); + +fclose(Stock); // Fichero Vendedores +fclose(Ref); // Fichero Vendedores +free(PS); // Libera la memoria + +if(Memory_ok==1) farfree(Addr); else free(Ref_inx_addr); + + + +} + +void Mueve_Abajo_Stock(void){ + + int CurrRecord = CurrTopLineStock + CurrRowStock1 - 1; + + if (CurrRowStock1==/*28*/40) { + if ( (CurrRecord - 1) >= Stock1_inx.Fin) { BEEP(); EditCursorStock(0); } + else { CurrTopLineStock++; + PrintWholeScreenStock(); + // + // + // + GetLineStock(); +// PrintLineStock(); + } + } else { + if( (CurrRecord - 1) >= Stock1_inx.Fin) { BEEP(); EditCursorStock(0); } + else { CurrRowStock1++; + GetLineStock(); +// PrintLineStock(); + } + } + +} + +void Mueve_Arriba_Stock(void){ + int CurrRecord = CurrTopLineStock + CurrRowStock1 - 1; + + if (CurrRowStock1==1) { + if ((CurrRecord - 1) <= 0) { BEEP(); EditCursorStock(0); } + else { + CurrTopLineStock--; + PrintWholeScreenStock(); + // + // + // + GetLineStock(); +// PrintLineStock(); + } + + } else { + if( (CurrRecord - 1) <= 0) BEEP(); + else { CurrRowStock1--; + + GetLineStock(); +// PrintLineStock(); + } + } + +} + +void EditCursorStock(int ShowHide) { + +char Buffer[80]; + + setcolor(GRIS_C); + setfillstyle(SOLID_FILL, GRIS_C); + bar(10, 455, 545, 473); + + + if (!ShowHide) { + setcolor(63); + setfillstyle(SOLID_FILL, 63); + bar((PS[CurrColStock1-1].left+2), PS[CurrColStock1-1].up+(CurrRowStock1-1)*/*15*/12+/*2*/4, PS[CurrColStock1-1].right-2, PS[CurrColStock1-1].up+/*3*/4+((CurrRowStock1)-1)*12+10); + setcolor(0); + } else { + setcolor(0); + setfillstyle(SOLID_FILL, 0); + bar((PS[CurrColStock1-1].left+2), PS[CurrColStock1-1].up+(CurrRowStock1-1)*/*15*/12+/*2*/4, PS[CurrColStock1-1].right-2, PS[CurrColStock1-1].up+/*3*/4+((CurrRowStock1)-1)*12+10); + Texto_Normal + } + + if(Ref_no_valid) setcolor(ROJO); + +// struct Stock_actual { int Ref; long Und_0; long Und_1; }; + + + switch(CurrColStock1){ +// LA REFERENCIA DEBE SER INDEDITABLE... + + case 1: //4 + sprintf(Buffer, "% 5d", Stock1.Ref ); + outtextxy( PS[0].left+2, (PS[0].up+3)+(CurrRowStock1-1)*12, Buffer ); + outtextxy( 15, 455, "Referencia de Producto. 4 digitos mximo."); + break; + case 2: + outtextxy( PS[1].left+2, (PS[1].up+3)+(CurrRowStock1-1)*12, Ref1.Concepto ); + outtextxy( 15, 455, "Concepto."); + break; + case 3: + sprintf(Buffer, " % 5d", Stock1.Und_1); // 4 + outtextxy( PS[2].left+2, (PS[2].up+3)+(CurrRowStock1-1)*12, Buffer); + outtextxy( 15, 455, "Unidades con Cod. 1"); + break; + case 4: + sprintf(Buffer, " % 5d", Stock1.Und_0); // 4 + outtextxy( PS[3].left+2, (PS[3].up+3)+(CurrRowStock1-1)*12, Buffer ); + outtextxy( 15, 455, "Unidades con Cod. 0"); + break; + case 5: + sprintf(Buffer, "% 10d", ( Stock1.Und_0 + Stock1.Und_1 ) ); // 4 + outtextxy( PS[4].left+2, (PS[4].up+3)+(CurrRowStock1-1)*12, Buffer ); + outtextxy( 15, 455, "Unidades TOTALES."); + break; + } + +} + + + +void PrintLineStock(void){ + + char Buffer[80]; + + setcolor(0); + setfillstyle(SOLID_FILL, 0); + bar((PS[0].left+2), PS[0].up+(CurrRowStock1-1)*12+/*2*/4, PS[0].right-2, PS[0].up+(CurrRowStock1-1)*12+10); + bar((PS[1].left+2), PS[1].up+(CurrRowStock1-1)*12+/*2*/4, PS[1].right-2, PS[1].up+(CurrRowStock1-1)*12+10); + bar((PS[2].left+2), PS[2].up+(CurrRowStock1-1)*12+/*2*/4, PS[2].right-2, PS[2].up+(CurrRowStock1-1)*12+10); + bar((PS[3].left+2), PS[3].up+(CurrRowStock1-1)*12+/*2*/4, PS[3].right-2, PS[3].up+(CurrRowStock1-1)*12+10); + bar((PS[4].left+2), PS[4].up+(CurrRowStock1-1)*12+/*2*/4, PS[4].right-2, PS[4].up+(CurrRowStock1-1)*12+10); + + Texto_Normal + + if(Ref_no_valid) setcolor(ROJO); + // + sprintf(Buffer, "% 5d", Stock1.Ref ); + outtextxy( PS[0].left+2, (PS[0].up+3)+(CurrRowStock1-1)*12, Buffer ); + outtextxy( PS[1].left+2, (PS[1].up+3)+(CurrRowStock1-1)*12, Ref1.Concepto ); + sprintf(Buffer, " % 5d", Stock1.Und_1); // 4 + outtextxy( PS[2].left+2, (PS[2].up+3)+(CurrRowStock1-1)*12, Buffer); + sprintf(Buffer, " % 5d", Stock1.Und_0); // 4 + outtextxy( PS[3].left+2, (PS[3].up+3)+(CurrRowStock1-1)*12, Buffer ); + sprintf(Buffer, "% 10d", ( Stock1.Und_0 + Stock1.Und_1 ) ); // 4 + outtextxy( PS[4].left+2, (PS[4].up+3)+(CurrRowStock1-1)*12, Buffer ); + +} + + +void PrintWholeScreenStock(void){ + +int tmp = CurrRowStock1; + +for(int i=0; i<5; i++) + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PS[i]); + + + for(CurrRowStock1 = 1; CurrRowStock1 < (/*28*/40+1); CurrRowStock1++) + + if ( (CurrTopLineStock + CurrRowStock1 - 1) <= (Stock1_inx.Fin + 1) ) { + GetLineStock(); + PrintLineStock(); + } + + + +CurrRowStock1 = tmp; + +} + +void Edit_Item_Stock(void){ + + char buffer[80]; + + switch (CurrColStock1) { + + case 1:/* + if( Stock1.Ref == -1 ) { + sprintf( buffer, "%d", Stock1.Ref); + InputCadenaG_T4( buffer, 1, 4, 63, 57, PS[0], CurrRowStock1-1); + Stock1.Ref = atoi(buffer); + PutLineStock(); + } + */ + while( kbhit() ) getch(); + break; + case 2: + while( kbhit() ) getch(); + break; + case 3: // int Old_Und_0 = Stock1.Und_0; + sprintf( buffer, "%d", Stock1.Und_1); + InputCadenaG_T4( buffer, 1, 4, 63, 57, PS[2], CurrRowStock1-1); + Stock1.Und_1 = atol(buffer); + PutLineStock(); + break; + case 4: // int Old_Und_1 = Stock1.Und_1; + sprintf( buffer, "%d", Stock1.Und_0); + InputCadenaG_T4( buffer, 1, 4, 63, 57, PS[3], CurrRowStock1-1); + Stock1.Und_0 = atol(buffer); + PutLineStock(); + break; + default: + return; + } + + PrintLineStock(); + +} + +void Abre_Ficha_Stock(void){ + +char ArchivoDatos[]="SV_Stock.DAT"; + +//// +// Stockrueba apertura correcta de Indice, y Datos y creacin... // +//// + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Stock_inx); + int LSC = sizeof(struct Stock_actual); + + if ( (Stock = fopen( ArchivoDatos, "r+b"))==NULL) { + + FILE *fa; + + if ( (fa = fopen( ArchivoDatos, "wb" ) )!=NULL ) { + + Poner_a_cero_estructura_actual_Stock(); + Stock1_inx.Fin = 0; + rewind(fa); + + fwrite(&cabecera, LSJ, 1, fa); fseek(fa, (long)LSJ, SEEK_SET); + fwrite(&Stock1_inx, LSI, 1, fa); fseek(fa, (long)LSJ+LSI, SEEK_SET); + fwrite(&Stock1, LSC, 1, fa); + + if (fclose(fa) == EOF ) exit(1); + } + + if ( (Stock = fopen( ArchivoDatos, "r+b"))==NULL) { + restorecrtmode(); + printf("NO SE PUDO ABRIR EL FICHERO INDICE EN LA 2 PASADA"); + exit(1); + } + } + + fseek(Stock, (long)LSJ, SEEK_SET); + if ( fread(&Stock1_inx, LSI, 1, Stock) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: INDICE"); + exit(1); + } + fseek(Stock, (long)LSJ+LSI, SEEK_SET); + if ( fread(&Stock1, LSC, 1, Stock) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: DATOS"); + exit(1); + } + + +} + +void DeleteRecordStock(void) { + +unsigned int CurrRecord; + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Stock_inx); + int LSC = sizeof(struct Stock_actual); + +CurrRecord = CurrTopLineStock + CurrRowStock1 - 1; + + if ( (Stock1_inx.Fin == 0) ) { BEEP(); + + Poner_a_cero_estructura_actual_Stock(); + Stock1.Ref=-1; + fseek(Stock, (long)LSJ + LSI + ( LSC * ( 0 ) ), SEEK_SET); // Se coloca + fwrite(&Stock1, LSC, 1, Stock); // Y escribe +/* */ PrintWholeScreenStock(); +/* */ GetLineStock(); + EditCursorStock(0); + + + } else { + + Stock1_inx.Fin -= 1; + + unsigned int p = CurrRecord - 1; + + while( p <= Stock1_inx.Fin ) { + + fseek(Stock, (long)LSJ + LSI + ( LSC * ( p + 1 ) ), SEEK_SET); // Se coloca + fread(&Stock1, LSC, 1, Stock); // Y lee + + fseek(Stock, (long)LSJ + LSI + ( LSC * p ), SEEK_SET); // Se coloca + fwrite(&Stock1, LSC, 1, Stock); // Y escribe + + p++; + }; + + fseek(Stock, (long)LSJ, SEEK_SET); + fwrite(&Stock1_inx, LSI, 1, Stock); // Acualiza n de registros + +/* */ if ((CurrRecord - 1) == Stock1_inx.Fin + 1) CurrRowStock1--; +/* */ +/* */ PrintWholeScreenStock(); +/* */ GetLineStock(); + EditCursorStock(0); + +// PrintLineStock(); + } +} + + + +void AddRecordStock(void){ + +unsigned int CurrRecord= CurrTopLineStock + CurrRowStock1 - 1; + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Stock_inx); + int LSC = sizeof(struct Stock_actual); + +if(CurrRecord < 10000 ) { + + long avance = Stock1_inx.Fin /*+ 1*/; + + while( avance >= (CurrRecord-1) ) { + + fseek(Stock, (long)LSJ + LSI + ( LSC * avance ), SEEK_SET); // Se coloca + fread(&Stock1, LSC, 1, Stock); // Y lee + + fseek(Stock, (long)LSJ + LSI + ( LSC * (avance + 1) ), SEEK_SET); // Se coloca + fwrite(&Stock1, LSC, 1, Stock); // Y escribe + + avance--; + }; + +// Stock1_inx.Fin = Stock1_inx.Fin + 1; + Stock1_inx.Fin++; + + fseek(Stock, (long)LSJ, SEEK_SET); + fwrite(&Stock1_inx, LSI, 1, Stock); // Acualiza n de registros + + Poner_a_cero_estructura_actual_Stock(); + Stock1.Ref=-1; + + fseek(Stock, (long)LSJ + LSI + ( LSC * ( CurrTopLineStock + CurrRowStock1 - 1) ), SEEK_SET); // Se coloca + fwrite(&Stock1, LSC, 1, Stock); // Y escribe + + CurrRowStock1++; + if (CurrRowStock1>/*28*/40) { CurrTopLineStock++; CurrRowStock1--; } + PrintWholeScreenStock(); + GetLineStock(); + EditCursorStock(0); +// PrintLineStock(); + + } + +} + + +void PutLineStock(void){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Stock_inx); + int LSC = sizeof(struct Stock_actual); + + int CurrRecord = CurrTopLineStock + CurrRowStock1 - 1; + +fseek(Stock, (long)LSJ + LSI + ( LSC * CurrRecord ) - LSC, SEEK_SET); // Se coloca +fwrite(&Stock1, LSC, 1, Stock); // Y escribe + +} + +void GetLineStock(void){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Stock_inx); + int LSC = sizeof(struct Stock_actual); + + int CurrRecord = CurrTopLineStock + CurrRowStock1 - 1; + +fseek(Stock, (long)LSJ + LSI + ( LSC * CurrRecord ) - LSC, SEEK_SET); // Se coloca +fread(&Stock1, LSC, 1, Stock); // Y lee + + BuscaReferencia(Stock1.Ref); + +} + + + + + +void Poner_a_cero_estructura_actual_Stock(void){ + + cabecera.esc = 27; strcpy(cabecera.color, "[31;40m"); + strcpy(cabecera.prog, "Jos David Guilln Dominguez"); + cabecera.nl = 13; cabecera.rt = 10; + strcpy(cabecera.autor, " 6 / Mayo / 1995 "); + cabecera.pt = 7; cabecera.ef = 26; + + Stock1.Ref=0; Stock1.Und_1=0; Stock1.Und_0=0; + +} + + +void Imprimir_Stock(void){ + +int LSJ = sizeof(struct JD); +int LSI = sizeof(struct Stock_inx); +int LSC = sizeof(struct Stock_actual); +int lprint = 3, Curr_Stock = 0; + +if ( Comprueba_Impresora() == 0 ) { +Confirma("Error Imprimiendo.", "Impresora Fuera de", "Servicio."); +return; +} + +fprintf( stdprn, "\n\r"); + + + fprintf( stdprn, " Ref Concepto Und.C.0 Und.C.1 TOTAL\n\r"); + fprintf( stdprn, "\n\r"); + + while( (Curr_Stock <= Stock1_inx.Fin) ){ + + fseek(Stock, (long)LSJ + LSI + ( LSC * Curr_Stock ), SEEK_SET); // Se coloca + fread(&Stock1, LSC, 1, Stock); // Y lee + BuscaReferencia(Stock1.Ref); + + fprintf( stdprn, "% 5d %-20s % 4ld % 4ld % 8ld \n\r", Stock1.Ref, Ref1.Concepto, Stock1.Und_0, Stock1.Und_1, ( Stock1.Und_0 + Stock1.Und_1 ) ); + + lprint++; + if (lprint==55) { lprint = 3; + fputc(12, stdprn); + fprintf( stdprn, " Ref Concepto Und.C.0 Und.C.1 TOTAL\n\r"); + fprintf( stdprn, "\n\r"); + } + Curr_Stock++; + } + fputc(12, stdprn); + GetLineStock(); + +} + + +void CompruebaLineasStock(void){ + // Check una pulsacion sobre un campo, y se situa, si es posible + int ok_p=0, inc=0, md=0; + int oldr, oldc; +// Anclar_Raton(); + + do{ + inc++; + if(x_raton >= (PS[(inc)-1].left+2) && x_raton <= (PS[inc-1].right-2) ) { ok_p=1; md = 1; + oldc=inc; } + if(inc==5) ok_p=1; + }while(!ok_p); + if(md==1){ + inc=0; ok_p=0; md = 0; + do{ + inc++; + if( (y_raton >= (PS[(oldc)-1].up+4+(inc-1)*15+2)) && (y_raton <= (PS[oldc-1].up+4+(inc-1)*15+16)) ) { ok_p=1; oldr=inc; md = 1;} + if(inc==26) ok_p=1; + }while(!ok_p); + } + int newc; + + switch(oldc){ + case 1: + case 2: newc = oldc; break; + case 4: + case 5: newc = (oldc - 1); break; + default: + break; + } + + + if( (md==1) && ((CurrColStock1!=newc) || (CurrRowStock1!=oldr)) ) + { + + if( (CurrTopLineStock + oldr - 2 )<= Stock1_inx.Fin ){ + EditCursorStock(1); + switch(oldc){ + case 1: + case 2: + CurrColStock1 = oldc; + CurrRowStock1 = oldr; + break; + case 4: + case 5: + CurrColStock1 = (oldc-1); + CurrRowStock1 = oldr; + break; + default: + EditCursorStock(0); + break; + } + GetLineStock(); + } + } + + } + + +void Actualizar_Stock(int Referencia, int Unidades, int Codigo){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Stock_inx); + int LSC = sizeof(struct Stock_actual); + + int ok = 0; + int Curr_Stock = 0, Encuentro = 0; + + + while( (Curr_Stock <= Stock1_inx.Fin) && (ok == 0) ){ + + fseek(Stock, (long)LSJ + LSI + ( LSC * Curr_Stock ), SEEK_SET); // Se coloca + fread(&Stock1, LSC, 1, Stock); // Y lee + + if( Stock1.Ref == Referencia ) { + if(Codigo==1) Stock1.Und_1 += Unidades; + else Stock1.Und_0 += Unidades; + fseek(Stock, (long)LSJ + LSI + ( LSC * Curr_Stock ), SEEK_SET); // Se coloca + fwrite(&Stock1, LSC, 1, Stock); // Y escribe + ok = 1; + Encuentro = 1; + } + + Curr_Stock++; + } + + if (Encuentro==0) { + Stock1.Ref = Referencia; + if(Codigo==1) { Stock1.Und_1 = Unidades; Stock1.Und_0 = 0; } + else { Stock1.Und_0 = Unidades; Stock1.Und_1 = 0; } + + fseek(Stock, (long)LSJ + LSI + ( LSC * (Stock1_inx.Fin + 1) ), SEEK_SET); // Se coloca + fwrite(&Stock1, LSC, 1, Stock); // Y escribe + + Stock1_inx.Fin ++; + + fseek(Stock, (long)LSJ, SEEK_SET); + fwrite(&Stock1_inx, LSI, 1, Stock); // Acualiza n de registros + } + + +} + +void Recalcula_Porcentaje(int Individual_Seleccionado){ + + if( Individual_Seleccionado == 1 ) { + + long P_0, P_1; + struct boton Ptmp; + + Ptmp.up = 15; Ptmp.down = 213; + Ptmp.left = 349; Ptmp.right = 549; + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, Ptmp); + +// Centro = (449, 114) radio = 80 +// si (Stock1.Und_0 + Stock1.Und_1) es 100 +// Stock1.Und_0 es PS + +// si 360 es 100 +// x es PS +if ( (abs(Stock1.Und_0)+abs(Stock1.Und_1) )!= 0 ) { + + P_0 = labs( ( 360 * ( (labs(Stock1.Und_0) * 100) / (labs(Stock1.Und_0)+labs(Stock1.Und_1)) ) ) / 100); + P_1 = labs( ( 360 * ( (labs(Stock1.Und_1) * 100) / (labs(Stock1.Und_0)+labs(Stock1.Und_1)) ) ) / 100); + // struct Stock_actual { int Ref; long Und_0; long Und_1; }; + if( Stock1.Und_1 < 0 ) + { P_0 += P_1; P_1 = 0; } + if( Stock1.Und_0 < 0 ) + { P_1 += P_0; P_0 = 0; } +if( P_1 != 0 ) { + setcolor(ROJO); + setfillstyle(9, ROJO); + pieslice(449, 114, 0, P_1, 80); +} +if( P_0 != 0 ) { + setcolor(AZUL); + setfillstyle(9, AZUL); + pieslice(449, 114, ( 360 - P_0 ), 360, 80); +} + +} + + + } else { + + // struct Stock_actual Stock1_Graficas[10]; + // bar3d + + + } + +} \ No newline at end of file diff --git a/SV_TEXT.CPP b/SV_TEXT.CPP new file mode 100644 index 0000000..5fe062c --- /dev/null +++ b/SV_TEXT.CPP @@ -0,0 +1,359 @@ +#include +#include +#include +#include + +#include "..\libs\make_bot\make_bot.h" + + +extern void BEEP(void); +int InputCadenaG(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo); +int InputCadenaG_l(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int Row); +int InputCadenaG_T4(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int RoW); + +int InputCadenaG(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo) +{ + + int ls; // longitud cadena + char *s1; // puntero a cadena inicial + int c, ok; + + s1 = s; // inicio cadena + + setcolor(cf); // pone color a 0 para borrar + setfillstyle(SOLID_FILL, cf); + bar(Campo.left+2, Campo.up+2, Campo.right-2, Campo.down-2); + + setcolor(cc); // devuelve el color a su estado + + outtextxy( Campo.left+2, Campo.up+2, s ); + + ls = strlen ( s ); // Longitud de actual + + if ( ls < lmax ) { + setcolor(4); + outtextxy( Campo.left+2+textwidth( s1 ), Campo.up+2, ""); + } + + s += ls; // se coloca en el final + + do{ + c = getch(); // obtiene tecla + + ok = ( c == 13 || c == 0); // 13 = INTRO || Especiales + + if ( c == 8 && ls > 0 && !ok ) { // 8 = Back Space + ls--; + s--; + + *s = '\0'; + + setcolor(cf); + setfillstyle(SOLID_FILL, cf); + bar(Campo.left+2, Campo.up+2, Campo.right-2, Campo.down-2); + setcolor(cc); + outtextxy( Campo.left+2, Campo.up+2, s1 ); + setcolor(4); + outtextxy( Campo.left+2+textwidth( s1 ), Campo.up+2, ""); + setcolor(cc); + + } else { + + if ( !numalp && c >= 32 && c <= 254 /* isprint(c) */ && ls < lmax) { + + *s++ = c; + ls++; + + *s = '\0'; + setcolor(cf); + setfillstyle(SOLID_FILL, cf); + bar(Campo.left+2, Campo.up+2, Campo.right-2, Campo.down-2); + setcolor(cc); + + outtextxy( Campo.left+2, Campo.up+2, s1 ); + + if ( ls < lmax ) { + setcolor(4); + outtextxy( Campo.left+2+textwidth( s1 ), Campo.up+2, ""); + setcolor(cc); + } + + + } else { + if ( numalp && isdigit(c) && ls < lmax) { + *s++ = c; + ls++; + + *s = '\0'; // Cero final + setcolor(cf); + setfillstyle(SOLID_FILL, cf); + bar(Campo.left+2, Campo.up+2, Campo.right-2, Campo.down-2); + setcolor(cc); + + outtextxy( Campo.left+2, Campo.up+2, s1 ); + + if ( ls < lmax ) { + setcolor(4); + outtextxy( Campo.left+2+textwidth( s1 ), Campo.up+2, ""); + setcolor(cc); + } + + + } + /**/ + else if( c == 27 ) {*s='\0'; ok = 1; } + /**/ + else BEEP(); + } + } + + }while(!ok); + + ok = 1; + *s = ' '; + while( ok ) { + if(*s==' ') { *s = '\0'; s--; + } else { s++; ok = 0; } + } + + *s = '\0'; + + while(kbhit()) getch(); // Vacia Buffer impidiendo falsas + // pulsaciones... + + return ls; +} + + + + +int InputCadenaG_l(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int RoW) +{ + + int ls; // longitud cadena + char *s1; // puntero a cadena inicial + int c, ok; + + s1 = s; // inicio cadena + + setcolor(cf); // pone color a 0 para borrar + setfillstyle(SOLID_FILL, cf); + bar(Campo.left+2, Campo.up+4+RoW*/*9*//*14*/15+2, Campo.right-2, Campo.up+4+RoW*/*9*//*14*/15 + /*9*/16); + + setcolor(cc); // devuelve el color a su estado + + outtextxy( Campo.left+2, Campo.up+/*3*/2+RoW*/*9*//*14*/15, s ); + + ls = strlen ( s ); // Longitud de actual + + if ( ls < lmax ) { + setcolor(4); + outtextxy( Campo.left+2+textwidth( s1 ), Campo.up+/*3*/2+RoW*/*9*//*14*/15, ""); + } + + s += ls; // se coloca en el final + + do{ + c = getch(); // obtiene tecla + + ok = ( c == 13 || c == 0); // 13 = INTRO || Especiales + + if ( c == 8 && ls > 0 && !ok ) { // 8 = Back Space + ls--; + s--; + + *s = '\0'; + + setcolor(cf); + setfillstyle(SOLID_FILL, cf); + bar(Campo.left+2, Campo.up+4+RoW*/*9*//*14*/15+2, Campo.right-2, Campo.up+4+RoW*/*9*//*14*/15 + /*9*/16); +// bar(Campo.left+2, Campo.up+3+RoW*/*9*/14+2, Campo.right-2, Campo.up+3+RoW*/*9*/14 + /*9*/16); + setcolor(cc); + outtextxy( Campo.left+2, Campo.up+/*3*/2+RoW*/*9*//*14*/15, s1 ); + setcolor(4); + outtextxy( Campo.left+2+textwidth( s1 ), Campo.up+/*3*/2+RoW*/*9*//*14*/15, ""); + setcolor(cc); + + } else { + if ( !numalp && c >= 32 && c <= 254 /* isprint(c) */ && ls < lmax) { + + *s++ = c; + ls++; + + *s = '\0'; + setcolor(cf); + setfillstyle(SOLID_FILL, cf); + bar(Campo.left+2, Campo.up+4+RoW*/*9*//*14*/15+2, Campo.right-2, Campo.up+4+RoW*/*9*//*14*/15 + /*9*/16); +// bar(Campo.left+2, Campo.up+3+RoW*/*9*/14+2, Campo.right-2, Campo.up+3+RoW*/*9*/14 + /*9*/16); + setcolor(cc); + outtextxy( Campo.left+2, Campo.up+/*3*/2+RoW*/*9*//*14*/15, s1 ); + + if ( ls < lmax ) { + setcolor(4); + outtextxy( Campo.left+2+textwidth( s1 ), Campo.up+/*3*/2+RoW*/*9*//*14*/15, ""); + setcolor(cc); + } + + + } else { + if ( numalp && isdigit(c) && ls < lmax) { + *s++ = c; + ls++; + + *s = '\0'; // Cero final + setcolor(cf); + setfillstyle(SOLID_FILL, cf); + bar(Campo.left+2, Campo.up+4+RoW*/*9*//*14*/15+2, Campo.right-2, Campo.up+4+RoW*/*9*//*14*/15 + /*9*/16); +// bar(Campo.left+2, Campo.up+3+RoW*/*9*/14+2, Campo.right-2, Campo.up+3+RoW*/*9*/14 + /*9*/16); + setcolor(cc); + + outtextxy( Campo.left+2, Campo.up+/*3*/2+RoW*/*9*//*14*/15, s1 ); + + if ( ls < lmax ) { + setcolor(4); + outtextxy( Campo.left+2+textwidth( s1 ), Campo.up+/*3*/+RoW*/*9*//*14*/15, ""); + setcolor(cc); + } + + + } + /**/ + else if( c == 27 ) {*s='\0'; ok = 1; } + /**/ + else BEEP(); + } + } + + }while(!ok); + + ok = 1; + *s = ' '; + while( ok ) { + if(*s==' ') { *s = '\0'; s--; + } else { s++; ok = 0; } + } + + *s = '\0'; + + while(kbhit()) getch(); // Vacia Buffer impidiendo falsas + // pulsaciones... + + return ls; +} + + + +//outtextxy( PS[0].left+2, (PS[0].up+3)+(CurrRowStock1-1)*12, Buffer ); + +int InputCadenaG_T4(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int RoW) +{ + + int ls; // longitud cadena + char *s1; // puntero a cadena inicial + int c, ok; + + s1 = s; // inicio cadena + + setcolor(cf); // pone color a 0 para borrar + setfillstyle(SOLID_FILL, cf); + bar(Campo.left+2, Campo.up+RoW*12+/*2*/4, Campo.right-2, Campo.up+4+RoW*12 + 10); + + setcolor(cc); // devuelve el color a su estado + + outtextxy( Campo.left+2, Campo.up+3+RoW*12, s ); + + ls = strlen ( s ); // Longitud de actual + + if ( ls < lmax ) { + setcolor(4); + outtextxy( Campo.left+2+textwidth( s1 ), Campo.up+3+RoW*12, ""); + } + + s += ls; // se coloca en el final + + do{ + c = getch(); // obtiene tecla + + ok = ( c == 13 || c == 0); // 13 = INTRO || Especiales + + if ( c == 8 && ls > 0 && !ok ) { // 8 = Back Space + ls--; + s--; + + *s = '\0'; + + setcolor(cf); + setfillstyle(SOLID_FILL, cf); + +bar(Campo.left+2, Campo.up+RoW*12+/*2*/4, Campo.right-2, Campo.up+4+RoW*12 + 10); + + setcolor(cc); + outtextxy( Campo.left+2, Campo.up+3+RoW*12, s1 ); + setcolor(4); + outtextxy( Campo.left+2+textwidth( s1 ), Campo.up+3+RoW*12, ""); + setcolor(cc); + + } else { + if ( !numalp && c >= 32 && c <= 254 /* isprint(c) */ && ls < lmax) { + + *s++ = c; + ls++; + + *s = '\0'; + setcolor(cf); + setfillstyle(SOLID_FILL, cf); +bar(Campo.left+2, Campo.up+RoW*12+/*2*/4, Campo.right-2, Campo.up+4+RoW*12 + 10); + setcolor(cc); + outtextxy( Campo.left+2, Campo.up+3+RoW*12, s1 ); + + if ( ls < lmax ) { + setcolor(4); + outtextxy( Campo.left+2+textwidth( s1 ), Campo.up+3+RoW*12, ""); + setcolor(cc); + } + + + } else { + if ( numalp && isdigit(c) && ls < lmax) { + *s++ = c; + ls++; + + *s = '\0'; // Cero final + setcolor(cf); + setfillstyle(SOLID_FILL, cf); +bar(Campo.left+2, Campo.up+RoW*12+/*2*/4, Campo.right-2, Campo.up+4+RoW*12 + 10); + setcolor(cc); + + outtextxy( Campo.left+2, Campo.up+3+RoW*12, s1 ); + + if ( ls < lmax ) { + setcolor(4); + outtextxy( Campo.left+2+textwidth( s1 ), Campo.up+3+RoW*12, ""); + setcolor(cc); + } + + + } + /**/ + else if( c == 27 ) {*s='\0'; ok = 1; } + /**/ + else BEEP(); + } + } + + }while(!ok); + + ok = 1; + *s = ' '; + while( ok ) { + if(*s==' ') { *s = '\0'; s--; + } else { s++; ok = 0; } + } + + *s = '\0'; + + while(kbhit()) getch(); // Vacia Buffer impidiendo falsas + // pulsaciones... + + return ls; +} diff --git a/SV_UTIL.CPP b/SV_UTIL.CPP new file mode 100644 index 0000000..567a851 --- /dev/null +++ b/SV_UTIL.CPP @@ -0,0 +1,497 @@ +#include +#include +#include +#include +#include +// #include +#include +#include +#include +#include "sv_util.h" +#include "..\libs\make_bot\make_bot.h" + + +#define Letra_Boton setcolor(1); +#define Azul 1 +#define Texto_Normal setcolor(63); +#define Texto_Negrita setcolor(0); + +extern int x_raton, y_raton, raton; +extern int boton_izq, boton_der; + +extern int InputCadenaG(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo); +extern void desactiva_raton(void); +extern void activa_raton(void); +// extern void Anclar_Raton(void); +extern void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py); +extern int Espera_Tecla_o_Raton(void); +extern void BEEP(void); +extern void textxy(int x, int y, char *text); + + +#define NEGRO 0 +#define AZUL 1 +#define ROJO 4 +#define VERDE 2 +#define BLANCO 63 +#define GRIS_O 56 +#define GRIS_C 7 +#define AMARILLO 62 + +extern void textxy(int x, int y, char *text); + +int Comprueba_Impresora(void); +int Confirma(char *T1, char *T2, char *T3); +int Desde_Hasta(int *Desde, int *Hasta); +int Pide_Fecha_Actual(void); +int file_exists(char *filename); + +int Confirma(char *T1, char *T2, char *T3){ + +void far *ptr; +unsigned size; +struct boton pregunta[2]; +int fins_print=0, key_print, bpush, ok = 0; +int TFuente; +struct textsettingstype textinfo; +gettextsettings(&textinfo); +TFuente = textinfo.charsize; + +size = imagesize(198, 138, 372, 257); + +/* get byte size of image */ +Fuente(SMALL_FONT, 5); + +if ( (ptr = farmalloc(size)) == NULL) { Fuente(SMALL_FONT, TFuente); return 0; } + +getimage(198, 138, 372, 257, ptr); + +pregunta[0].up = 140; pregunta[0].down = 255; +pregunta[0].left= 200; pregunta[0].right= 370; +ImprimeBoton (1, GRIS_C, GRIS_O, BLANCO, pregunta[0]); + +pregunta[0].up = 235; pregunta[0].down = 250; +pregunta[0].left= 210; pregunta[0].right= 270; +ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[0]); + +pregunta[1].up = 235; pregunta[1].down = 250; +pregunta[1].left= 300; pregunta[1].right= 360; +ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[1]); + +textxy(212, 237, " Si"); + textxy(212, 239, " _"); +textxy(302, 237, " No"); + textxy(302, 239, " _"); + +textxy(210+2, 150+2, T1); +textxy(210+2, 165+2, T2); +textxy(210+2, 180+2, T3); + + +// +do{ + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + if(kbhit()){ + key_print = getch(); + switch( toupper(key_print) ){ + // S Si + case 83: + ok = 1; + fins_print = 1; + break; + // N No + case 78: + ok = 0; + fins_print = 1; + break; + default: + break; + } + } else + if(raton!=0 && boton_izq==1 || boton_der==1) { + if( (bpush = CheckButon( 2, pregunta))>0 ) { + + switch(bpush){ + case 1: + ok = 1; + fins_print = 1; + break; + case 2: + ok = 0; + fins_print = 1; + break; + default: + break; + } + } + } + +}while(!fins_print); + + + + +putimage(198, 138, ptr, COPY_PUT); +farfree(ptr); +Fuente(SMALL_FONT, TFuente); + +return ok; + +} + + + +int Pide_Fecha_Actual(void){ + + int Fecha; + +// void far *ptr; +// unsigned size; + char mes[][11] = { " Enero", "Febrero", " Marzo", + " Abril", " Mayo", " Junio", + " Julio", " Agosto", "Septiemb", + "Octubre", "Noviemb", "Diciemb" + }; + + struct boton pregunta[3]; + struct boton meses[12]; + + int key_print, bpush, ok = 0; + int TFuente; + + for( Fecha = 0; Fecha < 4; Fecha++ ){ + meses[2+3*Fecha].left = 405; meses[2+3*Fecha].right = 455; + meses[1+3*Fecha].left = 350; meses[1+3*Fecha].right = 400; + meses[0+3*Fecha].left = 295; meses[0+3*Fecha].right = 345; + } + + for( Fecha = 0; Fecha < 3; Fecha++ ) { + meses[Fecha].up = 80+140; meses[Fecha].down = 80+160; + meses[Fecha+3].up = 80+165; meses[Fecha+3].down = 80+185; + meses[Fecha+6].up = 80+190; meses[Fecha+6].down = 80+210; + meses[Fecha+9].up = 80+215; meses[Fecha+9].down = 80+235; + } + + + struct textsettingstype textinfo; + gettextsettings(&textinfo); + TFuente = textinfo.charsize; + struct date d; + getdate(&d); + Fecha = d.da_mon; + + /* get byte size of image */ +// size = imagesize(198, 138, 372, 257); + + + +// if ( (ptr = farmalloc(size)) == NULL) { +// Fuente(SMALL_FONT, TFuente); +// return Fecha; +// } + +// getimage(198, 138, 372, 257, ptr); + + +pregunta[0].up = /*140*/130; pregunta[0].down = /*255*/400; +pregunta[0].left= /*200*/150; pregunta[0].right= /*370*/465; +ImprimeBoton (1, GRIS_C, GRIS_O, BLANCO, pregunta[0]); + +pregunta[0].up = /*143*/135; pregunta[0].down = /*252*/395; +pregunta[0].left= /*203*/155; pregunta[0].right= /*367*/460; +ImprimeBoton (0, GRIS_C, BLANCO, GRIS_O, pregunta[0]); + + +pregunta[0].up = /*235*/370; pregunta[0].down = /*250*/390; +pregunta[0].left= /*210*/160; pregunta[0].right= /*270*/230; +ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[0]); + +pregunta[1].up = /*235*/370; pregunta[1].down = /*250*/390; +pregunta[1].left= /*300*/385; pregunta[1].right= /*360*/455; +ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[1]); + +pregunta[2].up = /*165*/175; pregunta[2].down = /*185*/195; +pregunta[2].left= 212; pregunta[2].right= /*232*/245; +ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[2]); + +Fuente(SMALL_FONT, 4); +for( int i = 0; i < 12; i++ ) { + ImprimeBoton (1, GRIS_C, GRIS_O, BLANCO, meses[i]); + textxy(meses[i].left+4, meses[i].up+3, mes[i]); +} +ImprimeBoton (1, ROJO, GRIS_O, BLANCO, meses[Fecha-1]); +textxy(meses[Fecha-1].left+4, meses[Fecha-1].up+3, mes[Fecha-1]); + +Fuente(SMALL_FONT, 5); + +textxy(162, 372, " Aceptar"); + textxy(162, 373, " _"); +textxy(387, 372, " Cancelar"); + textxy(387, 373, " _"); + +textxy(160+2, 145+2, "Introduzca mes a gestionar:"); + +// textxy(210+2, 165+2, T2); +// textxy(210+2, 180+2, T3); +char buffer[80]; +int Mes=Fecha; + +sprintf( buffer, "% 2d", Fecha); +textxy(pregunta[2].left + 4, pregunta[2].up + 2, buffer); + +// +do{ + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + if(kbhit()){ + key_print = getch(); + if( key_print == 13 ) {Fecha = Mes; ok = 1; } else + if( isdigit(key_print) ) { + // Edita el mes actual + sprintf( buffer, "%d", Fecha); + do{ + InputCadenaG( buffer, 1, 4, 63, 57, pregunta[2]); + Fecha = atoi(buffer); + }while(Fecha<1 || Fecha>12); + } else + if(key_print==0) + switch( getch() ){ + // Flecha Izquierda + case 75: + case 15: + ImprimeBoton (0, GRIS_C, GRIS_O, BLANCO, meses[Mes-1]); + Mes--; + if ( (Mes + 1)== 1 ) Mes = 3; else + if ( (Mes + 1)== 4 ) Mes = 6; else + if ( (Mes + 1)== 7 ) Mes = 9; else + if ( (Mes + 1)==10 ) Mes = 12; + ImprimeBoton (0, GRIS_C, AZUL, AZUL, meses[Mes-1]); + break; + // Flecha Derecha + case 77: + case 9: + ImprimeBoton (0, GRIS_C, GRIS_O, BLANCO, meses[Mes-1]); + Mes++; + if ( (Mes - 1)== 3 ) Mes = 1; else + if ( (Mes - 1)== 6 ) Mes = 4; else + if ( (Mes - 1)== 9 ) Mes = 7; else + if ( (Mes - 1)==12 ) Mes = 10; + ImprimeBoton (0, GRIS_C, AZUL, AZUL, meses[Mes-1]); + break; + // Flecha Abajo + case 80: + ImprimeBoton (0, GRIS_C, GRIS_O, BLANCO, meses[Mes-1]); + Mes += 3; if ( Mes > 12) Mes = Mes - 12; + ImprimeBoton (0, GRIS_C, AZUL, AZUL, meses[Mes-1]); + break; + // Flecha Arriba + case 72: + ImprimeBoton (0, GRIS_C, GRIS_O, BLANCO, meses[Mes-1]); + Mes -= 3; if ( Mes < 1) Mes = 12 + Mes; + ImprimeBoton (0, GRIS_C, AZUL, AZUL, meses[Mes-1]); + break; + } + else + switch( toupper(key_print) ){ + // A Aceptar + case 65: + ok = 1; + break; + // C Cancelar + case 67: + ok = 1; + Fecha = -1; + break; + default: + break; + } + } else + if(raton!=0 && boton_izq==1 || boton_der==1) { + if( (bpush = CheckButon( 2, pregunta))>0 ) { + + switch(bpush){ + case 1: + ok = 1; + break; + case 2: + ok = 1; + Fecha = -1; + break; + default: + break; + } + } + } + +}while(!ok); + + +// putimage(198, 138, ptr, COPY_PUT); +// farfree(ptr); + + +Fuente(SMALL_FONT, TFuente); + +return Fecha; + +} + + +int file_exists(char *filename) +{ + return (access(filename, 0) == 0); +} + + +int Comprueba_Impresora(void){ + + unsigned int tmp; + union REGS Impresora_in, Impresora_out; + struct byte { + int a : 1; + int b : 1; + int c : 1; + int d : 1; + int e : 1; + int f : 1; + int g : 1; + int h : 1; + }; + union bits { + char ch; + struct byte bit; + } Imp_out; + + Impresora_in.h.ah = 0x02; + Impresora_in.x.dx = 0x0; + + int86(0x17, &Impresora_in, &Impresora_out); + + return ( Impresora_out.h.ah ? 1 : 0 ); + +} + +int Desde_Hasta(int *Desde, int *Hasta){ + +int fins_print= 0, key_print, bpush; +char buffer[80], devuelve = 0; +void far *ptr; +unsigned size; +struct boton pregunta[4]; + +struct date Fecha; +getdate(&Fecha); + +*Desde = *Hasta = Fecha.da_day; + +size = imagesize(198, 138, 372, 257); + +/* get byte size of image */ + +if ( (ptr = farmalloc(size)) == NULL) return -1; + getimage(198, 138, 372, 257, ptr); + + pregunta[0].up = 140; pregunta[0].down = 255; + pregunta[0].left= 200; pregunta[0].right= 370; + ImprimeBoton (1, ROJO, GRIS_C, BLANCO, pregunta[0]); + pregunta[0].up = 150; pregunta[0].down = /*175*/165; + pregunta[0].left= /*210*/250; pregunta[0].right= 360; + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, pregunta[0]); + pregunta[1].up = 185; pregunta[1].down = /*210*/200; + pregunta[1].left= /*210*/250; pregunta[1].right= 360; + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, pregunta[1]); + pregunta[2].up = 220; pregunta[2].down = 245; + pregunta[2].left= 210; pregunta[2].right= 280; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[2]); + pregunta[3].up = 220; pregunta[3].down = 245; + pregunta[3].left= 290; pregunta[3].right= 360; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[3]); + + Fuente(SMALL_FONT, 4); + +Letra_Boton +outtextxy(pregunta[0].left+2 - 40, pregunta[0].up+2, "DESDE"); +outtextxy(pregunta[1].left+2 - 40, pregunta[1].up+2, "HASTA"); +outtextxy(pregunta[2].left+2, pregunta[2].up+2, "CANCELAR"); + outtextxy(pregunta[2].left+2, pregunta[2].up+4, "_"); +outtextxy(pregunta[3].left+2, pregunta[3].up+2, "ACEPTAR"); + outtextxy(pregunta[3].left+2, pregunta[3].up+4, "_"); + +// +do{ + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + if(kbhit()){ + key_print = getch(); + if(key_print == 27 ) { fins_print = 1; devuelve = -1; } else + if(key_print == 'A' || key_print == 'a') { fins_print = 1; } else + if(key_print == 'C' || key_print == 'c') { fins_print = 1; devuelve = -1; } else + if( isprint(key_print) ) { + sprintf( buffer, "%d", *Desde); + do{ + InputCadenaG( buffer, 1, 2, 63, 57, pregunta[0]); + *Desde = atol(buffer); + }while(*Desde<1 || *Desde>12); + + sprintf( buffer, "%d", *Hasta); + do{ + InputCadenaG( buffer, 1, 2, 63, 57, pregunta[1]); + *Hasta = atol(buffer); + }while(*Hasta<1 || *Hasta>12); + } else + if( key_print == 0 ) { + switch( (key_print=getch()) ){ + // F1 Cancelar + case 59: + fins_print = 1; + devuelve = -1; + break; + // F3 Imprimir Ficha + default: + break; + } + } + } else + if(raton!=0 && boton_izq==1 || boton_der==1) { + if( (bpush = CheckButon( 3, pregunta))>0 ) { +/* + pregunta[0].up = 140; pregunta[0].down = 255; + pregunta[0].left= 200; pregunta[0].right= 370; + ImprimeBoton (1, GRIS_O, GRIS_C, BLANCO, pregunta[0]); +*/ + switch(bpush){ + // Cancelar + case 3: + fins_print=1; + devuelve = -1; + break; + case 4: + fins_print=1; + break; + } + } + } + + +}while(!fins_print); + +// + + + putimage(198, 138, ptr, COPY_PUT); + farfree(ptr); + + Fuente(SMALL_FONT, 5); + +return devuelve; +} diff --git a/SV_UTIL.H b/SV_UTIL.H new file mode 100644 index 0000000..a8fee19 --- /dev/null +++ b/SV_UTIL.H @@ -0,0 +1,5 @@ +extern int Desde_Hasta(int *Desde, int *Hasta); +extern int Confirma(char *T1, char *T2, char *T3); +extern int Pide_Fecha_Actual(void); +extern int file_exists(char *filename); +//extern int Comprueba_Impresora(void): \ No newline at end of file diff --git a/SV_VEND.CPP b/SV_VEND.CPP new file mode 100644 index 0000000..f0105d6 --- /dev/null +++ b/SV_VEND.CPP @@ -0,0 +1,1231 @@ +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "..\libs\make_bot\make_bot.h" +#include "sv_graph.h" +#include "sv_util.h" + +#define Letra_Boton setcolor(1); +#define Azul 2 +#define Texto_Normal setcolor(63); +#define Texto_Negrita setcolor(0); + +extern int x_raton, y_raton;extern char raton; +extern int boton_izq, boton_der; + +extern void desactiva_raton(void); +extern void activa_raton(void); +extern void Anclar_Raton(void); +extern void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py); +extern int Espera_Tecla_o_Raton(void); +extern void BEEP(void); +extern void textxy(int x, int y, char *text); + +extern int InputCadenaG(char *s, int numalp, int lmax, int cc, int cf, struct Make_Boton Campo); +extern int InputCadenaG_l(char *s, int numalp, int lmax, int cc, int cf, struct Make_Boton Campo, int Row); + +extern void Abre_Ficha_Clientes(void); + +void Menu_de_Vendedores (void); +void Mueve_Arriba(void); +void Mueve_Abajo(void); +void EditCursorVend(int ShowHide); +void PrintLineVend(int Rapida_Completa); +void PrintWholeScreenVend(void); +void Edit_Item_Vend(void); +void Abre_Ficha_Vendedores(void); +void DeleteRecordVend(void); +void AddRecordVend(void); +void PutLineVend(void); +void GetLineVend(void); +void Poner_a_cero_estructura_actual_vend(void); +void Coloca_Nombres_a_botones(void); +void Imprimir_Vendedores(void); +void Imprime_Ficha(void); +void Imprime_Lista_Rapida(void); +void CompruebaLineasVend(void); + + +//int Confirma(char *f1, char *f2, char *f3); +extern int Comprueba_Impresora(void); + + +struct JD { + char esc; char color[8]; char prog[40]; + char nl; char rt; char autor[36]; char pt; char ef; +}; + +struct Vend_inx { unsigned int Fin; }; + +struct Vendedores { + int Num_V; + char Nombre[15+1]; char Apellido1[15+1]; char Apellido2[15+1]; + char DNI[15+1]; unsigned long Telefono1; unsigned long Telefono2; + char Calle[30+1]; char Num[3+1]; char Piso[3+1]; + char Poblacion[18+1]; char Provincia[16+1]; unsigned long CP; + unsigned long CC; unsigned int PP; unsigned int Cr; +}; + +/*extern*/ struct Clientes_inx { + char Ncontrato_ocupado_SN[10000]; + unsigned int Fin; + }; + +/*extern*/ struct Clientes { + + int Address; + + char Nombre[15+1]; char Apellido1[15+1]; char Apellido2[15+1]; + char DNI[15+1]; unsigned long Telefono1; + char Calle1[30+1]; char Num1[5+1]; + + char Local[30+1]; unsigned long Telefono2; + char Calle2[30+1]; char Num2[5+1]; + char Poblacion[18+1]; char Provincia[16+1]; unsigned long CP; + + unsigned char GC; unsigned char MR; unsigned char SP; + unsigned char DP; unsigned int MA; + + struct date Fecha; int Vend; int NContrato; + +}; + +struct JD cabecera; +struct Vendedores Vend1; +struct Vend_inx Vend1_inx; +extern struct Clientes Clientes1; +extern struct Clientes_inx Clientes1_inx; + +struct Make_Boton *PV; //[19] +extern struct Make_Boton Comunes[9]; + +FILE *Vend; // Fichero Vendedores +extern FILE *Clientes; // Fichero Clientes + +int CurrRow1, CurrRow2; +int CurrCol1, CurrCol2; +int CurrTopLine; +int SWAP = 1; + + +void Menu_de_Vendedores (void) { + + + int finished = 0, key, bpush; + CurrRow1 = 1; CurrCol1 = 1; + CurrRow2 = 1; CurrCol2 = 1; + + CurrTopLine = 1; + + inicializa_raton_grafico(0, 0, 624, 464, 320, 240); + if(raton!=0) desactiva_raton(); + + if( ( PV = (struct Make_Boton *) malloc( sizeof(struct Make_Boton)*20 ) ) == NULL ) + { + Confirma("Memoria insuficiente", "para crear tablas de", "posisin PV."); + return ; + } + + + cleardevice(); + Dibuja_Pantalla_Vendedores(PV); + Fuente(SMALL_FONT, 5); + Coloca_Nombres_a_botones(); + + Fuente(SMALL_FONT, 6); + Abre_Ficha_Vendedores(); + + Abre_Ficha_Clientes(); + + PrintWholeScreenVend(); + GetLineVend(); + PrintLineVend(0); + PrintLineVend(1); + int oldCR1=0, oldCR2=0, oldCC1=0, oldCC2=0; + +do{ + + +if(oldCR1!=CurrRow1 || oldCC1!=CurrCol1 || oldCR2!=CurrRow2 || oldCC2!=CurrCol2 ) + EditCursorVend(0); + +oldCR1 = CurrRow1; oldCC1 = CurrCol1; +oldCR2 = CurrRow2; oldCC2 = CurrCol2; + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + + + if(kbhit()){ + EditCursorVend(1); + key = getch(); + if( isprint(key) || isspace(key) ) { + EditCursorVend(0); + if(key!=13) ungetch(key); + Edit_Item_Vend(); + EditCursorVend(0); + } else if( key == 0 ) { + switch( (key=getch()) ){ + // Flecha Arriba + case 72: + if(SWAP) Mueve_Arriba(); + else { CurrCol2--; if ( CurrCol2 < 1 ) CurrCol2=14; } + break; + // Flecha Izquierda + case 75: + case 15: + if(SWAP) { CurrCol1--; if ( CurrCol1<1 ) CurrCol1=4; } + else { CurrCol2--; if ( CurrCol2 < 1 ) CurrCol2=14; } + break; + // Flecha Derecha + case 77: + case 9: + if(SWAP) { CurrCol1++; if ( CurrCol1>4 ) CurrCol1=1; } + else { CurrCol2++; if ( CurrCol2 > 14 ) CurrCol2=1; } + break; + // Flecha Abajo + case 80: + if(SWAP) { Mueve_Abajo(); } + else { CurrCol2++; if ( CurrCol2 > 14 ) CurrCol2=1; } + break; + // Buscar F2 + case 60: + //BuscarVend(); + break; + // Imprimir Vendedores (incluye men desplegable) F5 + case 63: + Imprimir_Vendedores(); + break; + // SWAP (la parte de edicin) F6 + case 64: + if(SWAP){ SWAP=0; /* Fuente(SMALL_FONT, 5); */} + else { SWAP=1; /* Fuente(SMALL_FONT, 6); */} + EditCursorVend(0); + break; + // F9 --> AADIR + case 67: + AddRecordVend(); + break; + // F10 -> BORRAR + case 68: + if( Confirma("Desea eliminar al", "Vendedor Actual", "") ) DeleteRecordVend(); + break; + // INICIO + case 71: + if(SWAP) CurrCol1 = 1; else CurrCol2 = 1; + break; + // FIN + case 79: + if(SWAP) CurrCol1 = 4; else CurrCol2 = 14; + break; + // RePg + case 73: + // CurrRow = 1; + if(SWAP) { + if( CurrTopLine > 11 ) { CurrTopLine -= /*12*/11; } else { CurrTopLine = 1; } + if( CurrTopLine < 1 ) { CurrTopLine = 1; } + PrintWholeScreenVend(); + GetLineVend(); + PrintLineVend(1); + EditCursorVend(0); + } + break; + // AvPg + case 81: + // CurrRow = 1; + if(SWAP) { + CurrTopLine += /*12*/11; + if ( (CurrTopLine+CurrRow1) > Vend1_inx.Fin) { CurrTopLine = Vend1_inx.Fin; CurrRow1 = 1; } + if (CurrTopLine==0) CurrTopLine = 1; + PrintWholeScreenVend(); + GetLineVend(); + PrintLineVend(1); + EditCursorVend(0); + } + break; + // Salir F1 + case 59: + finished = 1; + break; + default: + break; + } + EditCursorVend(0); + } + } else if(raton!=0 && ( boton_izq==1 || boton_der==1 ) ) + if( (bpush = CheckButon( 9, Comunes))>0 ) { + EditCursorVend(1); + switch(bpush){ + // Flecha Arriba + case 1: + if(SWAP) Mueve_Arriba(); + else { CurrCol2--; if ( CurrCol2 < 1 ) CurrCol2=14; } + break; + // Buscar + case 2: + //BuscarVend(); + break; + // Flecha Abajo + case 3: + if(SWAP) Mueve_Abajo(); + else { CurrCol2++; if ( CurrCol2 > 14 ) CurrCol2=1; } + break; + case 4: + if(SWAP){ SWAP=0; /* Fuente(SMALL_FONT, 5); */ } + else { SWAP=1; /* Fuente(SMALL_FONT, 6); */ } + EditCursorVend(0); + break; + // Imprimir + case 5: + Imprimir_Vendedores(); + break; + // Aadir + case 6: + AddRecordVend(); + break; + // Borrar + case 7: + if( Confirma("Desea eliminar al", "Vendedor Actual", "") ) DeleteRecordVend(); + break; + // Salir + case 9: + finished = 1; + break; + default: + break; + } + EditCursorVend(0); + } else CompruebaLineasVend(); + +}while(!finished); + +fclose(Vend); // Fichero Vendedores +free(PV); + +} + +void Mueve_Abajo(void){ + + int CurrRecord = CurrTopLine + CurrRow1 - 1; + + if (CurrRow1==/*12*/11) { + if ( (CurrRecord - 1) >= Vend1_inx.Fin) BEEP(); + else { CurrTopLine++; + PrintWholeScreenVend(); + // + // + // + GetLineVend(); +// PrintLineVend(0); + PrintLineVend(1); + } + + } else { + if( (CurrRecord - 1) >= Vend1_inx.Fin) BEEP(); + else { CurrRow1++; + GetLineVend(); + PrintLineVend(1); + } + } + +} + +void Mueve_Arriba(void){ + int CurrRecord = CurrTopLine + CurrRow1 - 1; + + if (CurrRow1==1) { + if ((CurrRecord - 1) <= 0) BEEP(); + else { + CurrTopLine--; + PrintWholeScreenVend(); + // + // + // + GetLineVend(); +// PrintLineVend(0); + PrintLineVend(1); + } + + } else { + if( (CurrRecord - 1) <= 0) BEEP(); + else { CurrRow1--; + GetLineVend(); + PrintLineVend(1); + } + } + +} + +void EditCursorVend(int ShowHide) { +char Buffer[80]; + + setcolor(GRIS_C); + setfillstyle(SOLID_FILL, GRIS_C); + bar(10, 455, 545, 473); +/* + PR[0].Up = 450; PR[0].Down = 475; + PR[0].Left = 5; PR[0].Right = 549; +*/ + +if(SWAP==0) { + if (!ShowHide) { + ImprimeBoton (0, GRIS_C, ROJO, ROJO, PV[CurrCol2+3]); + setcolor(63); + setfillstyle(SOLID_FILL, 63); + bar(PV[CurrCol2+3].Left+2, PV[CurrCol2+3].Up+2, PV[CurrCol2+3].Right-2, PV[CurrCol2+3].Down-2); + setcolor(0); + } else { + ImprimeBoton (0, GRIS_C, GRIS_O, BLANCO, PV[CurrCol2+3]); + setcolor(0); + setfillstyle(SOLID_FILL, 0); + bar(PV[CurrCol2+3].Left+2, PV[CurrCol2+3].Up+2, PV[CurrCol2+3].Right-2, PV[CurrCol2+3].Down-2); + Texto_Normal + } + Fuente(SMALL_FONT, 5); + switch(CurrCol2) { + case 1: outtextxy( PV[4].Left+2, PV[4].Up+2, Vend1.Nombre ); + outtextxy( 15, 455, "Nombre del Vendedor. 15 digitos maximo."); + break; + case 2: outtextxy( PV[5].Left+2, PV[5].Up+2, Vend1.Apellido1 ); + outtextxy( 15, 455, "1er. Apellido. 15 digitos mximo."); + break; + case 3: outtextxy( PV[6].Left+2, PV[6].Up+2, Vend1.Apellido2 ); + outtextxy( 15, 455, "2 Apellido. 15 digitos mximo."); + break; + case 4: outtextxy( PV[7].Left+2, PV[7].Up+2, Vend1.DNI ); + outtextxy( 15, 455, "D.N.I. 15 digitos mximo."); + break; + case 5: sprintf(Buffer, "%ld", Vend1.Telefono1); + outtextxy( PV[8].Left+2, PV[8].Up+2, Buffer ); + outtextxy( 15, 455, "Telefono 1. 12 digitos mximo."); + break; + case 6: sprintf(Buffer, "%ld", Vend1.Telefono2); + outtextxy( PV[9].Left+2, PV[9].Up+2, Buffer ); + outtextxy( 15, 455, "Telefono 2. 12 digitos mximo."); + break; + case 7: outtextxy( PV[10].Left+2, PV[10].Up+2, Vend1.Calle ); + outtextxy( 15, 455, "Calle. 30 digitos mximo."); + break; + case 8: outtextxy( PV[11].Left+2, PV[11].Up+2, Vend1.Num ); + outtextxy( 15, 455, "Nmero de Calle. 3 digitos mximo."); + break; + case 9: outtextxy( PV[12].Left+2, PV[12].Up+2, Vend1.Piso ); + outtextxy( 15, 455, "Nm. de Piso, Letra... 3 digitos mximo."); + break; + case 10:outtextxy( PV[13].Left+2, PV[13].Up+2, Vend1.Poblacion ); + outtextxy( 15, 455, "Poblacin. 18 digitos mximo."); + break; + case 11:outtextxy( PV[14].Left+2, PV[14].Up+2, Vend1.Provincia ); + outtextxy( 15, 455, "Provincia. 16 digitos mximo."); + break; + case 12:sprintf(Buffer, "%ld", Vend1.CP); + outtextxy( PV[15].Left+2, PV[15].Up+2, Buffer ); + outtextxy( 15, 455, "Cdigo Postal. 5 digitos mximo."); + break; + case 13:sprintf(Buffer, "%ld", Vend1.CC); + outtextxy( PV[16].Left+2, PV[16].Up+2, Buffer ); + outtextxy( 15, 455, "Comisin por contrato. 5 digitos mximo."); + break; + case 14:sprintf(Buffer, "%d", Vend1.PP); + outtextxy( PV[17].Left+2, PV[17].Up+2, Buffer ); + outtextxy( 15, 455, "Porcentaje por Producto. 2 digitos maximo."); + break; +/* case 15:sprintf(Buffer, "%d", Vend1.Cr); + outtextxy( PV[18].Left+2, PV[18].Up+2, Buffer ); + break; +*/ + } +} else { + if (!ShowHide) { + setcolor(63); + setfillstyle(SOLID_FILL, 63); + bar((PV[(CurrCol1)-1].Left+2), PV[(CurrCol1)-1].Up+4+(CurrRow1-1)*/*9*//*14*/15+2, PV[(CurrCol1)-1].Right-2, PV[(CurrCol1)-1].Up+/*3*/4+((CurrRow1)-1)*/*9*//*14*/15+/*9*/16); + setcolor(0); + } else { + setcolor(0); + setfillstyle(SOLID_FILL, 0); + bar((PV[(CurrCol1)-1].Left+2), PV[(CurrCol1)-1].Up+4+(CurrRow1-1)*/*9*//*14*/15+2, PV[(CurrCol1)-1].Right-2, PV[(CurrCol1)-1].Up+/*3*/4+((CurrRow1)-1)*/*9*//*14*/15+/*9*/16); + Texto_Normal + } + Fuente(SMALL_FONT, 6); + switch(CurrCol1){ + case 1: + sprintf(Buffer, "%03d", Vend1.Num_V); + outtextxy( PV[0].Left+2, (PV[0].Up+2)+(CurrRow1-1)*/*9*//*14*/15, Buffer ); + outtextxy( 15, 455, "Nmero de vendedor. 3 digitos mximo."); + break; + case 2: + outtextxy( PV[1].Left+2, (PV[1].Up+2)+(CurrRow1-1)*/*9*//*14*/15,Vend1.Nombre ); + outtextxy( 15, 455, "Nombre del Vendedor. 15 digitos mximo."); + break; + case 3: + outtextxy( PV[2].Left+2, (PV[2].Up+2)+(CurrRow1-1)*/*9*//*14*/15, Vend1.Apellido1 ); + outtextxy( 15, 455, "1er. Apellido. 15 digitos mximo."); + break; + case 4: + sprintf(Buffer, "%ld", Vend1.Telefono1 ); + outtextxy( PV[3].Left+2, (PV[3].Up+2)+(CurrRow1-1)*/*9*//*14*/15,Buffer ); + outtextxy( 15, 455, "Telefono1. 12 digitos mximo."); + break; + } + +} + + + + + +} + + + +void PrintLineVend(int Rapida_Completa){ + +char Buffer[80]; + + if(Rapida_Completa) { + // Completa + Fuente(SMALL_FONT, 5); + + for(int i=4; i<19; i++) + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PV[i]); + + Texto_Normal + + outtextxy( PV[4].Left+2, PV[4].Up+2, Vend1.Nombre ); + outtextxy( PV[5].Left+2, PV[5].Up+2, Vend1.Apellido1 ); + outtextxy( PV[6].Left+2, PV[6].Up+2, Vend1.Apellido2 ); + outtextxy( PV[7].Left+2, PV[7].Up+2, Vend1.DNI ); + sprintf(Buffer, "%ld", Vend1.Telefono1); + outtextxy( PV[8].Left+2, PV[8].Up+2, Buffer ); + sprintf(Buffer, "%ld", Vend1.Telefono2); + outtextxy( PV[9].Left+2, PV[9].Up+2, Buffer ); + outtextxy( PV[10].Left+2, PV[10].Up+2, Vend1.Calle ); + outtextxy( PV[11].Left+2, PV[11].Up+2, Vend1.Num ); + outtextxy( PV[12].Left+2, PV[12].Up+2, Vend1.Piso ); + outtextxy( PV[13].Left+2, PV[13].Up+2, Vend1.Poblacion ); + outtextxy( PV[14].Left+2, PV[14].Up+2, Vend1.Provincia ); + sprintf(Buffer, "%ld", Vend1.CP); + outtextxy( PV[15].Left+2, PV[15].Up+2, Buffer ); + sprintf(Buffer, "%ld", Vend1.CC); + outtextxy( PV[16].Left+2, PV[16].Up+2, Buffer ); + sprintf(Buffer, "%d", Vend1.PP); + outtextxy( PV[17].Left+2, PV[17].Up+2, Buffer ); +setcolor(ROJO); + sprintf(Buffer, " %03d", Vend1.Cr); + outtextxy( PV[18].Left+2, PV[18].Up+2, Buffer ); + + } else { + // Rapida + Fuente(SMALL_FONT, 6); + /* + for(int i=0; i<4; i++) + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PV[i]); + */ + // outtextxy(20,15, "N Nombre 1er. Apellido Telf."); + Texto_Normal + sprintf(Buffer, "%03d", Vend1.Num_V); + outtextxy( PV[0].Left+2, PV[0].Up+2+(CurrRow1-1)*/*9*//*14*/15, Buffer ); + outtextxy( PV[1].Left+2, PV[1].Up+2+(CurrRow1-1)*/*9*//*14*/15, Vend1.Nombre ); + outtextxy( PV[2].Left+2, PV[2].Up+2+(CurrRow1-1)*/*9*//*14*/15, Vend1.Apellido1 ); + sprintf(Buffer, "%ld", Vend1.Telefono1 ); + outtextxy( PV[3].Left+2, PV[3].Up+2+(CurrRow1-1)*/*9*//*14*/15, Buffer ); + + } + + +} + +void PrintWholeScreenVend(void){ + +int tmp = CurrRow1; + +for(int i=0; i<19; i++) + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PV[i]); + + + for(CurrRow1 = 1; CurrRow1 < (/*12*/11+1); CurrRow1++) + + if ( (CurrTopLine + CurrRow1 - 1) <= (Vend1_inx.Fin + 1) ) { + GetLineVend(); + PrintLineVend(0); + } + + + +CurrRow1 = tmp; + +} + +void Edit_Item_Vend(void){ +char buffer[80]; +if(SWAP){ + Fuente(SMALL_FONT, 6); + switch (CurrCol1) { + case 1: sprintf( buffer, "%d", Vend1.Num_V); + InputCadenaG_l( buffer, 1, 3, 63, 57, PV[0], CurrRow1-1); + Vend1.Num_V = atoi(buffer); + break; + case 2: InputCadenaG_l( Vend1.Nombre, 0, 15, 63, 57, PV[1], CurrRow1-1); + break; + case 3: InputCadenaG_l( Vend1.Apellido1, 0, 14, 63, 57, PV[2], CurrRow1-1); + break; + case 4: sprintf( buffer, "%ld", Vend1.Telefono1 ); + InputCadenaG_l( buffer, 1, 12, 63, 57, PV[3], CurrRow1-1); + Vend1.Telefono1 = atol( buffer ); + break; + default: + return; + } + + PutLineVend(); + /**/ + /**/ GetLineVend(); /**/ + /**/ + PrintLineVend(1); + + +} else { + Fuente(SMALL_FONT, 5); + switch (CurrCol2) { + case 1: InputCadenaG( Vend1.Nombre, 0, 15, 63, 57, PV[4] ); + //PV[4] + break; + case 2: InputCadenaG( Vend1.Apellido1, 0, 14, 63, 57, PV[5] ); + //PV[5] + break; + case 3: InputCadenaG( Vend1.Apellido2, 0, 15, 63, 57, PV[6] ); + //PV[6] + break; + case 4: InputCadenaG( Vend1.DNI, 0, 15, 63, 57, PV[7] ); + //PV[7] + break; + case 5: sprintf(buffer, "%ld", Vend1.Telefono1); + InputCadenaG( buffer, 0, /*12*/9, 63, 57, PV[8] ); + Vend1.Telefono1 = atol( buffer ); + //PV[8] + break; + case 6: sprintf(buffer, "%ld", Vend1.Telefono2); + InputCadenaG( buffer, 0, /*12*/9, 63, 57, PV[9] ); + Vend1.Telefono2 = atol( buffer ); + //PV[9] + break; + case 7: InputCadenaG( Vend1.Calle, 0, 30, 63, 57, PV[10] ); + //PV[10] + break; + case 8: InputCadenaG( Vend1.Num, 0, 3, 63, 57, PV[11] ); + //PV[11] + break; + case 9: InputCadenaG( Vend1.Piso, 0, 3, 63, 57, PV[12] ); + //PV[12] + break; + case 10:InputCadenaG( Vend1.Poblacion, 0, 18, 63, 57, PV[13] ); + //PV[13] + break; + case 11:InputCadenaG( Vend1.Provincia, 0, 16, 63, 57, PV[14] ); + //PV[14] + break; + case 12:sprintf(buffer, "%ld", Vend1.CP); + InputCadenaG( buffer, 0, 5, 63, 57, PV[15] ); + Vend1.CP = atol( buffer ); + //PV[15] + break; + case 13:sprintf(buffer, "%ld", Vend1.CC); + InputCadenaG( buffer, 0, 5, 63, 57, PV[16] ); + Vend1.CC = atol( buffer ); + //PV[16] + break; + case 14:sprintf(buffer, "%d", Vend1.PP); + InputCadenaG( buffer, 0, 2, 63, 57, PV[17] ); + Vend1.PP = atoi( buffer ); + //PV[17] + break; + default: return; + } + + PutLineVend(); + /**/ + /**/ GetLineVend(); /**/ + /**/ + PrintLineVend(0); + +} + +} + +void Abre_Ficha_Vendedores(void){ + +char ArchivoDatos[]="SV_VEND.DAT"; + +//// +// Comprueba apertura correcta de Indice, y Datos y creacin... // +//// + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Vend_inx); + int LSC = sizeof(struct Vendedores); + + if ( (Vend = fopen( ArchivoDatos, "r+b"))==NULL) { + + FILE *fa; + + if ( (fa = fopen( ArchivoDatos, "wb" ) )!=NULL ) { + + Poner_a_cero_estructura_actual_vend(); + Vend1_inx.Fin = 0; + + rewind(fa); + + fwrite(&cabecera, LSJ, 1, fa); fseek(fa, (long)LSJ, SEEK_SET); + fwrite(&Vend1_inx, LSI, 1, fa); fseek(fa, (long)LSJ+LSI, SEEK_SET); + fwrite(&Vend1, LSC, 1, fa); + + if (fclose(fa) == EOF ) exit(1); + } + + if ( (Vend = fopen( ArchivoDatos, "r+b"))==NULL) { + restorecrtmode(); + printf("NO SE PUDO ABRIR EL FICHERO INDICE EN LA 2 PASADA"); + exit(1); + } + } + + fseek(Vend, (long)LSJ, SEEK_SET); + if ( fread(&Vend1_inx, LSI, 1, Vend) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: INDICE"); + exit(1); + } + fseek(Vend, (long)LSJ+LSI, SEEK_SET); + if ( fread(&Vend1, LSC, 1, Vend) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: DATOS"); + exit(1); + } + +} + +void DeleteRecordVend(void) { + +unsigned int CurrRecord; + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Vend_inx); + int LSC = sizeof(struct Vendedores); + int LSCl = sizeof(struct Clientes); + int ok = 0; + int Count=0, CF = 0; + +CurrRecord = CurrTopLine + CurrRow1 - 1; + + if ( Vend1_inx.Fin == 0 ) { +// + Poner_a_cero_estructura_actual_vend(); + PutLineVend(); + PrintLineVend(1); + BEEP(); +// + } else { + + if ( Vend1.Cr > 0 ) + do{ + + fseek(Clientes, (long)LSJ + LSI + LSCl*Count, SEEK_SET); // Se coloca + fread(&Clientes1, LSCl, 1, Clientes); // Y lee + + if(Clientes1.Vend == Vend1.Num_V ) { + Clientes1.Vend = -1; // El contrato es para la empresa + fseek(Clientes, (long)LSJ + LSI + LSCl*Count, SEEK_SET); // Se coloca + fwrite(&Clientes1, LSCl, 1, Clientes); // Y lee + CF++; + if(CF == Vend1.Cr) ok = 1; + } + Count++; + }while(!ok || Count<= Clientes1_inx.Fin); + + + + Vend1_inx.Fin -= 1; + + unsigned int p = CurrRecord - 1; + + while( p <= Vend1_inx.Fin ) { + + fseek(Vend, (long)LSJ + LSI + ( LSC * ( p + 1 ) ), SEEK_SET); // Se coloca + fread(&Vend1, LSC, 1, Vend); // Y lee + + fseek(Vend, (long)LSJ + LSI + ( LSC * p ), SEEK_SET); // Se coloca + fwrite(&Vend1, LSC, 1, Vend); // Y escribe + + p++; + }; + + fseek(Vend, (long)LSJ, SEEK_SET); + fwrite(&Vend1_inx, LSI, 1, Vend); // Acualiza n de registros + + PrintWholeScreenVend(); + if ((CurrRecord - 1) == Vend1_inx.Fin + 1) CurrRow1--; + if( Vend1_inx.Fin == 0 ) CurrRow1 = 1; + GetLineVend(); + PrintLineVend(1); + } +} + + + +void AddRecordVend(void){ + +unsigned int CurrRecord= CurrTopLine + CurrRow1 - 1; + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Vend_inx); + int LSC = sizeof(struct Vendedores); + +if(CurrRecord < 1000 ) { + + long avance = Vend1_inx.Fin /*+ 1*/; + + while( avance >= (CurrRecord-1) ) { + + fseek(Vend, (long)LSJ + LSI + ( LSC * avance ), SEEK_SET); // Se coloca + fread(&Vend1, LSC, 1, Vend); // Y lee + + fseek(Vend, (long)LSJ + LSI + ( LSC * (avance + 1) ), SEEK_SET); // Se coloca + fwrite(&Vend1, LSC, 1, Vend); // Y escribe + + avance--; + }; + +// Vend1_inx.Fin = Vend1_inx.Fin + 1; + Vend1_inx.Fin++; + + fseek(Vend, (long)LSJ, SEEK_SET); + fwrite(&Vend1_inx, LSI, 1, Vend); // Acualiza n de registros + + Poner_a_cero_estructura_actual_vend(); + + fseek(Vend, (long)LSJ + LSI + ( LSC * ( CurrTopLine + CurrRow1 - 1) ), SEEK_SET); // Se coloca + fwrite(&Vend1, LSC, 1, Vend); // Y escribe + + CurrRow1++; + if (CurrRow1>/*12*/11) { CurrTopLine++; CurrRow1--; } + PrintWholeScreenVend(); + GetLineVend(); + PrintLineVend(1); + + } + +} + + +void PutLineVend(void){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Vend_inx); + int LSC = sizeof(struct Vendedores); + + int CurrRecord = CurrTopLine + CurrRow1 - 1; + +fseek(Vend, (long)LSJ + LSI + ( LSC * CurrRecord ) - LSC, SEEK_SET); // Se coloca +fwrite(&Vend1, LSC, 1, Vend); // Y escribe + +} + +void GetLineVend(void){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Vend_inx); + int LSC = sizeof(struct Vendedores); + + int CurrRecord = CurrTopLine + CurrRow1 - 1; + +fseek(Vend, (long)LSJ + LSI + ( LSC * CurrRecord ) - LSC, SEEK_SET); // Se coloca +fread(&Vend1, LSC, 1, Vend); // Y lee + +} + + + + + +void Poner_a_cero_estructura_actual_vend(void){ + + cabecera.esc = 27; strcpy(cabecera.color, "[31;40m"); + strcpy(cabecera.prog, "Jos David Guilln Dominguez"); + cabecera.nl = 13; cabecera.rt = 10; + strcpy(cabecera.autor, " 31 / Abril / 1995 "); + cabecera.pt = 7; cabecera.ef = 26; + +// Vend1_inx.Fin = 0; + + Vend1.Num_V = 0; + strcpy(Vend1.Nombre, "\0"); strcpy(Vend1.Apellido1, "\0"); strcpy(Vend1.Apellido2, "\0"); + strcpy(Vend1.DNI, "\0"); Vend1.Telefono1 = 0; Vend1.Telefono2 = 0; + strcpy(Vend1.Calle, "\0"); strcpy(Vend1.Num, "\0"); strcpy(Vend1.Piso, "\0"); + strcpy(Vend1.Poblacion, "\0"); strcpy(Vend1.Provincia, "\0"); Vend1.CP = 41; + Vend1.CC = 0; Vend1.PP = 0; Vend1.Cr = 0; +} + + +void Coloca_Nombres_a_botones(void){ + +Letra_Boton + + /*out*/textxy(Comunes[0].Left, Comunes[0].Up, " Subir" ); +//out*/text(Comunes[0].Left, Comunes[0].Up+18, " -----" ); + + /*out*/textxy(Comunes[1].Left, Comunes[1].Up, " Buscar" ); +/*out*/textxy(Comunes[1].Left, Comunes[1].Up+18, " F2 " ); + + /*out*/textxy(Comunes[2].Left, Comunes[2].Up, " Bajar" ); +//out*/textxy(Comunes[2].Left, Comunes[2].Up+18, " -----" ); + + /*out*/textxy(Comunes[3].Left, Comunes[3].Up, " SWAP" ); +/*out*/textxy(Comunes[3].Left, Comunes[3].Up+18, " F6 " ); + + /*out*/textxy(Comunes[4].Left, Comunes[4].Up, " Imprimir" ); +/*out*/textxy(Comunes[4].Left, Comunes[4].Up+18, " F5 " ); + + /*out*/textxy(Comunes[5].Left, Comunes[5].Up, " Aadir" ); +/*out*/textxy(Comunes[5].Left, Comunes[5].Up+18, " F9 " ); + + /*out*/textxy(Comunes[6].Left, Comunes[6].Up, " SUpr." ); +/*out*/textxy(Comunes[6].Left, Comunes[6].Up+18, " F10 " ); + + /*out*/textxy(Comunes[8].Left, Comunes[8].Up, " Salir" ); +/*out*/textxy(Comunes[8].Left, Comunes[8].Up+18, " F1 " ); + +} + + + +void Imprimir_Vendedores(void){ + +int Where_Ask = 1; +int fins_print= 0, key_print, bpush; + +void far *ptr; +unsigned size; +struct Make_Boton pregunta[3]; + +size = imagesize(198, 138, 372, 257); + +/* get byte size of image */ + +if ( (ptr = farmalloc(size)) != NULL) { + getimage(198, 138, 372, 257, ptr); + + pregunta[0].Up = 140; pregunta[0].Down = 255; + pregunta[0].Left= 200; pregunta[0].Right= 370; + ImprimeBoton (1, GRIS_O, GRIS_C, BLANCO, pregunta[0]); + pregunta[0].Up = 150; pregunta[0].Down = 175; + pregunta[0].Left= 210; pregunta[0].Right= 360; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[0]); + pregunta[1].Up = 185; pregunta[1].Down = 210; + pregunta[1].Left= 210; pregunta[1].Right= 360; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[1]); + pregunta[2].Up = 220; pregunta[2].Down = 245; + pregunta[2].Left= 210; pregunta[2].Right= 360; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[2]); + Fuente(SMALL_FONT, 4); +} else { + Where_Ask = 0; + pregunta[0].Up = 450; pregunta[0].Down = 475; + pregunta[0].Left= 5; pregunta[0].Right= 152; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[0]); + pregunta[1].Up = 450; pregunta[1].Down = 475; + pregunta[1].Left= 155; pregunta[1].Right= 309; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[1]); + pregunta[2].Up = 450; pregunta[2].Down = 475; + pregunta[2].Left= 312; pregunta[2].Right= 549; + ImprimeBoton (1, GRIS_C, BLANCO, GRIS_O, pregunta[2]); + Fuente(SMALL_FONT, 4); +} + +Letra_Boton +outtextxy(pregunta[0].Left+2, pregunta[0].Up+2, "F3 Imprimir Ficha Actual"); +outtextxy(pregunta[1].Left+2, pregunta[1].Up+2, "F2 Imprimir Lista Rpida"); +outtextxy(pregunta[2].Left+2, pregunta[2].Up+2, "F1 CANCELAR IMPRESION"); + +// +do{ + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + if(kbhit()){ + key_print = getch(); + if( key_print == 0 ) { + switch( (key_print=getch()) ){ + // F1 Cancelar + case 59: + fins_print = 1; + break; + // F3 Imprimir Ficha + case 61: + if(Where_Ask){ + pregunta[0].Up = 140; pregunta[0].Down = 255; + pregunta[0].Left= 200; pregunta[0].Right= 370; + } else { + pregunta[0].Up = 450; pregunta[0].Down = 475; + pregunta[0].Left= 5; pregunta[0].Right= 549; + } + ImprimeBoton (1, GRIS_O, GRIS_C, BLANCO, pregunta[0]); + + // + if( Comprueba_Impresora() ) { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Imprimiendo."); + outtextxy(210,170, "Por Favor, espere..."); + } else outtextxy(10,452, "Imprimiendo. Por Favor, espere..."); + Imprime_Ficha(); + } else { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Impresora no preparada."); + outtextxy(210,170, "Impresion Cancelada"); + } else { outtextxy(10,452, "Impresora no preparada. Impresin Cancelada."); } + Espera_Tecla_o_Raton(); + } + fins_print = 1; + + // + break; + // F2 Imprimir lista rpida + case 60: + if(Where_Ask){ + pregunta[0].Up = 140; pregunta[0].Down = 255; + pregunta[0].Left= 200; pregunta[0].Right= 370; + } else { + pregunta[0].Up = 450; pregunta[0].Down = 475; + pregunta[0].Left= 5; pregunta[0].Right= 549; + } + ImprimeBoton (1, GRIS_O, GRIS_C, BLANCO, pregunta[0]); + + // + if(Comprueba_Impresora()) { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Imprimiendo."); + outtextxy(210,170, "Por Favor, espere..."); + } else outtextxy(10,452, "Imprimiendo. Por Favor, espere..."); + Imprime_Lista_Rapida(); + } else { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Impresora no preparada."); + outtextxy(210,170, "Impresion Cancelada"); + } else { outtextxy(10,452, "Impresora no preparada. Impresin Cancelada."); } + Espera_Tecla_o_Raton(); + } + fins_print = 1; + + // + break; + default: + fins_print = 1; + } + } + } else + if(raton!=0 && boton_izq==1 || boton_der==1) { + if( (bpush = CheckButon( 3, pregunta))>0 ) { + + if(Where_Ask){ + pregunta[0].Up = 140; pregunta[0].Down = 255; + pregunta[0].Left= 200; pregunta[0].Right= 370; + } else { + pregunta[0].Up = 450; pregunta[0].Down = 475; + pregunta[0].Left= 5; pregunta[0].Right= 549; + } + ImprimeBoton (1, GRIS_O, GRIS_C, BLANCO, pregunta[0]); + + switch(bpush){ + // Imprimir Ficha + case 1: + // + if(Comprueba_Impresora()) { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Imprimiendo."); + outtextxy(210,170, "Por Favor, espere..."); + } else outtextxy(10,452, "Imprimiendo. Por Favor, espere..."); + Imprime_Ficha(); + } else { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Impresora no preparada."); + outtextxy(210,170, "Impresion Cancelada"); + } else { outtextxy(10,452, "Impresora no preparada. Impresin Cancelada."); } + Espera_Tecla_o_Raton(); + } + fins_print = 1; + // + + break; + // Imprime Lista Rpida + case 2: + // + if(Comprueba_Impresora()) { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Imprimiendo."); + outtextxy(210,170, "Por Favor, espere..."); + } else outtextxy(10,452, "Imprimiendo. Por Favor, espere..."); + Imprime_Lista_Rapida(); + } else { + Letra_Boton + if(Where_Ask){ outtextxy(210,150, "Impresora no preparada."); + outtextxy(210,170, "Impresion Cancelada"); + } else { outtextxy(10,452, "Impresora no preparada. Impresin Cancelada."); } + Espera_Tecla_o_Raton(); + } + fins_print = 1; + + // + break; + // Cancelar + case 3: + fins_print=1; + break; + default: + fins_print = 1; + } + } + } + + +}while(!fins_print); + +// + + if(Where_Ask == 1) { + putimage(198, 138, ptr, COPY_PUT); + farfree(ptr); + } else { + struct Make_Boton help; + help.Up = 450; help.Down = 475; + help.Left = 5; help.Right = 549; + ImprimeBoton (1, GRIS_C, GRIS_O, BLANCO, help); + } + +} + +void Imprime_Ficha(void){ + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "Nmero Vendedor: %03d\n\r", Vend1.Num_V); + fprintf( stdprn, "\n\r\n\r"); + fprintf( stdprn, "Nombre: %s %s, %s\n\r", Vend1.Apellido1, Vend1.Apellido2, Vend1.Nombre ); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "D.N.I.: %-15s \n\r\n\rTelfono(s): %12ld %12ld\n\r", Vend1.DNI, Vend1.Telefono1, Vend1.Telefono2 ); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "Calle: %-30s, %-3s, %-3s\n\r", Vend1.Calle, Vend1.Num, Vend1.Piso ); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "Poblacin: %-18s Provincia: %-16s C.P.: %ld\n\r", Vend1.Poblacion, Vend1.Provincia, Vend1.CP ); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "Comisin por Contrato: %05ld Porcentaje por producto: %03d\n\r", Vend1.CC, Vend1.PP); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "\n\r"); + fprintf( stdprn, "CONTRATOS REALIZADOS (y aun activos) ---> %04d <---", Vend1.Cr); + + fputc(12, stdprn); +} + + +void Imprime_Lista_Rapida(void){ + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Vend_inx); + int LSC = sizeof(struct Vendedores); + int lprint = 3; + +// 1 2 3 4 5 6 7 8 +// 123456789123456789123456789123456789123456789123456789123456789123456789 +int Curr_Vend = 0; + fprintf( stdprn, "\n\r"); + fprintf( stdprn, " Num_V Nombre Apellido Telfono Contratos Activos\n\r"); + fprintf( stdprn, "\n\r"); + + while(Curr_Vend <= Vend1_inx.Fin ){ + + fseek(Vend, (long)LSJ + LSI + ( LSC * Curr_Vend ), SEEK_SET); // Se coloca + fread(&Vend1, LSC, 1, Vend); // Y lee + + fprintf( stdprn, " %03d %-15s %-15s % 12ld % 12ld %04d\n\r", Vend1.Num_V, Vend1.Nombre, Vend1.Apellido1, Vend1.Telefono1, Vend1.Telefono2, Vend1.Cr); + + lprint++; + if (lprint==55) { lprint = 3; + fputc(12, stdprn); + fprintf( stdprn, " Num_V Nombre Apellido Telfono Contratos Activos\n\r"); + fprintf( stdprn, "\n\r"); + } + Curr_Vend++; + } + + + fputc(12, stdprn); +} + + + +void CompruebaLineasVend(void){ + // Check una pulsacion sobre un campo, y se situa, si es posible + int ok_p=0, inc=0, md=0; + int oldr, oldc; + +// if(SWAP) Anclar_Raton(); + + do{ + inc++; + if(x_raton >= (PV[(inc)-1].Left+2) && x_raton <= (PV[inc-1].Right-2) ) { ok_p=1; md = 1; + oldc=inc; } + if(inc==4) ok_p=1; + }while(!ok_p); + if(md==1){ + inc=0; ok_p=0; md = 0; + do{ + inc++; + if( (y_raton >= (PV[(oldc)-1].Up+4+(inc-1)*15+2)) && (y_raton <= (PV[oldc-1].Up+4+(inc-1)*15+16)) ) { ok_p=1; oldr=inc; md = 1;} + if(inc==11) ok_p=1; + }while(!ok_p); + } + if( (md==1) && ((CurrCol1!=oldc) || (CurrRow1!=oldr)) ) { + if( (CurrTopLine + oldr - 2 )<= Vend1_inx.Fin ){ + + EditCursorVend(1); + SWAP = 1; + CurrCol1 = oldc; + CurrRow1 = oldr; + GetLineVend(); + PrintLineVend(1); + } + } + + if( (md==0) && (inc = CheckButon_S( 19, 4, PV))>4 && (inc <=18) ) { EditCursorVend(1); SWAP = 0; CurrCol2 = (inc - 4); } + + + + +} + + + + + + + +/* +int Confirma(char *f1, char *f2, char *f3){ + +return 1; +} +*/ +/* +int comprueba_impresora(void){ +return 1; +} +*/ + + diff --git a/SV_VENT.CPP b/SV_VENT.CPP new file mode 100644 index 0000000..98eba7a --- /dev/null +++ b/SV_VENT.CPP @@ -0,0 +1,850 @@ +#define SV_REF_X + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "..\libs\make_bot\make_bot.h" +#include "sv_util.h" +#include "sv_graph.h" +#include "sv_ref_x.h" + + +#define Letra_Boton setcolor(1); +#define Azul 1 +#define Texto_Normal setcolor(63); +#define Texto_Negrita setcolor(0); + + +void Poner_a_cero_estructura_actual_Ventas(void); +void Abre_Ficha_Ventas(void); +void Actualizar_Ventas(int Referencia, int Unidades, int Codigo); + +extern int x_raton, y_raton, raton; +extern int boton_izq, boton_der; + +extern void desactiva_raton(void); +extern void activa_raton(void); +extern void Anclar_Raton(void); +extern void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py); +extern int Espera_Tecla_o_Raton(void); +extern void BEEP(void); + +extern int InputCadenaG(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo); +extern int InputCadenaG_l(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int Row); +extern int InputCadenaG_T4(char *s, int numalp, int lmax, int cc, int cf, struct boton Campo, int RoW); + +void GetLineVentas(void); +void Menu_de_Ventas(int Current_Date); +void PrintLineVentas(void); +void Mueve_Abajo_Ventas(void); +void Mueve_Arriba_Ventas(void); +void CompruebaLineasVentas(void); +void PrintWholeScreenVentas(void); +void EditCursorVentas(int ShowHide); +void Imprimir_Ventas(void); +// void Recalcula_Porcentaje(int Individual_Seleccionado); + +// void Llena_con_Ventas_basicas(void); +extern void Coloca_Nombres_a_botones(void); + +// extern int Confirma(char *f1, char *f2, char *f3); +extern int Comprueba_Impresora(void); + +struct Ventas_inx { unsigned int Fin; }; + +struct Ventas_actual { int Ref; long Und_0; long Und_1; }; + +struct Ventas_actual Ventas1_Graficas[10]; + +struct boton *PVent;//[5] +extern struct boton Comunes[9]; + + +int CurrRowVentas1; +int CurrColVentas1; +int CurrTopLineVentas; + + + + + + +struct Stock_inx { unsigned int Fin; }; + +struct Stock_actual { int Ref; long Und_0; long Und_1; }; + +struct Stock_actual Ventas1; +struct Stock_inx Ventas1_inx; + +FILE *Ventas; + + +extern int Fecha; + + +void Abre_Ficha_Ventas(void){ + + +char ArchivoDatos[]="12345678.1237"; +struct date Fecha2; +getdate(&Fecha2); + +sprintf( ArchivoDatos, "SV_V%02d%02d.dat", Fecha, (Fecha2.da_year - (Fecha2.da_year/100)*100 ) ); + + +//// +// Stockrueba apertura correcta de Indice, y Datos y creacin... // +//// + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Stock_inx); + int LSC = sizeof(struct Stock_actual); + + if ( (Ventas = fopen( ArchivoDatos, "r+b"))==NULL) { + + FILE *fa; + + if ( (fa = fopen( ArchivoDatos, "wb" ) )!=NULL ) { + + Poner_a_cero_estructura_actual_Ventas(); + Ventas1_inx.Fin = 0; + rewind(fa); + + fwrite(&cabecera, LSJ, 1, fa); fseek(fa, (long)LSJ, SEEK_SET); + fwrite(&Ventas1_inx, LSI, 1, fa); fseek(fa, (long)LSJ+LSI, SEEK_SET); + fwrite(&Ventas1, LSC, 1, fa); + + if (fclose(fa) == EOF ) exit(1); + } + + if ( (Ventas = fopen( ArchivoDatos, "r+b"))==NULL) { + restorecrtmode(); + printf("NO SE PUDO ABRIR EL FICHERO INDICE EN LA 2 PASADA"); + exit(1); + } + } + + fseek(Ventas, (long)LSJ, SEEK_SET); + if ( fread(&Ventas1_inx, LSI, 1, Ventas) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: INDICE"); + exit(1); + } + fseek(Ventas, (long)LSJ+LSI, SEEK_SET); + if ( fread(&Ventas1, LSC, 1, Ventas) != 1 ) { + restorecrtmode(); + printf("NO SE PUDO LEER EN EL FICHERO: DATOS"); + exit(1); + } + + +} + + +void Actualizar_Ventas(int Referencia, int Unidades, int Codigo){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Stock_inx); + int LSC = sizeof(struct Stock_actual); + + int ok = 0; + int Curr_Ventas = 0, Encuentro = 0; + + + while( (Curr_Ventas <= Ventas1_inx.Fin) && (ok == 0) ){ + + fseek(Ventas, (long)LSJ + LSI + ( LSC * Curr_Ventas ), SEEK_SET); // Se coloca + fread(&Ventas1, LSC, 1, Ventas); // Y lee + + if( Ventas1.Ref == Referencia ) { + if(Codigo==1) Ventas1.Und_1 += Unidades; + else Ventas1.Und_0 += Unidades; + fseek(Ventas, (long)LSJ + LSI + ( LSC * Curr_Ventas ), SEEK_SET); // Se coloca + fwrite(&Ventas1, LSC, 1, Ventas); // Y escribe + ok = 1; + Encuentro = 1; + } + + Curr_Ventas++; + } + + if (Encuentro==0) { + Ventas1.Ref = Referencia; + if(Codigo==1) { Ventas1.Und_1 = Unidades; Ventas1.Und_0 = 0; } + else { Ventas1.Und_0 = Unidades; Ventas1.Und_1 = 0; } + + fseek(Ventas, (long)LSJ + LSI + ( LSC * (Ventas1_inx.Fin + 1) ), SEEK_SET); // Se coloca + fwrite(&Ventas1, LSC, 1, Ventas); // Y escribe + + Ventas1_inx.Fin ++; + + fseek(Ventas, (long)LSJ, SEEK_SET); + fwrite(&Ventas1_inx, LSI, 1, Ventas); // Acualiza n de registros + } + + +} + +void Poner_a_cero_estructura_actual_Ventas(void){ + + cabecera.esc = 27; strcpy(cabecera.color, "[31;40m"); + strcpy(cabecera.prog, "Jos David Guilln Dominguez"); + cabecera.nl = 13; cabecera.rt = 10; + strcpy(cabecera.autor, " 6 / Mayo / 1995 "); + cabecera.pt = 7; cabecera.ef = 26; + + Ventas1.Ref=0; Ventas1.Und_1=0; Ventas1.Und_0=0; + +} + + + + + + + + + + + + + + + + + + + + +void Menu_de_Ventas(int Current_Date) { + + int finished = 0, key, bpush; + CurrRowVentas1 = 1; CurrColVentas1 = 1; + + Fecha = Current_Date; + + CurrTopLineVentas = 1; + + inicializa_raton_grafico(0, 0, 624, 464, 320, 240); + if(raton!=0) desactiva_raton(); + + if( ( PVent = (struct boton *) malloc( sizeof(struct boton)*15 ) ) == NULL ) + { + Confirma("Memoria insuficiente", "para crear tablas de", "posisin PVent."); + return ; + } + + + cleardevice(); + Dibuja_Pantalla_Ventas(PVent); + Fuente(SMALL_FONT, 5); + setcolor(NEGRO); + Coloca_Nombres_a_botones(); + setcolor(GRIS_C); + outtextxy(Comunes[3].left, Comunes[3].up, " SWAP" ); + outtextxy(Comunes[3].left, Comunes[3].up+18, " F6 " ); + + + Fuente(SMALL_FONT, 4); + Abre_Ficha_Ventas(); + Abre_Ficha_Referencias(); + Carga_Referencias(); + + PrintWholeScreenVentas(); + GetLineVentas(); + int oldCR1=0, oldCC1=0; + +do{ + +if(oldCR1!=CurrRowVentas1 || oldCC1!=CurrColVentas1 ) + EditCursorVentas(0); + +oldCR1 = CurrRowVentas1; oldCC1 = CurrColVentas1; + + if(raton!=0) activa_raton(); + Espera_Tecla_o_Raton(); + if(raton!=0) desactiva_raton(); + + if(kbhit()){ +// EditCursorVentas(1); + key = getch(); +/* + if( isprint(key) || isspace(key) ) { + EditCursorVentas(0); + if(key!=13) ungetch(key); + Edit_Item_Ventas(); + Recalcula_Porcentaje(1); + EditCursorVentas(0); + } else*/ if( key == 0 ) { + + EditCursorVentas(1); + + switch( (key=getch()) ){ + // Flecha Arriba + case 72: + Mueve_Arriba_Ventas(); +// Recalcula_Porcentaje(1); + break; + // Flecha Izquierda + case 75: + case 15: + CurrColVentas1--; + if ( CurrColVentas1<1 ) CurrColVentas1=8; + break; + // Flecha Derecha + case 77: + case 9: + CurrColVentas1++; + if ( CurrColVentas1>8) CurrColVentas1=1; + break; + // Flecha Abajo + case 80: + Mueve_Abajo_Ventas(); +// Recalcula_Porcentaje(1); + break; + // Buscar F2 + case 60: +// BuscarVentas(); + break; + // Imprimir Ventas F5 + case 63: + Imprimir_Ventas(); + break; + + // F9 --> AADIR + case 67: +// if( Confirma("AADIR NUEVO STOCK", "INICIAL", "") ) +// if ( Pide_Codigo(SV_CFG.COD_Ventas) ) +// AddRecordVentas(); + break; + // F10 -> BORRAR + case 68: +// if( Confirma("ELIMINAR TOTALMENTE", "STOCK ACTUAL", "") ) +// if ( Pide_Codigo(SV_CFG.COD_Ventas) ) +// DeleteRecordVentas(); +// Recalcula_Porcentaje(1); + break; + + // INICIO + case 71: + CurrColVentas1 = 1; + break; + // FIN + case 79: + CurrColVentas1 = 5; + break; + // RePg + case 73: + // CurrRow = 1; +// + if( CurrTopLineVentas > /*28*/26 ) { CurrTopLineVentas -= /*28*/26; } else { CurrTopLineVentas = 1; } + if( CurrTopLineVentas < 1 ) { CurrTopLineVentas = 1; } + PrintWholeScreenVentas(); + GetLineVentas(); + EditCursorVentas(0); +// Recalcula_Porcentaje(1); + break; +// + // AvPg + case 81: + // CurrRow = 1; +// + CurrTopLineVentas += /*28*/26; + if ( (CurrTopLineVentas+CurrRowVentas1) > Ventas1_inx.Fin) { CurrTopLineVentas = Ventas1_inx.Fin; CurrRowVentas1 = 1; } + if (CurrTopLineVentas==0) CurrTopLineVentas = 1; + PrintWholeScreenVentas(); + GetLineVentas(); + EditCursorVentas(0); +// Recalcula_Porcentaje(1); +// + break; + // Salir F1 + case 59: + finished = 1; + break; + default: + break; + } + EditCursorVentas(0); + } + } else if(raton!=0 && ( boton_izq==1 || boton_der==1 ) ) + if( (bpush = CheckButon( 9, Comunes))>0 ) { + EditCursorVentas(1); + switch(bpush){ + // Flecha Arriba + case 1: + Mueve_Arriba_Ventas(); +// Recalcula_Porcentaje(1); + break; + // Buscar + case 2: +// BuscarVend(); + break; + // Flecha Abajo + case 3: + Mueve_Abajo_Ventas(); +// Recalcula_Porcentaje(1); + break; + case 4: + break; + // Imprimir + case 5: + Imprimir_Ventas(); + break; + // Aadir + case 6: +// if( Confirma("AADIR NUEVO STOCK", "INICIAL", "") ) +// if ( Pide_Codigo(SV_CFG.COD_Ventas) ) +// AddRecordVentas(); + break; + // Borrar + case 7: +// if( Confirma("ELIMINAR TOTALMENTE", "STOCK ACTUAL", "") ) +// if ( Pide_Codigo(SV_CFG.COD_Ventas) ) +// DeleteRecordVentas(); +// Recalcula_Porcentaje(1); + break; + // Salir + case 9: + finished = 1; + break; + default: + break; + } + EditCursorVentas(0); + } else CompruebaLineasVentas(); + +}while(!finished); + +fclose(Ventas); // Fichero Vendedores +fclose(Ref); // Fichero Vendedores +free(PVent); // Libera la memoria + +if(Memory_ok==1) farfree(Addr); else free(Ref_inx_addr); + + + +} + +void Mueve_Abajo_Ventas(void){ + + int CurrRecord = CurrTopLineVentas + CurrRowVentas1 - 1; + + if (CurrRowVentas1==/*28*/40) { + if ( (CurrRecord - 1) >= Ventas1_inx.Fin) { BEEP(); EditCursorVentas(0); } + else { CurrTopLineVentas++; + PrintWholeScreenVentas(); + // + // + // + GetLineVentas(); +// PrintLineVentas(); + } + } else { + if( (CurrRecord - 1) >= Ventas1_inx.Fin) { BEEP(); EditCursorVentas(0); } + else { CurrRowVentas1++; + GetLineVentas(); +// PrintLineVentas(); + } + } + +} + +void Mueve_Arriba_Ventas(void){ + int CurrRecord = CurrTopLineVentas + CurrRowVentas1 - 1; + + if (CurrRowVentas1==1) { + if ((CurrRecord - 1) <= 0) { BEEP(); EditCursorVentas(0); } + else { + CurrTopLineVentas--; + PrintWholeScreenVentas(); + // + // + // + GetLineVentas(); +// PrintLineVentas(); + } + + } else { + if( (CurrRecord - 1) <= 0) BEEP(); + else { CurrRowVentas1--; + + GetLineVentas(); +// PrintLineVentas(); + } + } + +} + +void EditCursorVentas(int ShowHide) { + +char Buffer[80]; +long Beneficio1, Beneficio2, Total; + + setcolor(GRIS_C); + setfillstyle(SOLID_FILL, GRIS_C); + bar(10, 455, 545, 473); + + + if (!ShowHide) { + setcolor(63); + setfillstyle(SOLID_FILL, 63); + bar((PVent[CurrColVentas1-1].left+2), PVent[CurrColVentas1-1].up+(CurrRowVentas1-1)*/*15*/12+/*2*/4, PVent[CurrColVentas1-1].right-2, PVent[CurrColVentas1-1].up+/*3*/4+((CurrRowVentas1)-1)*12+10); + setcolor(0); + } else { + setcolor(0); + setfillstyle(SOLID_FILL, 0); + bar((PVent[CurrColVentas1-1].left+2), PVent[CurrColVentas1-1].up+(CurrRowVentas1-1)*/*15*/12+/*2*/4, PVent[CurrColVentas1-1].right-2, PVent[CurrColVentas1-1].up+/*3*/4+((CurrRowVentas1)-1)*12+10); + Texto_Normal + } + + if(Ref_no_valid) setcolor(ROJO); + +// struct Ventas_actual { int Ref; long Und_0; long Und_1; }; + + + switch(CurrColVentas1){ + case 1: //4 + sprintf(Buffer, "% 5d", Ventas1.Ref ); + outtextxy( PVent[0].left+2, (PVent[0].up+3)+(CurrRowVentas1-1)*12, Buffer ); + outtextxy( 15, 455, "Referencia de Producto. 4 digitos mximo."); + break; + case 2: + outtextxy( PVent[1].left+2, (PVent[1].up+3)+(CurrRowVentas1-1)*12, Ref1.Concepto ); + outtextxy( 15, 455, "Concepto."); + break; + case 3: /*d*/ + sprintf(Buffer, " % 5ld", Ventas1.Und_1); // 4 + outtextxy( PVent[2].left+2, (PVent[2].up+3)+(CurrRowVentas1-1)*12, Buffer); + outtextxy( 15, 455, "Unidades con Cod. 1"); + break; + case 4: + Beneficio1 = +// Precio de venta al cliente + I.V.A + ( Ref1.PVP + ( ( Ref1.PVP * Ref1.P2 ) / 100 ) ) - +// Precio de unitario de coste + I.V.A + ( Ref1.P_und + ( ( Ref1.P_und * Ref1.P1 ) / 100 ) ); + Total = Beneficio1 * Ventas1.Und_1; + sprintf(Buffer, " % 9ld", Total); // 4 + outtextxy( PVent[3].left+2, (PVent[3].up+3)+(CurrRowVentas1-1)*12, Buffer); + outtextxy( 15, 455, "Ganancias Brutas Cod. 1"); + break; + case 5: /*d*/ + sprintf(Buffer, " % 5ld", Ventas1.Und_0); // 4 + outtextxy( PVent[4].left+2, (PVent[4].up+3)+(CurrRowVentas1-1)*12, Buffer ); + outtextxy( 15, 455, "Unidades con Cod. 0"); + break; + case 6: + Beneficio2 = +// Precio de venta al cliente + I.V.A + ( Ref1.PVP + ( ( Ref1.PVP * Ref1.P2 ) / 100 ) ) - +// Precio de unitario de coste + I.V.A + ( Ref1.P_und /*+ ( ( Stock1.P_und * P1 ) / 100 ) */ ); + Total = Beneficio2 * Ventas1.Und_0; + sprintf(Buffer, " % 9ld", Total); // 4 + outtextxy( PVent[5].left+2, (PVent[5].up+3)+(CurrRowVentas1-1)*12, Buffer); + outtextxy( 15, 455, "Ganancias Brutas Cod. 0"); + break; + case 7: /*d*/ + sprintf(Buffer, " % 7ld", ( Ventas1.Und_1 + Ventas1.Und_0) ); // 4 + outtextxy( PVent[6].left+2, (PVent[6].up+3)+(CurrRowVentas1-1)*12, Buffer); + outtextxy( 15, 455, "Unidades Totales Cdigos. 1 y 0"); + break; + case 8: + Beneficio1 = +// Precio de venta al cliente + I.V.A + ( Ref1.PVP + ( ( Ref1.PVP * Ref1.P2 ) / 100 ) ) - +// Precio de unitario de coste + I.V.A + ( Ref1.P_und + ( ( Ref1.P_und * Ref1.P1 ) / 100 ) ); + + Beneficio2 = +// Precio de venta al cliente + I.V.A + ( Ref1.PVP + ( ( Ref1.PVP * Ref1.P2 ) / 100 ) ) - +// Precio de unitario de coste + I.V.A + ( Ref1.P_und /*+ ( ( Stock1.P_und * P1 ) / 100 ) */ ); + Total = Beneficio1 * Ventas1.Und_1 + Beneficio2 * Ventas1.Und_0; + + sprintf(Buffer, " % 12ld", Total); // 4 + outtextxy( PVent[7].left+2, (PVent[7].up+3)+(CurrRowVentas1-1)*12, Buffer ); + outtextxy( 15, 455, "Beneficio Total Bruto."); + break; + } + +} + + + +void PrintLineVentas(void){ + + char Buffer[80]; + long Beneficio1, Beneficio2, Total; + + setcolor(0); + setfillstyle(SOLID_FILL, 0); + bar((PVent[0].left+2), PVent[0].up+(CurrRowVentas1-1)*12+/*2*/4, PVent[0].right-2, PVent[0].up+(CurrRowVentas1-1)*12+10); + bar((PVent[1].left+2), PVent[1].up+(CurrRowVentas1-1)*12+/*2*/4, PVent[1].right-2, PVent[1].up+(CurrRowVentas1-1)*12+10); + bar((PVent[2].left+2), PVent[2].up+(CurrRowVentas1-1)*12+/*2*/4, PVent[2].right-2, PVent[2].up+(CurrRowVentas1-1)*12+10); + bar((PVent[3].left+2), PVent[3].up+(CurrRowVentas1-1)*12+/*2*/4, PVent[3].right-2, PVent[3].up+(CurrRowVentas1-1)*12+10); + bar((PVent[4].left+2), PVent[4].up+(CurrRowVentas1-1)*12+/*2*/4, PVent[4].right-2, PVent[4].up+(CurrRowVentas1-1)*12+10); + + Texto_Normal + + if(Ref_no_valid) setcolor(ROJO); + + sprintf(Buffer, "% 5d", Ventas1.Ref ); + outtextxy( PVent[0].left+2, (PVent[0].up+3)+(CurrRowVentas1-1)*12, Buffer ); + outtextxy( PVent[1].left+2, (PVent[1].up+3)+(CurrRowVentas1-1)*12, Ref1.Concepto ); + /*d*/ + sprintf(Buffer, " % 5ld", Ventas1.Und_1); // 4 + outtextxy( PVent[2].left+2, (PVent[2].up+3)+(CurrRowVentas1-1)*12, Buffer); + Beneficio1 = ( Ref1.PVP + ( ( Ref1.PVP * Ref1.P2 ) / 100 ) ) - ( Ref1.P_und + ( ( Ref1.P_und * Ref1.P1 ) / 100 ) ); +// Precio de venta al cliente + I.V.A +// ( Ref1.PVP + ( ( Ref1.PVP * Ref1.P2 ) / 100 ) ) - +// Precio de unitario de coste + I.V.A +// ( Ref1.P_und + ( ( Ref1.P_und * Ref1.P1 ) / 100 ) ); + Total = Beneficio1 * Ventas1.Und_1; + sprintf(Buffer, " % 9ld", Total); // 4 + outtextxy( PVent[3].left+2, (PVent[3].up+3)+(CurrRowVentas1-1)*12, Buffer); + /*d*/ + sprintf(Buffer, " % 5ld", Ventas1.Und_0); // 4 + outtextxy( PVent[4].left+2, (PVent[4].up+3)+(CurrRowVentas1-1)*12, Buffer ); + Beneficio2 = ( Ref1.PVP + ( ( Ref1.PVP * Ref1.P2 ) / 100 ) ) - ( Ref1.P_und ); +// Precio de venta al cliente + I.V.A +// ( Stock1.PVP + ( ( Stock1.PVP * P2 ) / 100 ) ) - +// Precio de unitario de coste + I.V.A +// ( Stock1.P_und /*+ ( ( Stock1.P_und * P1 ) / 100 ) */ ); + Total = Beneficio2 * Ventas1.Und_0; + sprintf(Buffer, " % 9ld", Total); // 4 + outtextxy( PVent[5].left+2, (PVent[5].up+3)+(CurrRowVentas1-1)*12, Buffer); + /*d*/ + sprintf(Buffer, " % 7ld", (Ventas1.Und_1 + Ventas1.Und_0) ); // 4 + outtextxy( PVent[6].left+2, (PVent[6].up+3)+(CurrRowVentas1-1)*12, Buffer); + + Total = Beneficio1 * Ventas1.Und_1 + Beneficio2 * Ventas1.Und_0; + sprintf(Buffer, " % 12ld", Total); // 4 + outtextxy( PVent[7].left+2, (PVent[7].up+3)+(CurrRowVentas1-1)*12, Buffer ); + +} + + +void PrintWholeScreenVentas(void){ + +int tmp = CurrRowVentas1; + +for(int i=0; i<8; i++) + ImprimeBoton (1, NEGRO, GRIS_O, BLANCO, PVent[i]); + + + for(CurrRowVentas1 = 1; CurrRowVentas1 < (/*28*/40+1); CurrRowVentas1++) + + if ( (CurrTopLineVentas + CurrRowVentas1 - 1) <= (Ventas1_inx.Fin + 1) ) { + GetLineVentas(); + PrintLineVentas(); + } + + + +CurrRowVentas1 = tmp; + +} + + +void GetLineVentas(void){ + + int LSJ = sizeof(struct JD); + int LSI = sizeof(struct Ventas_inx); + int LSC = sizeof(struct Ventas_actual); + + int CurrRecord = CurrTopLineVentas + CurrRowVentas1 - 1; + +fseek(Ventas, (long)LSJ + LSI + ( LSC * CurrRecord ) - LSC, SEEK_SET); // Se coloca +fread(&Ventas1, LSC, 1, Ventas); // Y lee + + BuscaReferencia(Ventas1.Ref); + +} + + + + +void Imprimir_Ventas(void){ + +int LSJ = sizeof(struct JD); +int LSI = sizeof(struct Ventas_inx); +int LSC = sizeof(struct Ventas_actual); +int lprint = 3, Curr_Ventas = 0; +long Beneficio1, Beneficio2, Total1, Total2; +if ( Comprueba_Impresora() == 0 ) { +Confirma("Error Imprimiendo.", "Impresora Fuera de", "Servicio."); +return; +} + +fprintf( stdprn, "\n\r"); + +fprintf( stdprn, "Ref Concepto Und. 1 V. Bruto 1 Und. 0 V. Bruto 0 Unds Total\n\r"); +fprintf( stdprn, "\n\r"); + + while( (Curr_Ventas <= Ventas1_inx.Fin) ){ + + fseek(Ventas, (long)LSJ + LSI + ( LSC * Curr_Ventas ), SEEK_SET); // Se coloca + fread(&Ventas1, LSC, 1, Ventas); // Y lee + BuscaReferencia(Ventas1.Ref); + + Beneficio1 = +// Precio de venta al cliente + I.V.A + ( Ref1.PVP + ( ( Ref1.PVP * Ref1.P2 ) / 100 ) ) - +// Precio de unitario de coste + I.V.A + ( Ref1.P_und + ( ( Ref1.P_und * Ref1.P1 ) / 100 ) ); + + Beneficio2 = +// Precio de venta al cliente + I.V.A + ( Ref1.PVP + ( ( Ref1.PVP * Ref1.P2 ) / 100 ) ) - +// Precio de unitario de coste + I.V.A + ( Ref1.P_und /*+ ( ( Stock1.P_und * P1 ) / 100 ) */ ); + +Total1 = (Beneficio1*Ventas1.Und_1); +Total2 = (Beneficio2*Ventas1.Und_0); + +fprintf( stdprn, "% 4d %-20s % 4ld", Ventas1.Ref, Ref1.Concepto, Ventas1.Und_1); +fprintf( stdprn, " % 8ld % 4ld", Total1, Ventas1.Und_0); +fprintf( stdprn, " % 8ld % 8ld\n\r", Total2, ( Ventas1.Und_0 + Ventas1.Und_1 ) ); + + lprint++; + if (lprint==55) { lprint = 3; + fputc(12, stdprn); +fprintf( stdprn, "Ref Concepto Und. 1 V. Bruto 1 Und. 0 V. Bruto 0 Unds Total\n\r"); +fprintf( stdprn, "\n\r"); + } + Curr_Ventas++; + } + + fputc(12, stdprn); + GetLineVentas(); +} + + +void CompruebaLineasVentas(void){ + // Check una pulsacion sobre un campo, y se situa, si es posible + int ok_p=0, inc=0, md=0; + int oldr, oldc; +// Anclar_Raton(); + + do{ + inc++; + if(x_raton >= (PVent[(inc)-1].left+2) && x_raton <= (PVent[inc-1].right-2) ) { ok_p=1; md = 1; + oldc=inc; } + if(inc==5) ok_p=1; + }while(!ok_p); + if(md==1){ + inc=0; ok_p=0; md = 0; + do{ + inc++; + if( (y_raton >= (PVent[(oldc)-1].up+4+(inc-1)*15+2)) && (y_raton <= (PVent[oldc-1].up+4+(inc-1)*15+16)) ) { ok_p=1; oldr=inc; md = 1;} + if(inc==26) ok_p=1; + }while(!ok_p); + } + int newc; + + switch(oldc){ + case 1: + case 2: newc = oldc; break; + case 4: + case 5: newc = (oldc - 1); break; + default: + break; + } + + + if( (md==1) && ((CurrColVentas1!=newc) || (CurrRowVentas1!=oldr)) ) + { + + if( (CurrTopLineVentas + oldr - 2 )<= Ventas1_inx.Fin ){ + EditCursorVentas(1); + switch(oldc){ + case 1: + case 2: + CurrColVentas1 = oldc; + CurrRowVentas1 = oldr; + break; + case 4: + case 5: + CurrColVentas1 = (oldc-1); + CurrRowVentas1 = oldr; + break; + default: + EditCursorVentas(0); + break; + } + GetLineVentas(); + } + } + + } + + + + + +// +// +// +// +// +// +void Lee_Datos_Ganancias(unsigned long *Compras_mes){ + + setcolor(ROJO); + setfillstyle( SOLID_FILL, ROJO ); + char Buffer[80]; + + CurrTopLineVentas = 1; + + struct date Fecha2; + getdate(&Fecha2); + +// struct Ventas_actual { int Ref; long Und_0; long Und_1; }; + +for(Fecha=1; Fecha<=12; Fecha++ ){ + +sprintf( Buffer, "SV_V%02d%02d.dat", Fecha, (Fecha2.da_year - (Fecha2.da_year/100)*100 ) ); + +if( file_exists( Buffer ) ){ + Abre_Ficha_Ventas(); + for(CurrRowVentas1 = 1; CurrRowVentas1 <= (Ventas1_inx.Fin + 1); CurrRowVentas1++){ + + GetLineVentas(); +// Codigo 1 + Compras_mes[ (Fecha - 1)*2 + 1 ] += (Ventas1.Und_1* + ( ( Ref1.PVP + (( Ref1.PVP * Ref1.P2 ) / 100 )) - + (Ref1.P_und + ( ( Ref1.P_und * Ref1.P1 ) / 100 ) ) ) ); + +// Codigo 0 + Compras_mes[ (Fecha - 1)*2 ] += (Ventas1.Und_0* + ( ( Ref1.PVP + ( ( Ref1.PVP * Ref1.P2 ) / 100 ) ) - + ( Ref1.P_und ) ) ); +/* + Compras_mes[ (Fecha - 1)*2 + (Ventas1.Cod ? 1 : 0 ) ] + += ( Ventas1.Cod + ? + (((Ref1.P_und * Ref1.P1)/100) + Ref1.P_und) + : + ( Ref1.P_und ) + )*Ventas1.Und; +*/ + bar(152,372, 152 + (20*(CurrRowVentas1-1)) + ( (/*240*/20*(CurrRowVentas1*100)/(Ventas1_inx.Fin + 1)) / 100 ), 388); +// ^----------^ + } + fclose(Ventas); +} + +} + +}