Você está na página 1de 43

Frm_acomp_Viagem - 1 Dim Erro As String Sub Habilita(ByVal Habilita As Boolean) ' msk_data.Enabled = Habilita msk_dt_cheg.Enabled = Habilita cbo_saida_uf.

Enabled = Habilita cbo_saida_cid.Enabled = Habilita txt_saida_odo.Enabled = Habilita cbo_veicu.Enabled = Habilita cbo_dest_uf.Enabled = Habilita cbo_dest_cid.Enabled = Habilita txt_dest_odo.Enabled = Habilita cbo_condutor.Enabled = Habilita msk_hr_cheg.Enabled = Habilita msk_hr_sai.Enabled = Habilita SSTab.Enabled = Habilita CMD_INCLUIR_AC.Enabled = Habilita End Sub Function InCluir_VIAGEM() As Boolean On Error GoTo trata_erro Dim X_RETORNA As Boolean Dim xSQL As String Dim X_SIT As Integer Erro = "N" Critica If Erro = "S" Then Screen.MousePointer = 0 InCluir_VIAGEM = False Exit Function 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 '=================== Db_ADO.BeginTrans ' ABRE TRANSAO '=================== xSQL = ""

' x_ultimo = lst_trechos.ListItems.Count ' If x_ultimo > 0 Then ' If Trim(cbo_dest_uf.Text) = lst_trechos.ListItems(x_ultimo).Text And Trim(cbo_dest_cid.Te xt) = lst_trechos.ListItems(x_ultimo).SubItems(1) Then ' If MsgBox("O LTIMO Trecho Lanado confere com o Destino Final da Viagem" & vbNewLine _ ' & "Confirme para Marcar a Viagem como FECHADA " & vbNewLine _ ' & "Caso Contrrio a Viagem continuar ABERTA.", vbYesNo + vbDefaultButton2 + vbQue stion, "ATENO") = vbYes Then ' ' X_SIT = 2 ' ' Else ' ' X_SIT = 1 ' End If ' End If ' End If If CMD_INCLUIR_AC.Caption = "Incluir" Then '---------------------------------------------------- monta INSERT xSQL = "DECLARE @ident int;" _ & " INSERT INTO GT_AC_VIAGEM ( AC_DT_PARTI, " _ & "AC_DT_CHEG, " _ & "AC_SAI_UF, " _ & "AC_SAI_MUN, " _ & "AC_SAI_KM, " _ VIAGEM

