Pascal/Turbo Pascal - No se terminar ejercicio Pascal

 
Vista:

No se terminar ejercicio Pascal

Publicado por PepitoPerez (1 intervención) el 06/12/2013 12:32:19
Hola! Tengo que hacer un ejercicio en Pascal que cumpla esto:
-Dar alta artículo: Esta opción permite dar de alta a un nuevo artículo, como la compañía es pequeña el número máximo de artículos de que dispone es de 100. Para ello, si existe sitio en el almacén, el sistema n os preguntará por el código de artículo y el resto de datos que forman el registro de artículos. Si ya existe un artículo con ese código, no se podrá dar de alta.
-Dar de baja un artículo. Se introducirá el código de artículo y se eliminará.
-Modificar un artículo. Pedirá el código de artículo y mostrará los campos, para elegir el que se desee modificar (Nombre, características, precio o cantidad), solo un cambio por operación.
-Listado de artículos. Se devolverá por pantalla un listado de artículos, mostrando el código, el nombre, las características, el precio y la cantidad (Lo más parecido a una tabla)
Realizar Venta: Esta funcionalidad solicita el código de artículo a vender (sólo uno por venta) y la cantidad; el sistema buscará el precio del artículo en el array de artículos, calculará el coste de la venta (precio más el 10% de beneficio) y la almacenará en el array de ventas. Debido al tamaño de la ferretería solo se pueden realizar 200 ventas diarias
como máximo.

En el ejercicio venían muchos otros datos, con los que he comenzado el programa, pero a partir de ahí no se seguir. Espero que me ayuden con lo que puedan
AQUÍ DEJO LO QUE HICE!

PD: Hay que hacerlo con subprogramas. Muchas gracias!!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
program prog;
CONST
NCNOMBRE = 15; {número caracteres nombre}
NCARTICULO =4; {número caracteres del código del artículo}
NCCARACTERISTICA = 50; {número caracteres de la característica}
MAXARTICULOS=100; {número de artículos máximo de la ferretería}
MAXVENTAS = 200; {número de ventas máximas diarias de la ferretería}
BENEFICIO = 0.1; {beneficio de cada venta}
 
TYPE
TFecha= string[8]; {Tipo para almacenar la fecha dd/mm/aa}
TNombre= string[NCNOMBRE]; {Tipo para almacenar el nombre}
TCodart = string[NCARTICULO]; {Tipo para almacenar el código}
TCaracteristicas= string[NCCARACTERISTICA];
TNumArticulos=1..MAXARTICULOS; {tipo para almacenar el número de artículos}
TNumVentas = 1..MAXVENTAS; {tipo para almacenar el número de ventas diarias}
 
TArticulo= RECORD
codart: TCodart; {código de artículo}
nombre: TNombre; {nombre artículo}
caracteristicas: TCaracteristicas; {características}
precio:real; {precio del artículo}
cantidad:integer;{cantidad de artículos en stock}
END;{Registro deArtículos}
 
TArticulos=ARRAY [TNumArticulos] OF TArticulo; {array que contiene los artículos de laFerretería}
 
TTodoFerreteria= RECORD
articulos: TArticulos;
numarticulos:integer;
END; {Representa a los artículos dela ferretería}
 
TVenta= RECORD
codart: TCodart; {código de artículo}
precioart:real; {precio del articulo vendido}
cantidad:integer; {cantidad de artículos vendidos}
pvp: real; {precio de venta de un articulo al público}
costeTotal:real; {Coste de la venta realizada (pvp*cantidad)}
END; {Registro de venta de un artículo}
 
TVentas=ARRAY [TNumVentas] OF TVenta; {array que contiene las ventas diarias de la ferretería}
TVentaTot= RECORD
ventas: TVentas;
numVentas: integer;
END; {Representa a las ventas totales deldía}
TFicheroVentas=
FILE OF TVenta;
TFicheroArticulos= FILE OF TArticulo;
 
 
 
