You are on page 1of 18

new 2

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

quarta-feira, 6 de julho de 2011 12:42

Private Sub cmd_rel_ok_Click()


X_Where = ""
Dim
Dim
Dim
Dim
Dim
Dim

RS
RS_AD
RS_AB
RS_PD
RS_TR
RS_DP

As
As
As
As
As
As

ADODB.Recordset
ADODB.Recordset
ADODB.Recordset
ADODB.Recordset
ADODB.Recordset
ADODB.Recordset

Dim
Dim
Dim
Dim
Dim

Imp_CAB_AD
Imp_CAB_PD
Imp_CAB_TR
Imp_CAB_AB
Imp_CAB_DP

As
As
As
As
As

Boolean
Boolean
Boolean
Boolean
Boolean

Dim TOT_FRETE
As Double
Dim PERC_GANHO_LIQ As Double
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim

X_TOT_ADI
X_TOT_DESP
X_TOT_VLR_L
X_TOT_AGENC
X_TOT_PED
X_BASE_COMIS
X_COMISSAO
X_SALDO_VIAG

Dim
Dim
Dim
Dim
Dim
Dim
Dim

X_KM_RODADOS
X_KM_VAZIO
X_KM_CHEIO
X_LITROS
X_CONS_MED_L
X_Custo_MED_L
X_Custo_KM_ROD

As
As
As
As
As
As
As
As
As
As
As
As
As
As
As

Double
Double
Double
Double
Double
Double
Double
Double
Double
Double
Double
Double
Double
Double
Double

If msk_cons_dt1.Text <> " / /


" Then
If Not IsDate(msk_Rel_dt1.Text) Then
MsgBox "Primeira Data Invlida", vbCritical, "Ateno"
msk_Rel_dt1.SetFocus
Exit Sub
End If
If Not IsDate(MSk_REL_DT2.Text) Then
MsgBox "Segunda Data Invlida", vbCritical, "Ateno"
MSk_REL_DT2.SetFocus
Exit Sub
End If
If CDate(MSk_REL_DT2.Text) < CDate(msk_Rel_dt1.Text) Then
MsgBox "Perodo Invlido", vbCritical, "Ateno"
msk_Rel_dt1.SetFocus
Exit Sub
End If
X_Where = " where ( AC_DT_PARTI between " & BPRCorrige_Valor(msk_Rel_dt1.Text
-1-

new 2

quarta-feira, 6 de julho de 2011 12:42

, "D", True) & " and " & BPRCorrige_Valor(MSk_REL_DT2.Text, "D", True) & ") "
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

End If
If Val_Sgt(txt_Rel_viag.Text) > 0 Then
If Trim(X_Where) = "" Then
X_Where = " where "
Else
X_Where = X_Where & " and "
End If
X_Where = X_Where & " AC_NUMERO = " & Val_Sgt(txt_Rel_viag.Text)
End If
If Cbo_Rel_Veic.Text <> "" Then
If Trim(X_Where) = "" Then
X_Where = " where "
Else
X_Where = X_Where & " and "
End If
X_Where = X_Where & " AC_veicu='" & Cbo_Rel_Veic.Text & "'"
End If
If cbo_Rel_Cond.Text <> "" Then
If Trim(X_Where) = "" Then
X_Where = " where "
Else
X_Where = X_Where & " and "
End If
X = InStr(1, cbo_condutor.Text, " | ")
If X > 0 Then
X_condutor = Mid(cbo_condutor.Text, 1, X - 1)
Else
X_condutor = cbo_condutor.Text
End If
X_Where = X_Where & " AC_CONDUTOR ='" & X_condutor & "'"
End If

If chk_fexadas.Value = 1 Then
If Trim(X_Where) = "" Then
X_Where = " where "
Else
X_Where = X_Where & " and "
End If
X_Where = X_Where & " AC_SIT=2"
End If

Sql = "SELECT GT_AC_VIAGEM.*, mt_nome FROM GT_AC_VIAGEM inner join gt_motor on


gt_ac_viagem.ac_condutor = gt_motor.mt_cpf " & X_Where & "ORDER BY AC_NUMERO"
-2-

new 2

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

quarta-feira, 6 de julho de 2011 12:42

Set RS = New ADODB.Recordset


RS.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly
If RS.RecordCount > 0 Then
'--------------------------------- prepra impresso
If opt_tela.Value = True Then
CamT = GdDir & "textosgt\REL_VIAGENS.Txt"
If Dir(CamT) <> "" Then 'existe
Kill CamT
End If
Open CamT For Output As #1
Else
Printer.FontName = "DRAFT 12CPI"
Printer.FontSize = 10
LnMax = 63
ContLn = 0
If UCase(Printer.FontName) <> "DRAFT 12CPI" Then
Printer.FontName = "courier new"
Printer.FontSize = 10
LnMax = 75
End If
End If

Do While RS.EOF = False


