First commit 11/11/1991
This commit is contained in:
723
SV_REF.CPP
Normal file
723
SV_REF.CPP
Normal file
@ -0,0 +1,723 @@
|
||||
#include<graphics.h>
|
||||
#include<conio.h>
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
#include<ctype.h>
|
||||
#include<alloc.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
|
||||
#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", "posisi<EFBFBD>n 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 --> A<>ADIR
|
||||
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;
|
||||
// ReP<65>g
|
||||
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;
|
||||
// AvP<76>g
|
||||
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;
|
||||
// A<>adir
|
||||
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();
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
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();
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
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); //<2F>// //<2F>// //<2F>// //<2F>//
|
||||
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); //<2F>// //<2F>// //<2F>// //<2F>//
|
||||
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, "N<EFBFBD>mero de Referencia. 4 digitos m<>ximo.");
|
||||
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 m<>ximo.");
|
||||
|
||||
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 m<>ximo.");
|
||||
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 m<>ximo.");
|
||||
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 m<>ximo.");
|
||||
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 m<>ximo.");
|
||||
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();
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
/*<2A>*/ GetLineRef(); /*<2A>*/
|
||||
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
PrintLineRef();
|
||||
|
||||
}
|
||||
|
||||
void Abre_Ficha_Referencias(void){
|
||||
|
||||
char ArchivoDatos[]="SV__REF.DAT";
|
||||
int ok = 0;
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>//
|
||||
//<2F> Comprueba apertura correcta de Indice, y Datos y creaci<63>n... <20>//
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>//
|
||||
|
||||
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
|
||||
|
||||
/* <20> */ if ((CurrRecord - 1) == Ref1_inx.Fin + 1) CurrRowRef1--;
|
||||
/* <20> */ if( Ref1_inx.Fin == 4 ) AddRecordRef(1);
|
||||
/* <20> */
|
||||
/* <20><><EFBFBD><EFBFBD> */ PrintWholeScreenRef();
|
||||
/* <20> */ 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<EFBFBD> David Guill<6C>n 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, "Serpent<EFBFBD>n/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
|
||||
// 123456789<38>123456789<38>123456789<38>123456789<38>123456789<38>123456789<38>123456789<38>123456789<38>
|
||||
fprintf( stdprn, " Refer. Concepto P.C. I.V.A P.V.P. I.V.A \n\r");
|
||||
fprintf( stdprn, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\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, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user