Frm_acomp_Viagem - 2 & & & & & & & & " values (" & & alor(msk_dt_cheg.Text, "D", False)) & "," & & & & "'," _ & & "'," _ & & & & .Text & "'") & "," xSQL = xSQL & & "AC_DEST_UF, " _ "AC_DEST_MUN, " _ "AC_DEST_KM, " _ "AC_VEICU, " _ "AC_hr_sai, " _ "AC_hr_cheg, AC_PERC_COMISS," _ "AC_SIT,AC_CONDUTOR )" _ BPRCorrige_Valor(msk_data.Text, "D", False) & "," _ IIf(msk_dt_cheg.Text = " / / ", "Null", BPRCorrige_V _ "'" & cbo_saida_uf.Text & "'," _ "'" & cbo_saida_cid.Text & "'," _ Val_Sgt(txt_saida_odo.Text) & "," _ "'" & IIf(cbo_dest_uf.Text = "", " ", cbo_dest_uf.Text) & "'" & IIf(cbo_dest_cid.Text = "", " ", cbo_dest_cid.Text) Val_Sgt(txt_dest_odo.Text) & "," _ "'" & cbo_veicu.Text & "'," _ "'" & msk_hr_sai.Text & "'," _ IIf(msk_hr_cheg.Text = " : ", "Null", "'" & msk_hr_cheg Val_Sgt(txt_perc_comiss.Text) & "," _ "'1','" & X_condutor & "');"

xSQL = xSQL & " set @ident = SCOPE_IDENTITY(); " '------- (MTO IMPORTANTE) PARA PODER EXECU TAR AS OUTRAS Else '========================================================================================== ================ UPDATE x_Erro = False '--------------------------------------------------------------------------- DELETA DESPESA S Sql = "DELETE FROM GT_AC_DESP WHERE DP_NUM_AC=" & Val_Sgt(TXT_NUMERO.Text) Db_ADO.Execute Sql, REC_aff If REC_aff <> Val_Sgt(lbl_gd_desp.Caption) Then x_Erro = True End If '--------------------------------------------------------------------------- DELETA ABASTEC IMENTOS Sql = "DELETE FROM GT_AC_ABAST WHERE AB_NUM_AC=" & Val_Sgt(TXT_NUMERO.Text) Db_ADO.Execute Sql, REC_aff If REC_aff <> Val_Sgt(lbl_gd_abast.Caption) Then x_Erro = True End If '--------------------------------------------------------------------------- DELETA TRECHOS Sql = "DELETE FROM GT_AC_TRECHOS WHERE TR_NUM_AC=" & Val_Sgt(TXT_NUMERO.Text) Db_ADO.Execute Sql, REC_aff If REC_aff <> Val_Sgt(lbl_gd_trechos) Then x_Erro = True End If '--------------------------------------------------------------------------- DELETA ADIANTA MENTOS Sql = "DELETE FROM GT_AC_ADIantamento WHERE AD_NUM_AC=" & Val_Sgt(TXT_NUMERO.Text) Db_ADO.Execute Sql, REC_aff If REC_aff <> Val_Sgt(lbl_gd_ADI.Caption) Then x_Erro = True End If '--------------------------------------------------------------------------- DELETA PEDGIO S Sql = "DELETE FROM GT_AC_PEDAGIO WHERE PD_NUM_AC=" & Val_Sgt(TXT_NUMERO.Text) Db_ADO.Execute Sql, REC_aff If REC_aff <> Val_Sgt(lbl_gd_ped) Then x_Erro = True End If '------------------------------------------------------------------------------------------------- ALTERA VIAGEM Sql = "UPDATE GT_AC_VIAGEM SET AC_DT_PARTI=" & BPRCorrige_Valor(msk_data.Text, "D", False) & "," _

Frm_acomp_Viagem - 3 & "AC_DT_CHEG =" & IIf(msk_dt_cheg.Text = " / / ", "null", BPRCorrige_Valor(msk_dt_cheg.Text, "D", False)) & "," _ & "AC_SAI_UF =" & "'" & cbo_saida_uf.Text & "'," _ & "AC_SAI_MUN ='" & cbo_saida_cid.Text & "'," _ & "AC_SAI_KM =" & Val_Sgt(txt_saida_odo.Text) & "," _ & "AC_DEST_UF ='" & IIf(cbo_dest_uf.Text = "", " ", cbo_dest_uf .Text) & "'," _ & "AC_DEST_MUN='" & IIf(cbo_dest_cid.Text = "", " ", cbo_dest_c id.Text) & "'," _ & "AC_DEST_KM =" & Val_Sgt(txt_dest_odo.Text) & "," _ & "AC_VEICU ='" & cbo_veicu.Text & "'," _ & "AC_HR_SAI ='" & msk_hr_sai.Text & "'," _ & "AC_PERC_COMISS =" & Val_Sgt(txt_perc_comiss.Text) & "," _ & "AC_HR_cheg =" & IIf(msk_hr_cheg.Text = " : ", "Null", "'" & msk_hr_cheg.Text & "'") & "," _ & "AC_CONDUTOR='" & X_condutor & "' " _ & "WHERE AC_NUMERO=" & Val_Sgt(TXT_NUMERO.Text) & ";" Db_ADO.Execute Sql, REC_aff If REC_aff = 0 Then x_Erro = True End If If x_Erro = True Then Db_ADO.RollbackTrans InCluir_VIAGEM = False Exit Function End If '========================================================================================== =============== FECHA UPDATE End If ' TABELINHAS FILHAS SEMPRE INSERT '--------------------------------------------------------------------- MONTA INSERT DESPESAS For I = 1 To lst_desp.ListItems.Count xSQL = xSQL & " INSERT INTO GT_AC_DESP (DP_KEY, " _ & "DP_NUM_AC, " _ & "DP_DATA, " _ & "DP_HORA, " _ & "DP_VALOR, " _ & "DP_AUTORIZADO, " _ & "DP_FPGTO, " _ & "DP_DESC)" _ & " VALUES (" _ & I & "," _ & " @ident , " _ & BPRCorrige_Valor(lst_desp.ListItems(I).Text, "D", False) & ", " _ & "'" & lst_desp.ListItems(I).SubItems(1) & "', " _ & Val_Sgt(lst_desp.ListItems(I).SubItems(2)) & ", " _ & "'" & Trim(lst_desp.ListItems(I).SubItems(3)) & "', " _ & "'" & Trim(lst_desp.ListItems(I).SubItems(4)) & "', " _ & "'" & Trim(lst_desp.ListItems(I).SubItems(5)) & "');" Next I '--------------------------------------------------------------------- MONTA INSERT abastecimen tos For I = 1 To lst_abast.ListItems.Count xSQL = xSQL & " INSERT INTO GT_AC_ABAST (AB_KEY, " _ & "AB_NUM_AC, " _ & "AB_DATA, " _ & "AB_HORA, " _ & "AB_UF," _ & "AB_MUN," _ & "AB_QTDE_L, " _ & "AB_TOTAL, " _ & "AB_FPGTO) " _ & " VALUES (" _ & I & "," _ & " @ident , " _ & BPRCorrige_Valor(lst_abast.ListItems(I).Text, "D", False) & " , " _ & "'" & lst_abast.ListItems(I).SubItems(1) & "', " _ & "'" & lst_abast.ListItems(I).SubItems(2) & "', " _ & "'" & Trim(lst_abast.ListItems(I).SubItems(3)) & "', " _ & "'" & Trim(lst_abast.ListItems(I).SubItems(4)) & "', " _

Frm_acomp_Viagem - 4 & "'" & Trim(lst_abast.ListItems(I).SubItems(5)) & "'," _ & "'" & Trim(lst_abast.ListItems(I).SubItems(6)) & "');" Next I '--------------------------------------------------------------------- MONTA INSERT TRECHOS For I = 1 To lst_trechos.ListItems.Count If Trim(lst_trechos.ListItems(I).SubItems(13)) <> "" Then X = InStr(1, lst_trechos.ListItems(I).SubItems(13), " - ") If X > 0 Then x_PARC = Mid(lst_trechos.ListItems(I).SubItems(13), 1, X - 1) End If End If xSQL = xSQL & " INSERT INTO GT_AC_TRECHOS (TR_KEY, " _ & "TR_NUM_AC, " _ & "TR_UF, " _ & "TR_MUN, " _ & "TR_DT_PART, " _ & "TR_KM_PART," _ & "TR_UF_DEST, " _ & "TR_CID_DEST, " _ & "TR_DT_CHEG, " _ & "TR_KM_CHEG, " _ & "TR_VL_SALDO," _ & "TR_FPGTO_SALDO, " xSQL = xSQL & "TR_VL_ADI, " _ & "TR_FPGTO_ADI, " _ & "TR_PESO, " _ & "TR_AGENC, " _ & "TR_DESP_AG, " _ & "TR_vlr_base_comiss, " _ & "TR_FPAGTO_ag) " _ & " VALUES (" _ & I & "," _ & " @ident , " _ & BPRCorrige_Valor(lst_trechos.ListItems(I).Text, "D", False) & ", " _ & "'" & lst_trechos.ListItems(I).SubItems(1) & "', " _ & BPRCorrige_Valor(lst_trechos.ListItems(I).SubItems(2), "D", F alse) & "," _ & & & & alse) & "," _ & & & & & xSQL = xSQL & & & & & Next I '--------------------------------------------------------------------- MONTA INSERT ADIANTAMENT OS For I = 1 To lst_adi.ListItems.Count xSQL = xSQL & " INSERT INTO GT_AC_adiantamento(ad_KEY, " _ & "AD_NUM_AC, " _ & "AD_DATA, " _ & "AD_VLR, " _ & "AD_AUTORIZADO) " _ & " VALUES (" _ & I & "," _ & " @ident , " _ & BPRCorrige_Valor(lst_adi.ListItems(I).Text, "D", False) & ", " _ & lst_adi.ListItems(I).SubItems(1) & ", " _ & "'" & lst_adi.ListItems(I).SubItems(2) & "');" Next I '--------------------------------------------------------------------- MONTA INSERT PEDAGIOS For I = 1 To LST_PED.ListItems.Count Val_Sgt(lst_trechos.ListItems(I).SubItems(7)) & "," _ Val_Sgt(lst_trechos.ListItems(I).SubItems(8)) & "," _ "'" & Trim(lst_trechos.ListItems(I).SubItems(9)) & "'," _ Val_Sgt(lst_trechos.ListItems(I).SubItems(10)) & "," _ "'" & Trim(lst_trechos.ListItems(I).SubItems(11)) & "'," Val_Sgt(lst_trechos.ListItems(I).SubItems(12)) & "," _ Val_Sgt(x_PARC) & "," _ Val_Sgt(lst_trechos.ListItems(I).SubItems(14)) & "," _ Val_Sgt(lst_trechos.ListItems(I).SubItems(16)) & "," _ "'" & Trim(lst_trechos.ListItems(I).SubItems(15)) & "');" Val_Sgt(lst_trechos.ListItems(I).SubItems(3)) & ", " _ "'" & Trim(lst_trechos.ListItems(I).SubItems(4)) & "', " _ "'" & Trim(lst_trechos.ListItems(I).SubItems(5)) & "'," _ BPRCorrige_Valor(lst_trechos.ListItems(I).SubItems(6), "D", F

Frm_acomp_Viagem - 5 xSQL = xSQL & " INSERT INTO GT_AC_PEDAGIO(PD_KEY, " _ & "PD_NUM_AC, " _ & "PD_UF, " _ & "PD_MUN, " _ & "PD_DATA, " _ & "PD_VaLoR, " _ & "PD_fpgto) " _ & " VALUES (" _ & I & "," _ & " @ident , " _ & "'" & LST_PED.ListItems(I).Text & "', " _ & "'" & LST_PED.ListItems(I).SubItems(1) & "', " _ & BPRCorrige_Valor(LST_PED.ListItems(I).SubItems(2), "D", False ) & "," _ & LST_PED.ListItems(I).SubItems(3) & ", " _ & "'" & LST_PED.ListItems(I).SubItems(4) & "');" Next If CMD_INCLUIR_AC.Caption = "Alterar" Then xSQL = Replace(xSQL, "@ident", Val_Sgt(TXT_NUMERO.Text)) End If If xSQL <> "" Then Db_ADO.Execute xSQL, RegAt If RegAt = 0 Then Db_ADO.RollbackTrans InCluir_VIAGEM = False Else Db_ADO.CommitTrans InCluir_VIAGEM = True End If Else Db_ADO.CommitTrans InCluir_VIAGEM = True End If Exit Function 'Resume trata_erro: Db_ADO.RollbackTrans InCluir_VIAGEM = False If Err.Number = -2147217900 Then MsgBox "Sistema Desatualizado, por favor atualize!" & vbNewLine & "Seus dados No foram Gravados", vbCritical, "ATENO !!! " Else MsgBox Err.Number & Err.Description, vbCritical, "AVISO" End If End Function Sub TOTALIZA_RESUMO() '---------------- LIMPA LABELS DO RESUMO PRA GARANTIR! lbl_TOT_DESP.Caption = "0.00" lbl_tot_fat_desp.Caption = "0.00" lbl_tot_pago_desp.Caption = "0.00" lbl_tot_ABAST.Caption = "0.00" lbl_tot_fat_abast.Caption = "0.00" lbl_tot_pago_abast.Caption = "0.00" lbl_TOT_AG.Caption = "0.00" lbl_tot_fat_dp_agenc.Caption = "0.00" lbl_tot_pago_dp_agenc.Caption = "0.00" lbl_TOT_PEDs.Caption = "0.00" lbl_tot_pg_cli_ped.Caption = "0.00" lbl_tot_pg_cond_ped.Caption = "0.00" LBL_TOT_ADI.Caption = "0.00" lbl_TOT_FRT.Caption = "0.00" lbl_tot_fat_frt.Caption = "0.00" lbl_tot_pago_frt.Caption = "0.00" lbl_saldo_cond.Caption = "0.00" lbl_res_custo_km_rod.Caption = "0.00" lbl_res_geral_p_litro.Caption = "0.00" lbl_res_km_rod.Caption = "0" lbl_res_litros.Caption = "0"

Frm_acomp_Viagem - 6 lbl_res_media_p_litro.Caption = "0" lbl_saldo_cond.Caption = "0.00" lbl_perc_ganho_liq.Caption = "0.00" lbl_res_adi.Caption = "0.00" lbl_res_saldo.Caption = "0.00" LBL_KM_VAZIO.Caption = "0" lbl_km_cheio.Caption = "0" '--------------------------- CARREGA GRID despesas x_tot = 0 X_Fat = 0 X_Pago = 0 For I = 1 To lst_desp.ListItems.Count x_tot = x_tot + lst_desp.ListItems(I).SubItems(2) If Mid(lst_desp.ListItems(I).SubItems(4), 1, 8) = "Faturado" Then X_Fat = X_Fat + lst_desp.ListItems(I).SubItems(2) Else X_Pago = X_Pago + lst_desp.ListItems(I).SubItems(2) End If Next lbl_TOT_DESP.Caption = Format(x_tot, "0.00") lbl_tot_fat_desp.Caption = Format(X_Fat, "0.00") lbl_tot_pago_desp.Caption = Format(X_Pago, "0.00") '--------------------------- CARREGA GRID ABASTECIMENTOS x_tot = 0 X_Fat = 0 X_Pago = 0 X_Litros = 0 For I = 1 To lst_abast.ListItems.Count x_tot = x_tot + lst_abast.ListItems(I).SubItems(5) If Mid(lst_abast.ListItems(I).SubItems(6), 1, 8) = "Faturado" Then X_Fat = X_Fat + lst_abast.ListItems(I).SubItems(5) Else X_Pago = X_Pago + lst_abast.ListItems(I).SubItems(5) End If '--------------------------------------------------------------------- resumo litros de com bustivel X_Litros = X_Litros + Val_Sgt(lst_abast.ListItems(I).SubItems(4)) Next lbl_tot_ABAST.Caption = Format(x_tot, "0.00") lbl_tot_fat_abast.Caption = Format(X_Fat, "0.00") lbl_tot_pago_abast.Caption = Format(X_Pago, "0.00") lbl_res_litros.Caption = X_Litros '--------------------------------------------------------------- CARREGA GRID TRECHOS x_tot = 0 x_tot2 = 0 X_FAT_SALDO = 0 x_PAGO_ = 0 X_FAT_AG = 0 x_PAGO_AG = 0 x_PAGO_adi = 0 X_OUTROS = 0 X_KMS_RODADOS = 0 x_vazio_km = 0 X_BASE_COMISS = 0 For I = 1 To lst_trechos.ListItems.Count x_tot = x_tot + Val_Sgt(lst_trechos.ListItems(I).SubItems(14)) ' agenciamento desp x_tot2 = x_tot2 + Val_Sgt(lst_trechos.ListItems(I).SubItems(8)) + Val_Sgt(lst_trechos.ListI tems(I).SubItems(10)) '--------------------------------------------------------------------------- saldo FAT If lst_trechos.ListItems(I).SubItems(9) = "Faturado" Or lst_trechos.ListItems(I).SubItems(9 ) = "Depsito Bancrio" Then

Frm_acomp_Viagem - 7 X_FAT_SALDO = X_FAT_SALDO + Val_Sgt(lst_trechos.ListItems(I).SubItems(8)) X_OUTROS = X_OUTROS + Val_Sgt(lst_trechos.ListItems(I).SubItems(8)) Else X_FAT_SALDO = X_FAT_SALDO + Val_Sgt(lst_trechos.ListItems(I).SubItems(8)) x_PAGO_ = x_PAGO_ + Val_Sgt(lst_trechos.ListItems(I).SubItems(8)) End If '--------------------------------------------------------------------------- ADIANTAMENTO If lst_trechos.ListItems(I).SubItems(11) = "Faturado" Or lst_trechos.ListItems(I).SubItems( 11) = "Depsito Bancrio" Then X_FAT_ADI = X_FAT_ADI + Val_Sgt(lst_trechos.ListItems(I).SubItems(10)) X_OUTROS = X_OUTROS + Val_Sgt(lst_trechos.ListItems(I).SubItems(10)) Else x_PAGO_ = x_PAGO_ + Val_Sgt(lst_trechos.ListItems(I).SubItems(10)) X_FAT_ADI = X_FAT_ADI + Val_Sgt(lst_trechos.ListItems(I).SubItems(10)) End If '--------------------------------------------------------------------------- DESP AGENCIAME NTO If Mid(lst_trechos.ListItems(I).SubItems(15), 1, 18) = "Pago pelo Condutor" Then x_PAGO_AG = x_PAGO_AG + Val_Sgt(lst_trechos.ListItems(I).SubItems(14)) Else X_FAT_AG = X_FAT_AG + Val_Sgt(lst_trechos.ListItems(I).SubItems(14)) End If X_KMS_RODADOS = X_KMS_RODADOS + (Val_Sgt(lst_trechos.ListItems(I).SubItems(7)) - Val_Sgt(ls t_trechos.ListItems(I).SubItems(3))) If I = 1 Then x_vazio_km = Val_Sgt(lst_trechos.ListItems(I).SubItems(3)) - Val_Sgt(txt_saida_odo.Text ) Else x_vazio_km = x_vazio_km + Val_Sgt(lst_trechos.ListItems(I).SubItems(3)) - Val_Sgt(lst_t rechos.ListItems(I - 1).SubItems(7)) End If X_BASE_COMISS = X_BASE_COMISS + Val_Sgt(lst_trechos.ListItems(I).SubItems(16)) Next x_LAST = lst_trechos.ListItems.Count If Val_Sgt(txt_dest_odo.Text) > 0 And x_LAST > 0 Then x_vazio_km = x_vazio_km + (Val_Sgt(txt_dest_odo.Text) - Val_Sgt(lst_trechos.ListItems(x_LAS T).ListSubItems(7))) End If lbl_res_adi.Caption = Format(X_FAT_ADI, "0.00") lbl_res_saldo.Caption = Format(X_FAT_SALDO, "0.00") lbl_TOT_AG.Caption = Format(x_tot, "0.00") lbl_TOT_FRT.Caption = Format(x_tot2, "0.00") lbl_tot_fat_frt.Caption = Format(X_OUTROS, "0.00") lbl_tot_pago_frt.Caption = Format(x_PAGO_, "0.00") lbl_tot_fat_dp_agenc.Caption = Format(X_FAT_AG, "0.00") lbl_tot_pago_dp_agenc.Caption = Format(x_PAGO_AG, "0.00") '--------------------------- CARREGA GRID ADIANTAMENTOS x_tot = 0 For I = 1 To lst_adi.ListItems.Count x_tot = x_tot + lst_adi.ListItems(I).SubItems(1) ' agenciamento desp Next LBL_TOT_ADI.Caption = Format(x_tot, "0.00") '--------------------------- CARREGA GRID PEDAGIOS x_tot = 0 x_CLI = 0 X_COND = 0 For I = 1 To LST_PED.ListItems.Count x_tot = x_tot + LST_PED.ListItems(I).SubItems(3) '--------------------------------------------------------------------- FRETE FAT If Mid(LST_PED.ListItems(I).SubItems(4), 11, 3) = "Cli" Then

Frm_acomp_Viagem - 8 x_CLI = x_CLI + LST_PED.ListItems(I).SubItems(3) Else X_COND = X_COND + LST_PED.ListItems(I).SubItems(3) End If Next lbl_TOT_PEDs.Caption = Format(x_tot, "0.00") lbl_tot_pg_cli_ped.Caption = Format(x_CLI, "0.00") lbl_tot_pg_cond_ped.Caption = Format(X_COND, "0.00") '----------------------------------------------------------------------------- saldo com condut or X_REC_MOT = Val_Sgt(LBL_TOT_ADI.Caption) + Val_Sgt(lbl_tot_pago_frt) X_DESP_MOT = Val_Sgt(lbl_tot_pago_desp) + Val_Sgt(lbl_tot_pago_abast) + Val_Sgt(lbl_tot_pago_dp _agenc) + Val_Sgt(lbl_tot_pg_cond_ped) lbl_saldo_cond.Caption = Format(X_REC_MOT - X_DESP_MOT, "0.00") '----------------------------------------------------------------------------' ---------------------------------------- RESUMO KMS RODADOS If lst_trechos.ListItems.Count > 0 Then lbl_res_km_rod.Caption = x_vazio_km + X_KMS_RODADOS LBL_KM_VAZIO.Caption = x_vazio_km lbl_km_cheio.Caption = X_KMS_RODADOS End If '-----------------------------------------------------------------------------'------------------------------------------------------------ CUSTO MEDIO GERAL POR LITRO If Val_Sgt(lbl_res_litros.Caption) > 0 Then lbl_res_geral_p_litro.Caption = Format(Val_Sgt(lbl_tot_ABAST.Caption) / Val_Sgt(lbl_res_lit ros.Caption), "0.00") End If '-----------------------------------------------------------'------------------------------------------------------------ CONSUMO MEDIO GERAL POR LITRO If Val_Sgt(lbl_res_litros.Caption) > 0 Then lbl_res_media_p_litro.Caption = Format(Val_Sgt(lbl_res_km_rod.Caption) / Val_Sgt(lbl_res_li tros.Caption), "0.00") End If '-----------------------------------------------------------'------------------------------------------------------------ custo do km rodado If Val_Sgt(lbl_res_km_rod.Caption) > 0 Then lbl_res_custo_km_rod.Caption = Format((Val_Sgt(lbl_TOT_DESP.Caption) + Val_Sgt(lbl_tot_ABAS T.Caption) _ + Val_Sgt(lbl_TOT_AG.Caption) + Val_Sgt(lbl_TOT_PEDs.C aption) + Val_Sgt(LBL_TOT_ADI.Caption) + Val_Sgt(lbl_comiss.Caption)) / Val_Sgt(lbl_res_km_rod.Capt ion), "0.00") End If '-----------------------------------------------------------'------------------------------------------------------------------------------------------calc ulo comisso 'If cbo_veicu.Text <> "" Then 'Dim RS As ADODB.Recordset 'Sql = "SELECT VI_PERC_COMISS from gt_veicu where vi_placa ='" & cbo_veicu.Text & "'" 'Set RS = New ADODB.Recordset 'RS.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly 'If RS.RecordCount > 0 Then x_Perc = Val_Sgt(txt_perc_comiss.Text) txt_vlr_base.Text = Format(Val_Sgt(X_BASE_COMISS) - Val_Sgt(lbl_TOT_PEDs.Caption), "0.0 0") 'If VAL_SGT(lbl_TOT_FRT.Caption) > 0 Then 'x_liq = VAL_SGT(lbl_TOT_FRT.Caption) - (VAL_SGT(lbl_TOT_DESP.Caption) + VAL_SGT(lb l_tot_ABAST.Caption) _ + VAL_SGT(lbl_TOT_AG.Caption) + VAL_SGT(lbl_TOT_PEDs.Cap tion) + VAL_SGT(LBL_TOT_ADI.Caption)) lbl_reS_saldo_viag.Caption = Format(Val_Sgt(lbl_TOT_FRT.Caption) - (Val_Sgt(lbl_TOT _DESP.Caption) + Val_Sgt(lbl_tot_ABAST.Caption) + Val_Sgt(lbl_TOT_AG.Caption) + Val_Sgt(lbl_TOT_PED s.Caption) + Val_Sgt(lbl_comiss.Caption)), "0.00") '+ Val_Sgt(LBL_TOT_ADI.Caption) lbl_comiss.Caption = Format((Val_Sgt(txt_vlr_base.Text) * x_Perc) / 100, "0.00") lbl_ACERTO.Caption = Format(Val_Sgt(lbl_saldo_cond.Caption) - Val_Sgt(lbl_comiss.Ca ption), "0.00")

Frm_acomp_Viagem - 9 'End If 'End If 'End If '-------------------------------------------------------------------------------------------- % DE ganho LIQUIDO If Val_Sgt(lbl_TOT_FRT.Caption) > 0 Then lbl_perc_ganho_liq = Format((Val_Sgt(lbl_reS_saldo_viag.Caption) / Val_Sgt(lbl_TOT_FRT.Capt ion)) * 100, "0.00") End If '------------------------------------------------------------------------------------------End Sub Private Sub cbo_abast_forma_Change() ProcuraCbo cbo_abast_forma End Sub Private Sub cbo_abast_forma_GotFocus() Marca End Sub Private Sub CBO_ABAST_MUN_Change() ProcuraCbo CBO_ABAST_MUN End Sub Private Sub CBO_ABAST_MUN_GotFocus() Marca End Sub Private Sub CBO_ABAST_UF_Change() CBO_ABAST_MUN.Text = "" ProcuraCbo CBO_ABAST_UF End Sub Private Sub CBO_ABAST_UF_GotFocus() Marca End Sub Private Sub CBO_ABAST_UF_LostFocus() If CBO_ABAST_UF.Text <> "" Then CarregaCidade CBO_ABAST_MUN, CBO_ABAST_UF ' End If End Sub Private Sub cbo_adi_pagto_Change() 'ProcuraCbo cbo_adi_pagto End Sub Private Sub cbo_adi_pagto_GotFocus() Marca End Sub Private Sub cbo_condutor_Change() ProcuraCbo cbo_condutor End Sub Private Sub cbo_condutor_GotFocus() Marca End Sub Private Sub cbo_condutor_LostFocus() If cbo_condutor.Text <> "" Then X = InStr(1, cbo_condutor.Text, " | ") X_CONDU = Mid(cbo_condutor.Text, 1, X - 1) Sql = "select ac_numero from gt_ac_viagem where ac_CONDUTOR='" & X_CONDU & "' and 1" Set RS = New ADODB.Recordset RS.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly If RS.RecordCount > 0 Then

ac_sit=

Frm_acomp_Viagem - 10 If RS("ac_numero") = TXT_NUMERO Then Exit Sub MsgBox "No Possvel Lanar uma Nova Viagem para esse CONDUTOR" & vbNewLine _ & "Pois o mesmo possui uma Viagem em Andamento" & vbNewLine _ & "Viagem : " & RS("ac_numero"), vbExclamation, "AVISO" cbo_condutor.Text = "" cbo_condutor.SetFocus Exit Sub End If End If End Sub Private Sub cbo_cons_cond_Change() ProcuraCbo cbo_cons_cond End Sub Private Sub cbo_cons_cond_GotFocus() Marca End Sub Private Sub cbo_cons_pesq_Click() Dim RS As ADODB.Recordset xWhr = "" If msk_cons_dt1.Text <> " / / " And msk_cons_dt2.Text <> " If Not IsDate(msk_cons_dt1.Text) Then MsgBox "Primeira Data Invlida", vbCritical, "Ateno" msk_cons_dt1.SetFocus Exit Sub End If If Not IsDate(msk_cons_dt2.Text) Then MsgBox "Segunda Data Invlida", vbCritical, "Ateno" msk_cons_dt2.SetFocus Exit Sub End If If CDate(msk_cons_dt2.Text) < CDate(msk_cons_dt1.Text) Then MsgBox "Perodo Invlido", vbCritical, "Ateno" msk_cons_dt1.SetFocus Exit Sub End If / / " Then

xWhr = xWhr & " where ( AC_DT_PARTI between " & BPRCorrige_Valor(msk_cons_dt1.Text, "D", Tr ue) & " and " & BPRCorrige_Valor(msk_cons_dt2.Text, "D", True) & ") " End If If cbo_cons_veicu.Text <> "" Then If xWhr = "" Then xWhr = "Where " Else xWhr = xWhr & " AND " End If x_veicu = cbo_cons_veicu.Text xWhr = xWhr & " ( AC_VEICU='" & x_veicu & "') " End If If cbo_cons_cond.Text <> "" Then If xWhr = "" Then xWhr = "Where " Else xWhr = xWhr & " AND " End If X = InStr(1, cbo_cons_cond.Text, " | ") X_COND = Mid(cbo_cons_cond.Text, 1, X - 1) xWhr = xWhr & " ( AC_CONDUTOR='" & X_COND & "') " End If If cbo_cons_sit.Text <> "" Then If xWhr = "" Then xWhr = "Where " Else xWhr = xWhr & " AND " End If xWhr = xWhr & " ( AC_sit=" & Mid(cbo_cons_sit.Text, 1, 1) & ") " End If

Frm_acomp_Viagem - 11

Sql = "select AC_SAI_UF,AC_DT_PARTI,mt_nome," _ & " AC_SAI_MUN," _ & " AC_DEST_UF,ac_numero," _ & " AC_DEST_MUN," _ & " AC_VEICU," _ & " AC_CONDUTOR," _ & " AC_sit from GT_AC_VIAGEM inner join gt_motor on gt_ac_viagem.ac_condutor = gt_mot or.mt_cpf " _ & xWhr Set RS = New ADODB.Recordset RS.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly If RS.RecordCount > 0 Then RS.MoveLast RS.MoveFirst lst_cons_ac.ListItems.Clear Do While RS.EOF = False Set Litem = lst_cons_ac.ListItems.Add Litem.Text = RS("AC_numero") Litem.SubItems(1) = RS("AC_DT_PARTI") Litem.SubItems(2) = RS("AC_SAI_UF") & " - " & RS("AC_SAI_MUN") Litem.SubItems(3) = RS("AC_dest_UF") & " - " & RS("AC_dest_MUN") Litem.SubItems(4) = RS("mt_nome") Litem.SubItems(5) = RS("ac_veicu") Litem.SubItems(6) = IIf(RS("ac_sit") = 1, "1 - Aberta", "2 - Fechada") RS.MoveNext Loop Else lst_cons_ac.ListItems.Clear MsgBox "Nenhum Registro encontrado!", vbExclamation, "AVISO" Exit Sub End If End Sub Private Sub cbo_cons_sit_GotFocus() Marca End Sub Private Sub cbo_cons_veicu_Change() ProcuraCbo cbo_cons_veicu End Sub Private Sub cbo_cons_veicu_GotFocus() Marca End Sub Private Sub cbo_desp_pgto_Change() ProcuraCbo cbo_desp_pgto End Sub Private Sub cbo_desp_pgto_GotFocus() Marca End Sub Private Sub cbo_dest_cid_Change() ProcuraCbo cbo_dest_cid End Sub Private Sub cbo_dest_cid_GotFocus() Marca End Sub Private Sub cbo_ped_fpgto_Change() ProcuraCbo cbo_ped_fpgto End Sub Private Sub cbo_ped_fpgto_GotFocus() Marca End Sub

Frm_acomp_Viagem - 12 Private Sub CBO_PED_MUN_Change() ProcuraCbo CBO_PED_MUN End Sub Private Sub CBO_PED_MUN_GotFocus() Marca End Sub Private Sub CBO_PED_UF_Change() CBO_PED_MUN.Text = "" ProcuraCbo CBO_PED_UF End Sub Private Sub CBO_PED_UF_GotFocus() Marca End Sub Private Sub CBO_PED_UF_LostFocus() CarregaCidade CBO_PED_MUN, CBO_PED_UF End Sub Private Sub cbo_Rel_Cond_Change() ProcuraCbo cbo_Rel_Cond End Sub Private Sub cbo_Rel_Cond_GotFocus() Marca End Sub Private Sub Cbo_Rel_Veic_Change() ProcuraCbo Cbo_Rel_Veic End Sub Private Sub Cbo_Rel_Veic_GotFocus() Marca End Sub Private Sub cbo_tch_ag_Change() ProcuraCbo cbo_tch_ag End Sub Private Sub cbo_tch_ag_GotFocus() Marca End Sub Private Sub cbo_tch_cid_Dest_Change() ProcuraCbo cbo_tch_cid_Dest End Sub Private Sub cbo_tch_fpgto_adi_Change() ProcuraCbo cbo_tch_fpgto_adi End Sub Private Sub cbo_tch_fpgto_adi_GotFocus() Marca End Sub Private Sub cbo_TCH_pgto_frete_saldo_Change() ProcuraCbo cbo_TCH_pgto_frete_saldo End Sub Private Sub cbo_TCH_pgto_frete_saldo_GotFocus() Marca End Sub Private Sub cbo_tch_uf_dest_Change() cbo_tch_cid_Dest.Text = "" ProcuraCbo cbo_tch_uf_dest End Sub

Frm_acomp_Viagem - 13 Private Sub cbo_tch_uf_dest_GotFocus() Marca End Sub Private Sub cbo_tch_uf_dest_LostFocus() If cbo_tch_uf_dest.Text <> "" Then CarregaCidade cbo_tch_cid_Dest, cbo_tch_uf_dest End If End Sub Private Sub CMD_ADI_CANC_Click() On Error GoTo trata_erro msk_adi_data.Text = " / txt_adi_vlr.Text = "" txt_adi_auto.Text = "" / "

msk_adi_data.SetFocus Exit Sub trata_erro: If Err = 5 Then Resume Next Else MsgBox Err.Description, vbCritical, "Erro" Exit Sub End If End Sub Private Sub CMD_CANC_AC_Click() On Error GoTo trata_erro If CMD_CANC_AC.Caption = "Cancelar" Then Rot_Voltar Else If Flg_Adi_Viag = True Then Screen.MousePointer = 0 If MsgBox("Voc fez Alteraes Referentes aos ADIANTAMENTOS que No Foram Confirmadas, Deseja Realmente cancelar essas Alteraes? Elas sero Perdidas" & _ vbNewLine & "Caso Contrrio Cancele e Confirme-as Antes No Boto '" & C MD_INCLUIR_AC.Caption & "'", vbQuestion + vbYesNo + vbDefaultButton2, "ATENO") = vbNo Then Exit Sub End If End If If Flg_Abast_Viag = True Then Screen.MousePointer = 0 If MsgBox("Voc fez Alteraes Referentes aos ABASTECIMENTOS que No Foram Confirmadas, Deseja Realmente cancelar essas Alteraes? Elas sero Perdidas" & _ vbNewLine & "Caso Contrrio Cancele e Confirme-as Antes No Boto '" & C MD_INCLUIR_AC.Caption & "'", vbQuestion + vbYesNo + vbDefaultButton2, "ATENO") = vbNo Then Exit Sub End If End If If Flg_Desp_Viag = True Then Screen.MousePointer = 0 If MsgBox("Voc fez Alteraes Referentes s DESPESAS que No Foram Confirmadas, Deseja Realmente cancelar essas Alteraes?" & vbNewLine & "Elas sero Perdidas" & _ vbNewLine & "Caso Contrrio Cancele e Confirme-as Antes No Boto '" & C MD_INCLUIR_AC.Caption & "'", vbQuestion + vbYesNo + vbDefaultButton2, "ATENO") = vbNo Then Exit Sub End If End If If Flg_PEd_Viag = True Then Screen.MousePointer = 0 If MsgBox("Voc fez Alteraes Referentes aos PEDGIOS que No Foram Confirmadas, Desej a Realmente cancelar essas Alteraes? Elas sero Perdidas" & _ vbNewLine & "Caso Contrrio Cancele e Confirme-as Antes No Boto '" & C MD_INCLUIR_AC.Caption & "'", vbQuestion + vbYesNo + vbDefaultButton2, "ATENO") = vbNo Then Exit Sub End If End If If Flg_Trecho_Viag = True Then

Frm_acomp_Viagem - 14 Screen.MousePointer = 0 If MsgBox("Voc fez Alteraes Referentes aos TRECHOS que No Foram Confirmadas, Deseja Realmente cancelar essas Alteraes? Elas sero Perdidas" & _ vbNewLine & "Caso Contrrio Confirme-as Antes No Boto '" & CMD_INCLUIR _AC.Caption & "'", vbQuestion + vbYesNo + vbDefaultButton2, "ATENO") = vbNo Then Exit Sub End If End If Flg_Desp_Viag = False Flg_Abast_Viag = False Flg_Trecho_Viag = False Flg_PEd_Viag = False Flg_Adi_Viag = False msk_data.Text = " / / " msk_dt_cheg.Text = " / / msk_hr_cheg.Text = " : " msk_hr_sai.Text = " : " cbo_saida_uf.Text = "" txt_saida_odo.Text = "" cbo_saida_cid.Text = "" cbo_dest_uf.Text = "" cbo_dest_cid.Text = "" txt_dest_odo.Text = "" cbo_veicu.Text = "" cbo_condutor.Text = "" txt_vlr_base.Text = "" txt_perc_comiss.Text = "" LBL_DADOS_VEIC.Visible = False TXT_NUMERO.Text = "" TXT_NUMERO.Enabled = True CMD_desp_canc_Click CMD_CANC_ABAST_Click CMD_TCH_LIMPA_Click CMD_PED_CANC_Click CMD_ADI_CANC_Click '------------------------msk_data.Enabled = True '-------------------------fra_adi.Enabled = True CMD_REMOVE_ADI.Visible = True fra_DESP.Enabled = True CMD_DEL_desp.Visible = True FRA_ABASTE.Enabled = True CMD_DEL_abast.Visible = True FRA_TRECHOS.Enabled = True CMD_DEL_tch.Visible = True lst_trechos.Enabled = True FRA_PED.Enabled = True CMD_PED_REMOVE.Visible = True lst_abast.ListItems.Clear lst_desp.ListItems.Clear lst_trechos.ListItems.Clear LST_PED.ListItems.Clear lst_adi.ListItems.Clear cmd_NOVO.Enabled = True SSTab.Tab = 0 SSTab.Enabled = True "

Frm_acomp_Viagem - 15 '-------------- limpa aba resumo lbl_TOT_DESP.Caption = "0.00" lbl_tot_fat_desp.Caption = "0.00" lbl_tot_pago_desp.Caption = "0.00" lbl_tot_ABAST.Caption = "0.00" lbl_tot_fat_abast.Caption = "0.00" lbl_tot_pago_abast.Caption = "0.00" lbl_TOT_AG.Caption = "0.00" lbl_tot_fat_dp_agenc.Caption = "0.00" lbl_tot_pago_dp_agenc.Caption = "0.00" lbl_TOT_PEDs.Caption = "0.00" lbl_tot_pg_cli_ped.Caption = "0.00" lbl_tot_pg_cond_ped.Caption = "0.00" LBL_TOT_ADI.Caption = "0.00" lbl_TOT_FRT.Caption = "0.00" lbl_tot_fat_frt.Caption = "0.00" lbl_tot_pago_frt.Caption = "0.00" lbl_saldo_cond.Caption = "0.00" lbl_res_custo_km_rod.Caption = "0.00" lbl_res_geral_p_litro.Caption = "0.00" lbl_res_km_rod.Caption = "0.00" lbl_res_litros.Caption = "0.00" lbl_res_media_p_litro.Caption = "0.00" lbl_saldo_cond.Caption = "0.00" lbl_perc_ganho_liq.Caption = "0.00" lbl_res_adi.Caption = "0.00" lbl_res_saldo.Caption = "0.00" LBL_KM_VAZIO.Caption = "0.00" lbl_gd_abast.Caption = "" lbl_gd_ADI.Caption = "" lbl_gd_desp.Caption = "" lbl_gd_ped.Caption = "" lbl_gd_trechos.Caption = "" lbl_sit.Caption = "" CMD_INCLUIR_AC.Caption = "Incluir"

TXT_NUMERO.SetFocus Habilita False If CMD_CANC_AC.Caption = "Voltar" Then fra_FICHa.Visible = False fra_cons.Visible = True End If End If Exit Sub trata_erro: If Err = 5 Then Resume Next Else MsgBox Err.Description, vbCritical, "ERRO" Rot_Voltar End If End Sub Private Sub cmd_FEXAR_Click() If MsgBox("Deseja Realmente ENCERRAR a Viagem" & vbNewLine & " - Alterao Irreversv el - ", vbQuestion + vbYesNo + vbDefaultButton2, "ATENO") = vbYes Then If InCluir_VIAGEM = False Then If CMD_INCLUIR_AC.Caption = "Alterar" Then MsgBox "No foi possvel Alterar a Viagem", vbCritical, "AVISO" Else MsgBox "No foi possvel Incluir a Viagem", vbCritical, "AVISO" End If Exit Sub End If Sql = " UPDATE GT_AC_VIAGEM SET AC_SIT=2 , AC_LOG_USER='" & GdUsuario & "', AC_LOG_DTHR=" & BPRCorrige_Valor(Format(Now, "DD/MM/YYYY"), "DH", False) _ & " WHERE AC_NUMERO=" & Val_Sgt(TXT_NUMERO.Text) Db_ADO.Execute Sql, REC_aff

Frm_acomp_Viagem - 16 If REC_aff = 0 Then MsgBox "No foi possvel ENCERRAR a Viagem.", vbCritical, "ERRO" Exit Sub Else MsgBox "Viagem ENCERRADA!", vbExclamation, "SUCESSO!" X = Val_Sgt(TXT_NUMERO.Text) CMD_CANC_AC.Caption = "Limpar" CMD_CANC_AC_Click TXT_NUMERO.Text = X TXT_NUMERO_LostFocus Form_Load End If End If End Sub Private Sub cmd_NOVO_Click() TXT_NUMERO.Text = "NOVO" TXT_NUMERO.Enabled = False Habilita True CMD_CANC_AC.Caption = "Limpar" CMD_INCLUIR_AC.Caption = "Incluir" cmd_NOVO.Enabled = False lbl_sit.Caption = "1 - ABERTA" End Sub Private Sub cmd_adi_conf_Click() If IsDate(msk_adi_data.Text) = False Then MsgBox "Data Invlida", vbCritical, "AVISO" msk_adi_data.SetFocus Exit Sub End If If IsDate(msk_data.Text) = True Then If CDate(msk_adi_data.Text) < CDate(msk_data.Text) Then MsgBox "A Data do Abastecimento No pode Ser Inferior data da viagem", vbCritical, "A VISO" msk_adi_data.SetFocus Exit Sub End If End If If Val_Sgt(txt_adi_vlr.Text) = 0 Then MsgBox "Informe o Valor do Adiantamento", vbCritical, "AVISO" txt_adi_vlr.SetFocus Exit Sub End If Set Litem = lst_adi.ListItems.Add Litem.Text = msk_adi_data.Text Litem.SubItems(1) = Val_Sgt(txt_adi_vlr.Text) Litem.SubItems(2) = IIf(Trim(txt_adi_auto.Text) = "", " ", txt_adi_auto.Text) Flg_Adi_Viag = True CMD_ADI_CANC_Click End Sub Private Sub CMD_PED_CANC_Click() On Error GoTo trata_erro CBO_PED_MUN.Text = "" CBO_PED_UF.Text = "" MSK_PED_DT.Text = " / / " TXT_PED_VLR.Text = "" cbo_ped_fpgto.Text = ""

Frm_acomp_Viagem - 17 CBO_PED_UF.SetFocus Exit Sub trata_erro: If Err = 5 Then Resume Next Else MsgBox Err.Description, vbCritical, "Erro" Exit Sub End If End Sub Private Sub CMD_PED_CONF_Click() If CBO_PED_UF.Text = "" Then MsgBox "Informe a UF", vbCritical, "AVISO" CBO_PED_UF.SetFocus Exit Sub End If If CBO_PED_MUN.Text = "" Then MsgBox "Informe a Cidade", vbCritical, "AVISO" CBO_PED_MUN.SetFocus Exit Sub End If If IsDate(MSK_PED_DT.Text) = False Then MsgBox "Data invlida", vbCritical, "AVISO" MSK_PED_DT.SetFocus Exit Sub End If If msk_data.Text <> " / / " Then If CDate(MSK_PED_DT.Text) < CDate(msk_data.Text) Then MsgBox "A Data do Pedgio No pode Ser Inferior data da viagem", vbCritical, "AVISO" MSK_PED_DT.SetFocus Exit Sub End If End If If Val_Sgt(TXT_PED_VLR.Text) = 0 Then MsgBox "Informe O Valor do Pedgio", vbCritical, "AVISO" TXT_PED_VLR.SetFocus Exit Sub End If If cbo_ped_fpgto.Text = "" Then MsgBox "Informe a Forma de Pagamento", vbCritical, "AVISO" cbo_ped_fpgto.SetFocus Exit Sub End If Set Litem = LST_PED.ListItems.Add Litem.Text = CBO_PED_UF.Text Litem.SubItems(1) = CBO_PED_MUN.Text Litem.SubItems(2) = MSK_PED_DT.Text Litem.SubItems(3) = Format(Val_Sgt(TXT_PED_VLR.Text), "0.00") Litem.SubItems(4) = Trim(cbo_ped_fpgto.Text) Flg_PEd_Viag = True CMD_PED_CANC_Click End Sub Private Sub cmd_rel_ok_Click() X_Where = "" Dim Dim Dim Dim 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 As As As As Boolean Boolean Boolean Boolean

Imp_CAB_AD Imp_CAB_PD Imp_CAB_TR Imp_CAB_AB

Frm_acomp_Viagem - 18 Dim Imp_CAB_DP As Boolean 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, "D", True) & " and " & BPRCorrige_Valor(MSk_REL_DT2.Text, "D", True) & ") " End If If Val_Sgt(txt_Rel_viag.Text) > 0 Then If Trim(X_Where) = "" Then X_Where = " where " Else 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 = " 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 = " 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 = " and " End If X_Where = X_Where & " AC_SIT=2" End If Sql = "SELECT * FROM GT_AC_VIAGEM " & X_Where

Frm_acomp_Viagem - 19 Set RS = New ADODB.Recordset RS.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly If RS.RecordCount > 0 Then LnMax = 63 CamT = GdDir & "textosgt\REL_VIAGENS.Txt" If Dir(CamT) <> "" Then 'existe Kill CamT End If Open CamT For Output As #1 Do While RS.EOF = False If ContLn + 4 > LnMax Then For I = ContLn + 1 To LnMax + 3 Print #1, ContLn = ContLn + 1 Next ContLn = 0 End If If ContLn = 0 Then ContPg = ContPg + 1 CAB1 = Comp_Str(PrEmp, 80, " ", True) & "PAG.:" & Comp_Str(ContPg, 3, " ", False) CAB2 = "LISTAGEM DE ACOMPANHAMENTO DE VIAGEM" & Space(53) & "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("AC_CONDUTOR"), 40, "@", True) & Space(1) _ & "SITUAO:" & IIf(RS("AC_SIT") = 1, "1 - ABERTA", "2 - FECHADA") CAB5 = Comp_Str("PARTIDA:" & Format(RS("ac_DT_PARTI"), "DD/MM/YYYY"), 21, "@", True ) & IIf(IsNull(RS("AC_HR_SAI")) = True, " ", RS("AC_HR_SAI")) & Space(1) _ & Comp_Str("CHEGADA:" & IIf(IsNull(RS("AC_DT_CHEG")) = False, Format(RS("AC _DT_CHEG"), "DD/MM/YYYY"), " / / "), 21, "@", True) & IIf(IsNull(RS("AC_HR_CHEG")) = True, " " , RS("AC_HR_CHEG")) CAB6 = , 96, "@", True, True) CAB7 = C_DEST_KM")), 96, "@", HIF8 = Print Print Print Print Print Print Print Print Comp_Str("ORI:" & RS("AC_SAI_MUN") & "/" & RS("AC_SAI_UF") & RS("AC_SAI_KM") Comp_Str("DST:" & RS("AC_DEST_MUN") & "/" & RS("AC_DEST_UF") & Val_Sgt(RS("A True, True) String(96, "=") #1, #1, #1, #1, #1, #1, #1, #1, CAB1 CAB2 HIF3 CAB4 CAB5 CAB6 CAB7 HIF8

ContLn = 8 End If '--------------------------------------------------------------------------------------ADIANTAMENTOS Sql = "SELECT * FROM GT_AC_ADIANTAMENTOS WHERE AD_NUM_AC=" & RS("AC_NUM_AC") Set RS_AD = New ADODB.Recordset RS_AD.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly Imp_CAB_AD = True If RS_DP.RecordCount > 0 Then Do While RS_AD.EOF = False If ContLn + 4 > LnMax Then For I = ContLn + 1 To LnMax + 3 Print #1, ContLn = ContLn + 1 Next ContLn = 0 End If If ContLn = 0 Then ContPg = ContPg + 1 Print #1, CAB1 Print #1, CAB2 Print #1, HIF3 Print #1, CAB4 Print #1, CAB5

Frm_acomp_Viagem - 20 Print #1, CAB6 Print #1, CAB7 Print #1, HIF8 ContLn = 8 Imp_CAB_AD = True End If If Imp_CAB_AD = True Then Imp_CAB_AD = False Print #1, "ADIANTAMENTOS" Print #1, HIF3 Print #1, Comp_Str("DATA", 12, " ", True) _ & Comp_Str("VALOR", 15, " ", False) & Space(1) _ & Comp_Str("AUTORIZADO POR", 50, " ", True) Print #1, HIF3 ContLn = ContLn + 4 End If Print #1, 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_AUTORIZADO"), 50, " ", True) ContLn = ContLn + 1 Loop End If '--------------------------------------------------------- \ ADIANTAMENTOS '-------------------------------------------------------------------------------------- DESPESAS Sql = "SELECT * FROM GT_AC_DESPESA WHERE DP_NUM_AC=" & RS("AC_NUM_AC") Set RS_DP = New ADODB.Recordset RS_DP.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly Imp_CAB_DP = True If RS_DP.RecordCount > 0 Then Do While RS_DP.EOF = False If ContLn + 4 > LnMax Then For I = ContLn + 1 To LnMax + 3 Print #1, ContLn = ContLn + 1 Next ContLn = 0 End If If ContLn = 0 Then ContPg = ContPg + 1 Print #1, CAB1 Print #1, CAB2 Print #1, HIF3 Print #1, CAB4 Print #1, CAB5 Print #1, CAB6 Print #1, CAB7 Print #1, HIF8 ContLn = 8 Imp_CAB_DP = True End If If Imp_CAB_DP = True Then Imp_CAB_DP = False Print #1, "PEDGIOS" Print #1, HIF3 Print #1, Comp_Str("DATA", 12, " ", True) _ & Comp_Str("HORA", 6, " ", True) _ & Comp_Str("VALOR", 8, " ", False) & Space(1) _ & Comp_Str("DESCRIO", 30, " ", True) & Space(1) _ & Comp_Str("AUTORIZADO", 25, " ", False) & Space(1) _ & Comp_Str("F.PAGTO", 10, " ", False) Print #1, HIF3 ContLn = ContLn + 4 End If Print #1, Comp_Str(Format(RS_DP("dp _data"), "dd/mm/yyyy"), 12, " ", True) _ & Comp_Str(RS_DP("dp_hora"), 6, " ", True) _

Frm_acomp_Viagem - 21 & Comp_Str(Format(RS_DP("dp_valor"), "0.00"), 8, " ", False) & Space(1) _ & Comp_Str(RS_DP("dp_desc"), 30, " ", True) & Space(1) _ & Comp_Str(RS_DP("dp_autorizado"), 25, " ", False) & Space(1) _ & Comp_Str(RS_DP("dp_fpgto"), 10, " ", False) ContLn = ContLn + 1 Loop End If '--------------------------------------------------------- \ ADIANTAMENTOS '-------------------------------------------------------------------------------------- ABASTECIMENTOS Sql = "SELECT * FROM GT_AC_ABAST WHERE AB_NUM_AC=" & RS("AC_NUM_AC") Set RS_AB = New ADODB.Recordset RS_AB.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly Imp_CAB_AB = True If RS_AB.RecordCount > 0 Then Do While RS_AB.EOF = False If ContLn + 4 > LnMax Then For I = ContLn + 1 To LnMax + 3 Print #1, ContLn = ContLn + 1 Next ContLn = 0 End If If ContLn = 0 Then ContPg = ContPg + 1 Print #1, CAB1 Print #1, CAB2 Print #1, HIF3 Print #1, CAB4 Print #1, CAB5 Print #1, CAB6 Print #1, CAB7 Print #1, HIF8 ContLn = 8 Imp_CAB_AB = True End If If Imp_CAB_AB = True Then Imp_CAB_AB = False Print #1, "ABASTECIMENTOS" Print #1, HIF3 Print #1, Comp_Str("DATA", 12, " ", True) _ & Comp_Str("HORA", 6, " ", True) _ & Comp_Str("CIDADE", 20, " ", True) & Space(1) _ & Comp_Str("UF", 4, " ", True) & Space(1) _ & Comp_Str("QTDE", 8, " ", False) & Space(1) _ & Comp_Str("TOTAL", 10, " ", False) & Space(1) _ & Comp_Str("F PGTO", 10, " ", False) Print #1, HIF3 ContLn = ContLn + 4 End If Print #1, 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"), 20, " ", True) & Space(1) _ & Comp_Str(RS_AB("ab_uf"), 4, " ", True) & Space(1) _ & Comp_Str(RS_AB("ab_qtde"), 8, " ", False) & Space(1) _ & Comp_Str(RS_AB("ab_total"), 10, " ", False) & Space(1) _ & Comp_Str(RS_AB("ab_FPGTO"), 10, " ", False) ContLn = ContLn + 1 Loop End If '--------------------------------------------------------- \ ABASTECIMENTOS

Frm_acomp_Viagem - 22

Loop Else RS.Close MsgBox "No ha dados h serem Listados", vbExclamation, "AVISO" Exit Sub End If End Sub Private Sub CMD_REMOVE_ADI_Click() If lst_adi.ListItems.Count > 0 Then If lst_adi.SelectedItem.Selected = True Then lst_adi.ListItems.Remove (lst_adi.SelectedItem.Index) Flg_Adi_Viag = True Else MsgBox "Selecione Algum Item para Remover da Lista.", vbExclamation, "AVISO." Exit Sub End If Else MsgBox "Selecione Algum Item para Remover da Lista.", vbExclamation, "AVISO." Exit Sub End If End Sub Private Sub CMD_PED_REMOVE_Click() If LST_PED.ListItems.Count > 0 Then If LST_PED.SelectedItem.Selected = True Then LST_PED.ListItems.Remove (LST_PED.SelectedItem.Index) Flg_PEd_Viag = True Else MsgBox "Selecione Algum Item para Remover da Lista.", vbExclamation, "AVISO." Exit Sub End If Else MsgBox "Selecione Algum Item para Remover da Lista.", vbExclamation, "AVISO." Exit Sub End If

End Sub Private Sub cbo_cons_sit_Change() ProcuraCbo cbo_cons_sit End Sub Private Sub Form_Unload(Cancel As Integer) Chv_AcompViag = "" End Sub Private Sub lst_cons_ac_DblClick() If lst_cons_ac.ListItems.Count > 0 Then fra_cons.Visible = False xKey = lst_cons_ac.SelectedItem.Text CMD_CANC_AC.Caption = "Voltar" fra_FICHa.Visible = True TXT_NUMERO.Text = xKey TXT_NUMERO_LostFocus End If End Sub Private Sub lst_trechos_DblClick() If lst_trechos.ListItems.Count = 0 Then Exit Sub If lst_trechos.SelectedItem.Index <> lst_trechos.ListItems.Count Then

Frm_acomp_Viagem - 23 MsgBox "Impossvel Editar esse Trecho, Delete os Mais recentes para edit-lo", vbCritical, "AVISO" Exit Sub End If cbo_tch_uf.Text = lst_trechos.SelectedItem.Text cbo_tch_uf_LostFocus cbo_tch_cid.Text = lst_trechos.SelectedItem.SubItems(1) msk_tch_dt_partida.Text = Format(lst_trechos.SelectedItem.SubItems(2), "dd/mm/yyyy") txt_tch_km_partida.Text = lst_trechos.SelectedItem.SubItems(3) cbo_tch_uf_dest.Text = lst_trechos.SelectedItem.SubItems(4) cbo_tch_uf_dest_LostFocus cbo_tch_cid_Dest.Text = lst_trechos.SelectedItem.SubItems(5) msk_tch_dt_cheg.Text = IIf(IsDate(lst_trechos.SelectedItem.SubItems(6)) = False, " / / ", lst_trechos.SelectedItem.SubItems(6)) txt_tch_odo_dest.Text = lst_trechos.SelectedItem.SubItems(7) txt_tch_saldo.Text = lst_trechos.SelectedItem.SubItems(8) cbo_TCH_pgto_frete_saldo.Text = lst_trechos.SelectedItem.SubItems(9) txT_tch_adi.Text = lst_trechos.SelectedItem.SubItems(10) txt_tch_tot_frete.Text = Format(Val_Sgt(txT_tch_adi.Text) + Val_Sgt(txt_tch_saldo.Text), "0.00" ) cbo_tch_fpgto_adi.Text = lst_trechos.SelectedItem.SubItems(11) txt_tch_peso.Text = lst_trechos.SelectedItem.SubItems(12) cbo_tch_ag.Text = lst_trechos.SelectedItem.SubItems(13) cbo_tch_ag.SelLength = 0 txt_tch_desp_Ag.Text = lst_trechos.SelectedItem.SubItems(14) cbo_tch_Fpagto_ag.Text = lst_trechos.SelectedItem.SubItems(15) txt_TCH_base_comiss.Text = lst_trechos.SelectedItem.SubItems(16) lst_trechos.ListItems.Remove (lst_trechos.SelectedItem.Index) Flg_mudou_Viag = True

End Sub Private Sub msk_adi_data_GotFocus() Marca End Sub Private Sub msk_adi_data_LostFocus() LostFocus_Datas msk_adi_data End Sub Private Sub msk_cons_dt1_GotFocus() Marca End Sub Private Sub msk_cons_dt1_LostFocus() LostFocus_Datas msk_cons_dt1, msk_cons_dt2 End Sub Private Sub msk_cons_dt2_GotFocus() Marca End Sub Private Sub msk_cons_dt2_LostFocus() LostFocus_Datas msk_cons_dt2, msk_cons_dt1 End Sub Private Sub msk_dt_cheg_GotFocus() Marca End Sub

Frm_acomp_Viagem - 24 Private Sub msk_dt_cheg_LostFocus() LostFocus_Datas msk_dt_cheg End Sub Private Sub msk_hr_cheg_GotFocus() Marca End Sub Private Sub msk_hr_sai_GotFocus() Marca End Sub Private Sub MSK_PED_DT_GotFocus() Marca End Sub Private Sub MSK_PED_DT_LostFocus() LostFocus_Datas MSK_PED_DT End Sub Private Sub msk_Rel_dt1_GotFocus() Marca End Sub Private Sub msk_Rel_dt1_LostFocus() LostFocus_Datas msk_Rel_dt1, MSk_REL_DT2 End Sub Private Sub MSk_REL_DT2_GotFocus() Marca End Sub Private Sub MSk_REL_DT2_LostFocus() LostFocus_Datas MSk_REL_DT2, msk_Rel_dt1 End Sub Private Sub msk_tch_dt_cheg_GotFocus() Marca End Sub Private Sub msk_tch_dt_cheg_LostFocus() LostFocus_Datas msk_tch_dt_cheg End Sub Private Sub SSTab_Click(PreviousTab As Integer) On Error GoTo trata_erro Select Case SSTab.Tab Case 0 msk_adi_data.SetFocus Case 1 MSK_desp_dt.SetFocus Case 2 msk_abast_dt.SetFocus Case 3 cbo_tch_uf.SetFocus Case 4 CBO_PED_UF.SetFocus Case 5 TOTALIZA_RESUMO

Frm_acomp_Viagem - 25 End Select Exit Sub trata_erro: If Err = 5 Then Resume Next Else MsgBox Err.Description, vbCritical, "erro" Rot_Voltar End If End Sub

Private Sub txt_adi_auto_GotFocus() Marca End Sub Private Sub txt_adi_vlr_GotFocus() Marca End Sub Private Sub txt_adi_vlr_LostFocus() txt_adi_vlr.Text = Format(txt_adi_vlr.Text, "0.00") End Sub Private Sub txt_dest_odo_GotFocus() Marca End Sub Private Sub txt_dest_odo_KeyPress(KeyAscii As Integer) TrancaString KeyAscii End Sub Private Sub cbo_dest_uf_Change() cbo_dest_cid.Text = "" ProcuraCbo cbo_dest_uf End Sub Private Sub cbo_dest_uf_GotFocus() Marca End Sub Private Sub cbo_dest_uf_LostFocus() If cbo_dest_uf.Text <> "" Then CarregaCidade cbo_dest_cid, cbo_dest_uf End If End Sub Private Sub cbo_saida_cid_Change() ProcuraCbo cbo_saida_cid End Sub Private Sub cbo_saida_cid_GotFocus() Marca End Sub Private Sub cbo_saida_uf_Change() cbo_saida_cid.Text = "" ProcuraCbo cbo_saida_uf End Sub Private Sub cbo_saida_uf_GotFocus() Marca End Sub

Frm_acomp_Viagem - 26 Private Sub cbo_saida_uf_LostFocus() If cbo_saida_uf.Text <> "" Then CarregaCidade cbo_saida_cid, cbo_saida_uf End If End Sub Private Sub cbo_tch_cid_Change() ProcuraCbo cbo_tch_cid End Sub Private Sub cbo_tch_cid_GotFocus() Marca End Sub Private Sub cbo_tch_Fpagto_ag_Change() ProcuraCbo cbo_tch_Fpagto_ag End Sub Private Sub cbo_tch_Fpagto_ag_GotFocus() Marca End Sub Private Sub cbo_tch_uf_Change() cbo_tch_cid.Text = "" ProcuraCbo cbo_tch_uf End Sub Private Sub cbo_tch_uf_GotFocus() Marca End Sub Private Sub cbo_tch_uf_LostFocus() If cbo_tch_uf.Text <> "" Then CarregaCidade cbo_tch_cid, cbo_tch_uf End If End Sub Private Sub cbo_veicu_Change() ProcuraCbo cbo_veicu LBL_DADOS_VEIC.Visible = False cbo_condutor.Text = "" End Sub Private Sub cbo_veicu_GotFocus() Marca End Sub Private Sub cbo_veicu_LostFocus() Dim RS As ADODB.Recordset If cbo_veicu.Text <> "" Then Sql = "select vi_proprie, vi_condutor from gt_veicu where vi_placa='" & cbo_veicu.Text & " '" Set RS = New ADODB.Recordset RS.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly If RS.RecordCount > 0 Then LBL_DADOS_VEIC.Visible = True LBL_DADOS_VEIC.Caption = "Prop.: " & RS("vi_proprie") If cbo_condutor.Text = "" Then If IsNull(RS("vi_condutor")) = False And Trim(RS("vi_condutor")) <> "" Then cbo_condutor.Text = RS("vi_condutor") cbo_condutor.SelLength = 0 End If End If End If Sql = "select sit=1" Set RS = New ADODB.Recordset ac_numero from gt_ac_viagem where ac_veicu='" & cbo_veicu.Text & "' and ac_

Frm_acomp_Viagem - 27 RS.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly If RS.RecordCount > 0 Then If RS("ac_numero") = TXT_NUMERO Then Exit Sub MsgBox "No Possvel Lanar uma Nova Viagem para esse Veculo," & vbNewLine _ & " Pois o mesmo possui uma Viagem em Andamento" & vbNewLine _ & " Viagem : " & RS("ac_numero"), vbExclamation, "AVISO" cbo_veicu.Text = "" cbo_veicu.SetFocus Exit Sub End If End If End Sub Private Sub cmd_abast_conf_Click() If IsDate(msk_abast_dt.Text) = False Then MsgBox "Data Invlida", vbCritical, "AVISO" msk_abast_dt.SetFocus Exit Sub End If If msk_data.Text <> " / / " Then If CDate(msk_abast_dt.Text) < CDate(msk_data.Text) Then MsgBox "A Data do Abastecimento No pode Ser Inferior data da viagem", vbCritical, "A VISO" msk_abast_dt.SetFocus Exit Sub End If End If If txt_abast_hora.Text <> " : " Then If IsDate(txt_abast_hora.Text) = False Then MsgBox "Hora Invlida", vbCritical, "AVISO" txt_abast_hora.SetFocus Exit Sub End If End If If CBO_ABAST_UF.Text = "" Then MsgBox "Informe a UF", vbCritical, "AVISO" CBO_ABAST_UF.SetFocus Exit Sub End If If CBO_ABAST_MUN.Text = "" Then MsgBox "Informe a Cidade", vbCritical, "AVISO" CBO_ABAST_MUN.SetFocus Exit Sub End If If Val_Sgt(txt_abast_qtd.Text) = 0 Then MsgBox "Informe o Qde de LITROS ", vbCritical, "AVISO" txt_abast_qtd.SetFocus Exit Sub End If If Val_Sgt(txt_abast_vlr.Text) = 0 Then MsgBox "Informe o Valor Total", vbCritical, "AVISO" txt_abast_vlr.SetFocus Exit Sub End If If Trim(cbo_abast_forma.Text) = "" Then MsgBox "Informe a Forma de PGTO", vbCritical, "AVISO" cbo_abast_forma.SetFocus Exit Sub End If Set Litem = lst_abast.ListItems.Add Litem.Text = msk_abast_dt.Text Litem.SubItems(1) = txt_abast_hora.Text Litem.SubItems(2) = CBO_ABAST_UF.Text Litem.SubItems(3) = CBO_ABAST_MUN.Text Litem.SubItems(4) = Val_Sgt(txt_abast_qtd.Text) Litem.SubItems(5) = Val_Sgt(txt_abast_vlr.Text) Litem.SubItems(6) = cbo_abast_forma Flg_Abast_Viag = True CMD_CANC_ABAST_Click End Sub

Frm_acomp_Viagem - 28 Private Sub CMD_CANC_ABAST_Click() On Error GoTo trata_erro msk_abast_dt.Text = " / / " cbo_abast_forma.Text = "" CBO_ABAST_MUN.Text = "" CBO_ABAST_UF.Text = "" txt_abast_hora.Text = " : " txt_abast_qtd.Text = "" txt_abast_vlr.Text = "" msk_abast_dt.SetFocus Exit Sub trata_erro: If Err = 5 Then Resume Next Else MsgBox Err.Description, vbCritical, "Erro" Exit Sub End If End Sub Private Sub CMD_DEL_abast_Click() If lst_abast.ListItems.Count > 0 Then If lst_abast.SelectedItem.Selected = True Then lst_abast.ListItems.Remove (lst_abast.SelectedItem.Index) Flg_Abast_Viag = True Else MsgBox "Selecione Algum Item para Remover da Lista.", vbExclamation, "AVISO." Exit Sub End If Else MsgBox "Selecione Algum Item para Remover da Lista.", vbExclamation, "AVISO." Exit Sub End If End Sub Private Sub CMD_DEL_desp_Click() If lst_desp.ListItems.Count > 0 Then If lst_desp.SelectedItem.Selected = True Then lst_desp.ListItems.Remove (lst_desp.SelectedItem.Index) Flg_Desp_Viag = True Else MsgBox "Selecione Algum Item para Remover da Lista.", vbExclamation, "AVISO." Exit Sub End If Else MsgBox "Selecione Algum Item para Remover da Lista.", vbExclamation, "AVISO." Exit Sub End If End Sub Private Sub CMD_DEL_tch_Click() If lst_trechos.ListItems.Count > 0 Then If lst_trechos.SelectedItem.Selected = True Then lst_trechos.ListItems.Remove (lst_trechos.SelectedItem.Index) Flg_Trecho_Viag = True Else MsgBox "Selecione Algum Item para Remover da Lista.", vbExclamation, "AVISO." Exit Sub End If Else MsgBox "Selecione Algum Item para Remover da Lista.", vbExclamation, "AVISO." Exit Sub End If End Sub Private Sub CMD_desp_canc_Click() On Error GoTo trata_erro MSK_desp_dt.Text = " / / txt_desp_hora.Text = " : " txt_desp_auto.Text = "" txt_desp_desc.Text = "" txt_desp_vlr.Text = "" cbo_desp_pgto.Text = "" MSK_desp_dt.SetFocus "

Frm_acomp_Viagem - 29 Exit Sub trata_erro: If Err = 5 Then Resume Next Else MsgBox Err.Description, vbCritical, "Erro" Exit Sub End If End Sub Private Sub Cmd_desp_ok_Click() If IsDate(MSK_desp_dt.Text) = False Then MsgBox "Data Invlida", vbCritical, "AVISO" MSK_desp_dt.SetFocus Exit Sub End If If msk_data.Text <> " / / " Then If CDate(MSK_desp_dt.Text) < CDate(msk_data.Text) Then MsgBox "A Data da Despesa No pode Ser Inferior data da viagem", vbCritical, "AVISO" MSK_desp_dt.SetFocus Exit Sub End If End If If txt_desp_hora.Text <> " : " Then If IsDate(txt_desp_hora.Text) = False Then MsgBox "Hora Invlida", vbCritical, "AVISO" txt_desp_hora.SetFocus Exit Sub End If End If If Val_Sgt(txt_desp_vlr.Text) = 0 Then MsgBox "Informe o Valor", vbCritical, "AVISO" txt_desp_vlr.SetFocus Exit Sub End If If Trim(txt_desp_auto.Text) = "" Then MsgBox "Informe o campo de Autorizao", vbCritical, "AVISO" txt_desp_auto.SetFocus Exit Sub End If If Trim(cbo_desp_pgto.Text) = "" Then MsgBox "Informe a Forma de PGTO", vbCritical, "AVISO" cbo_desp_pgto.SetFocus Exit Sub End If Set Litem = lst_desp.ListItems.Add Litem.Text = MSK_desp_dt.Text Litem.SubItems(1) = txt_desp_hora.Text Litem.SubItems(2) = Format(Val_Sgt(txt_desp_vlr.Text), "0.00") Litem.SubItems(3) = Trim(txt_desp_auto.Text) Litem.SubItems(4) = cbo_desp_pgto.Text Litem.SubItems(5) = Trim(txt_desp_desc.Text) Flg_Desp_Viag = True CMD_desp_canc_Click End Sub Private Sub CMD_INCLUIR_AC_Click() Flg_Adi_Viag = False Flg_Desp_Viag = False Flg_Abast_Viag = False Flg_Trecho_Viag = False Flg_PEd_Viag = False If InCluir_VIAGEM = True Then If CMD_INCLUIR_AC.Caption = "Alterar" Then MsgBox "Alterao Ocorrida com Sucesso", vbExclamation, "AVISO" Else MsgBox "Incluso Ocorrida com Sucesso", vbExclamation, "AVISO" End If

Frm_acomp_Viagem - 30 Form_Load ElseIf Erro = "N" Then If CMD_INCLUIR_AC.Caption = "Alterar" Then MsgBox "No foi possvel Alterar a Viagem", vbCritical, "AVISO" Else MsgBox "No foi possvel Incluir a Viagem", vbCritical, "AVISO" End If Exit Sub End If End Sub Sub Critica() If IsDate(msk_data.Text) = False Then Erro = "S" MsgBox "Data de Sada invlida", vbCritical, "AVISO" msk_data.SetFocus Exit Sub End If If IsDate(msk_hr_sai.Text) = False Then Erro = "S" MsgBox "Hora de Sada invlida", vbCritical, "AVISO" msk_hr_sai.SetFocus Exit Sub End If If cbo_saida_uf.Text = "" Then Erro = "S" MsgBox "Informe a UF de Sada", vbCritical, "AVISO" cbo_saida_uf.SetFocus Exit Sub End If If cbo_saida_cid.Text = "" Then Erro = "S" MsgBox "Informe a CIDADE de Sada", vbCritical, "AVISO" cbo_saida_cid.SetFocus Exit Sub End If If Val_Sgt(txt_saida_odo.Text) = 0 Then Erro = "S" MsgBox "Informe o Odometro de Sada", vbCritical, "AVISO" txt_saida_odo.SetFocus Exit Sub End If If cbo_dest_uf.Text = "" Then Erro = "S" MsgBox "Informe a UF de Chegada", vbCritical, "AVISO" cbo_dest_uf.SetFocus Exit Sub End If If cbo_dest_cid.Text = "" Then Erro = "S" MsgBox "Informe a Cidade de Chegada", vbCritical, "AVISO" cbo_dest_cid.SetFocus Exit Sub End If If VAL_SGT(txt_dest_odo.Text) = 0 Then Erro = "S" MsgBox "Informe o Odometro de Chegada", vbCritical, "AVISO" txt_dest_odo.SetFocus Exit Sub End If If cbo_veicu.Text = "" Then Erro = "S" MsgBox "Informe o Veculo", vbCritical, "AVISO" cbo_veicu.SetFocus Exit Sub End If If cbo_condutor.Text = "" Then Erro = "S" MsgBox "Informe o Condutor", vbCritical, "AVISO" cbo_condutor.SetFocus Exit Sub End If If Val_Sgt(txt_dest_odo.Text) > 0 Then If Val_Sgt(txt_dest_odo.Text) < Val_Sgt(txt_saida_odo.Text) Then Erro = "S"

' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '

Frm_acomp_Viagem - 31 MsgBox "O Odometro de Chegada NO pode ser MENOR do que o Odometro de Sada.", vbCritic al, "AVISO" txt_dest_odo.SetFocus Exit Sub End If End If If cbo_dest_uf.Text <> "" Then If cbo_dest_cid.Text = "" Then Erro = "S" MsgBox "Informe a Cidade de Chegada.", vbCritical, "AVISO" cbo_dest_cid.SetFocus Exit Sub End If If Val_Sgt(txt_dest_odo.Text) = 0 Then Erro = "S" MsgBox "Informe o Odometro de Chegada.", vbCritical, "AVISO" txt_dest_odo.SetFocus Exit Sub End If End If

End Sub Private Sub CMD_TCH_LIMPA_Click() On Error GoTo trata_erro cbo_tch_cid.Text = "" cbo_tch_Fpagto_ag.Text = "" cbo_tch_uf.Text = "" msk_tch_dt_partida = " / / txt_tch_km_partida.Text = "" "

txt_tch_desp_Ag.Text = "" txt_tch_peso.Text = "" txt_tch_saldo.Text = "" txt_tch_tot_frete.Text = "" cbo_TCH_pgto_frete_saldo.Text = "" cbo_tch_uf_dest.Text = "" cbo_tch_cid_Dest.Text = "" msk_tch_dt_cheg.Text = " / / " txt_tch_odo_dest.Text = "" txT_tch_adi.Text = "" cbo_tch_fpgto_adi.Text = "" cbo_tch_ag.Text = "" txt_TCH_base_comiss.Text = "" cbo_tch_uf.SetFocus Exit Sub trata_erro: If Err = 5 Then Resume Next Else MsgBox Err.Description, vbCritical, "Erro" Exit Sub End If End Sub Private Sub CMD_TCH_ok_Click() If cbo_tch_uf.Text = "" Then MsgBox "Informe a UF de partida", vbCritical, "AVISO" cbo_tch_uf.SetFocus Exit Sub End If If cbo_tch_cid.Text = "" Then MsgBox "Informe a Cidade de partida", vbCritical, "AVISO" cbo_tch_cid.SetFocus Exit Sub End If If IsDate(msk_tch_dt_partida.Text) = False Then MsgBox "Data de partida Invlida", vbCritical, "AVISO" msk_tch_dt_partida.SetFocus Exit Sub End If

Frm_acomp_Viagem - 32 If Val_Sgt(txt_tch_km_partida.Text) = 0 Then MsgBox "Informe o Odometro de Partida", vbCritical, "AVISO" txt_tch_km_partida.SetFocus Exit Sub End If '----- dest If cbo_tch_uf_dest.Text = "" Then MsgBox "Informe a UF de Destino", vbCritical, "AVISO" cbo_tch_uf_dest.SetFocus Exit Sub End If If cbo_tch_cid_Dest.Text = "" Then MsgBox "Informe a Cidade de Destino", vbCritical, "AVISO" cbo_tch_cid_Dest.SetFocus Exit Sub End If If CDate(msk_tch_dt_partida.Text) < CDate(msk_data.Text) Then MsgBox "A data de Partida do Trecho No pode ser Menor do que a Data de Partida da Viagem." , vbCritical, "AVISO" msk_tch_dt_partida.SetFocus Exit Sub End If If msk_tch_dt_cheg.Text <> " / / " Then If CDate(msk_tch_dt_cheg.Text) < CDate(msk_tch_dt_partida.Text) Then MsgBox "A data de Chegada No pode ser Menor do que a Data de Partida.", vbCritical, "A VISO" msk_tch_dt_cheg.SetFocus Exit Sub End If If Val_Sgt(txt_tch_odo_dest.Text) = 0 Then MsgBox "Informe o Km de Chegada", vbCritical, "AVISO" txt_tch_odo_dest.SetFocus Exit Sub End If End If If Val_Sgt(txt_tch_peso.Text) = 0 Then MsgBox "Informe o PESO", vbCritical, "AVISO" txt_tch_peso.SetFocus Exit Sub End If If Val_Sgt(txt_tch_km_partida.Text) < Val_Sgt(txt_saida_odo.Text) Then MsgBox "O Km de Partida Desse Trecho, No Pode Ser MENOR que o Km de Sada da Viagem", vbCr itical, "AVISO" txt_tch_km_partida.SetFocus Exit Sub End If If Val_Sgt(txt_tch_odo_dest.Text) > 0 Then If Val_Sgt(txt_tch_km_partida.Text) > Val_Sgt(txt_tch_odo_dest.Text) Then MsgBox "O Km de Partida Desse Trecho, No Pode Ser MAIOR que o Km de Chegada", vbCritic al, "AVISO" txt_tch_km_partida.SetFocus Exit Sub End If End If If Val_Sgt(txt_dest_odo.Text) > 0 Then If Val_Sgt(txt_tch_km_partida.Text) > Val_Sgt(txt_dest_odo.Text) Then MsgBox "O odometro de Partida do Trecho No pode ser Maior do que o Odometro FINAL da V iagem", vbCritical, "AVISO" txt_tch_km_partida.SetFocus End If If Val_Sgt(txt_tch_odo_dest.Text) > Val_Sgt(txt_dest_odo.Text) Then MsgBox "O odometro de Chegada do Trecho No pode ser Maior do que o Odometro FINAL da V iagem", vbCritical, "AVISO" txt_tch_odo_dest.SetFocus Exit Sub End If End If

Frm_acomp_Viagem - 33 If Val_Sgt(txt_tch_saldo.Text) > 0 Then If Trim(cbo_TCH_pgto_frete_saldo.Text) = "" Then MsgBox "Informe a Forma de PGTO DO Saldo", vbCritical, "AVISO" cbo_TCH_pgto_frete_saldo.SetFocus Exit Sub End If End If If Val_Sgt(txT_tch_adi.Text) > 0 Then If Trim(cbo_tch_fpgto_adi.Text) = "" Then MsgBox "Informe a Forma de PGTO DO adiantamento", vbCritical, "AVISO" cbo_tch_fpgto_adi.SetFocus Exit Sub End If If Val_Sgt(txT_tch_adi.Text) > Val_Sgt(txt_tch_tot_frete.Text) Then MsgBox "O Valor do Adiantamento no pode ser Maior do que o Total do Frete", vbCritical , "AVISO" txT_tch_adi.SetFocus Exit Sub End If End If If Val_Sgt(txt_tch_odo_dest.Text) > 0 Then If Val_Sgt(txt_tch_odo_dest.Text) < Val_Sgt(txt_tch_km_partida.Text) Then MsgBox "O Odometro de Chegada No pode Ser maior do que o Odometro de Sada", vbCritica l, "AVISO" txt_tch_km_partida.SetFocus Exit Sub End If End If x_ultimo = lst_trechos.ListItems.Count If x_ultimo > 0 Then If Val_Sgt(lst_trechos.ListItems(x_ultimo).SubItems(7)) = 0 Then MsgBox "Impossvel Lanar esse Trecho, pois Ainda no Foi Finalizado o ltimo Lanado", vbCritical, "AVISO" Exit Sub End If If Val_Sgt(txt_tch_km_partida.Text) <= Val_Sgt(lst_trechos.ListItems(x_ultimo).SubItems(3)) Then MsgBox "O Km de Partida , No Pode ser Menor do que ltimo lanado", vbExclamation, "AV ISO" Exit Sub End If End If If Val_Sgt(txt_TCH_base_comiss.Text) = 0 Then MsgBox "Informe o Valor base para o Clculo da Comisso do motorista", vbCritical, "AVISO" txt_TCH_base_comiss.SetFocus Exit Sub End If 'If cbo_dest_uf.Text <> "" Then ' If Trim(cbo_dest_uf.Text) = Trim(cbo_tch_uf.Text) And Trim(cbo_dest_cid.Text) = Trim(cbo_t ch_cid.Text) Then ' MsgBox "O Trecho a ser Lanado confere com o Destino Final da viagem," & vbNewLine _ ' & "Ser solicitado sua confirmao de FECHAMENTO ao Concluir a Operao FINAL", vb Information, "AVISO" ' End If 'End If Set Litem = lst_trechos.ListItems.Add Litem.Text = cbo_tch_uf.Text Litem.SubItems(1) = cbo_tch_cid.Text Litem.SubItems(2) = Format(msk_tch_dt_partida.Text, "dd/mm/yyyy") Litem.SubItems(3) = Val_Sgt(txt_tch_km_partida.Text) Litem.SubItems(4) = cbo_tch_uf_dest.Text Litem.SubItems(5) = cbo_tch_cid_Dest.Text Litem.SubItems(6) = IIf(msk_tch_dt_cheg.Text = " / / ", " ", msk_tch_dt_cheg.Text) Litem.SubItems(7) = Val_Sgt(txt_tch_odo_dest.Text) Litem.SubItems(8) = Format(Val_Sgt(txt_tch_saldo), "0.00")

Frm_acomp_Viagem - 34 Litem.SubItems(9) = IIf(Trim(cbo_TCH_pgto_frete_saldo.Text) = "", " ", cbo_TCH_pgto_frete_saldo .Text) Litem.SubItems(10) = Format(Val_Sgt(txT_tch_adi), "0.00") Litem.SubItems(11) = IIf(Trim(cbo_tch_fpgto_adi.Text) = "", " ", cbo_tch_fpgto_adi.Text) Litem.SubItems(12) = Val_Sgt(txt_tch_peso.Text) Litem.SubItems(13) = IIf(Trim(cbo_tch_ag.Text) = "", " ", cbo_tch_ag.Text) Litem.SubItems(14) = Format(Val_Sgt(txt_tch_desp_Ag.Text), "0.00") Litem.SubItems(15) = IIf(cbo_tch_Fpagto_ag.Text = "", " ", cbo_tch_Fpagto_ag.Text) Litem.SubItems(16) = Format(Val_Sgt(txt_TCH_base_comiss.Text), "0.00") Flg_Trecho_Viag = True CMD_TCH_LIMPA_Click End Sub Private Sub Form_Activate() CarregaEstado cbo_saida_uf CopiaCbo cbo_saida_uf, cbo_dest_uf CopiaCbo cbo_saida_uf, cbo_tch_uf CopiaCbo cbo_saida_uf, CBO_ABAST_UF CopiaCbo cbo_saida_uf, CBO_PED_UF CopiaCbo CBO_PED_UF, cbo_tch_uf_dest CarregaVeiculo cbo_veicu, False CarregaMotora cbo_condutor CarregaVeiculo cbo_cons_veicu, False CarregaMotora cbo_cons_cond CarregaEntreg cbo_tch_ag CopiaCbo cbo_veicu, Cbo_Rel_Veic CopiaCbo cbo_condutor, cbo_Rel_Cond '------------- VERIFICA ULTIMO LANCAMENTO VerificaDados '------------End Sub Sub VerificaDados() Dim ULT_LANC As Long ULT_LANC = Pesq_Seq("GT_AC_VIAGEM", "AC_NUMERO", "") - 1 lbl_ult_lanc.Caption = "N Ultimo Lanamento : " & ULT_LANC End Sub Private Sub Form_Load() fra_FICHa.Visible = False fra_cons.Visible = False Fra_Rel.Visible = False SSTab.Tab = 0 VerificaDados Select Case Chv_AcompViag Case "INCLUSAO" Frm_acomp_Viagem.Caption = " Incluso \ Manuteno de Viagens " fra_FICHa.Visible = True CMD_CANC_AC.Caption = "Limpar" CMD_CANC_AC_Click Case "CONSULTA" Frm_acomp_Viagem.Caption = " Consulta de Viagens " fra_cons.Visible = True msk_cons_dt1.Text = DateAdd("D", -30, Format(Now, "dd/mm/yyyy")) msk_cons_dt2.Text = Format(Now, "dd/mm/yyyy") cbo_cons_sit.Text = "1 - Aberta" cbo_cons_pesq_Click

Frm_acomp_Viagem - 35 Case "RELAT" Frm_acomp_Viagem.Caption = " Listagem de Acompanhamento de Viagem " Fra_Rel.Visible = True End Select

End Sub Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Select Case UCase(TypeName(ActiveControl)) Case Is = "TEXTBOX" ' testa que tipo de controle SetFocuTxt KeyCode Case Is = "COMMANDBUTTON" Exit Sub Case Else SetFocusOpt KeyCode End Select End Sub Private Sub Form_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then KeyAscii = 0# End If TrancaCrtEspec KeyAscii End Sub Private Sub Form_Resize() 'FICHA Resize_BORDA Shape(4), fra_FICHa fra_FICHa.Top = (Frm_acomp_Viagem.Height - fra_FICHa.Height - 500) / 2 fra_FICHa.Left = (Frm_acomp_Viagem.Width - fra_FICHa.Width - 150) / 2 Resize_BORDA Resize_BORDA Resize_BORDA Resize_BORDA Resize_BORDA Shape(2), Shape(3), Shape(5), Shape(6), Shape(7), FRA_ABASTE fra_DESP FRA_TRECHOS fra_adi FRA_PED

'Consulta Resize_BORDA Shape(9), fra_cons fra_cons.Top = (Frm_acomp_Viagem.Height - fra_cons.Height - 500) / 2 fra_cons.Left = (Frm_acomp_Viagem.Width - fra_cons.Width - 150) / 2 'RELATRIOS Resize_BORDA Shape(13), Fra_Rel Fra_Rel.Top = (Frm_acomp_Viagem.Height - Fra_Rel.Height - 500) / 2 Fra_Rel.Left = (Frm_acomp_Viagem.Width - Fra_Rel.Width - 150) / 2

End Sub Private Sub msk_abast_dt_GotFocus() Marca End Sub Private Sub msk_abast_dt_LostFocus() LostFocus_Datas msk_abast_dt End Sub Private Sub msk_data_GotFocus() Marca End Sub Private Sub msk_data_LostFocus() LostFocus_Datas msk_data

Frm_acomp_Viagem - 36 End Sub Private Sub txt_comis_GotFocus() Marca End Sub Private Sub MSK_desp_dt_GotFocus() Marca End Sub Private Sub MSK_desp_dt_LostFocus() LostFocus_Datas MSK_desp_dt End Sub Private Sub msk_tch_dt_partida_GotFocus() Marca End Sub Private Sub msk_tch_dt_partida_LostFocus() LostFocus_Datas msk_tch_dt_partida End Sub Private Sub txt_abast_hora_GotFocus() Marca End Sub Private Sub txt_abast_qtd_GotFocus() Marca End Sub Private Sub txt_abast_qtd_KeyPress(KeyAscii As Integer) TrancaString1 KeyAscii End Sub Private Sub txt_abast_vlr_GotFocus() Marca End Sub Private Sub txt_abast_vlr_KeyPress(KeyAscii As Integer) TrancaString1 KeyAscii End Sub Private Sub txt_abast_vlr_LostFocus() txt_abast_vlr.Text = Format(txt_abast_vlr.Text, "0.00") End Sub

Private Sub txt_desp_auto_GotFocus() Marca End Sub Private Sub txt_desp_desc_GotFocus() Marca End Sub Private Sub txt_desp_hora_GotFocus() Marca

Frm_acomp_Viagem - 37 End Sub Private Sub txt_desp_vlr_GotFocus() Marca End Sub Private Sub txt_desp_vlr_KeyPress(KeyAscii As Integer) TrancaString1 KeyAscii End Sub Private Sub txt_desp_vlr_LostFocus() txt_desp_vlr.Text = Format(txt_desp_vlr, "0.00") End Sub Private Sub txt_dest_odo_LostFocus() If Val_Sgt(txt_dest_odo.Text) > 0 Then If lst_trechos.ListItems.Count > 0 Then If Val_Sgt(txt_dest_odo.Text) < Val_Sgt(lst_trechos.ListItems(lst_trechos.ListItems.Cou nt).SubItems(7)) Then MsgBox "O Km de Chegada NO pode ser Menor do que o Km de Chegada do ltimo Trecho Lanado", vbCritical, "AVISO" txt_dest_odo.Text = "" txt_dest_odo.SetFocus Exit Sub End If End If End If End Sub Private Sub TXT_NUMERO_KeyPress(KeyAscii As Integer) TrancaString KeyAscii End Sub Private Sub TXT_NUMERO_LostFocus() Dim RS As ADODB.Recordset lbl_gd_abast.Caption = "" lbl_gd_ADI.Caption = "" lbl_gd_desp.Caption = "" lbl_gd_ped.Caption = "" lbl_gd_trechos.Caption = "" If Val_Sgt(TXT_NUMERO.Text) > 0 Then Sql = "SELECT * FROM GT_AC_VIAGEM WHERE AC_NUMERO =" & Val_Sgt(TXT_NUMERO.Text) Set RS = New ADODB.Recordset RS.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly If RS.RecordCount > 0 Then /yyyy"), " msk_data.Text = IIf(IsNull(RS("AC_DT_PARTI")) = False, Format(RS("AC_DT_PARTI"), "dd/mm / / ") msk_hr_sai.Text = RS("ac_hr_sai") '------------------------ pedido por ed 27/06 msk_data.Enabled = False '-----------------------If IsNull(RS("AC_DT_CHEG")) = False Then msk_dt_cheg.Text = Format(RS("AC_DT_CHEG"), "dd/mm/yyyy") End If If IsNull(RS("AC_hr_CHEG")) = False Then msk_hr_cheg.Text = RS("AC_HR_CHEG") End If lbl_sit.Caption = IIf(RS("AC_SIT") = 1, "1 - ABERTA", "2 - FECHADA") cbo_saida_uf.Text = RS("AC_SAI_UF") cbo_saida_uf_LostFocus txt_saida_odo.Text = RS("AC_SAI_KM") cbo_saida_cid.Text = RS("AC_SAI_MUN")

Frm_acomp_Viagem - 38 cbo_veicu.Text = RS("AC_VEICU") cbo_condutor.Text = RS("AC_CONDUTOR") cbo_condutor.SelLength = 0 cbo_dest_uf.Text = RS("AC_DEST_UF") cbo_dest_uf_LostFocus cbo_dest_cid.Text = RS("AC_DEST_MUN") txt_dest_odo.Text = IIf(RS("AC_DEST_KM") = 0, " ", RS("AC_DEST_KM")) 'txt_vlr_base.Text = Format(RS("AC_vlr_base"), "0.00") txt_perc_comiss.Text = IIf(IsNull(RS("ac_perc_comiss")) = True, " ", RS("ac_perc_comiss ")) '--------------------------- CARREGA GRID DESPESAS Sql = "SELECT * FROM GT_AC_DESP WHERE DP_NUM_AC=" & Val_Sgt(TXT_NUMERO.Text) & " ORDER BY DP_KEY " Set RS = New ADODB.Recordset RS.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly lst_desp.ListItems.Clear If RS.RecordCount > 0 Then Do While RS.EOF = False Set Litem = lst_desp.ListItems.Add Litem.Text = RS("DP_DATA") Litem.SubItems(1) = RS("DP_HORA") Litem.SubItems(2) = Format(RS("DP_VALOR"), "0.00") Litem.SubItems(3) = RS("DP_AUTORIZADO") Litem.SubItems(4) = RS("DP_fPGTO") Litem.SubItems(5) = RS("DP_dESC") RS.MoveNext Loop '--------------------------------------------- guarda qntos reg tem, para verficar na alterao se deletou todos lbl_gd_desp.Caption = lst_desp.ListItems.Count '--------------------------------------------RS.Close End If '--------------------------- CARREGA GRID ABASTECIMENTOS Sql = "SELECT * FROM GT_AC_ABAST WHERE AB_NUM_AC=" & Val_Sgt(TXT_NUMERO.Text) & " ORDER BY AB_KEY " Set RS = New ADODB.Recordset RS.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly lst_abast.ListItems.Clear If RS.RecordCount > 0 Then Do While RS.EOF = False Set Litem = lst_abast.ListItems.Add Litem.Text = RS("AB_DATA") Litem.SubItems(1) = RS("AB_HORA") Litem.SubItems(2) = RS("AB_UF") Litem.SubItems(3) = RS("AB_MUN") Litem.SubItems(4) = RS("AB_QTDE_L") Litem.SubItems(5) = Format(RS("AB_TOTAL"), "0.00") Litem.SubItems(6) = RS("AB_FPGTO") RS.MoveNext Loop '--------------------------------------------- guarda qntos reg tem, para verficar na alterao se deletou todos lbl_gd_abast.Caption = lst_abast.ListItems.Count '--------------------------------------------RS.Close End If '--------------------------- CARREGA GRID TRECHOS Sql = "SELECT * FROM GT_AC_TRECHOS WHERE TR_NUM_AC=" & Val_Sgt(TXT_NUMERO.Text) & " ORD ER BY TR_KEY " Set RS = New ADODB.Recordset RS.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly lst_trechos.ListItems.Clear If RS.RecordCount > 0 Then

Frm_acomp_Viagem - 39 Do While RS.EOF = False Set Litem = lst_trechos.ListItems.Add Litem.Text = RS("TR_UF") Litem.SubItems(1) = RS("TR_MUN") Litem.SubItems(2) = IIf(IsNull(RS("TR_DT_PART")) = False, Format(RS("TR_DT_PART "), "dd/mm/yyyy"), " / / ") Litem.SubItems(3) = RS("TR_KM_PART") Litem.SubItems(4) = RS("TR_uf_DEST") Litem.SubItems(5) = RS("TR_CID_DEST") Litem.SubItems(6) = IIf(IsNull(RS("TR_DT_CHEG")) = True, " / / ", Format(R S("TR_DT_CHEG"), "dd/mm/yyyy")) Litem.SubItems(7) = RS("TR_KM_CHEG") Litem.SubItems(8) = Format(RS("TR_VL_SALDO"), "0.00") Litem.SubItems(9) = IIf(IsNull(RS("TR_FPGTO_SALDO")) = True, " ", RS("TR_FPGTO_ SALDO")) Litem.SubItems(10) = Format(RS("TR_VL_ADI"), "0.00") Litem.SubItems(11) = IIf(Trim(RS("TR_FPGTO_ADI")) = "", " ", RS("TR_FPGTO_ADI") ) Litem.SubItems(12) = RS("tr_peso") Litem.SubItems(13) = RS("TR_AGENC") Litem.SubItems(14) = Format(Val_Sgt(RS("TR_DESP_AG")), "0.00") Litem.SubItems(15) = IIf(RS("TR_FPAGTO_ag") = "", " ", RS("TR_FPAGTO_ag")) Litem.SubItems(16) = IIf(RS("TR_VLR_BASE_COMISS") = "", 0, Format(RS("TR_vlr_ba se_comiss"), "0.00")) RS.MoveNext Loop '--------------------------------------------- guarda qntos reg tem, para verficar na alterao se deletou todos lbl_gd_trechos.Caption = lst_trechos.ListItems.Count '--------------------------------------------RS.Close End If '--------------------------- CARREGA GRID ADIANTAMENTOS Sql = "SELECT * FROM GT_AC_ADIANTAMENTO WHERE AD_NUM_AC=" & Val_Sgt(TXT_NUMERO.Text) & " ORDER BY AD_KEY " Set RS = New ADODB.Recordset RS.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly lst_adi.ListItems.Clear If RS.RecordCount > 0 Then Do While RS.EOF = False Set Litem = lst_adi.ListItems.Add Litem.Text = RS("AD_DATA") Litem.SubItems(1) = Format(RS("AD_VLR"), "0.00") Litem.SubItems(2) = RS("AD_AUTORIZADO") RS.MoveNext Loop '--------------------------------------------- guarda qntos reg tem, para verficar na alterao se deletou todos lbl_gd_ADI.Caption = lst_adi.ListItems.Count '--------------------------------------------RS.Close End If '--------------------------- CARREGA GRID PEDAGIOS Sql = "SELECT * FROM GT_AC_PEDAGIO WHERE PD_NUM_AC=" & Val_Sgt(TXT_NUMERO.Text) & " ORD ER BY PD_KEY " Set RS = New ADODB.Recordset RS.Open Sql, Db_ADO, adOpenStatic, adLockReadOnly LST_PED.ListItems.Clear If RS.RecordCount > 0 Then Do While RS.EOF = False Set Litem = LST_PED.ListItems.Add Litem.Text = RS("PD_UF") Litem.SubItems(1) = RS("PD_MUN") Litem.SubItems(2) = RS("PD_DATA") Litem.SubItems(3) = Format(RS("PD_VaLoR"), "0.00") Litem.SubItems(4) = RS("PD_fpgto") RS.MoveNext Loop '--------------------------------------------- guarda qntos reg tem, para verficar

Frm_acomp_Viagem - 40 na alterao se deletou todos lbl_gd_ped.Caption = LST_PED.ListItems.Count '--------------------------------------------RS.Close End If If Mid(lbl_sit.Caption, 1, 1) = 1 Then Habilita True Else If MDIMenu!MnuUsuario.Enabled = True Then Habilita True SSTab.Enabled = True fra_adi.Enabled = True CMD_REMOVE_ADI.Visible = True fra_DESP.Enabled = True CMD_DEL_desp.Visible = True FRA_ABASTE.Enabled = True CMD_DEL_abast.Visible = True FRA_TRECHOS.Enabled = True CMD_DEL_tch.Visible = True lst_trechos.Enabled = True FRA_PED.Enabled = True CMD_PED_REMOVE.Visible = True End If End If TXT_NUMERO.Enabled = False CMD_INCLUIR_AC.Caption = "Alterar" cmd_NOVO.Enabled = False '--------------TOTALIZA_RESUMO '------------'---- HABILITA BOTAO DE FECHAMENTO ---If Mid(lbl_sit.Caption, 1, 1) = 1 Then cmd_FEXAR.Visible = True Else cmd_FEXAR.Visible = False End If '-------------------------------------Else MsgBox "NENHUM REGISTRO ENCONTRADO!", vbExclamation, "AVISO" TXT_NUMERO.Text = "" TXT_NUMERO.SetFocus Exit Sub End If

End If End Sub Private Sub TXT_PED_VLR_GotFocus() Marca End Sub Private Sub TXT_PED_VLR_LostFocus() TXT_PED_VLR.Text = Format(TXT_PED_VLR.Text, "0.00") End Sub Private Sub txt_perc_comiss_GotFocus() Marca End Sub Private Sub txt_perc_comiss_KeyPress(KeyAscii As Integer) TrancaString1 KeyAscii End Sub

Frm_acomp_Viagem - 41

Private Sub txt_perc_comiss_LostFocus() txt_vlr_base_LostFocus TOTALIZA_RESUMO End Sub Private Sub txt_Rel_viag_GotFocus() Marca End Sub Private Sub txt_Rel_viag_KeyPress(KeyAscii As Integer) TrancaString KeyAscii End Sub Private Sub txt_saida_odo_KeyPress(KeyAscii As Integer) TrancaString KeyAscii End Sub

Private Sub txt_frt_ida_GotFocus() Marca End Sub Private Sub txt_frt_ida_LostFocus() txt_frt_ida.Text = Format(txt_frt_ida.Text, "0.00") End Sub Private Sub txt_frt_volta_GotFocus() Marca End Sub Private Sub txt_frt_volta_LostFocus() txt_frt_volta.Text = Format(txt_frt_volta.Text, "0.00") End Sub Private Sub TXT_NUMERO_GotFocus() Marca End Sub Private Sub txt_peso_ida_GotFocus() Marca End Sub Private Sub txt_peso_volta_GotFocus() Marca End Sub Private Sub txt_saida_odo_GotFocus() Marca End Sub Private Sub txT_tch_adi_GotFocus() Marca End Sub Private Sub txT_tch_adi_LostFocus() txT_tch_adi.Text = Format(txT_tch_adi.Text, "0.00") txt_tch_saldo.Text = Format(Val_Sgt(txt_tch_tot_frete.Text) - Val_Sgt(txT_tch_adi.Text), "0.00" ) End Sub Private Sub txt_TCH_base_comiss_GotFocus() Marca

Frm_acomp_Viagem - 42 End Sub Private Sub txt_TCH_base_comiss_KeyPress(KeyAscii As Integer) TrancaString1 KeyAscii End Sub Private Sub txt_TCH_base_comiss_LostFocus() txt_TCH_base_comiss.Text = Format(txt_TCH_base_comiss.Text, "0.00") End Sub Private Sub txt_tch_desp_Ag_GotFocus() Marca End Sub Private Sub txt_tch_desp_Ag_KeyPress(KeyAscii As Integer) TrancaString1 KeyAscii End Sub Private Sub txt_tch_desp_Ag_LostFocus() txt_tch_desp_Ag.Text = Format(txt_tch_desp_Ag, "0.00") End Sub Private Sub txt_tch_km_partida_GotFocus() Marca End Sub Private Sub txt_tch_km_partida_KeyPress(KeyAscii As Integer) TrancaString KeyAscii End Sub Private Sub txt_tch_odo_dest_GotFocus() Marca End Sub Private Sub txt_tch_odo_dest_KeyPress(KeyAscii As Integer) TrancaString KeyAscii End Sub Private Sub txt_tch_peso_GotFocus() Marca End Sub Private Sub txt_tch_peso_KeyPress(KeyAscii As Integer) TrancaString1 KeyAscii End Sub Private Sub txt_tch_saldo_GotFocus() Marca End Sub Private Sub txt_tch_saldo_LostFocus() txt_tch_saldo.Text = Format(txt_tch_saldo.Text, "0.00") End Sub

Private Sub txt_tch_saldo_KeyPress(KeyAscii As Integer) TrancaString1 KeyAscii End Sub Private Sub txt_tch_tot_frete_GotFocus() Marca End Sub

Frm_acomp_Viagem - 43 Private Sub txt_tch_tot_frete_LostFocus() txt_tch_tot_frete.Text = Format(txt_tch_tot_frete.Text, "0.00") txT_tch_adi_LostFocus End Sub Private Sub txt_vlr_base_GotFocus() Marca End Sub Private Sub txt_vlr_base_KeyPress(KeyAscii As Integer) TrancaString1 KeyAscii End Sub Private Sub txt_vlr_base_LostFocus() txt_vlr_base.Text = Format(txt_vlr_base.Text, "0.00") TOTALIZA_RESUMO End Sub