begin
 
 
end.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

No se terminar ejercicio Pascal

Publicado por ramon (2158 intervenciones) el 06/12/2013 21:04:57
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
{A ver si esto ayuda}
 
 program prog;
 uses
    crt;
 
   CONST
       NCNOMBRE = 15; {número caracteres nombre}
       NCARTICULO = 4; {número caracteres del código del artículo}
       NCCARACTERISTICA = 50; {número caracteres de la característica}
       MAXARTICULOS = 100; {número de artículos máximo de la ferretería}
       MAXVENTAS = 200; {número de ventas máximas diarias de la ferretería}
       BENEFICIO = 0.1; {beneficio de cada venta}
 
   TYPE
    TFecha = string[8]; {Tipo para almacenar la fecha dd/mm/aa}
    TNombre = string[NCNOMBRE]; {Tipo para almacenar el nombre}
    TCodart = string[NCARTICULO]; {Tipo para almacenar el código}
    TCaracteristicas = string[NCCARACTERISTICA];
    TNumArticulos = 1..MAXARTICULOS; {tipo para almacenar el número de
                                                           artículos}
    TNumVentas = 1..MAXVENTAS; {tipo para almacenar el número de ventas
                                                             diarias}
 
   TArticulo = RECORD
          codart : TCodart; {código de artículo}
          nombre : TNombre; {nombre artículo}
 caracteristicas : TCaracteristicas; {características}
          precio : real; {precio del artículo}
        cantidad : integer;{cantidad de artículos en stock}
          END;{Registro deArtículos}
 
    TArticulos = ARRAY[TNumArticulos] OF TArticulo; {array que contiene
                                          los artículos de laFerretería}
 
      TTodoFerreteria = RECORD
             articulos : TArticulos;
          numarticulos : integer;
                   END; {Representa a los artículos dela ferretería}
 
           TVenta = RECORD
               codart : TCodart; {código de artículo}
            precioart : real; {precio del articulo vendido}
             cantidad : integer; {cantidad de artículos vendidos}
                  pvp : real; {precio de venta de un articulo al público}
           costeTotal : real; {Coste de la venta realizada (pvp*cantidad)}
                 END; {Registro de venta de un artículo}
 
      TVentas = ARRAY[TNumVentas] OF TVenta; {array que contiene las ventas
                                                diarias de la ferretería}
 
        TVentaTot = RECORD
               ventas : TVentas;
            numVentas : integer;
                  END; {Representa a las ventas totales deldía}
 
       TFicheroVentas = FILE OF TVenta;
       TFicheroArticulos = FILE OF TArticulo;
 
  var
    artic : TArticulos;
    venta : TVentas;
     fart : TFicheroArticulos;
     fven : TFicheroVentas;
     numarti : integer;
     salir : boolean;
     tecla : char;
 
 
 
 
   procedure guardararticulo(gu : TArticulo);
   begin
       assign(fart,'articulo.dat');
    {$I-} reset(fart); {$I+}
    if ioresult <> 0 then
    begin
       rewrite(fart);
       seek(fart,0);
       write(fart,gu);
       close(fart);
    end
  else
      begin
          seek(fart,filesize(fart));
          write(fart,gu);
          close(fart);
      end;
   end;
 
   function abrearchiboarticulos : boolean;
   begin
      assign(fart,'articulo.dat');
    {$I-} reset(fart); {$I+}
    if ioresult <> 0 then
    abrearchiboarticulos := false
  else
    abrearchiboarticulos := true;
   end;
 
 
   function existecodigo(co : TCodart) : boolean;
   var
     co1 : longint;
     esta : boolean;
     toma : TArticulo;
   begin
       if abrearchiboarticulos = true then
       begin
          esta := false;
          for co1 := 0 to filesize(fart) - 1 do
          begin
          seek(fart,co1);
          read(fart,toma);
          if toma.codart = co then
          esta := true;
          end;
          existecodigo := esta;
          close(fart);
       end
    else
       begin
         writeln('  Error De Archivo Pulse Una Tecla ');
         readkey;
       end;
   end;
 
   procedure bajadeunarticulo;
   var
     rr, cv : longint;
     codi : TCodart;
     tom : TArticulo;
     quita : TFicheroArticulos;
   begin
       clrscr;
       write('  Entre Codigo A Anular : ');
       readln(codi);
       if existecodigo(codi) = true then
       begin
          if abrearchiboarticulos = true then
          begin
             rr := 0;
             assign(quita,'temporal.ten');
             rewrite(quita);
             for cv := 0 to filesize(fart) - 1 do
             begin
                seek(fart,cv);
                read(fart,tom);
                if tom.codart <> codi then
                begin
                   seek(quita,rr);
                   write(quita,tom);
                   rr := rr + 1;
                end;
             end;
          end;
            close(fart);
            close(quita);
            erase(fart);
            rename(quita,'articulo.dat');
       end;
     end;
 
   procedure Daraltaarticulo(n : integer);
   begin
       write('  Entre Codigo           : ');
       readln(artic[n].codart);
       if n > 1 then
       begin
       if existecodigo(artic[n].codart) = false then
       begin
          write('  Entre Nombre          : ');
          readln(artic[n].nombre);
          write('  Entre Caracteristicas : ');
          readln(artic[n].caracteristicas);
          write('  Entre Precio          : ');
          readln(artic[n].precio);
          write('  Entre Cantidad        : ');
          readln(artic[n].cantidad);
          guardararticulo(artic[n]);
       end
     else
        begin
           writeln('  El Codigo Entrado Ya Existe Pulse Una Tecla ');
           readkey;
        end;
      end
    else
       begin
          write('  Entre Nombre          : ');
          readln(artic[n].nombre);
          write('  Entre Caracteristicas : ');
          readln(artic[n].caracteristicas);
          write('  Entre Precio          : ');
          readln(artic[n].precio);
          write('  Entre Cantidad        : ');
          readln(artic[n].cantidad);
          guardararticulo(artic[n]);
       end;
   end;
 
  procedure visualizaarticulos;
  var
    tomado : TArticulo;
    cont : longint;
    yy : integer;
  begin
      if abrearchiboarticulos = true then
      begin
         cont := 0;
         yy := 1;
       repeat
       seek(fart,cont);
       read(fart,tomado);
       with tomado do
       begin
       writeln(codart,'   ',nombre,'   ',caracteristicas,'   ',precio:0:2,
       '   ',cantidad);
       end;
       yy := yy + 1;
       if yy > 22 then
       begin
          yy := 1;
          writeln('  Pulse Una Tecla Para Segir ');
          readkey;
          clrscr;
       end;
       cont := cont + 1;
       until cont > filesize(fart) - 1;
       close(fart);
       writeln('  Pulse Una Tecla Para Segir ');
       readkey;
      end
   else
      begin
        writeln('   Error De Archivo Pulse Una Tecla ');
        readkey;
      end;
  end;
 
 
  procedure menu;
  var
    pul : char;
    fin : boolean;
  begin
      fin := false;
    repeat
       clrscr;
       writeln('***** Menu Jeneral *****');
       writeln;
       writeln('  [A] = Altas Y Nueva Entrada');
       writeln('  [B] = Baja De Ficha');
       writeln('  [V] = Visualizar Fichas');
       writeln('  [S] = Salir');
       writeln;
       writeln('<<<<< Elija Opcion >>>>>>');
       repeat
          pul := upcase(readkey);
       until pul in['A','B','V','S'];
       clrscr;
    case pul of
 'A' : begin
         salir := false;
      repeat
         Daraltaarticulo(numarti);
         writeln('  Desea Entrar Mas Datos [S/N]');
        repeat
           tecla := upcase(readkey);
        until tecla in['S','N'];
        if tecla = 'N' then
         salir := true
      else
         begin
          clrscr;
           numarti := numarti + 1;
           if numarti > 100 then
           begin
             writeln('   Almacen Lleno Pulse Una Tecla ');
             readkey;
             salir := true;
           end;
        end;
         until salir = true;
       end;
 'B' : begin
         bajadeunarticulo;
       end;
 'V' : begin
         visualizaarticulos;
       end;
 'S' : fin := true;
    end;
    until fin = true;
  end;
 
 
