/////////////////////////////////////////////////////////////////////////// //// Nombre: CPedidos.CPP /// //// Modulo: Perteneciente a Catalogo.CPP /// //// Descripci¢n: M¢dulo para editar o modificar los pedidos /// //// enlazados a este m¢dulo por CaddView.CPP /// //// /// //// Autor: Jos‚ David Guill‚n Dominguez /// //// Fecha: 22 - 12 - 1994 /// //// /// //// Comentario: /// //// /// //// /// //// Compilador Borland C++ 3.0 /// /////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include #include /////////////////////////////////////////////////////////////////////////// //ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ// /////////////////////////////////////////////////////////////////////////// struct pedidos_descripcion { unsigned int n_records; // n§ de grabaciones en el fichero char nombre[24+1]; // Nombre 24 digitos + NULL char apelli[21+1]; // Apellidos 21 digitos + NULL char direcc[21+1]; // Direcci¢n 21 digitos + NULL long telefono; // Tel‚fono 5 digitos permitidos char cpu[10 + 1]; // C.P.U. 10 digitos + NULL int ram; // R.A.M 2 digitos permitidos int hd; // HD. 4 digitos permitidos }; struct pedidos_datos { unsigned int record_zone ; int record_name; char nombre[13+1] ; char zip[3+1] ; int kbytes ; }; struct pedidos_descripcion JD_dp; // Descripci¢n... struct pedidos_datos JD_dt; // Datos... FILE *JD_p; // Fichero Pedidos // Variables de posici¢n y registro int CurrRowP, CurrColP; unsigned int CurrTopLineP; int CurrRowPD, CurrColPD= 1; char ArchivoPedidos[]="CPedidos.DAT"; /////////////////////////////////////////////////////////////////////////// //ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ// /////////////////////////////////////////////////////////////////////////// extern struct boton { int left; int up; int right; int down; }; extern int boton_izq; extern int boton_der; extern int x_raton; extern int y_raton; extern int raton; extern int bpush; extern int sb; extern int InputCadenaG(char *s, int numalp, int lmax, int px, int py, int cc, int cf); extern void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py); extern void ImprimeBoton2 (int fill, int cdf, int cs1, int cs2, struct boton parm); extern int CheckButon(int nb, struct boton menu[]); extern void Sound_SN(char *headfile); extern void BorraViewPort(int view); extern void desactiva_raton(void); extern void activa_raton(void); void EditarModificarPedidos(void); void EditCursorPD(int ShowHide); void EditCursorP(int ShowHide); void PrintLineP(int permiso); void PrintWholeScreenP(void); void CreaPresentacion(void); void DeleteRecordP(void); void AddRecordP(void); void EditItemPD(void); void EditItemP(void); void MoveDownP(void); void PutLineP(void); void GetLineP(void); void MoveUpP(void); void Print_in_Printer(void); void EditarModificarPedidos(void){ union REGS ent, sal; int finished, key, swap = 1; CurrRowP = 1; CurrColP = 1; CurrTopLineP = 1; CurrRowPD= 1; struct boton menu[11]; menu[0]. left = 217; menu[0]. up = 34; menu[0]. right = 297; menu[0]. down = 65; menu[1]. left = 217; menu[1]. up = 66; menu[1]. right = 297; menu[1]. down = 97; menu[2]. left = 217; menu[2]. up = 98; menu[2]. right = 297; menu[2]. down = 129; menu[3]. left = 217; menu[3]. up = 130; menu[3]. right = 256; menu[3]. down = 149; menu[4]. left = 258; menu[4]. up = 130; menu[4]. right = 297; menu[4]. down = 149; menu[5]. left = 217; menu[5]. up = 150; menu[5]. right = 256; menu[5]. down = 171; menu[6]. left = 258; menu[6]. up = 150; menu[6]. right = 297; menu[6]. down = 171; menu[7]. left = 217; menu[7]. up = 172; menu[7]. right = 297; menu[7]. down = 204; menu[8]. left = 325; menu[8]. up = 150; menu[8]. right = 414; menu[8]. down = 204; menu[9]. left = 415; menu[9]. up = 150; menu[9]. right = 503; menu[9]. down = 204; menu[10]. left = 504; menu[10]. up = 150; menu[10]. right = 592; menu[10]. down = 204; CreaPresentacion(); for(auto int i=0; i<11; i++) ImprimeBoton2 (1, 7, 63, 56, menu[i]); setcolor(15); outtextxy(222, 50 , "ADD F9 "); outtextxy(222, 80 , "DEL F10"); outtextxy(223, 107, " SWAP "); outtextxy(223, 115," F3 "); outtextxy(222, 136, " UP "); outtextxy(263, 136, "DOWN"); outtextxy(222, 156, "RePg"); outtextxy(262, 156, "AvPg"); outtextxy(222, 180, "Salir F2"); outtextxy(335, 160, "Imprimir"); outtextxy(335, 170, " F8"); outtextxy(425, 160, "Borrar y"); outtextxy(425, 170, "Salir F7"); /* outtextxy(506, 130, "Borrar"); outtextxy(506, 140, ""); */ setcolor(0); outtextxy(221, 49 , "ADD F9 "); outtextxy(221, 79 , "DEL F10"); outtextxy(222, 106, " SWAP "); outtextxy(222, 114," F3 "); outtextxy(221, 135, " UP "); outtextxy(262, 135, "DOWN"); outtextxy(221, 155, "RePg"); outtextxy(261, 155, "AvPg"); outtextxy(221, 179, "Salir F2"); outtextxy(334, 159, "Imprimir"); outtextxy(334, 169, " F8"); outtextxy(424, 159, "Borrar y"); outtextxy(424, 169, "Salir F7"); /* outtextxy(505, 129, "Borrar"); outtextxy(505, 139, "y Salir F6"); */ //ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ// //ÛÛ Comprueba apertura correcta de Pedidos o creaci¢n... ÛÛ// //ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ// if ( (JD_p = fopen( ArchivoPedidos, "r+b"))==NULL) { FILE *fa; if ( (fa = fopen( ArchivoPedidos, "wb" ) )!=NULL ) { JD_dp. n_records = 1; strcpy(JD_dp. nombre, "\0"); strcpy(JD_dp. apelli, "\0"); strcpy(JD_dp. direcc, "\0"); JD_dp. telefono = 0; strcpy(JD_dp. cpu, "\0"); JD_dp. ram = 0; JD_dp. hd = 0; rewind(fa); fwrite(&JD_dp, sizeof(struct pedidos_descripcion), 1, fa); JD_dt. record_zone = 0; strcpy(JD_dt. nombre, "\0"); strcpy(JD_dt. zip, "\0"); JD_dt. kbytes = 0; fwrite(&JD_dt, sizeof(struct pedidos_datos), 1, fa); if (fclose(fa) == EOF ) exit(1); } if ( (JD_p = fopen( ArchivoPedidos, "r+b"))==NULL) { printf("NO SE PUDO ABRIR EL FICHERO PEDIDOS EN LA 2§ PASADA"); exit(1); } } if ( fread(&JD_dp, sizeof(struct pedidos_descripcion), 1, JD_p) != 1 ) { // Lee n§ de registros // Mensaje("No se pudo LEER CPedidos.DAT", 0) printf("NO SE PUDO LEER EL FICHERO PEDIDOS"); return; } setcolor(14); outtextxy( 50 * 8 - 7, 4 * 16 - 16, JD_dp. nombre ); outtextxy( 53 * 8 - 7, 5 * 16 - 16, JD_dp. apelli ); outtextxy( 53 * 8 - 7, 6 * 16 - 16, JD_dp. direcc ); { // Bloque abierto para la destrucci¢n prematura del string auto char string[15]; ltoa(JD_dp. telefono, string, 10); outtextxy( 52 * 8 - 7, 7 * 16 - 16, string ); outtextxy( 47 * 8 - 7, 8 * 16 - 16, JD_dp. cpu ); itoa(JD_dp. ram, string, 10); outtextxy( 63 * 8 - 7, 8 * 16 - 16, string ); itoa(JD_dp. hd, string, 10); outtextxy( 70 * 8 - 7, 8 * 16 - 16, string ); } PrintWholeScreenP(); GetLineP(); if ( CurrRowP >= 11 ) /* N£mero de lineas DISPONIBLES */ PrintLineP(0); else PrintLineP(1); finished = 0; int borrar_todo = 0; if(raton) inicializa_raton_grafico(0, 0, 624, 464, 320, 240); do{ if(swap) EditCursorP(0); else EditCursorPD(0); if(raton) activa_raton(); /////////////////////// Aqui va una pausa de TECLADO y RATON al mismo TIEMPO do{ if(raton){ ent.x.ax = 3; int86(0x33, &ent, &sal); // lee posici¢n y estados del bot¢n boton_izq = sal.x.bx & 1; boton_der = (sal.x.bx >> 1) & 1; x_raton = sal.x.cx; y_raton = sal.x.dx; } else boton_izq = 1; }while( !boton_izq && !kbhit() ); if(raton) desactiva_raton(); if( kbhit() ) { //////////////////////////////////////////////////////////////////////// ///////////////////////////////////////// ¨ Hay una tecla en buffer ... key = getch(); if(swap) EditCursorP(1); else EditCursorPD(1); if( isprint(key) || isspace(key) ) { if(key!=13) ungetch(key); if(swap) EditItemP(); else EditItemPD(); } else { if( key == 0 ) { key = getch(); switch ( key ) { // INICIO case 71: if (swap) CurrColP = 1; else CurrRowPD = 1; break; // FIN case 79: if (swap) CurrColP = 3; else CurrRowPD = 7; break; // FLECHA ARRIBA case 72: if (swap) MoveUpP(); else { CurrRowPD--; if (CurrRowPD == 0) CurrRowPD = 7; } break; // FLECHA ABAJO case 80: if (swap) MoveDownP(); else { CurrRowPD++; if (CurrRowPD == 8) CurrRowPD = 1; } break; // FLECHA IZQUIERDA case 75: case 15: if (swap) { CurrColP--; if (CurrColP == 0) CurrColP = 3; } else { CurrRowPD--; if (CurrRowPD == 0) CurrRowPD = 7; } break; // FLECHA DERECHA case 77: case 9: if (swap) { CurrColP++; if (CurrColP == 4) CurrColP = 1; } else { CurrRowPD++; if (CurrRowPD == 8) CurrRowPD = 1; } break; // F3 ---> SWAP case 61: if(swap) swap=0; else swap = 1; break; // ReP g case 73: if(swap){ CurrRowP = 1; if(CurrTopLineP >= 20 ) { CurrTopLineP -= 19; } else { CurrTopLineP = 1; } if(CurrTopLineP < JD_dp.n_records ) { CurrTopLineP = 1; } PrintWholeScreenP(); GetLineP(); } break; // AvP g case 81: if (swap) { CurrRowP = 1; CurrTopLineP = CurrTopLineP + 19; if (CurrTopLineP >= JD_dp.n_records) CurrTopLineP = JD_dp.n_records; PrintWholeScreenP(); GetLineP(); } break; // F2 --> PARA SALIR case 60: finished = 1; break; // F9 --> A¥ADIR case 67: if (swap) AddRecordP(); break; // F10 -> BORRAR case 68: if (swap) DeleteRecordP(); break; // F8 --> Imprimir case 66: Print_in_Printer(); GetLineP(); break; // F7 --> Reinicializar marcas case 65: borrar_todo = 1; finished = 1; break; default: if (sb) Sound_SN("catalog3"); break; } // Fin de Swicth } // Fin Key = 0 } // Fin Is Print Key? } // Fin Tecla en Buffer ///////////////////////////////////////////////////////////////////////////// //ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ// ////////////////////////// Comprueba con rat¢n ( SI ) /////////////////////// //ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß// ///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////// ... o es el RATON ? if(raton && boton_izq==1 || boton_der==1) { if( CheckButon(11, menu) ) { if(swap) EditCursorP(1); else EditCursorPD(1); switch ( bpush ) { // F9 --> A¥ADIR case 1: if(swap) AddRecordP(); break; // F10 -> BORRAR case 2: if(swap) DeleteRecordP(); break; // F3 ---> SWAP case 3: if(swap) swap=0; else swap = 1; break; // FLECHA ARRIBA case 4: if (swap) MoveUpP(); else { CurrRowPD--; if (CurrRowPD == 0) CurrRowPD = 7; } break; // FLECHA ABAJO case 5: if (swap) MoveDownP(); else { CurrRowPD++; if (CurrRowPD == 8) CurrRowPD = 1; } break; // ReP g case 6: if(swap){ CurrRowP = 1; if(CurrTopLineP >= 20 ) { CurrTopLineP -= 19; } else { CurrTopLineP = 1; } if(CurrTopLineP < JD_dp.n_records ) { CurrTopLineP = 1; } PrintWholeScreenP(); GetLineP(); } break; // AvP g case 7: if(swap){ CurrRowP = 1; CurrTopLineP = CurrTopLineP + 19; if (CurrTopLineP >= JD_dp.n_records) CurrTopLineP = JD_dp.n_records; PrintWholeScreenP(); GetLineP(); } break; // F2 --> PARA SALIR case 8: finished = 1; break; // F8 --> Imprimir case 9: Print_in_Printer(); GetLineP(); break; // F7 --> Reinicializar marcas case 10: borrar_todo = 1; finished = 1; break; // BOTON VACIO case 11: break; default: if (sb) Sound_SN("catalog3"); break; } // Fin de Swicth } // fin de check buttons } // fin ¨ pulsa boton izq. || drch ? ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// }while( !finished ); fclose(JD_p); // Fichero Pedidos if(borrar_todo) remove(ArchivoPedidos); BorraViewPort(1); BorraViewPort(2); BorraViewPort(3); } // End Function // void EditCursorP(int ShowHide) { int cc, cf, lmax, i, py, pxx, Px; // registro de color actual y de fondo // Longitud M xima y contador de bucle // desviaci¢n vertical y reajuste final // desviaci¢n horizontal y "" "" if( CurrRowP >= 11 ){ Px = CurrColP + 3; py = 18 + (CurrRowP) - 10; } else { Px = CurrColP; py = 18 + (CurrRowP); } switch (Px) { case 1: pxx = 28; lmax = 13; break; case 2: pxx = 42; lmax = 3; break; case 3: pxx = 46; lmax = 5; break; case 4: pxx = 52; lmax = 13; break; case 5: pxx = 66; lmax = 3; break; case 6: pxx = 70; lmax = 5; break; default: pxx = 1; lmax = 80; break; } if (!ShowHide) { cc = 63; cf = 57; } else { cc = 14; cf = 0; } setcolor(cf); // pone color de fondo '0' para borrar for (i=0; i= 11 ){ Px = CurrColP + 3; py = 18 + (CurrRowP) - 10; } else { Px = CurrColP; py = 18 + (CurrRowP); } switch (Px) { case 1: pxx = 28; lmax = 13; break; case 2: pxx = 42; lmax = 3; break; case 3: pxx = 46; lmax = 5; break; case 4: pxx = 52; lmax = 13; break; case 5: pxx = 66; lmax = 3; break; case 6: pxx = 70; lmax = 5; break; default: pxx = 1; lmax = 80; break; } switch (Px) { case 1: case 4: InputCadenaG( JD_dt.nombre, 0, lmax, pxx, py, 63, 57); break; case 2: case 5: InputCadenaG( JD_dt.zip, 0, lmax, pxx, py, 63, 57); break; case 3: case 6: char cadena[] = "32766"; itoa( (JD_dt.kbytes), cadena, 10 ); do{ if ( atoi(cadena) < 0 || atoi(cadena) > 32765 ) strcpy(cadena, "0"); InputCadenaG( cadena, 1, lmax, pxx, py, 63, 57); }while( atoi(cadena) < 0 || atoi(cadena) > 32765); JD_dt.kbytes = atoi(cadena); break; } PutLineP(); GetLineP(); if ( CurrRowP >= 11 ) PrintLineP(0); else PrintLineP(1); } void EditItemPD(void) { int lmax, pxx, py, Px; int LSCm = sizeof(struct pedidos_descripcion); char string[15]; switch (CurrRowPD) { case 1: InputCadenaG( JD_dp.nombre, 0, 24, 50, 4, 63, 57); break; case 2: InputCadenaG( JD_dp.apelli, 0, 21, 53, 5, 63, 57); break; case 3: InputCadenaG( JD_dp.direcc, 0, 21, 53, 6, 63, 57); break; case 4: ltoa(JD_dp. telefono, string, 10); InputCadenaG( string, 1, 9, 52, 7, 63, 57); JD_dp. telefono = atol(string); break; case 5: InputCadenaG( JD_dp.cpu, 0, 10, 47, 8, 63, 57); break; case 6: itoa(JD_dp. ram, string, 10); InputCadenaG( string, 1, 2, 63, 8, 63, 57); JD_dp. ram = atoi(string); break; case 7: itoa(JD_dp. hd, string, 10); InputCadenaG( string, 1, 4, 70, 8, 63, 57); JD_dp. hd = atoi(string); break; default: outtextxy( ( 1 ) * 8 - 7, 2 * 16 - 16, "ERROR Modulo SHOW_HIDE-Cursor, secci¢n CADDVIEW, P_CATALOGO"); break; } rewind(JD_p); fwrite(&JD_dp, LSCm, 1, JD_p); } void MoveUpP(void) { if(CurrRowP==1) { if(sb) Sound_SN("catalog3"); } else { CurrRowP--; GetLineP(); if ( CurrRowP >= 11 ) PrintLineP(0); else PrintLineP(1); } } void MoveDownP(void) { if( (CurrRowP + CurrTopLineP - 1) >= (JD_dp. n_records) || CurrRowP == 20 ) { if (sb) Sound_SN("catalog3"); } else { CurrRowP++; GetLineP(); if ( CurrRowP >= 11 ) PrintLineP(0); else PrintLineP(1); } } void PrintLineP( int permiso ) { unsigned int CurrRecord = CurrTopLineP + CurrRowP - 1; int py, i; if ( CurrRowP >= 11 ) { py = 18 + (CurrRowP) - 10; } else { py = 18 + (CurrRowP); } setcolor(14); // devuelve el color a su estado if ( CurrRecord <= (JD_dp.n_records) ) { // | Me preparo para convertir char kbytes[6]; // | los int a char // para que puedan ser utilizados // itoa( JD_dt.kbytes, kbytes, 10); // por outtext y outtextxy... sprintf(kbytes, "%5d", JD_dt.kbytes); switch(permiso) { case 0: outtextxy( ( 52 ) * 8 - 7, py * 16 - 16, JD_dt.nombre); outtextxy( ( 66 ) * 8 - 7, py * 16 - 16, JD_dt.zip); outtextxy( ( 70 ) * 8 - 7, py * 16 - 16, kbytes); break; case 1: outtextxy( ( 28 ) * 8 - 7, py * 16 - 16, JD_dt.nombre); outtextxy( ( 42 ) * 8 - 7, py * 16 - 16, JD_dt.zip); outtextxy( ( 46 ) * 8 - 7, py * 16 - 16, kbytes); break; default: outtextxy( ( 1 ) * 8 - 7, py * 16 - 16, "ERROR Modulo PrintLine, secci¢n CADDVIEW, P_CATALOGO _-JD-_"); break; } } } void DeleteRecordP(void) { unsigned int CurrRecord; int LSC = sizeof(struct pedidos_datos); int LSCm = sizeof(struct pedidos_descripcion); if (JD_dp. n_records == 1) { if (sb) Sound_SN("catalog5"); } else { CurrRecord = CurrTopLineP + CurrRowP - 1; JD_dp. n_records --; unsigned int p = CurrRecord; while(p <= JD_dp. n_records) { fseek(JD_p, (long)LSCm + ( LSC * ( p + 1 ) - LSC ), SEEK_SET); // Se coloca fread(&JD_dt, LSC, 1, JD_p); // Y lee fseek(JD_p, (long)LSCm + ( LSC * p - LSC ), SEEK_SET); // Se coloca fwrite(&JD_dt, LSC, 1, JD_p); // Y escribe p++; }; rewind(JD_p); fwrite(&JD_dp, LSCm, 1, JD_p); // Acualiza n§ de registros int TmpRow = CurrRowP; int TmpCol = CurrColP; PrintWholeScreenP(); CurrRowP = TmpRow; CurrColP = TmpCol; if ( (CurrRecord = CurrTopLineP + CurrRowP - 1) > JD_dp. n_records ) MoveUpP(); GetLineP(); if ( CurrRowP >= 11 ) PrintLineP(0); else PrintLineP(1); } } void AddRecordP(void){ unsigned int CurrRecord= CurrTopLineP + CurrRowP - 1; if(CurrRecord < 160) { int LSC = sizeof(struct pedidos_datos); int LSCm = sizeof(struct pedidos_descripcion); unsigned int avance = JD_dp. n_records; while(avance > CurrRecord) { fseek(JD_p, (long)LSCm + ( LSC * avance - LSC ), SEEK_SET); // Se coloca fread(&JD_dt, LSC, 1, JD_p); // Y lee fseek(JD_p, (long)LSCm + ( LSC * (avance + 1) - LSC ), SEEK_SET); // Se coloca fwrite(&JD_dt, LSC, 1, JD_p); // Y escribe avance--; }; JD_dp. n_records ++; rewind(JD_p); fwrite(&JD_dp, LSCm, 1, JD_p); // Acualiza n§ de registros JD_dt.record_zone = 0; JD_dt.record_name = 0; strcpy(JD_dt.nombre, "\0"); strcpy(JD_dt.zip, "\0"); JD_dt.kbytes = 0; fseek(JD_p, (long)LSCm + ( LSC * ( CurrTopLineP + CurrRowP ) - LSC ), SEEK_SET); // Se coloca fwrite(&JD_dt, LSC, 1, JD_p); // Y escribe PrintWholeScreenP(); if ( (CurrRecord = CurrTopLineP + CurrRowP - 1) > JD_dp. n_records ) MoveUpP(); GetLineP(); if ( CurrRowP >= 11 ) PrintLineP(0); else PrintLineP(1); } } void PrintWholeScreenP(void){ int tmp = CurrRowP; BorraViewPort(3); for(CurrRowP = 1; CurrRowP < 21; CurrRowP++) { if ( ( CurrTopLineP + CurrRowP - 1 ) <= JD_dp. n_records ) { GetLineP(); if ( CurrRowP >= 11 ) PrintLineP(0); else PrintLineP(1); } } CurrRowP = tmp; } void PutLineP(void){ unsigned int CurrRecord = CurrTopLineP + CurrRowP - 1; int LSC = sizeof(struct pedidos_datos); int LSCm = sizeof(struct pedidos_descripcion); fseek(JD_p, (long)LSCm + ( LSC * CurrRecord - LSC ), SEEK_SET); // Se coloca fwrite(&JD_dt, LSC, 1, JD_p); // Y escribe } void GetLineP(void){ unsigned int CurrRecord = CurrTopLineP + CurrRowP - 1; int LSC = sizeof(struct pedidos_datos); int LSCm = sizeof(struct pedidos_descripcion); fseek(JD_p, (long)LSCm + ( LSC * CurrRecord - LSC ), SEEK_SET); // Se coloca fread(&JD_dt, LSC, 1, JD_p); // Y lee } void CreaPresentacion(void){ BorraViewPort(2); // Para los mensajes... setcolor(12); outtextxy( 42 * 8 - 7, 4 * 16 - 16, "Nombre:" ); outtextxy( 42 * 8 - 7, 5 * 16 - 16, "Apellidos:" ); outtextxy( 42 * 8 - 7, 6 * 16 - 16, "Direcci¢n:" ); outtextxy( 42 * 8 - 7, 7 * 16 - 16, "Tel‚fono:" ); outtextxy( 42 * 8 - 7, 8 * 16 - 16, "CPU:" ); outtextxy( 58 * 8 - 7, 8 * 16 - 16, "RAM:" ); outtextxy( 66 * 8 - 7, 8 * 16 - 16, "HD:" ); setcolor( 4); // Sistema utilizado para sombra == -1 outtextxy( 328, 47 , "Nombre:" ); outtextxy( 328, 63 , "Apellidos:" ); outtextxy( 328, 79 , "Direcci¢n:" ); outtextxy( 328, 95 , "Tel‚fono:" ); outtextxy( 328, 111 , "CPU:" ); outtextxy( 456, 111 , "RAM:" ); outtextxy( 520, 111 , "HD:" ); } void Print_in_Printer(void){ unsigned int cont = 0; int columna = 1, linea = 9; int LSC = sizeof(struct pedidos_datos); int LSCm = sizeof(struct pedidos_descripcion); // char buffer[28]; ////////////////////////////////////////////////////////////////////////////// // Mensaje es la funci¢n que espero incorporar no muy tarde, para mostrar // // los mensajes, recibiendo como parametros ( 0 espera una tecla ) // // ( 1 espera 'S' o 'N' ) // // // // En el par metro 0, devolvera 1 si se pulsa ESC // // En el caso del parametro 1, devolvera 1's , 2'n [...] // // // ////////////////////////////////////////////////////////////////////////////// // if( !Mensaje("Prepare la impresora y pulse una tecla", 0) ) { // ////////////////////////////////////////////////////////////////////////////// fprintf(stdprn, "\n\r" ); if (ferror(stdprn)) { clearerr(stdprn); // Mensaje("Error en el dispositivo PRN", 0) return; } fprintf(stdprn, "Nombre: %s. \n\r", JD_dp. nombre ); fprintf(stdprn, "Apellidos: %s. \n\r", JD_dp. apelli ); fprintf(stdprn, "Direcci¢n: %s. \n\r", JD_dp. direcc ); fprintf(stdprn, "Tel‚fono: %ld. \n\r", JD_dp. telefono ); fprintf(stdprn, "C.P.U.: %-10s ", JD_dp. cpu ); fprintf(stdprn, "R.A.M.: %2.d ", JD_dp. ram ); fprintf(stdprn, "HD: %4d. \n\r\n\r\n\r", JD_dp. hd ); fseek(JD_p, (long)LSCm, SEEK_SET); while( cont < JD_dp. n_records ) { fread(&JD_dt, LSC, 1, JD_p); fprintf(stdprn, "%-13s %-3s %4d ³ ", (JD_dt. nombre), (JD_dt. zip), (JD_dt. kbytes) ); columna ++; if(columna==4) { fprintf(stdprn, "\n\r"); if (ferror(stdprn)) { clearerr(stdprn); // Mensaje("Error en el dispositivo PRN", 0) return; } columna=1; linea ++; if(linea==60) { fputc(12, stdprn); // Va al principio de // la p gina siguiente if (ferror(stdprn)) { clearerr(stdprn); // Mensaje("Error en el dispositivo PRN", 0) return; } // Mensaje("Inserte un nuevo folio", 0); linea = 1; } } cont++; } fputc(12, stdprn); // } // Fin Comprueba Mensaje }