If opt_anal.Value = True Then
If ContLn > 0 Then
ContLn = LnMax
If opt_tela.Value = True Then
For I = ContLn + 1 To LnMax + 3
Print #1,
ContLn = ContLn + 1
Next
Else
Printer.NewPage
End If
ContLn = 0
End If
ContPg = ContPg + 1

CAB1 = Comp_Str(PrEmp, 80, " ", True) & "PAG.:" & Comp_Str(ContPg, 3,
" ", False)

160
161
162
163
164

CAB2 = "LISTAGEM DE ACOMPANHAMENTO DE VIAGEM" & Space(45) & "DATA: "


& Format(Now, "dd/mm/yyyy")
HIF3 = String(96, "-")
CAB4 = Comp_Str("VIAGEM :" & RS("ac_numero"), 15, " ", True) & Space(
1) _
& Comp_Str("VECULO:" & RS("AC_VEICU"), 16, " ", True) &
Space(1) _
& Comp_Str("CONDUTOR:" & RS("mt_nome"), 40, " ", True) &
Space(1) _
-3-

new 2

quarta-feira, 6 de julho de 2011 12:42

165

& "SITUAO:" & IIf(RS("AC_SIT") = 1, "1 - ABERTA", "2 FECHADA")

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

CAB5 = Comp_Str("PARTIDA:" & Format(RS("ac_DT_PARTI"), "DD/MM/YYYY")


& " " & IIf(IsNull(RS("AC_HR_SAI")) = True, " ", RS("AC_HR_SAI")) & Space(1) _
& "CHEGADA:" & IIf(IsNull(RS("AC_DT_CHEG")) = False, Format(
RS("AC_DT_CHEG"), "DD/MM/YYYY"), " / /
") & " " & IIf(IsNull(RS("AC_HR_CHEG")) =
True, " ", RS("AC_HR_CHEG")), 96, " ", True, True)
CAB6 = Comp_Str("ORIGEM:" & RS("AC_SAI_MUN") & "/" & RS("AC_SAI_UF")
& " KM: " & RS("AC_SAI_KM"), 96, " ", True, True)
CAB7 = Comp_Str("DESTINO:" & RS("AC_DEST_MUN") & "/" & RS(
"AC_DEST_UF") & " KM: " & Val_Sgt(RS("AC_DEST_KM")), 96, " ", True, True)
HIF8 = String(96, "=")
If opt_tela.Value = True Then
Print #1, CAB1
Print #1, CAB2
Print #1, HIF3
Print #1, CAB4
Print #1, CAB5
Print #1, CAB6
Print #1, CAB7
'Print #1, HIF8
Else
Printer.Print CAB1
Printer.Print CAB2
Printer.Print HIF3
Printer.Print CAB4
Printer.Print CAB5
Printer.Print CAB6
Printer.Print CAB7
End If
ContLn = 8
End If

'-------------------------------------------------------------------------------------- ADIANTAMENTOS
Sql = "SELECT * FROM GT_AC_ADIANTAMENTO WHERE AD_NUM_AC=" & RS(
"AC_NUMERO")
Set RS_AD = New ADODB.Recordset
RS_AD.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly
Imp_CAB_AD = True
X_TOT_ADI = 0
If RS_AD.RecordCount > 0 Then
Do While RS_AD.EOF = False
If opt_anal.Value = True Then
If ContLn + 13 > LnMax Then
If opt_tela.Value = True Then
For I = ContLn + 1 To LnMax + 3
Print #1,
ContLn = ContLn + 1
Next
Else
Printer.NewPage
-4-

new 2

quarta-feira, 6 de julho de 2011 12:42

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

End If
ContLn = 0
End If
If ContLn = 0 Then
If opt_tela.Value = True Then
Print #1, CAB1
Print #1, CAB2
Print #1, HIF3
Print #1, CAB4
Print #1, CAB5
Print #1, CAB6
Print #1, CAB7
'Print #1, HIF8
Else
Printer.Print CAB1
Printer.Print CAB2
Printer.Print HIF3
Printer.Print CAB4
Printer.Print CAB5
Printer.Print CAB6
Printer.Print CAB7
End If
ContLn = 8
End If
Imp_CAB_AD = True
If Imp_CAB_AD = True Then
Imp_CAB_AD = False
If opt_anal.Value = True Then
If opt_tela.Value = True Then
Print #1, HIF8
Print #1, "ADIANTAMENTOS"
Print #1, HIF3
Print #1, Space(5) & Comp_Str("DATA", 12, " ",
True) _

249

& Comp_Str("VALOR", 15, " ", False) &


Space(1) _

250

& Comp_Str("AUTORIZADO POR", 50, " ",


True)

251
252
253
254
255
256

Print #1, HIF3


Else
Printer.Print
Printer.Print
Printer.Print
Printer.Print

HIF8
"ADIANTAMENTOS"
HIF3
Space(5) & Comp_Str("DATA", 12, " "

, True) _
257

& Comp_Str("VALOR", 15, " ", False) &


Space(1) _

258