begin
    clrscr;
    numarti := 1;
    menu;
end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

No se terminar ejercicio Pascal

Publicado por PepitoPerez (1 intervención) el 07/12/2013 13:34:04
Hola! Muchas gracias, funciona perfecto, también si me pudieses ayudar con los otros dos apartados que quedan por añadir al menú... Te lo agradecería mucho, aquí te los pongo para que no vuelvas a buscar, no se hacerlos :/
-Modificar un artículo. Pedirá el código de artículo y mostrará los campos, para elegir el que se desee modificar (Nombre, características, precio o cantidad), solo un cambio por operación.
-Realizar Venta: Esta funcionalidad solicita el código de artículo a vender (sólo uno por venta) y la cantidad; el sistema buscará el precio del artículo en el array de artículos, calculará el coste de la venta (precio más el 10% de beneficio) y la almacenará en el array de ventas. Debido al tamaño de la ferretería solo se pueden realizar 200 ventas diarias
como máximo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

No se terminar ejercicio Pascal

Publicado por ramon (2158 intervenciones) el 08/12/2013 23:59:19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
{A qui tienes todo y algo mas }
 
 program prog;
 uses
    crt;
 
   CONST
       NCNOMBRE = 15; {número caracteres nombre}
       NCARTICULO = 4; {número caracteres del código del artículo}
       NCCARACTERISTICA = 50; {número caracteres de la característica}
       MAXARTICULOS = 100; {número de artículos máximo de la ferretería}
       MAXVENTAS = 200; {número de ventas máximas diarias de la ferretería}
       BENEFICIO = 0.1; {beneficio de cada venta}
 
   TYPE
    TFecha = string[8]; {Tipo para almacenar la fecha dd/mm/aa}
    TNombre = string[NCNOMBRE]; {Tipo para almacenar el nombre}
    TCodart = string[NCARTICULO]; {Tipo para almacenar el código}
    TCaracteristicas = string[NCCARACTERISTICA];
    TNumArticulos = 1..MAXARTICULOS; {tipo para almacenar el número de
                                                           artículos}
    TNumVentas = 1..MAXVENTAS; {tipo para almacenar el número de ventas
                                                             diarias}
 
   TArticulo = RECORD
          codart : TCodart; {código de artículo}
          nombre : TNombre; {nombre artículo}
 caracteristicas : TCaracteristicas; {características}
          precio : real; {precio del artículo}
        cantidad : integer;{cantidad de artículos en stock}
          END;{Registro deArtículos}
 
    TArticulos = ARRAY[TNumArticulos] OF TArticulo; {array que contiene
                                          los artículos de laFerretería}
 
      TTodoFerreteria = RECORD
             articulos : TArticulos;
          numarticulos : integer;
                   END; {Representa a los artículos dela ferretería}
 
           TVenta = RECORD
               codart : TCodart; {código de artículo}
            precioart : real; {precio del articulo vendido}
             cantidad : integer; {cantidad de artículos vendidos}
                  pvp : real; {precio de venta de un articulo al público}
           costeTotal : real; {Coste de la venta realizada (pvp*cantidad)}
                 END; {Registro de venta de un artículo}
 
      TVentas = ARRAY[TNumVentas] OF TVenta; {array que contiene las ventas
                                                diarias de la ferretería}
 
        TVentaTot = RECORD
               ventas : TVentas;
            numVentas : integer;
                  END; {Representa a las ventas totales deldía}
 
       TFicheroVentas = FILE OF TVenta;
       TFicheroArticulos = FILE OF TArticulo;
 
  var
    artic : TArticulos;
    venta : TVentas;
     fart : TFicheroArticulos;
     fven : TFicheroVentas;
     nuvet, numarti : integer;
     salir : boolean;
     tecla : char;
 
 
 
   procedure guardaventa(ve : TVenta);
   begin
      assign(fven,'ventas.dat');
      {$I-} reset(fven); {$I+}
      if ioresult <> 0 then
       begin
          rewrite(fven);
          seek(fven,0);
          write(fven,ve);
          close(fven);
      end
  else
      begin
          seek(fven,filesize(fven));
          write(fven,ve);
          close(fven);
      end;
   end;
 
   function abrearchiboventas : boolean;
   begin
      assign(fven,'ventas.dat');
    {$I-} reset(fven); {$I+}
    if ioresult <> 0 then
    abrearchiboventas := false
  else
    abrearchiboventas := true;
   end;
 
   procedure muestraventas;
   var
     vt : longint;
     vtas : TVenta;
     tty : integer;
    begin
       if abrearchiboventas = true then
       begin
         clrscr;
         tty := 1;
         writeln('Codigo   Precio   Cantidad   PvP         Total');
         for vt := 0 to filesize(fven) - 1 do
         begin
            seek(fven,vt);
            read(fven,vtas);
            writeln(vtas.codart,'        ',vtas.precioart:0:2,'      ',
            vtas.cantidad,'       ',vtas.pvp:0:2,'      ',vtas.costeTotal:0:2);
            tty := tty + 1;
            if tty > 22 then
            begin
                tty := 1;
                writeln;
                writeln('  Pulse Una Tecla Para Segir ');
                readkey;
                clrscr;
                writeln('Codigo   Precio   Cantidad   PvP         Total');
            end;
         end;
         close(fven);
         writeln;
         writeln('  Fin De Presentacion Pulse Una Tecla ');
         readkey;
       end;
    end;
 
 
   procedure guardararticulo(gu : TArticulo);
   begin
       assign(fart,'articulo.dat');
    {$I-} reset(fart); {$I+}
    if ioresult <> 0 then
    begin
       rewrite(fart);
       seek(fart,0);
       write(fart,gu);
       close(fart);
    end
  else
      begin
          seek(fart,filesize(fart));
          write(fart,gu);
          close(fart);
      end;
   end;
 
   function abrearchiboarticulos : boolean;
   begin
      assign(fart,'articulo.dat');
    {$I-} reset(fart); {$I+}
    if ioresult <> 0 then
    abrearchiboarticulos := false
  else
    abrearchiboarticulos := true;
   end;
 
 
   function existecodigo(co : TCodart) : boolean;
   var
     co1 : longint;
     esta : boolean;
     toma : TArticulo;
   begin
       if abrearchiboarticulos = true then
       begin
          esta := false;
          for co1 := 0 to filesize(fart) - 1 do
          begin
          seek(fart,co1);
          read(fart,toma);
          if toma.codart = co then
          esta := true;
          end;
          existecodigo := esta;
          close(fart);
       end
    else
       begin
         writeln('  Error De Archivo Pulse Una Tecla ');
         readkey;
       end;
   end;
 
   procedure bajadeunarticulo;
   var
     rr, cv : longint;
     codi : TCodart;
     tom : TArticulo;
     quita : TFicheroArticulos;
   begin
       clrscr;
       write('  Entre Codigo A Anular : ');
       readln(codi);
       if existecodigo(codi) = true then
       begin
          if abrearchiboarticulos = true then
          begin
             rr := 0;
             assign(quita,'temporal.ten');
             rewrite(quita);
             for cv := 0 to filesize(fart) - 1 do
             begin
                seek(fart,cv);
                read(fart,tom);
                if tom.codart <> codi then
                begin
                   seek(quita,rr);
                   write(quita,tom);
                   rr := rr + 1;
                end;
             end;
          end;
            close(fart);
            close(quita);
            erase(fart);
            rename(quita,'articulo.dat');
       end;
     end;
 
   procedure Daraltaarticulo(n : integer);
   begin
       write('  Entre Codigo           : ');
       readln(artic[n].codart);
       if n > 1 then
       begin
       if existecodigo(artic[n].codart) = false then
       begin
          write('  Entre Nombre          : ');
          readln(artic[n].nombre);
          write('  Entre Caracteristicas : ');
          readln(artic[n].caracteristicas);
          write('  Entre Precio          : ');
          readln(artic[n].precio);
          write('  Entre Cantidad        : ');
          readln(artic[n].cantidad);
          guardararticulo(artic[n]);
       end
     else
        begin
           writeln('  El Codigo Entrado Ya Existe Pulse Una Tecla ');
           readkey;
        end;
      end
    else
       begin
          write('  Entre Nombre          : ');
          readln(artic[n].nombre);
          write('  Entre Caracteristicas : ');
          readln(artic[n].caracteristicas);
          write('  Entre Precio          : ');
          readln(artic[n].precio);
          write('  Entre Cantidad        : ');
          readln(artic[n].cantidad);
          guardararticulo(artic[n]);
       end;
   end;
 
  procedure visualizaarticulos;
  var
    tomado : TArticulo;
    cont : longint;
    yy : integer;
  begin
      if abrearchiboarticulos = true then
      begin
         cont := 0;
         yy := 1;
       repeat
       seek(fart,cont);
       read(fart,tomado);
       with tomado do
       begin
       writeln(codart,'   ',nombre,'   ',caracteristicas,'   ',precio:0:2,
       '   ',cantidad);
       end;
       yy := yy + 1;
       if yy > 22 then
       begin
          yy := 1;
          writeln('  Pulse Una Tecla Para Segir ');
          readkey;
          clrscr;
       end;
       cont := cont + 1;
       until cont > filesize(fart) - 1;
       close(fart);
       writeln('  Pulse Una Tecla Para Segir ');
       readkey;
      end
   else
      begin
        writeln('   Error De Archivo Pulse Una Tecla ');
        readkey;
      end;
  end;
 
  procedure modificadatos;
  var
    tt : char;
    codi : TCodart;
    cc, bus : longint;
    tomado : TArticulo;
    nad, est : boolean;
  begin
     clrscr;
     writeln('***** Modificacion De Datos *****');
     writeln;
     write('  Entre Cidigo : ');
     readln(codi);
     if abrearchiboarticulos = true then
     begin
        est := false;
        nad := false;
       for bus := 0 to filesize(fart) - 1 do
       begin
          seek(fart,bus);
          read(fart,tomado);
          if tomado.codart = codi then
          begin
             est := true;
             cc := bus;
             break;
          end;
       end;
       if est = true then
       begin
          gotoxy(3,1);write(' 1 = Nombre         2 = Caracteristicas');
          gotoxy(3,3);write(' 3 = Precio         4 = Cantidad');
          gotoxy(3,5);write(' 5 = Nada');
          gotoxy(3,7);write('  Elija Opcion ');
          repeat
              tt := readkey;
          until tt in['1','2','3','4','5'];
      case tt of
  '1' : begin
          gotoxy(8,2);readln(tomado.nombre);
        end;
  '2' : begin
          gotoxy(27,2);readln(tomado.caracteristicas);
        end;
  '3' : begin
          gotoxy(8,4);readln(tomado.precio);
        end;
  '4' : begin
          gotoxy(27,4);readln(tomado.cantidad);
        end;
  '5' : nad := true;
    end;
       if nad = false then
       begin
          seek(fart,cc);
          write(fart,tomado);
       end;
         close(fart);
      end
     else
        begin
          writeln(' Error Codigo No Existe Pulse Una Tecla ');
          readkey;
        end;
      end
    else
       begin
         writeln(' Error De Archivo Pulse Una Tecla ');
         readkey;
       end;
  end;
 
  procedure RealizarVenta;
  var
    codi : TCodart;
    canti : integer;
    preci, total : real;
    cc, bus : longint;
    tomado : TArticulo;
    nad, est : boolean;
    begin
       clrscr;
       writeln('*** Entradas Ventas ***');
       writeln;
       write('  Entre Codigo : ');
       readln(codi);
       if abrearchiboarticulos = true then
       begin
          for bus := 0 to filesize(fart) - 1 do
          begin
             seek(fart,bus);
             read(fart,tomado);
             if tomado.codart = codi then
             begin
               est := true;
               cc := bus;
               break;
             end;
          end;
          if est = true then
          begin
             venta[nuvet].codart := codi;
             preci := tomado.precio;
             venta[nuvet].precioart := preci;
             writeln;
             write('  Entre Cantidad : ');
             readln(canti);
             venta[nuvet].cantidad := canti;
             venta[nuvet].pvp := preci + (preci * 10) / 100;
             venta[nuvet].costeTotal := canti * venta[nuvet].pvp;
             guardaventa(venta[nuvet]);
             nuvet := nuvet + 1;
          end
        else
          begin
             writeln(' Error Codigo No Existe Pulse Una Tecla ');
             readkey;
          end;
          close(fart);
       end
    else
      begin
         writeln(' Error De Archivo Pulse Una Tecla ');
         readkey;
      end;
    end;
 
 
  procedure menu;
  var
    pul : char;
    fin : boolean;
  begin
      fin := false;
    repeat
       clrscr;
       writeln('***** Menu Jeneral *****');
       writeln;
       writeln('  [A] = Altas Y Nueva Entrada');
       writeln('  [B] = Baja De Ficha');
       writeln('  [V] = Visualizar Fichas');
       writeln('  [M] = Modificar Articulo');
       writeln('  [R] = Realizacion Ventas');
       writeln('  [T] = Visualiza Ventas');
       writeln('  [S] = Salir');
       writeln;
       writeln('<<<<< Elija Opcion >>>>>>');
       repeat
          pul := upcase(readkey);
       until pul in['A','B','V','M','R','T','S'];
       clrscr;
    case pul of
 'A' : begin
         salir := false;
      repeat
         Daraltaarticulo(numarti);
         writeln('  Desea Entrar Mas Datos [S/N]');
        repeat
           tecla := upcase(readkey);
        until tecla in['S','N'];
        if tecla = 'N' then
         salir := true
      else
         begin
          clrscr;
           numarti := numarti + 1;
           if numarti > 100 then
           begin
             writeln('   Almacen Lleno Pulse Una Tecla ');
             readkey;
             salir := true;
           end;
        end;
         until salir = true;
       end;
 'B' : begin
         bajadeunarticulo;
       end;
 'V' : begin
         visualizaarticulos;
       end;
 'M' : begin
         modificadatos;
      end;
 'R' : begin
         RealizarVenta;
       end;
 'T' : begin
         muestraventas;
       end;
 'S' : fin := true;
    end;
    until fin = true;
  end;
 
 
begin
    clrscr;
    numarti := 1;
    nuvet := 1;
    menu;
end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

No se terminar ejercicio Pascal

Publicado por PepitoPerez (2 intervenciones) el 09/12/2013 21:36:23
Una ultima preguntita!
¿Cómo se podrían cambiar los subprogramas para que en vez de utilizar el fichero lo hicieses todo desde los arrays que te dí?
Los unicos subprogramas en los que has utilizado el fichero en vez de los arrays son: Muestraventas, baja de articulo, visualizar articulo, modificar articulo y realizar venta
Muchas gracias!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

No se terminar ejercicio Pascal

Publicado por ramon (2158 intervenciones) el 13/12/2013 19:45:38
Siempre que la memoria lo permita descarga los archivos al array y trabaja con el pero no te lo aconsejo por
el tamaño que ocupan.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar