Pascal/Turbo Pascal - Apareo de archivo comisiones

 
Vista:
sin imagen de perfil

Apareo de archivo comisiones

Publicado por Horacio (53 intervenciones) el 23/10/2012 04:51:05
Hola a todos,ayuda con este ejercicio de archivos:

Apareo de archivos (uno, varios o ningún registro)

Una empresa desea un informe sobre los montos de comisiones que debe abonar a sus vendedores el presente mes. Para ello cuenta con los siguientes datos:

Archivo 1: Un registro por vendedor
SECCIÓN Nº VENDEDOR NOMBRE Y APELLIDO ÚLTIMO MES PROCESO

Archivo 2: Uno, varios o ningún registro por vendedor (ventas del mes actual) (rubro de 1 a 3)

SECCIÓN Nº VENDEDOR RUBRO MONTO VENDIDO MES PROCESO

Calcular el total de comisión de cada vendedor (comisión venta = monto vendido * comisión por rubro). La comisión se rescata de una tabla de tres elementos de acuerdo al rubro que se ingresa al inicio. Señalar en un campo de observaciones con "*" aquellos que no realizaron ventas.
Obtener el total a pagar y actualizar el maestro.

Diseño de la salida impresa (una línea por vendedor):
SECCIÓN Nº VENDEDOR NOMBRE Y APELLIDO COMISIÓN OBSERVACIONES
XXXX XXXX XXXXXXXXXXXXXXXX XXXXX,XX *
XXXX XXXX XXXXXXXXXXXXXXXX XXXXX,XX *

TOTAL GENERAL DE COMISIONES: XXXXXXX,XX


desde ya gracias,saludos.
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

Apareo de archivo comisiones

Publicado por ramon (2158 intervenciones) el 24/10/2012 18:52:58
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
{A ver este programa presenta datos de un archivo maestro y otro de resultados como tu
 expresas, pero fíjate que tus record no tienen los mismos valores de modificación.
 SECCIÓN	Nº VENDEDOR	NOMBRE Y APELLIDO	ÚLTIMO MES PROCESO no es como
 SECCIÓN	Nº VENDEDOR	RUBRO	 MONTO VENDIDO	 MES PROCESO por lo cual
 si puedo presentar según formato  SECCIÓN	Nº VENDEDOR  y MES PROCESO  por ser correcto
 en los dos pero el resto no puedes madamas que presentar en pantalla puesto que no puedes
  actualizar nada en el maestro por falta de datos en el registro.
 Te dejo este programa a ver si ayuda.
 
program aaventas;
 uses
    crt;
  const
      rublo : array[1..3] of integer = (
      5,10,20);
      vendedor = 'DatoVend.dat';
      ventas = 'Vetreali.dat';
  type
    archivo1 = record
            SECCION  : integer;
           NVENDEDOR : integer;
     NOMBRE_APELLIDO : string[80];
         MES_PROCESO : word;
         end;
 
    archivo2 = record
           SECCION  : integer;
          NVENDEDOR : integer;
              RUBRO : integer;
      MONTO_VENDIDO : real;
        MES_PROCESO : word;
        vediosino   : array[1..12] of char;
         end;
 
     infovent = record
           seccion : integer;
           nombre  : string[80];
           venta : real;
           comisi : real;
           nvend : integer;
           total : real;
           vendio : char;
         end;
 
   var
     dat1 : archivo1;
     dat2 : archivo2;
     f1 : file of archivo1;
     f2 : file of archivo2;
     comision : array[1..20] of real;
     infor : array[1..100] of infovent;
     num : integer;
     totalcomisiones : real;
 
   procedure entradavendedor;
   var
      salir : boolean;
      tecl : char;
   begin
      salir := false;
     repeat
       clrscr;
       writeln('**** Entrada Datos Vendedor ****');
       writeln;
       write('Srccion N§ : ');
       readln(dat1.seccion);
       write('N§ Vendedor : ');
       readln(dat1.nvendedor);
       write('Nombre y Apellido : ');
       readln(dat1.nombre_apellido);
       write('Mes de Proceso : ');
       readln(dat1.mes_proceso);
       assign(f1,vendedor);
   {$I-} reset(f1); {$I+}
   if ioresult <> 0 then
   begin
       rewrite(f1);
       seek(f1,0);
       write(f1,dat1);
       close(f1);
   end
 else
    begin
       seek(f1,filesize(f1));
       write(f1,dat1);
       close(f1);
    end;
       writeln;
       writeln('<<< Desea Entrar Mas Datos [S/N] >>>');
       repeat
           tecl := upcase(readkey);
       until tecl in['S','N'];
       if tecl = 'N' then
       salir := true
     until salir = true;
   end;
 
   procedure entradaventas;
   var
     salir : boolean;
     tec, tecl : char;
   begin
     salir := false;
     repeat
          clrscr;
          writeln('*** Entrada Ventas Realizadas ***');
          writeln;
          write('Seccion N§ : ');
          readln(dat2.seccion);
          write('N§ Vendedor : ');
          readln(dat2.nvendedor);
          write('N§ Del Rubro 1/2/3 : ');
          repeat
              tec := readkey;
              write(tec);
          until tec in['0','1','2','3'];
          case tec of
       '0' : dat2.rubro := 0;
       '1' : dat2.rubro := 1;
       '2' : dat2.rubro := 2;
       '3' : dat2.rubro := 3;
         end;
         writeln;
         write('Monton de Venta : ');
         readln(dat2.MONTO_VENDIDO);
         write('Mes de Proceso : ');
         readln(dat2.mes_proceso);
     assign(f2,ventas);
   {$I-} reset(f2); {$I+}
   if ioresult <> 0 then
   begin
       rewrite(f2);
       seek(f2,0);
       write(f2,dat2);
       close(f2);
   end
 else
    begin
       seek(f2,filesize(f2));
       write(f2,dat2);
       close(f2);
    end;
       writeln;
       writeln('<<< Desea Entrar Mas Datos [S/N] >>>');
       repeat
           tecl := upcase(readkey);
       until tecl in['S','N'];
       if tecl = 'N' then
       salir := true
     until salir = true;
   end;
 
   procedure presentaresultados(nu : integer);
   begin
    with infor[nu] do
    begin
    writeln('   ',seccion,'       ',nvend,'         ',nombre,
                             '          ',comisi:0:2,'      ',vendio);
    end;
   end;
 
   procedure apareadoarchivos;
   var
     n, t : longint;
     encontre : boolean;
   begin
 
      assign(f1,vendedor);
   {$I-} reset(f1); {$I+}
   if ioresult = 0 then
   begin
      assign(f2,ventas);
   {$I-} reset(f2); {$I+}
   if ioresult <> 0 then
   begin
   clrscr;
  writeln('### Error De Archivo ',ventas,' No Encontrado Pulse [Enter] ###');
   readln;
   exit;
   end
 else
     begin
     num := 1;
    totalcomisiones := 0;
     writeln(' SECCION   NVENDEDOR  NOMBRE Y APELLIDO    COMISION   OBSERVACIONES');
     for n := 0 to filesize(f2) - 1 do
     begin
       seek(f2,n);
       read(f2,dat2);
       t := 0;
       encontre := false;
     repeat
         seek(f1,t);
         read(f1,dat1);
         if dat1.NVENDEDOR = dat2.NVENDEDOR then
         encontre := true
       else
          t := t + 1;
     until (encontre = true) or (t > filesize(f1) - 1);
     if (encontre = true) and (dat2.MONTO_VENDIDO > 0) then
     begin
         infor[num].nombre := dat1.NOMBRE_APELLIDO;
         infor[num].seccion := dat1.SECCION;
         infor[num].venta := dat2.MONTO_VENDIDO;
         infor[num].comisi := (dat2.MONTO_VENDIDO * rublo[dat2.RUBRO] / 100);
         infor[num].nvend := dat2.NVENDEDOR;
         infor[num].total := infor[num].comisi * dat2.RUBRO;
         infor[num].vendio := ' ';
         dat2.vediosino[dat2.mes_proceso] := ' ';
         totalcomisiones := totalcomisiones + infor[num].total;
         num := num + 1;
     end
  else
     begin
         infor[num].nombre := dat1.NOMBRE_APELLIDO;
         infor[num].seccion := dat1.SECCION;
         infor[num].venta := 0;
         infor[num].comisi := 0;
         infor[num].nvend := dat2.NVENDEDOR;
         infor[num].total := 0;
         infor[num].vendio := '*';
         dat2.vediosino[dat2.mes_proceso] := '*';
         num := num + 1;
     end;
       presentaresultados(num - 1);
    end;
       writeln;
       writeln('  Total De Pago Comisiones = ',totalcomisiones:0:2);
       close(f1);
       close(f2);
       writeln;
       writeln('   >> Pulse [Enter] <<');
       readln;
     end;
   end
  else
     begin
     clrscr;
   writeln('??? Error Archivo ',vendedor,' No Encontrado Pulse [Enter] ???');
   readln;
   exit;
     end;
   end;
 
  procedure menu;
  var
     sal : boolean;
     teh : char;
  begin
    sal := false;
    repeat
    clrscr;
    writeln('  ****** Menu General ******');
    writeln;
    writeln('  1 : Entrada Datos Vendedor');
    writeln('  2 : Entrada datos Ventas');
    writeln('  3 : Apareado y presentacion');
    writeln('  4 : Salir');
    writeln;
    writeln('   <<<< Elija Opcion >>>>');
    repeat
        teh := readkey;
    until teh in['1','2','3','4'];
   case teh of
  '1' : begin clrscr; entradavendedor; end;
  '2' : begin clrscr; entradaventas; end;
  '3' : begin clrscr; apareadoarchivos; end;
  '4' : sal := true;
   end;
    until sal = true;
  end;
 
 begin
     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
sin imagen de perfil

Apareo de archivo comisiones

Publicado por Horacio Daniel (53 intervenciones) el 24/10/2012 21:04:30
Si la verdad las consignas de estos ejercicios le faltan datos o mas claridad para poder interpretar mejor el problema a resolver.igualmente,muchas gracias por tu tiempo en la realización del mismo.saludos
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