& Comp_Str("AUTORIZADO POR", 50, " ",


True)

259
260
261
262
263

Printer.Print HIF3
End If
ContLn = ContLn + 5
End If
-5-

new 2

264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285

quarta-feira, 6 de julho de 2011 12:42

End If
If opt_tela.Value = True Then
Print #1, Space(5) & Comp_Str(Format(RS_AD("AD_DATA"),
"DD/MM/YYYY"), 12, " ", True) _
& Comp_Str(Format(RS_AD("AD_VLR"), "0.00"), 15,
" ", False) & Space(1) _
& Comp_Str(RS_AD("AD_AUTORIZADO"), 50, " ", True)
Else
Printer.Print Space(5) & Comp_Str(Format(RS_AD("AD_DATA"
), "DD/MM/YYYY"), 12, " ", True) _
& Comp_Str(Format(RS_AD("AD_VLR"), "0.00"), 15,
" ", False) & Space(1) _
& Comp_Str(RS_AD("AD_AUTORIZADO"), 50, " ", True)
End If
ContLn = ContLn + 1
End If
'------- total -----------------------------------X_TOT_ADI = X_TOT_ADI + Val_Sgt(RS_AD("AD_VLR"))
'-------------------------------------------------RS_AD.MoveNext
Loop
End If '--------------------------------------------------------- \
ADIANTAMENTOS

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

'-------------------------------------------------------------------------------------- DESPESAS
Sql = "SELECT * FROM GT_AC_DESP WHERE DP_NUM_AC=" & RS("AC_NUMERO")
Set RS_DP = New ADODB.Recordset
RS_DP.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly
Imp_CAB_DP = True
X_TOT_DESP = 0
If RS_DP.RecordCount > 0 Then
Do While RS_DP.EOF = False
If opt_anal.Value = True Then
If ContLn + 13 > LnMax Then
If opt_tela.Value = True Then
For I = ContLn + 1 To LnMax + 3
Print #1,
ContLn = ContLn + 1
Next
Else
Printer.NewPage
End If
ContLn = 0
End If
If ContLn = 0 Then
ContPg = ContPg + 1
If opt_tela.Value = True Then
Print #1, CAB1
Print #1, CAB2
Print #1, HIF3
Print #1, CAB4
-6-

new 2

quarta-feira, 6 de julho de 2011 12:42

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

Print #1, CAB5


Print #1, CAB6
Print #1, CAB7
'Print #1, HIF8
Else
Printer.Print
Printer.Print
Printer.Print
Printer.Print
Printer.Print
Printer.Print
Printer.Print
End If
ContLn = 8
Imp_CAB_DP = True
End If

CAB1
CAB2
HIF3
CAB4
CAB5
CAB6
CAB7

If Imp_CAB_DP = True Then


Imp_CAB_DP = False
If opt_tela.Value = True Then
Print #1, HIF8
Print #1, "DESPESAS"
Print #1, HIF3
Print #1, Space(5) & Comp_Str("DATA", 12, " ", True) _
& Comp_Str("HORA", 6, " ", True) _
& Comp_Str("VALOR", 8, " ", False) & Space(1)
_

340

& Comp_Str("DESCRIO", 22, " ", True) &


Space(1) _

341

& Comp_Str("AUTORIZADO", 20, " ", True) &


Space(1) _

342
343
344
345
346
347
348

& Comp_Str("F.PAGTO", 20, " ", True)


Print #1, HIF3
Else
Printer.Print
Printer.Print
Printer.Print
Printer.Print

HIF8
"DESPESAS"
HIF3
Space(5) & Comp_Str("DATA", 12, " ",

True) _
349
350

& Comp_Str("HORA", 6, " ", True) _


& Comp_Str("VALOR", 8, " ", False) & Space(1)
_

351

& Comp_Str("DESCRIO", 22, " ", True) &


Space(1) _

352

& Comp_Str("AUTORIZADO", 20, " ", True) &


Space(1) _

353
354
355
356
357
358
359
360
361
362

& Comp_Str("F.PAGTO", 20, " ", True)


Printer.Print HIF3
End If
ContLn = ContLn + 5
End If
If opt_tela.Value = True Then
Print #1, Space(5) & Comp_Str(Format(RS_DP("dp_data"),
"dd/mm/yyyy"), 12, " ", True) _
& Comp_Str(RS_DP("dp_hora"), 6, " ", True) _
-7-

new 2

quarta-feira, 6 de julho de 2011 12:42

363

& Comp_Str(Format(RS_DP("dp_valor"), "0.00"), 8,


" ", False) & Space(1) _

364

& Comp_Str(RS_DP("dp_desc"), 22, " ", True) &


Space(1) _

365

& Comp_Str(RS_DP("dp_autorizado"), 20, " ", True)


& Space(1) _

366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385

& Comp_Str(RS_DP("dp_fpgto"), 20, " ", True)


Else
Printer.Print Space(5) & Comp_Str(Format(RS_DP("dp_data"
), "dd/mm/yyyy"), 12, " ", True) _
& Comp_Str(RS_DP("dp_hora"), 6, " ", True) _
& Comp_Str(Format(RS_DP("dp_valor"), "0.00"), 8,
" ", False) & Space(1) _
& Comp_Str(RS_DP("dp_desc"), 22, " ", True) &
Space(1) _
& Comp_Str(RS_DP("dp_autorizado"), 20, " ", True)
& Space(1) _
& Comp_Str(RS_DP("dp_fpgto"), 20, " ", True)
End If
ContLn = ContLn + 1
End If
'------- total -----------------------------------X_TOT_DESP = X_TOT_DESP + Val_Sgt(RS_DP("dp_valor"))
'-------------------------------------------------RS_DP.MoveNext
Loop
End If '--------------------------------------------------------- \
DESPESA

386
387
388

389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409

'-------------------------------------------------------------------------------------- ABASTECIMENTOS
Sql = "SELECT * FROM GT_AC_ABAST WHERE AB_NUM_AC=" & RS("AC_NUMERO")
Set RS_AB = New ADODB.Recordset
RS_AB.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly
Imp_CAB_AB = True
X_LITROS = 0
X_TOT_VLR_L = 0
If RS_AB.RecordCount > 0 Then
Do While RS_AB.EOF = False
If opt_anal.Value = True Then
If ContLn + 13 > LnMax Then
If opt_tela.Value = True Then
For I = ContLn + 1 To LnMax + 3
Print #1,
ContLn = ContLn + 1
Next
Else
Printer.NewPage
End If
ContLn = 0
End If
If ContLn = 0 Then
-8-

new 2

quarta-feira, 6 de julho de 2011 12:42

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

ContPg = ContPg + 1
If opt_tela.Value = True Then
Print #1, CAB1
Print #1, CAB2
Print #1, HIF3
Print #1, CAB4
Print #1, CAB5
Print #1, CAB6
Print #1, CAB7
'Print #1, HIF8
Else
Printer.Print CAB1
Printer.Print CAB2
Printer.Print HIF3
Printer.Print CAB4
Printer.Print CAB5
Printer.Print CAB6
Printer.Print CAB7
End If
ContLn = 8
Imp_CAB_AB = True
End If
If Imp_CAB_AB = True Then
Imp_CAB_AB = False
If opt_tela.Value = True Then
Print #1, HIF8
Print #1, "ABASTECIMENTOS"
Print #1, HIF3
Print #1, Space(5) & Comp_Str("DATA", 12, " ", True) _
& Comp_Str("HORA", 6, " ", True) _
& Comp_Str("CIDADE", 25, " ", True) & Space(1
) _

443
444
445

& Comp_Str("UF", 4, " ", True) & Space(1) _


& Comp_Str("QTDE", 8, " ", False) & Space(1) _
& Comp_Str("TOTAL", 10, " ", False) & Space(1
) _

446
447
448
449
450
451
452

& Comp_Str("F PGTO", 21, " ", True)


Print #1, HIF3
Else
Printer.Print
Printer.Print
Printer.Print
Printer.Print

HIF8
"ABASTECIMENTOS"
HIF3
Space(5) & Comp_Str("DATA", 12, " ",

True) _
453
454

& Comp_Str("HORA", 6, " ", True) _


& Comp_Str("CIDADE", 25, " ", True) & Space(1
) _

455
456
457

& Comp_Str("UF", 4, " ", True) & Space(1) _


& Comp_Str("QTDE", 8, " ", False) & Space(1) _
& Comp_Str("TOTAL", 10, " ", False) & Space(1
) _

458
459
460
461

& Comp_Str("F PGTO", 21, " ", True)


Printer.Print HIF3
End If
-9-

new 2

462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485

quarta-feira, 6 de julho de 2011 12:42

ContLn = ContLn + 5
End If
If opt_tela.Value = True Then
Print #1, Space(5) & Comp_Str(Format(RS_AB("ab_data"),
"dd/mm/yyyy"), 12, " ", True) _
& Comp_Str(RS_AB("ab_hora"), 6, " ", True) _
& Comp_Str(RS_AB("ab_mun"), 25, " ", True) &
Space(1) _
& Comp_Str(RS_AB("ab_uf"), 4, " ", True) &
Space(1) _
& Comp_Str(RS_AB("ab_qtde_L"), 8, " ", False)
& Space(1) _
& Comp_Str(RS_AB("ab_total"), 10, " ", False)
& Space(1) _
& Comp_Str(RS_AB("ab_FPGTO"), 21, " ", True)
Else
Printer.Print Space(5) & Comp_Str(Format(RS_AB("ab_data"
), "dd/mm/yyyy"), 12, " ", True) _
& Comp_Str(RS_AB("ab_hora"), 6, " ", True) _
& Comp_Str(RS_AB("ab_mun"), 25, " ", True) &
Space(1) _
& Comp_Str(RS_AB("ab_uf"), 4, " ", True) &
Space(1) _
& Comp_Str(RS_AB("ab_qtde_L"), 8, " ", False)
& Space(1) _
& Comp_Str(RS_AB("ab_total"), 10, " ", False)
& Space(1) _
& Comp_Str(RS_AB("ab_FPGTO"), 21, " ", True)
End If
ContLn = ContLn + 1
End If
'----------------------------------------------- ACUMULA LITROS
DE COMBUSTIVEL

486
487
488

X_LITROS = X_LITROS + Val_Sgt(RS_AB("ab_qtde_L"))


X_TOT_VLR_L = X_TOT_VLR_L + Val_Sgt(RS_AB("ab_total"))
'------------------------------------------------------------------------------

489
490
491
492

RS_AB.MoveNext
Loop
End If '--------------------------------------------------------- \
ABASTECIMENTOS

493
494
495

496
497
498
499
500
501
502
503

'-------------------------------------------------------------------------------------- PEDAGIOS
Sql = "SELECT * FROM GT_AC_pedagio WHERE pd_NUM_AC=" & RS("AC_NUMERO")
Set RS_PD = New ADODB.Recordset
RS_PD.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly
Imp_CAB_PD = True
X_TOT_PED = 0
If RS_PD.RecordCount > 0 Then
Do While RS_PD.EOF = False
If opt_anal.Value = True Then
-10-

new 2

quarta-feira, 6 de julho de 2011 12:42

504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547

If ContLn + 13 > LnMax Then


If opt_tela.Value = True Then
For I = ContLn + 1 To LnMax + 3
Print #1,
ContLn = ContLn + 1
Next
Else
Printer.NewPage
End If
ContLn = 0
End If
If ContLn = 0 Then
ContPg = ContPg + 1
If opt_tela.Value = True Then
Print #1, CAB1
Print #1, CAB2
Print #1, HIF3
Print #1, CAB4
Print #1, CAB5
Print #1, CAB6
Print #1, CAB7
'Print #1, HIF8
Else
Printer.Print CAB1
Printer.Print CAB2
Printer.Print HIF3
Printer.Print CAB4
Printer.Print CAB5
Printer.Print CAB6
Printer.Print CAB7
End If
ContLn = 8
Imp_CAB_PD = True
End If
If Imp_CAB_PD = True Then
Imp_CAB_PD = False
If opt_tela.Value = True Then
Print #1, HIF8
Print #1, "PEDGIOS"
Print #1, HIF3
Print #1, Space(5) & Comp_Str("DATA", 12, " ", True) _
& Comp_Str("CIDADE", 30, " ", True) & Space(1
) _

548
549

& Comp_Str("UF", 4, " ", True) & Space(1) _


& Comp_Str("VALOR", 10, " ", False) & Space(1
) _

550
551
552
553
554
555
556

& Comp_Str("F.PGTO", 21, " ", True)


Print #1, HIF3
Else
Printer.Print
Printer.Print
Printer.Print
Printer.Print

HIF8
"PEDGIOS"
HIF3
Space(5) & Comp_Str("DATA", 12, " ",

True) _
557

& Comp_Str("CIDADE", 30, " ", True) & Space(1


-11-

new 2

quarta-feira, 6 de julho de 2011 12:42

) _
558
559

& Comp_Str("UF", 4, " ", True) & Space(1) _


& Comp_Str("VALOR", 10, " ", False) & Space(1
) _

560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588

& Comp_Str("F.PGTO", 21, " ", True)


Printer.Print HIF3
End If
ContLn = ContLn + 5
End If
If opt_tela.Value = True Then
Print #1, Space(5) & Comp_Str(Format(RS_PD("PD_data"),
"dd/mm/yyyy"), 12, " ", True) _
& Comp_Str(RS_PD("PD_MUN"), 30, " ", True) &
Space(1) _
& Comp_Str(RS_PD("PD_uf"), 4, " ", True) &
Space(1) _
& Comp_Str(Format(RS_PD("PD_VALOR"), "0.00"),
10, " ", False) & Space(1) _
& Comp_Str(RS_PD("PD_FPGTO"), 21, " ", True)
Else
Printer.Print Space(5) & Comp_Str(Format(RS_PD("PD_data"
), "dd/mm/yyyy"), 12, " ", True) _
& Comp_Str(RS_PD("PD_MUN"), 30, " ", True) &
Space(1) _
& Comp_Str(RS_PD("PD_uf"), 4, " ", True) &
Space(1) _
& Comp_Str(Format(RS_PD("PD_VALOR"), "0.00"),
10, " ", False) & Space(1) _
& Comp_Str(RS_PD("PD_FPGTO"), 21, " ", True)
End If
ContLn = ContLn + 1
End If
'---------------- total -------------------X_TOT_PED = X_TOT_PED + RS_PD("PD_VALOR")
'------------------------------------------RS_PD.MoveNext
Loop
End If '--------------------------------------------------------- \
PEDAGIOS

589
590
591

