#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 creaci¢n... Û// //ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß// 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 Guill‚n 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", "posisi¢n 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 --> A¥ADIR case 67: // if( Confirma("A¥ADIR 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; // ReP g 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; //ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ // AvP g 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; // A¤adir case 6: // if( Confirma("A¥ADIR 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 m ximo."); 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 C¢digos. 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); } } }