592
593
594
595
596
597
598
599
600

'-------------------------------------------------------------------------------------- TRECHOS
Sql = "SELECT * FROM GT_AC_TRECHOS WHERE TR_NUM_AC=" & RS("AC_NUMERO") &
" ORDER BY TR_KM_PART "
Set RS_TR = New ADODB.Recordset
RS_TR.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly
Imp_CAB_TR = True
X_KM_RODADOS = 0
X_KM_VAZIO = 0
X_KM_CHEIO = 0
X_TOT_AGENC = 0
-12-

new 2

quarta-feira, 6 de julho de 2011 12:42

601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653

X_BASE_COMIS = 0
TOT_FRETE = 0
If RS_TR.RecordCount > 0 Then
RS_TR.MoveLast
RS_TR.MoveFirst
Do While RS_TR.EOF = False
If opt_anal.Value = True Then
If ContLn + 13 > LnMax Then
If opt_tela.Value = True Then
For I = ContLn + 1 To LnMax + 3
Print #1,
ContLn = ContLn + 1
Next
Else
Printer.NewPage
End If
ContLn = 0
End If
If ContLn = 0 Then
ContPg = ContPg + 1
If opt_tela.Value = True Then
Print #1, CAB1
Print #1, CAB2
Print #1, HIF3
Print #1, CAB4
Print #1, CAB5
Print #1, CAB6
Print #1, CAB7
'Print #1, HIF8
Else
Printer.Print CAB1
Printer.Print CAB2
Printer.Print HIF3
Printer.Print CAB4
Printer.Print CAB5
Printer.Print CAB6
Printer.Print CAB7
End If
ContLn = 8
Imp_CAB_TR = True
End If
If Imp_CAB_TR = True Then
Imp_CAB_TR = False
If opt_tela.Value = True Then
Print #1, HIF8
Print #1, "TRECHOS PERCORRIDOS"
Print #1, HIF3
Print #1, Comp_Str("DT. PARTIDA", 12, " ", True) _
& Comp_Str("KM PART.", 9, " ", True) _
& Comp_Str("ORIGEM", 15, " ", True) & Space(1
) _

654
655
656

& Comp_Str("UF", 3, " ", True) _


& Comp_Str("DT. CHEG.", 11, " ", True) _
& Comp_Str("KM CHEG.", 9, " ", True) _
-13-

new 2

quarta-feira, 6 de julho de 2011 12:42

657

& Comp_Str("DESTINO", 15, " ", True) & Space(


1) _

658
659

& Comp_Str("UF", 3, " ", True) _


& Comp_Str("ADIANT.", 8, " ", False) & Space(
1) _

660
661
662
663
664
665
666
667
668
669

& Comp_Str("SALDO", 8, " ", False)


Print #1, HIF3
Else
Printer.Print HIF8
Printer.Print "TRECHOS PERCORRIDOS"
Printer.Print HIF3
Printer.Print Comp_Str("DT. PARTIDA", 12, " ", True) _
& Comp_Str("KM PART.", 9, " ", True) _
& Comp_Str("ORIGEM", 15, " ", True) & Space(1
) _

670
671
672
673

&
&
&
&

Comp_Str("UF", 3, " ", True) _


Comp_Str("DT. CHEG.", 11, " ", True) _
Comp_Str("KM CHEG.", 9, " ", True) _
Comp_Str("DESTINO", 15, " ", True) & Space(

1) _
674
675

& Comp_Str("UF", 3, " ", True) _


& Comp_Str("ADIANT.", 8, " ", False) & Space(
1) _

676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699

& Comp_Str("SALDO", 8, " ", False)


Printer.Print HIF3
End If
ContLn = ContLn + 5
End If
If opt_tela.Value = True Then
Print #1, Comp_Str(Format(RS_TR("TR_DT_PART"),
"DD/MM/YYYY"), 12, " ", True) _
& Comp_Str(RS_TR("TR_KM_PART"), 9, " ", True) _
& Comp_Str(RS_TR("TR_MUN"), 15, " ", True) &
Space(1) _
& Comp_Str(RS_TR("TR_UF"), 3, " ", True) _
& Comp_Str(IIf(IsNull(RS_TR("TR_DT_CHEG")) = True
, " ", Format(RS_TR("TR_DT_CHEG"), "DD/MM/YYYY")), 11, " ", True) _
& Comp_Str(RS_TR("TR_KM_CHEG"), 9, " ", True) _
& Comp_Str(RS_TR("TR_CID_DEST"), 15, " ", True) &
Space(1) _
& Comp_Str(RS_TR("TR_UF_DEST"), 3, " ", True) _
& Comp_Str(Format(Val_Sgt(RS_TR("TR_VL_ADI")),
"0.00"), 8, " ", False) & Space(1) _
& Comp_Str(Format(Val_Sgt(RS_TR("TR_VL_SALDO")),
"0.00"), 8, " ", False)
Else
Printer.Print Comp_Str(Format(RS_TR("TR_DT_PART"),
"DD/MM/YYYY"), 12, " ", True) _
& Comp_Str(RS_TR("TR_KM_PART"), 9, " ", True) _
& Comp_Str(RS_TR("TR_MUN"), 15, " ", True) &
Space(1) _
& Comp_Str(RS_TR("TR_UF"), 3, " ", True) _
& Comp_Str(IIf(IsNull(RS_TR("TR_DT_CHEG")) = True
, " ", Format(RS_TR("TR_DT_CHEG"), "DD/MM/YYYY")), 11, " ", True) _
-14-

new 2

quarta-feira, 6 de julho de 2011 12:42

700
701

& Comp_Str(RS_TR("TR_KM_CHEG"), 9, " ", True) _


& Comp_Str(RS_TR("TR_CID_DEST"), 15, " ", True) &
Space(1) _

702
703

& Comp_Str(RS_TR("TR_UF_DEST"), 3, " ", True) _


& Comp_Str(Format(Val_Sgt(RS_TR("TR_VL_ADI")),
"0.00"), 8, " ", False) & Space(1) _

704

& Comp_Str(Format(Val_Sgt(RS_TR("TR_VL_SALDO")),
"0.00"), 8, " ", False)

705
706
707
708
709

710

End If
ContLn = ContLn + 1
End If

'---------------------------------------------------------------------------------TOTAIS
TOT_FRETE = TOT_FRETE + Val_Sgt(RS_TR("TR_VL_ADI")) + Val_Sgt(
RS_TR("TR_VL_SALDO"))

711
712

X_KM_CHEIO = X_KM_CHEIO + (RS_TR("TR_KM_CHEG") - RS_TR(


"TR_KM_PART"))

713
714
715
716
717
718
719
720
721
722
723
724

If RS_TR.AbsolutePosition = 1 Then
X_KM_VAZIO = RS_TR("TR_KM_PART") - RS("AC_SAI_KM")
Else
X_KM_VAZIO = X_KM_VAZIO + RS_TR("TR_KM_PART") - ODO_CHEG_ANT
End If
ODO_CHEG_ANT = Val_Sgt(RS_TR("TR_KM_CHEG"))
X_TOT_AGENC = X_TOT_AGENC + Val_Sgt(RS_TR("TR_DESP_AG"))
X_BASE_COMIS = X_BASE_COMIS + Val_Sgt(RS_TR("TR_VLR_BASE_COMISS"))
'-----------------------------------------------------------------------------------

725
726
727
728
729

RS_TR.MoveNext
Loop
End If '--------------------------------------------------------- \
TRECHOS

730
731
732
733
734
735
736
737
738
739
740
741
742
743
744

'------------------------------------------- IMPRIME TOTAIS


X_KM_RODADOS = (X_KM_VAZIO + X_KM_CHEIO)
If X_LITROS > 0 Then
X_Custo_MED_L = X_TOT_VLR_L / X_LITROS
'==================== CUSTO MDIO TOTAL POR LITRO
X_CONS_MED_L = Val_Sgt(X_KM_RODADOS) / Val_Sgt(X_LITROS)
'============================ CONSUMO MDIO TOTAL POR LITRO
End If

If Val_Sgt(X_KM_RODADOS) > 0 Then


X_BASE_COMIS = X_BASE_COMIS - X_TOT_PED
X_COMISSAO = (X_BASE_COMIS * RS("AC_PERC_COMISS")) / 100
'========================== CUSTO DO KM RODADO
-15-

new 2

745
746
747
748
749

quarta-feira, 6 de julho de 2011 12:42

X_Custo_KM_ROD = (Val_Sgt(X_TOT_DESP) + Val_Sgt(X_TOT_ADI) _


+ Val_Sgt(X_TOT_AGENC) + Val_Sgt(
X_TOT_PED) + Val_Sgt(X_TOT_VLR_L) + Val_Sgt(X_COMISSAO)) / Val_Sgt(X_KM_RODADOS)
End If
X_SALDO_VIAG = Val_Sgt(TOT_FRETE) - (Val_Sgt(X_TOT_DESP) + Val_Sgt(
X_TOT_VLR_L) + Val_Sgt(X_TOT_AGENC) + Val_Sgt(X_TOT_PED) + Val_Sgt(X_COMISSAO))

750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783

If Val_Sgt(TOT_FRETE) > 0 Then


PERC_GANHO_LIQ = (Val_Sgt(X_SALDO_VIAG) / Val_Sgt(TOT_FRETE)) * 100
End If

'--------------------------------------------------------------------------If opt_sint.Value = True Then


If ContLn + 10 > LnMax Then
If opt_tela.Value = True Then
For I = ContLn + 1 To LnMax + 3
Print #1,
ContLn = ContLn + 1
Next
Else
Printer.NewPage
End If
ContLn = 0
End If
If ContLn = 0 Then
If opt_tela.Value = True Then
Print #1, Comp_Str("RELATRIO SINTTICO PARA ACOMPANHAMENTO
DE VIAGEM", 96, " ", True, True)
Else
Printer.Print Comp_Str("RELATRIO SINTTICO PARA
ACOMPANHAMENTO DE VIAGEM", 96, " ", True, True)
End If
ContLn = ContLn + 1
End If
X_SPACE = Space(5)
If opt_tela.Value = True Then
Print #1, String(96, "=")
Print #1, Comp_Str("VIAGEM :" & RS("ac_numero"), 15, " ", True) &
Space(1) _

784

& Comp_Str("VECULO:" & RS("AC_VEICU"), 16, " ", True) &


Space(1) _

785

& Comp_Str("CONDUTOR:" & RS("mt_nome"), 40, " ", True) &


Space(1) _

786

& "SITUAO:" & IIf(RS("AC_SIT") = 1, "1 - ABERTA", "2 FECHADA")

787
788
789
790
791

Print #1,
Else
Printer.Print String(96, "=")
Printer.Print Comp_Str("VIAGEM :" & RS("ac_numero"), 15, " ",
True) & Space(1) _
-16-

new 2

quarta-feira, 6 de julho de 2011 12:42

792

& Comp_Str("VECULO:" & RS("AC_VEICU"), 16, " ", True) &


Space(1) _

793

& Comp_Str("CONDUTOR:" & RS("mt_nome"), 40, " ", True) &


Space(1) _

794

& "SITUAO:" & IIf(RS("AC_SIT") = 1, "1 - ABERTA", "2 FECHADA")

795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833

Printer.Print
End If
ContLn = ContLn + 3
Else
X_SPACE = Space(0)
If opt_tela.Value = True Then
Print #1,
Print #1, X_SPACE & HIF8
Else
Printer.Print
Printer.Print X_SPACE & HIF8
End If
ContLn = ContLn + 2
End If
If opt_tela.Value = True Then
Print #1, X_SPACE & "TOTAL DE KM RODADOS ..........:" & X_KM_RODADOS
& "
VAZIO: " & X_KM_VAZIO & "
CHEIO: " & X_KM_CHEIO
Print #1, X_SPACE & "LITROS DE COMBUSTVEL ........:" & X_LITROS
Print #1, X_SPACE & "CONSUMO MDIO TOTAL POR LITRO.:" & Format(
X_CONS_MED_L, "0.00")
Print #1, X_SPACE & "CUSTO MDIO GERAL POR LITRO ..:" & Format(
X_Custo_MED_L, "0.00")
Print #1, X_SPACE & "CUSTO DO KM RODADO ...........:" & Format(
X_Custo_KM_ROD, "0.00")
Print #1, X_SPACE & "% DE GANHO LIQUIDO ...........:" & Format(
PERC_GANHO_LIQ, "0.00")
Print #1, X_SPACE & "SALDO DA VIAGEM ..............:" & Format(
X_SALDO_VIAG, "0.00")
'Print #1, "SALDO COM CONDUTOR ...........:"
Else
Printer.Print X_SPACE & "TOTAL DE KM RODADOS ..........:" &
X_KM_RODADOS & "
VAZIO: " & X_KM_VAZIO & "
CHEIO: " & X_KM_CHEIO
Printer.Print X_SPACE & "LITROS DE COMBUSTVEL ........:" & X_LITROS
Printer.Print X_SPACE & "CONSUMO MDIO TOTAL POR LITRO.:" & Format(
X_CONS_MED_L, "0.00")
Printer.Print X_SPACE & "CUSTO MDIO GERAL POR LITRO ..:" & Format(
X_Custo_MED_L, "0.00")
Printer.Print X_SPACE & "CUSTO DO KM RODADO ...........:" & Format(
X_Custo_KM_ROD, "0.00")
Printer.Print X_SPACE & "% DE GANHO LIQUIDO ...........:" & Format(
PERC_GANHO_LIQ, "0.00")
Printer.Print X_SPACE & "SALDO DA VIAGEM ..............:" & Format(
X_SALDO_VIAG, "0.00")
End If
'Print #1, String(96, "=")
ContLn = ContLn + 7
RS.MoveNext
-17-

new 2

834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873

quarta-feira, 6 de julho de 2011 12:42

Loop

If opt_tela.Value = True Then


Close #1
RTxt.LoadFile CamT, 1
RTxt.Font.Name = "Courier New"
RTxt.Font.Size = 10
X = Frm_acomp_Viagem.Width - 200
If X < 50 Then
X = 50
End If
RTxt.Width = X
Y = Frm_acomp_Viagem.Height - 500
If Y < 50 Then
Y = 50
End If
RTxt.Height = Y
RTxt.Left = 75
RTxt.Top = 50
RTxt.RightMargin = 20000
RTxt.Visible = True
Fra_Rel.Visible = False
Else
Printer.EndDoc
End If
Else
RS.Close
MsgBox "No ha dados h serem Listados", vbExclamation, "AVISO"
Exit Sub
End If

End Sub

-18-

You might also like