Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Imports fatd_faturamento.BLL.Repositorio
Imports fatd_faturamento.ENTIDADE
Imports CrystalDecisions.CrystalReports.Engine
Friend Class frmImpFat
	Inherits System.Windows.Forms.Form
	Public impServ As String
	Private Medidas_Clientes As String
	Private Medidas_Total As String
	Private Cabecalho_Lin1 As String
	'Private irstNfTab As ADODB.Recordset
	Private ilngConta As Integer
	Private strTitulo As String
	Private strSubtitulo As String
	Private strSubTitulo2 As String
	Private strTamCab As String
	Private booLandCab As Boolean
	Private LCItens As System.Windows.Forms.ListViewItem
    Private dt, dt1, dt2, dt3, dt4 As DataTable
    Private dtGlobal As DataTable
    Private LImagem() As Byte
    Private sNomeEmpresa As String
    Private sEnderecoEmpresa As String
    Private sCepEmpresa As String
    Private sCidadeEmpresa As String
    Private sUFempresa As String
    Private sBairroEmpresa As String
    Private sFoneEmpresa As String
    Private sWebEmpresa As String

    Private objAtualizaBancoDados As New entidadeAtualizaBancoDados
	Private repositorioAtualizaBancosDados As New repositorioAtualizaBancoDados

	Private objExecAtualizaBancoDados As New entidadeAtualizaBancoDados
	Private repositorioExecAtualizaBancosDados As New repositorioAtualizaBancoDados

	'UPGRADE_WARNING: Event chkGrupoA.CheckStateChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub chkGrupoA_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkGrupoA.CheckStateChanged
		If Me.chkGrupoA.CheckState = 0 Then
			If Me.chkGrupoB.CheckState = 0 Then
				Me.chkGrupoB.CheckState = System.Windows.Forms.CheckState.Checked
			End If
		End If
		If Me.chkGrupoA.CheckState = 0 Then
			'Call inibeFrame(Me.FrameClasse.Name, False)
		Else
			'Call inibeFrame(Me.FrameClasse.Name, True)
		End If
	End Sub
	
	'UPGRADE_WARNING: Event chkGrupoB.CheckStateChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub chkGrupoB_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkGrupoB.CheckStateChanged
		If Me.chkGrupoB.CheckState = 0 Then
			If Me.chkGrupoA.CheckState = 0 Then
				Me.chkGrupoA.CheckState = System.Windows.Forms.CheckState.Checked
			End If
		End If
	End Sub
	
	'UPGRADE_WARNING: Event chkVencimento.CheckStateChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub chkVencimento_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkVencimento.CheckStateChanged
		If chkVencimento.CheckState = 1 Then
			lblDias.Enabled = True
			cmbDias.Enabled = True
		Else
			lblDias.Enabled = False
			cmbDias.Enabled = False
			cmbDias.Text = "GERAL"
		End If
	End Sub
	
	'UPGRADE_WARNING: Event cmbBancos.TextChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	'UPGRADE_WARNING: ComboBox event cmbBancos.Change was upgraded to cmbBancos.TextChanged which has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="DFCDE711-9694-47D7-9C50-45A99CD8E91E"'
	Private Sub cmbBancos_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmbBancos.TextChanged
		If cmbBancos.Text <> "" Then
			Me.OptSin.Enabled = True
		Else
			Me.OptSin.Enabled = False
			Me.OptAnal.Checked = True
			Me.OptGrupoBan.CheckState = System.Windows.Forms.CheckState.Unchecked
		End If
	End Sub
	
	'UPGRADE_WARNING: Event cmbBancos.SelectedIndexChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub cmbBancos_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmbBancos.SelectedIndexChanged
		If cmbBancos.Text <> "" Then
			Me.OptSin.Enabled = True
		Else
			Me.OptSin.Enabled = False
			Me.OptAnal.Checked = True
			Me.OptGrupoBan.CheckState = System.Windows.Forms.CheckState.Unchecked
		End If
	End Sub
	
	Private Sub cmbKWh_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmbKWh.Leave
		Me.cmbKWh.Tag = Me.cmbKWh.Text
	End Sub
	
	Private Sub cmdProcConsID_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdProcConsID.Click
		'  Call frmLocalizaUnidade.Show
		'  Call frmLocalizaUnidade.SetaLocalizaUnidade("C", Me)
	End Sub
	
	Private Sub cmdProcZLC_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdProcZLC.Click
		'  Call frmLocalizaUnidade.Show
		'  Call frmLocalizaUnidade.SetaLocalizaUnidade("U", Me)
	End Sub
	
	Private Sub cmdVisual_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdVisual.Click
		Dim sqlRel As String
		Dim sortRel As String
		Dim strOrd As String
		Dim strAND As String
		Dim dataA As String
        Dim dataB As String
        Dim lstrsql As String


        Try
            Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
            ' Call OnOffProcMon(True, "Selecionando dados...", 1000)
            'If irstNfTab.State = ADODB.ObjectStateEnum.adStateOpen Then irstNfTab.Close()
            System.Windows.Forms.Application.DoEvents()
            Me.cmdVisual.Enabled = False
            'Seleção dos dados
            Select Case impServ
                Case "Cart11" 'Todos faturados
                    sqlRel = "select * from `nf` where flgst<> 'X' "
                    strTitulo = Me.Text
                    'Mmdc.Value = "S"
                    Call queGrupoTitulo()
                    Call queClasseSubTitulo2()
                    booLandCab = False
                    strTamCab = "3"
                Case "Cart65" 'Arrecadação
                    sqlRel = "select * from `nf` where flgst='P'"
                    strTitulo = Me.Text & " - Total - "
                    If Me.txtPeriodoIni.Text <> "" Then
                        If Me.txtPeriodoFin.Text <> "" Then
                            strSubtitulo = "Arrecadação referente a " & Me.txtPeriodoIni.Text & " até " & Me.txtPeriodoFin.Text
                        Else
                            Me.txtPeriodoIni.Text = ""
                            strSubtitulo = "Arrecadação geral"
                        End If
                    Else
                        strSubtitulo = "Arrecadação geral"
                    End If
                    Call queClasseSubTitulo2()
                    booLandCab = False
                    strTamCab = "4"
                Case "Convênios e Diversos"


                    lstrsql = ""
                    lstrsql = "DELETE FROM AUX_CONVENIOS_DIVERSOS" & VB.Right(My.Computer.Name, 5)
                    objExecAtualizaBancoDados.QUERY_NAME = lstrsql
                    repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

                    lstrsql = ""
                    lstrsql = "DELETE FROM AUX_CONVENIOS_DIVERSOS_2" & VB.Right(My.Computer.Name, 5)
                    objExecAtualizaBancoDados.QUERY_NAME = lstrsql
                    repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

                    sqlRel = "select * from `nf` where flgst<>'X'"
                    strTitulo = Me.Text & " - Total - "
                    If Me.txtPeriodoIni.Text <> "" Then
                        If Me.txtPeriodoFin.Text <> "" Then
                            strSubtitulo = "Referente a " & Me.txtPeriodoIni.Text & " até " & Me.txtPeriodoFin.Text
                        Else
                            Me.txtPeriodoIni.Text = ""
                            strSubtitulo = "Geral"
                        End If
                    Else
                        strSubtitulo = "Geral"
                    End If
                    Call queClasseSubTitulo2()
                    booLandCab = False
                    strTamCab = "4"

                Case "Serviços Taxados"

                    lstrsql = ""
                    lstrsql = "DELETE FROM AUX_SERVICOS_TAXADOS" & VB.Right(My.Computer.Name, 5)
                    objExecAtualizaBancoDados.QUERY_NAME = lstrsql
                    repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

                    sqlRel = "select * from `nf` where flgst<>'X'"
                    strTitulo = Me.Text & " - Total - "
                    If Me.txtPeriodoIni.Text <> "" Then
                        If Me.txtPeriodoFin.Text <> "" Then
                            strSubtitulo = "Referente a " & Me.txtPeriodoIni.Text & " até " & Me.txtPeriodoFin.Text
                        Else
                            Me.txtPeriodoIni.Text = ""
                            strSubtitulo = "Geral"
                        End If
                    Else
                        strSubtitulo = "Geral"
                    End If
                    Call queClasseSubTitulo2()
                    booLandCab = False
                    strTamCab = "4"
                Case "Cart96" 'Vencidos e à vencer
                    sqlRel = "select * from `nf` where trim(flgst)=''"
                    strTitulo = Me.Text
                    Call queGrupoTitulo()
                    Call queClasseSubTitulo2()
                    booLandCab = False
                    strTamCab = "3"
                Case "Cart98" 'Total recebido no período
                    sqlRel = "select * from `nf` where flgst='P'"
                    strTitulo = Me.Text
                    Call queGrupoTitulo()
                    Call queClasseSubTitulo2()
                    booLandCab = False
                    strTamCab = "3"
                Case "Reserva"
                    '
                Case Else
                    Call MsgBox("Em análise", MsgBoxStyle.Exclamation, "NSS-Construção")
            End Select
            strSubTitulo2 = strSubTitulo2 & "   Grupo: " & Mid(Me.cmbClasse.Text, 4, Len(Me.cmbClasse.Text) - 3) & "    KWh: " & Me.cmbKWh.Text & ""
            If Me.OptKWhC.Visible = True And Me.OptKWhF.Visible = True Then
                If Me.OptKWhC.Checked = True Then
                    strSubTitulo2 = strSubTitulo2 & " Consumido   "
                Else
                    strSubTitulo2 = strSubTitulo2 & " Faturado   "
                End If
            End If
            strSubTitulo2 = strSubTitulo2 & " Fase: " & Me.cmbFase.Text
            'Filtragem
            '------ Seleção de faturas -------
            'Grupo A e B
            If chkGrupoA.CheckState = 1 And chkGrupoB.CheckState = 1 Then
                '
            ElseIf chkGrupoA.CheckState = 1 Then
                'Grupo A somente
                sqlRel = sqlRel & " and substring(ta,3,1)='A'"
                strAND = strAND & " and substring(ta,3,1)='A'"
            ElseIf chkGrupoB.CheckState = 1 Then
                'Grupo B somente
                sqlRel = sqlRel & " and substring(ta,3,1)='B'"
                strAND = strAND & " and substring(ta,3,1)='B'"
            End If
            'Por periodo
            If Me.FrameMesAno.Visible = True Then
                If Me.OptPeriodo.Checked = True Then 'Por período
                    If Me.txtPeriodoFin.Text <> "" And Me.txtPeriodoIni.Text <> "" Then
                        sqlRel = sqlRel & " and datapag >= '" & VB6.Format(Me.txtPeriodoIni.Text, "yyyy-MM-dd") & "' and datapag <= '" & VB6.Format(Me.txtPeriodoFin.Text, "yyyy-MM-dd") & "'"
                        strAND = strAND & " and datapag >= '" & VB6.Format(Me.txtPeriodoIni.Text, "yyyy-MM-dd") & "' and datapag <= '" & VB6.Format(Me.txtPeriodoFin.Text, "yyyy-MM-dd") & "'"
                    End If
                End If
            End If
            'Por fatura única
            If Me.FrameFatUni.Visible = True Then
                If Me.OptUniFat.Checked = True Then 'Por fatura
                    If Len(Me.txtNumFat.Text) > 4 Then
                        sqlRel = sqlRel & " and mesano='" & Mid(Me.txtNumFat.Text, 1, 5) & "' and numnf='" & Mid(Me.txtNumFat.Text, 6, Len(Me.txtNumFat.Text) - 6)
                        strAND = strAND & " and mesano='" & Mid(Me.txtNumFat.Text, 1, 5) & "' and numnf='" & Mid(Me.txtNumFat.Text, 6, Len(Me.txtNumFat.Text) - 6)
                    End If
                End If
            End If
            'Por mes/ano base
            If Me.FrameMesanoBase.Visible = True Then
                If Me.OptPeriodo.Checked = True Then 'Por período
                    If Me.txtMesano.Text <> "" Then
                        sqlRel = sqlRel & " and mesano = '" & Me.txtMesano.Text & "'"
                        strAND = strAND & " and mesano = '" & Me.txtMesano.Text & "'"
                    End If
                End If
            End If
            '--------------------------------
            'Bancos
            If Me.FrameBan.Visible = True Then
                If Me.cmbBancos.Text <> "" Then
                    If Mid(Me.cmbBancos.Text, 1, 2) <> "XX" Then
                        sqlRel = sqlRel & " and banarrec='" & VB6.GetItemData(Me.cmbBancos, Me.cmbBancos.SelectedIndex) & "'"
                        strAND = strAND & " and banarrec='" & VB6.GetItemData(Me.cmbBancos, Me.cmbBancos.SelectedIndex) & "'"
                    End If
                End If
            End If
            '------------------------------------------
            'UC
            If Me.FrameUC.Enabled = True Then
                If Me.txtUCsol.Enabled = True And Me.txtUCsol.Text <> "" Then
                    sqlRel = sqlRel & " and concat(zona,livro,conta) like '" & Me.txtUCsol.Text & "%'"
                    strAND = strAND & " and concat(zona,livro,conta) like '" & Me.txtUCsol.Text & "%'"
                End If
                If Me.cmbCidade.Enabled = True And Me.cmbCidade.Text <> "" Then
                    sqlRel = sqlRel & " and cidade='" & Me.cmbCidade.Text & "'"
                    strAND = strAND & " and cidade='" & Me.cmbCidade.Text & "'"
                End If
            End If
            '------------------------------------------
            'Classe
            If Me.FrameClasse.Enabled = True Then
                If Me.cmbClasse.Text <> "" And Mid(Me.cmbClasse.Text, 1, 2) <> "XX" Then
                    sqlRel = sqlRel & " and ta like '%" & Mid(Me.cmbClasse.Text, 1, 2) & "%'"
                    strAND = strAND & " and ta like '%" & Mid(Me.cmbClasse.Text, 1, 2) & "%'"
                End If
            End If
            '------------------------------------------
            'Consumidor
            If Me.FrameConsum.Enabled = True Then
                If Me.txtConsID.Text <> "" Then
                    sqlRel = sqlRel & " and cons_id='" & Me.txtConsID.Text & "'"
                    strAND = strAND & " and cons_id='" & Me.txtConsID.Text & "'"
                End If
            End If
            '------------------------------------------
            'Titulos a vencidos e à vencer
            If Me.FrameTitulos.Enabled = True Then
                If Me.OptVencidos.Checked = True Then
                    If Me.txtMesano.Text <> "" Then
                        sqlRel = sqlRel & " and datavenc =< '" & VB6.Format(Me.txtMesano.Text, "yyyy-MM-dd") & "'"
                        strAND = strAND & " and datavenc =< '" & VB6.Format(Me.txtMesano.Text, "yyyy-MM-dd") & "'"
                    End If
                End If
                If Me.OptVencer.Checked = True Then
                    If Me.txtMesano.Text <> "" Then
                        sqlRel = sqlRel & " and datavenc >= '" & VB6.Format(Me.txtMesano.Text, "yyyy-MM-dd") & "'"
                        strAND = strAND & " and datavenc >= '" & VB6.Format(Me.txtMesano.Text, "yyyy-MM-dd") & "'"
                    End If
                End If
            End If
            'Por Vencimento
            If Me.chkVencimento.CheckState = 1 Then
                If Me.OptVencidos.Checked = True Then
                    If cmbDias.Enabled = True Then
                        If cmbDias.Text <> "GERAL" Then
                            '	dataA = devolveAB((cmbDias.Text), "A")
                            '	dataB = devolveAB((cmbDias.Text), "B")
                            If dataA <> dataB Then
                                sqlRel = sqlRel & " and curdate() > DATE_ADD(DATAVENC, INTERVAL '" & dataA & "' DAY)"
                                sqlRel = sqlRel & " AND curdate() <= DATE_ADD(DATAVENC, INTERVAL '" & dataB & "' DAY)"
                                strAND = strAND & " and curdate() > DATE_ADD(DATAVENC, INTERVAL '" & dataA & "' DAY)"
                                strAND = strAND & " AND curdate() <= DATE_ADD(DATAVENC, INTERVAL '" & dataB & "' DAY)"
                            Else
                                Select Case Mid(dataA, 1, 1)
                                    Case ">"
                                        If Mid(dataA, 2, 1) = "=" Then
                                            sqlRel = sqlRel & " and curdate() >= DATE_ADD(DATAVENC, INTERVAL '" & Mid(dataA, 3, Len(dataA) - 2) & "' DAY)"
                                            strAND = strAND & " and curdate() >= DATE_ADD(DATAVENC, INTERVAL '" & Mid(dataA, 3, Len(dataA) - 2) & "' DAY)"
                                        Else
                                            sqlRel = sqlRel & " and curdate() > DATE_ADD(DATAVENC, INTERVAL '" & Mid(dataA, 2, Len(dataA) - 1) & "' DAY)"
                                            strAND = strAND & " and curdate() > DATE_ADD(DATAVENC, INTERVAL '" & Mid(dataA, 2, Len(dataA) - 1) & "' DAY)"
                                        End If
                                    Case "<"
                                        If Mid(dataA, 2, 1) = "=" Then
                                            sqlRel = sqlRel & " and curdate() <= DATE_ADD(DATAVENC, INTERVAL '" & Mid(dataA, 3, Len(dataA) - 2) & "' DAY)"
                                            strAND = strAND & " and curdate() <= DATE_ADD(DATAVENC, INTERVAL '" & Mid(dataA, 3, Len(dataA) - 2) & "' DAY)"
                                        Else
                                            sqlRel = sqlRel & " and curdate() < DATE_ADD(DATAVENC, INTERVAL '" & Mid(dataA, 2, Len(dataA) - 1) & "' DAY)"
                                            strAND = strAND & " and curdate() < DATE_ADD(DATAVENC, INTERVAL '" & Mid(dataA, 2, Len(dataA) - 1) & "' DAY)"
                                        End If
                                    Case "="
                                        sqlRel = sqlRel & " and curdate() = DATE_ADD(DATAVENC, INTERVAL '" & Mid(dataA, 2, Len(dataA) - 1) & "' DAY)"
                                        strAND = strAND & " and curdate() = DATE_ADD(DATAVENC, INTERVAL '" & Mid(dataA, 2, Len(dataA) - 1) & "' DAY)"
                                    Case Else
                                        Call MsgBox("Dias de vencimento ignorado!", MsgBoxStyle.Exclamation, gstrTituloMensagem)
                                End Select
                            End If
                        End If
                    End If
                Else
                    sqlRel = sqlRel & " and curdate() > DATAVENC"
                    strAND = strAND & " and curdate() > DATAVENC"
                End If
            End If
            ' Por Fase
            If Me.FrameFase.Enabled = True Then
                If Me.cmbFase.Text <> "Todas" And Me.cmbFase.Text <> "" Then
                    sqlRel = sqlRel & " and fase='" & cmbFase.Text & "'"
                    strAND = strAND & " and fase='" & cmbFase.Text & "'"
                End If
            End If
            'Por tipoUC
            'UPGRADE_WARNING: Lower bound of collection Me.LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
            If Me.LvClasses.Items.Item(1).Checked = False Then
                Me.LvClasses.Tag = CStr(0) 'Indicação de and ou OR
                For ilngConta = 2 To Me.LvClasses.Items.Count
                    'UPGRADE_WARNING: Lower bound of collection Me.LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
                    If Me.LvClasses.Items.Item(ilngConta).Checked = True Then
                        If CDbl(Me.LvClasses.Tag) = 0 Then
                            'UPGRADE_WARNING: Lower bound of collection LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
                            sqlRel = sqlRel & " and tipouc='" & Val(LvClasses.Items.Item(ilngConta).Text) & "'"
                        Else
                            'UPGRADE_WARNING: Lower bound of collection LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
                            sqlRel = sqlRel & " or tipouc='" & Val(LvClasses.Items.Item(ilngConta).Text) & "'"
                            sqlRel = sqlRel & strAND
                        End If
                        Me.LvClasses.Tag = CStr(1)
                    End If
                Next ilngConta
            End If
            '--- Agrupamento -----------------------------------
            'Bancos
            If Me.FrameBan.Enabled = True Then
                If Me.cmbBancos.Text = "" Or Mid(Me.cmbBancos.Text, 1, 2) = "XX" Then
                    If Me.OptGrupoBan.CheckState = 1 Then
                        sortRel = sortRel & " group by banident"
                    Else
                        sortRel = ""
                    End If
                End If
            End If
            '-------------------------------------
            'Classe
            If Me.FrameClasse.Enabled = True Then
                If Me.cmbClasse.Text = "" Or Mid(Me.cmbClasse.Text, 1, 2) = "XX" Then
                    If Me.OptGrupoClas.CheckState = 1 Then
                        If sortRel <> "" Then
                            sortRel = sortRel & ",codclas"
                        Else
                            sortRel = " group by codclas"
                        End If
                        If strOrd <> "" Then
                            strOrd = strOrd & ",codclas"
                        Else
                            strOrd = " Order By codclas"
                        End If
                    End If
                End If
            End If
            '  Agrupamentos -------------------------------
            '  bancos é prioridade sobre Classe
            If Me.FrameAGrupa.Enabled = True Then
                If Me.OptAGIdent.Checked = True Then
                    If sortRel <> "" Then
                        sortRel = sortRel & ",zona,livro,conta"
                    Else
                        sortRel = " group by zona,livro,conta"
                    End If
                    If strOrd <> "" Then
                        strOrd = strOrd & ",zona,livro,conta"
                    Else
                        strOrd = " Order By zona,livro,conta"
                    End If
                End If
            End If
            If Me.OptAGvenc.Checked = True Then 'Vcto
                If strOrd <> "" Then
                    strOrd = strOrd & ",datavenc"
                Else
                    strOrd = " Order By datavenc"
                End If
            End If
            If Me.OptAGpag.Checked = True Then 'Pag
                If sortRel <> "" Then
                    sortRel = sortRel & ",datapag"
                Else
                    sortRel = " group by datapag"
                End If
                If strOrd <> "" Then
                    strOrd = strOrd & ",datapag"
                Else
                    strOrd = " Order By datapag"
                End If
            End If
            'Ordenação -----------------------------------------------
            If Me.FrameOrdem.Enabled = True Then
                If Me.OpOrfat.Checked = True Then
                    If strOrd <> "" Then
                        strOrd = strOrd & ",numnf"
                    Else
                        strOrd = " Order By numnf"
                    End If
                ElseIf Me.OpOrVenc.Checked = True Then
                    If strOrd <> "" Then
                        strOrd = strOrd & ",datavenc"
                    Else
                        strOrd = " Order By datavenc"
                    End If
                ElseIf Me.OpOrpag.Checked = True Then
                    If strOrd <> "" Then
                        strOrd = strOrd & ",datapag"
                    Else
                        strOrd = " Order By datapag"
                    End If
                End If
            End If
            If strOrd <> "" Then
                strOrd = strOrd & ",codclas" ' O Adema é uma Santa!!
            Else
                strOrd = " Order By codclas"
            End If
            '-----------------------------------------------
            sqlRel = sqlRel & sortRel & strOrd
            '---------------------------------------------------------
            objAtualizaBancoDados.QUERY_NAME = sqlRel
            dtGlobal = repositorioAtualizaBancosDados.Consultar(objAtualizaBancoDados)

            'Call Conectar(sqlRel, irstNfTab)
            'frmProcessoMon.ProgressBar1.Value = frmProcessoMon.ProgressBar1.Value + 400
            ' Call OnOffProcMon(False)

            If dtGlobal.Rows.Count > 0 Then
                'If irstNfTab.EOF = False And irstNfTab.BOF = False Then
                '	'Inicio do documento
                '	irstNfTab.MoveFirst()
                Select Case impServ
                    Case "Cart65"
                   ' Call montaCart65(FrmRelatorio.VS)
                    Case "Serviços Taxados"
                        Call montaServTax()
                    Case "Convênios e Diversos"
                        Call montaConvDiv()
                    Case "Cart11"
                        'If Me.OptAnal.Checked = True Then Call montaAnalitico()
                        'If Me.OptSin.Checked = True Then Call montaSimplificado()
                    Case Else
                        If Me.chkSimples.CheckState = 0 Then
                            '  If Me.OptAnal.Checked = True Then Call montaAnalitico()
                            '  If Me.OptSin.Checked = True Then Call montaSintetico()
                        Else
                            ' Call montaSimplificado()
                        End If
                End Select
                '	'------------ fim mds -------------------------
            Else
                Call MsgBox("Não existem dados relativos a consulta!", MsgBoxStyle.Exclamation, gstrTituloMensagem)
            End If
            Me.cmdVisual.Enabled = True

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: cmdVisual_Click" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try
    End Sub

    Private Sub frmImpFat_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
        Try

            Dim SqlSel As String

            sCriaTabelaAuxiliar()

            SqlSel = "select distinct cidade from `uc_faturamento` "
            objAtualizaBancoDados.QUERY_NAME = SqlSel
            dt = repositorioAtualizaBancosDados.Consultar(objAtualizaBancoDados)

            If dt.Rows.Count > 0 Then
                For Each row As DataRow In dt.Rows
                    Me.cmbCidade.Items.Add(row.Item("cidade") & "")
                Next
            End If

            dt = Nothing

            Me.cmbBancos.Items.Add("XX - Todos os Bancos")
            SqlSel = "select distinct nrbco,nmbco,ban_id from `bancos` group by nrbco"
            objAtualizaBancoDados.QUERY_NAME = SqlSel
            dt1 = repositorioAtualizaBancosDados.Consultar(objAtualizaBancoDados)

            If dt1.Rows.Count > 0 Then
                For Each row1 As DataRow In dt1.Rows
                    Me.cmbBancos.Items.Add(row1.Item("Nrbco") & "-" & row1.Item("nmbco") & "")
                    VB6.SetItemData(Me.cmbBancos, Me.cmbBancos.Items.Count - 1, row1.Item("ban_id"))
                Next
            End If

            dt1 = Nothing

            SqlSel = "select num,descri from `codigos` where num like '01%' and mid(num, 3, 2)<>'00' and mid(num, 5, 6)='000000'"
            Me.cmbClasse.Items.Add("XX-Todos Grupos A de UC")
            Me.cmbClasse.Text = "XX-Todos Grupos A de UC"
            objAtualizaBancoDados.QUERY_NAME = SqlSel
            dt2 = repositorioAtualizaBancosDados.Consultar(objAtualizaBancoDados)

            If dt2.Rows.Count > 0 Then
                For Each row2 As DataRow In dt2.Rows
                    If Mid(row2.Item("Num"), 3, 1) = "A" Then
                        Me.cmbClasse.Items.Add(Mid(row2.Item("Num"), 3, 2) & "-" & row2.Item("descri") & "")
                    End If
                Next
            End If

            dt2 = Nothing

            'Call lrstAux.Close()
            With LvClasses
                .Columns.Add("", "Cód.", CInt(VB6.TwipsToPixelsX(600)))
                .Columns.Add("", "Classes", CInt(VB6.TwipsToPixelsX(2100)))
            End With

            SqlSel = "select num,descri from `codigos` where num like '0301%' and mid(num,5,6) <> '000000'"
            objAtualizaBancoDados.QUERY_NAME = SqlSel
            dt3 = repositorioAtualizaBancosDados.Consultar(objAtualizaBancoDados)

            If dt3.Rows.Count > 0 Then
                'LCItens = LvClasses.Items.Add("XX")
                'If LCItens.SubItems.Count > 1 Then
                '	LCItens.SubItems(1).Text = "Todas as classes"
                'Else
                '	LCItens.SubItems.Insert(1, New System.Windows.Forms.ListViewItem.ListViewSubItem(Nothing, "Todas as classes"))
                'End If
                For Each row3 As DataRow In dt3.Rows
                    'Ignora o primeiro registro

                    LCItens = LvClasses.Items.Add(Mid(CStr(row3.Item("Num")), 9, 10) & "")
                    If LCItens.SubItems.Count > 1 Then
                        LCItens.SubItems(1).Text = row3.Item("descri")
                    Else
                        LCItens.SubItems.Insert(1, New System.Windows.Forms.ListViewItem.ListViewSubItem(Nothing, row3.Item("descri")))
                    End If
                Next
            End If


            'Call lrstAux.Close()
            For ilngConta = 1 To LvClasses.Items.Count - 1
                Me.LvClasses.Items.Item(ilngConta).Checked = True
            Next ilngConta

            MontaFiltro()
            MontaFiltroDT()

            Select Case Me.impServ
                Case "Cart11"
                    Me.Text = "Total do faturamento do mês"
                    Call inibeFrame(Me.FrameVenc.Name, False)
                    Call inibeFrame(Me.FrameConsum.Name, False)
                    Call inibeFrame(Me.FrameBan.Name, False)
                    Call inibeFrame(Me.FrameAGrupa.Name, False)
                    Call inibeFrame(Me.FrameOrdem.Name, False)
                    Call inibeFrame(Me.FrameTitulos.Name, False)
                    Me.FrameMesanoBase.Visible = True
                    Me.FrameFatFaixa.Visible = False
                    Me.FrameFatUni.Visible = False
                    Me.FrameMesAno.Visible = False
                    Me.OptPeriodo.Enabled = True
                    Me.OptUniFat.Enabled = False
                    Me.OptVariasFat.Enabled = False
                    Me.txtUCsol.Enabled = False
                    Me.txtUCsol.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                    Me.cmdProcZLC.Enabled = False
                    Me.cmdProcZLC.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                    Me.lblIdentUC.Enabled = False
                    Me.OptSin.Enabled = True
                Case "Cart98"
                    'Me.lblServico.Caption = "Receb. período"
                    Me.Text = "Recebimentos no período"
                    Call inibeFrame(Me.FrameVenc.Name, False)
                    Call inibeFrame(Me.FrameConsum.Name, False)
                    Call inibeFrame(Me.FrameBan.Name, False)
                    Call inibeFrame(Me.FrameAGrupa.Name, False)
                    Call inibeFrame(Me.FrameOrdem.Name, False)
                    Call inibeFrame(Me.FrameTitulos.Name, False)
                    Me.FrameMesanoBase.Visible = False
                    Me.FrameFatFaixa.Visible = False
                    Me.FrameFatUni.Visible = False
                    Me.FrameMesAno.Visible = True
                    Me.OptPeriodo.Enabled = True
                    Me.OptUniFat.Enabled = False
                    Me.OptVariasFat.Enabled = False
                    Me.txtUCsol.Enabled = False
                    Me.txtUCsol.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                    Me.cmdProcZLC.Enabled = False
                    Me.cmdProcZLC.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                    Me.lblIdentUC.Enabled = False
                Case "Cart65"
                    Me.Text = "Arrecadação"
                    Call inibeFrame(Me.FrameVenc.Name, False)
                    Call inibeFrame(Me.FrameConsum.Name, False)
                    Call inibeFrame(Me.FrameBan.Name, False)
                    Call inibeFrame(Me.FrameAGrupa.Name, False)
                    Call inibeFrame(Me.FrameOrdem.Name, False)
                    Call inibeFrame(Me.FrameTitulos.Name, False)
                    Call inibeFrame(Me.FrameClasse.Name, False)
                    Call inibeFrame(Me.FrameKWh.Name, False)
                    Me.chkSimples.Enabled = False
                    Me.FrameMesAno.Visible = True
                    Me.OptPeriodo.Enabled = True
                    Me.OptUniFat.Enabled = False
                    Me.OptVariasFat.Enabled = False
                    Me.txtUCsol.Enabled = False
                    Me.txtUCsol.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                    Me.cmdProcZLC.Enabled = False
                    Me.cmdProcZLC.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                    Me.lblIdentUC.Enabled = False
                Case "Convênios e Diversos"
                    Me.Text = Me.impServ
                    Call inibeFrame(Me.FrameVenc.Name, False)
                    Call inibeFrame(Me.FrameConsum.Name, False)
                    Call inibeFrame(Me.FrameBan.Name, False)
                    Call inibeFrame(Me.FrameAGrupa.Name, False)
                    Call inibeFrame(Me.FrameOrdem.Name, False)
                    Call inibeFrame(Me.FrameTitulos.Name, False)
                    Call inibeFrame(Me.FrameClasse.Name, False)
                    Call inibeFrame(Me.FrameKWh.Name, False)
                    Me.chkSimples.Enabled = False
                    Me.FrameMesAno.Visible = True
                    Me.OptPeriodo.Enabled = True
                    Me.OptUniFat.Enabled = False
                    Me.OptVariasFat.Enabled = False
                    Me.txtUCsol.Enabled = False
                    Me.txtUCsol.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                    Me.cmdProcZLC.Enabled = False
                    Me.cmdProcZLC.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                    Me.lblIdentUC.Enabled = False
                Case "Serviços Taxados"
                    Me.Text = Me.impServ
                    Call inibeFrame(Me.FrameVenc.Name, False)
                    Call inibeFrame(Me.FrameConsum.Name, False)
                    Call inibeFrame(Me.FrameBan.Name, False)
                    Call inibeFrame(Me.FrameAGrupa.Name, False)
                    Call inibeFrame(Me.FrameOrdem.Name, False)
                    Call inibeFrame(Me.FrameTitulos.Name, False)
                    Call inibeFrame(Me.FrameClasse.Name, False)
                    Call inibeFrame(Me.FrameKWh.Name, False)
                    Me.chkSimples.Enabled = False
                    Me.FrameMesAno.Visible = True
                    Me.OptPeriodo.Enabled = True
                    Me.OptUniFat.Enabled = False
                    Me.OptVariasFat.Enabled = False
                    Me.txtUCsol.Enabled = False
                    Me.txtUCsol.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                    Me.cmdProcZLC.Enabled = False
                    Me.cmdProcZLC.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                    Me.lblIdentUC.Enabled = False
                Case "Cart96"
                    'Me.lblServico.Caption = "Vencidos"
                    Me.Text = "Titulos Vencidos e a Vencer"
                    Me.cmbDias.Enabled = False
                    Me.lblDias.Enabled = False
                    Me.OptPeriodo.Enabled = True
                    Me.OptUniFat.Enabled = False
                    Me.OptVariasFat.Enabled = False
                    Call inibeFrame(Me.FrameTitulos.Name, True)
                    Call inibeFrame(Me.FrameConsum.Name, False)
                Case "Reserva"
                    '
            End Select

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: frmImpFat_Load" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try
    End Sub

    Private Sub lvClasses_ItemCheck(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.ItemCheckEventArgs) Handles LvClasses.ItemCheck
        Try

            Dim Item As System.Windows.Forms.ListViewItem = LvClasses.Items(eventArgs.Index)

            'If Item.Text = "XX" Then
            '	'UPGRADE_WARNING: Lower bound of collection LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
            '	If LvClasses.Items.Item(1).Checked = True Then
            '		For ilngConta = 1 To LvClasses.Items.Count
            '			'UPGRADE_WARNING: Lower bound of collection LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
            '			LvClasses.Items.Item(ilngConta).Checked = True
            '		Next ilngConta
            '	End If
            'Else
            '	'UPGRADE_WARNING: Lower bound of collection LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
            '	LvClasses.Items.Item(1).Checked = False
            'End If

            If LvClasses.Items.Item(7).Checked = True Then
                Call inibeFrame(Me.FrameKWh.Name, True)
            Else
                Call inibeFrame(Me.FrameKWh.Name, False)
            End If

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: lvClasses_ItemCheck" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try
    End Sub

    'UPGRADE_WARNING: Event optagident.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
    Private Sub optagident_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles OptAGIdent.CheckedChanged
        Try
            If eventSender.Checked Then
                Me.OpOrfat.Enabled = True
                Me.OpOrVenc.Enabled = True
                'Me.OpORemis.Enabled = True
                Me.OpOrpag.Enabled = True
                OptAGIdent.Tag = 1
            End If

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: optagident_CheckedChanged" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub

    'UPGRADE_WARNING: Event optagvenc.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
    Private Sub optagvenc_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles OptAGvenc.CheckedChanged
        Try
            If eventSender.Checked Then
                Me.OpOrfat.Enabled = True
                Me.OpOrVenc.Enabled = False
                'Me.OpORemis.Enabled = True
                Me.OpOrpag.Enabled = True

                Me.OpOrfat.Checked = True
                OptAGIdent.Tag = 2
            End If

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: optagvenc_CheckedChanged" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub

    Private Sub optagemis_Click()
        Try
            Me.OpOrfat.Enabled = True
            Me.OpOrVenc.Enabled = True
            'Me.OpORemis.Enabled = False
            Me.OpOrpag.Enabled = True
            OptAGIdent.Tag = 3

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: optagemis_Click" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub

    'UPGRADE_WARNING: Event optagpag.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
    Private Sub optagpag_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles OptAGpag.CheckedChanged
        Try
            If eventSender.Checked Then
                Me.OpOrfat.Enabled = True
                Me.OpOrVenc.Enabled = True
                'Me.OpORemis.Enabled = True
                Me.OpOrpag.Enabled = False
                OptAGIdent.Tag = 4
            End If

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: optagpag_CheckedChanged" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub

    'UPGRADE_WARNING: Event OptAnal.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
    Private Sub OptAnal_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles OptAnal.CheckedChanged
		If eventSender.Checked Then
			If Me.impServ = "Cart96" Then chkSimples.Enabled = True
		End If
	End Sub

    'UPGRADE_WARNING: Event OptPeriodo.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
    Private Sub OptPeriodo_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles OptPeriodo.CheckedChanged
        Try
            If eventSender.Checked Then
                Me.FrameMesAno.Visible = True
                Me.FrameFatFaixa.Visible = False
                Me.FrameFatUni.Visible = False
            End If

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: OptPeriodo_CheckedChanged" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub

    Private Sub chkTodos_CheckedChanged(sender As Object, e As EventArgs) Handles chkTodos.CheckedChanged
        Dim intConta As Short

        Try
            If chkTodos.Checked = True Then
                For intConta = 0 To LvClasses.Items.Count - 1
                    LvClasses.Items.Item(intConta).Checked = True
                Next

            ElseIf chkTodos.Checked = False Then
                For intConta = 0 To LvClasses.Items.Count - 1
                    LvClasses.Items.Item(intConta).Checked = False
                Next intConta
            End If

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: chktodos_CheckedChanged" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try
    End Sub


    'UPGRADE_WARNING: Event OptSin.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
    Private Sub OptSin_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles OptSin.CheckedChanged
        If eventSender.Checked Then
            'chkSimples.Enabled = False
            'chkSimples.Value = 0
        End If
    End Sub

    'UPGRADE_WARNING: Event OptUniFat.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
    Private Sub OptUniFat_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles OptUniFat.CheckedChanged
        Try
            If eventSender.Checked Then
                Me.FrameMesAno.Visible = False
                Me.FrameFatFaixa.Visible = False
                Me.FrameFatUni.Visible = True
            End If

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: chktodos_CheckedChanged" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Exit Sub
        End Try

    End Sub

    'UPGRADE_WARNING: Event OptVariasFat.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
    Private Sub OptVariasFat_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles OptVariasFat.CheckedChanged
		If eventSender.Checked Then
			Me.FrameMesAno.Visible = False
			Me.FrameFatFaixa.Visible = True
			Me.FrameFatUni.Visible = False
		End If
	End Sub

    'Public Function CabecaRel() As Object

    '	'	FrmRelatorio.VS.Font = VB6.FontChangeName(FrmRelatorio.VS.Font, "Times New Roman")
    '	'		FrmRelatorio.VS.Font = VB6.FontChangeSize(FrmRelatorio.VS.Font, 8)
    '	Call Cabecalho_Relatorio((FrmRelatorio.VS), strTitulo, strSubtitulo, strTamCab, booLandCab, strSubTitulo2)
    '	Call LineFeed((FrmRelatorio.VS), 2)

    '	' FrmRelatorio.VS.MarginLeft = "25mm"

    '	If impServ = "Cart96" Or impServ = "Cart98" Then

    '		If Me.OptSin.Checked = True Then

    '			'UPGRADE_ISSUE: VBControlExtender method VS.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
    '			FrmRelatorio.VS.CurrentY = "33mm"

    '			Select Case Me.OptAGIdent.Tag

    '				Case CStr(5)
    '					Medidas_Clientes = "<176mm;"
    '					Medidas_Total = ">121mm|>45mm;"
    '					Cabecalho_Lin1 = "^15mm|^28mm |^18mm|^20mm|^20mm|^20mm|>45mm;"
    '					FrmRelatorio.VS.AddTable(Cabecalho_Lin1, "CLIENTE|ZLC|FATURA|PERIODO|VENCTO|EMISSÃO|VLR.FATURA", "", &HE0E0E0, 0, False)
    '				Case Else

    '					Medidas_Clientes = "<161mm;"
    '					Medidas_Total = ">116mm|>45mm;"
    '					Cabecalho_Lin1 = "^28mm |^18mm|^20mm|^20mm|^20mm|>45mm;"
    '					FrmRelatorio.VS.AddTable(Cabecalho_Lin1, "ZLC|FATURA|PERIODO|VENCTO|EMISSÃO|VLR.FATURA", "", &HE0E0E0, 0, False)

    '			End Select

    '			FrmRelatorio.VS.TableBorder = VSVIEW6.TableBorderSettings.tbNone
    '			FrmRelatorio.VS.Table = "<199mm;|"

    '			FrmRelatorio.VS.MarginLeft = "25mm"
    '			FrmRelatorio.VS.Font = VB6.FontChangeSize(FrmRelatorio.VS.Font, 8)
    '			FrmRelatorio.VS.BrushStyle = VSVIEW6.BrushStyleSettings.bsSolid
    '			FrmRelatorio.VS.LineSpacing = 100
    '			FrmRelatorio.VS.TableBorder = VSVIEW6.TableBorderSettings.tbAll

    '		Else

    '			FrmRelatorio.VS.Font = VB6.FontChangeName(FrmRelatorio.VS.Font, "Times New Roman")
    '			FrmRelatorio.VS.Font = VB6.FontChangeSize(FrmRelatorio.VS.Font, 8)
    '			'UPGRADE_ISSUE: VBControlExtender method VS.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
    '			FrmRelatorio.VS.CurrentY = "33mm"

    '		End If
    '	End If
    '	FrmRelatorio.VS.Font = VB6.FontChangeSize(FrmRelatorio.VS.Font, 7)

    'End Function
    'Public Function CabecaRel_res()


    ' Select Case impServ
    ' Case "Cart11"

    ' subTituSTR = "Faturamento - Mês:"
    ' If Me.txtMesano <> "" Then
    '  subTituSTR = subTituSTR & Me.txtMesano
    'Else
    '  subTituSTR = subTituSTR & " Todos"
    'End If
    'If (Me.chkGrupoA.Value = 1 And chkGrupoB.Value = 1) Or (Me.chkGrupoA.Value = 0 And chkGrupoB.Value = 0) Then
    '   subTituSTR = subTituSTR & " - GRUPO A e B"
    'Else
    ' If chkGrupoA.Value = 1 Then subTituSTR = subTituSTR & " - GRUPO A "
    '  If chkGrupoB.Value = 1 Then subTituSTR = subTituSTR & " - GRUPO B "

    'End If
    'Call Cabecalho_Relatorio(FrmRelatorio.VS, Me.Caption, subTituSTR, "3")

    'FrmRelatorio.VS.FontName = "Times New Roman"
    'FrmRelatorio.VS.FontSize = 8
    'FrmRelatorio.VS.CurrentY = "33mm"



    ' Case "Cart65"
    'Call Cabecalho_Relatorio(FrmRelatorio.VS, strTitulo, strSubtitulo, "4", , strSubTitulo2)

    'Call LineFeed(FrmRelatorio.VS, 2)

    ' Case "Cart96"



    '   'FrmRelatorio.VS.MarginLeft = "25mm"
    '   'FrmRelatorio.VS.TableBorder = tbAll
    '   'FrmRelatorio.VS.CurrentY = "12mm"

    '
    ' If Me.OptSin = True Then

    '' Call Cabecalho_Relatorio(FrmRelatorio.VS, Me.Caption, "Lista", "2")


    '  FrmRelatorio.VS.FontName = "Times New Roman"
    '  FrmRelatorio.VS.FontSize = 8
    '  FrmRelatorio.VS.CurrentY = "33mm"

    '  Select Case Me.OptAGIdent.Tag

    '    Case 5
    '     Medidas_Clientes = "<176mm;"
    '     Medidas_Total = ">121mm|>45mm;"
    '     Cabecalho_Lin1 = "^15mm|^28mm |^18mm|^20mm|^20mm|^20mm|>45mm;"
    '     FrmRelatorio.VS.AddTable Cabecalho_Lin1, "CLIENTE|ZLC|FATURA|PERIODO|VENCTO|EMISSÃO|VLR.FATURA", "", &HE0E0E0, 0, False
    '    Case Else

    '     Medidas_Clientes = "<161mm;"
    '     Medidas_Total = ">116mm|>45mm;"
    '     Cabecalho_Lin1 = "^28mm |^18mm|^20mm|^20mm|^20mm|>45mm;"
    '     FrmRelatorio.VS.AddTable Cabecalho_Lin1, "ZLC|FATURA|PERIODO|VENCTO|EMISSÃO|VLR.FATURA", "", &HE0E0E0, 0, False

    '   End Select

    '   FrmRelatorio.VS.TableBorder = tbNone
    '   FrmRelatorio.VS.Table = "<199mm;|"

    '   FrmRelatorio.VS.MarginLeft = "25mm"
    '   FrmRelatorio.VS.FontSize = 8
    '   FrmRelatorio.VS.BrushStyle = bsSolid
    '   FrmRelatorio.VS.LineSpacing = 100
    '   FrmRelatorio.VS.TableBorder = tbAll

    ' Else

    ''   Call Cabecalho_Relatorio(FrmRelatorio.VS, Me.Caption, "Lista", "3")
    '  'Call LineFeed(FrmRelatorio.VS, 2)

    '  FrmRelatorio.VS.FontName = "Times New Roman"
    '  FrmRelatorio.VS.FontSize = 8
    '  FrmRelatorio.VS.CurrentY = "33mm"

    ' End If


    ' Case "Cart98"

    '  Call Cabecalho_Relatorio(FrmRelatorio.VS, Me.Caption, "Lista", "3")
    'Call LineFeed(FrmRelatorio.VS, 2)

    ' FrmRelatorio.VS.FontName = "Times New Roman"
    ' FrmRelatorio.VS.FontSize = 8
    ' FrmRelatorio.VS.CurrentY = "33mm"

    ''FrmRelatorio.VS.MarginLeft = "25mm"
    ''FrmRelatorio.VS.TableBorder = tbAll
    ' 'FrmRelatorio.VS.CurrentY = "12mm"

    '
    '   If Me.OptSin = True Then
    '      Select Case Me.OptAGIdent.Tag

    '        Case 5
    '         Medidas_Clientes = "<176mm;"
    '         Medidas_Total = ">121mm|>45mm;"
    '         Cabecalho_Lin1 = "^15mm|^28mm |^18mm|^20mm|^20mm|^20mm|>45mm;"
    '         FrmRelatorio.VS.AddTable Cabecalho_Lin1, "CLIENTE|ZLC|FATURA|PERIODO|VENCTO|EMISSÃO|VLR.FATURA", "", &HE0E0E0, 0, False
    '        Case Else

    '         Medidas_Clientes = "<161mm;"
    '         Medidas_Total = ">116mm|>45mm;"
    '         Cabecalho_Lin1 = "^28mm |^18mm|^20mm|^20mm|^20mm|>45mm;"
    '         FrmRelatorio.VS.AddTable Cabecalho_Lin1, "ZLC|FATURA|PERIODO|VENCTO|EMISSÃO|VLR.FATURA", "", &HE0E0E0, 0, False

    '       End Select

    '       FrmRelatorio.VS.TableBorder = tbNone
    '       FrmRelatorio.VS.Table = "<199mm;|"

    '       FrmRelatorio.VS.MarginLeft = "25mm"
    '       FrmRelatorio.VS.FontSize = 8
    '       FrmRelatorio.VS.BrushStyle = bsSolid
    '       FrmRelatorio.VS.LineSpacing = 100
    '       FrmRelatorio.VS.TableBorder = tbAll

    '      End If
    '     End Select

    'End Function
    '	Private Sub montaCart96(ByVal Cart96 As AxVSVIEW6.AxVSPrinter)
    '		Call iniDoc(Cart96, True)
    '		' Call LineFeed(Cart96, 2)
    '		Call MontaCtPagar(Cart96)
    '		Call iniDoc(Cart96, False)
    '		' Me.cmdImprime.Enabled = False
    '		Me.cmdVisual.Enabled = True
    '	End Sub

    '	Private Sub montaCart65(ByVal Cart65 As AxVSVIEW6.AxVSPrinter)
    '		FrmRelatorio.quem_chama = Me
    '		Call iniDoc(Cart65, True)
    '		criafiltro2()
    '		Call montaImpCart65(Cart65)
    '		Call iniDoc(Cart65, False)
    '		Me.cmdVisual.Enabled = True
    '		FrmRelatorio.Show()
    '	End Sub

    Private Sub montaConvDiv()
        Try
            CriaFiltro()
            criafiltro2()
            Call sDadosEmpresa(LImagem, sNomeEmpresa, sEnderecoEmpresa, sCepEmpresa, sCidadeEmpresa, sUFempresa, sBairroEmpresa, sFoneEmpresa, sWebEmpresa)
            Call detalhaDiversos("DETALHAMENTO DOS CONVÊNIOS", "9030", True)
            Call detalhaDiversos("DETALHAMENTO DOS DIVERSOS", "9080", False)
            lPrint("rptRelConveniosDiversos")
        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: montaConvDiv" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try
    End Sub
    Private Sub montaServTax()
        Try
            CriaFiltro()
            criafiltro2()
            Call sDadosEmpresa(LImagem, sNomeEmpresa, sEnderecoEmpresa, sCepEmpresa, sCidadeEmpresa, sUFempresa, sBairroEmpresa, sFoneEmpresa, sWebEmpresa)
            Call detalhaDiversos("DETALHAMENTO DOS TAXADOS", "9040", False)
            lPrint("rptRelServicosTaxados")
            Me.cmdVisual.Enabled = True
        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: montaServTax" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try
    End Sub

    '	Private Sub montaCart11(ByVal Cart11 As AxVSVIEW6.AxVSPrinter)
    '		Dim X As String
    '		Dim Y As String
    '		Dim Medida As String
    '		Dim Dado As String
    '		Dim Medida2 As String
    '		Dim posi As String
    '		Dim posiText As String
    '		Medida = ">50mm|>20mm>|>27mm|>20mm|>30mm|>20mm|>27mm|>20mm|>27mm|>20mm;"
    '		Medida2 = ">20mm|<250mm"
    '		posi = "40mm"
    '		posiText = "45mm"
    '		X = "0.00"
    '		For ilngConta = 1 To Me.fgridFiltro.Rows - 1
    '			Y = "Classe " & Me.fgridFiltro.get_TextMatrix(ilngConta, 1) & "  KWh(" & Me.cmbKWh.Tag & ")"
    '			posi = CStr(ilngConta * 25 + 40) & "mm"
    '			Cart11.CurrentX = posi
    '			Cart11.AddTable(Medida2, "|" & Y, "", &HE0E0E0, 0, False)
    '			Call FrmRelatorio.LineFeed(1)
    '			Dado = "No. DE CONSUMIDORES:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 2) & "|CONSUMO.......R$:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 6) & "|CIP..........R$:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 10) & "|EAE..........R$:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 14) & "|JUROS......R$:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 18) & ""
    '			Cart11.AddTable(Medida, Dado, "")
    '			Dado = "Kwh CONSUMIDO......:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 3) & "|F.POTENCIA....R$:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 7) & "|ENC.CAP.EMER.R$:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 11) & "|ICMS EAE ....R$:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 15) & "|CONVÊNIOS..R$:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 19) & ""
    '			Cart11.AddTable(Medida, Dado, "")
    '			Dado = "Kwh FATURADO.......:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 4) & "|DEMANDA.....R$:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 8) & "|ICMS ECE ....R$:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 12) & "|MULTA EAE....R$:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 16) & "|SERV. TAX..R$:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 20) & ""
    '			Cart11.AddTable(Medida, Dado, "")
    '			Dado = "Kw FATURADO........:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 5) & "|ICMS..........R$:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 9) & "|MULTA S/ ECE.R$:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 13) & "|DIVERSOS.....R$:|" & Me.fgridFiltro.get_TextMatrix(ilngConta, 17) & "|Total.....R$: |" & X & ""
    '			Cart11.AddTable(Medida, Dado, "")
    '			Call FrmRelatorio.LineFeed(2)
    '		Next 
    '	End Sub

    '	Private Sub montaCart98(ByVal Cart98 As AxVSVIEW6.AxVSPrinter)
    '		'Call IniDoc(Cart98, True, True)
    '		'Call Cabecalho_Relatorio(Cart98, "Total recebido no período", "Lista", "1")
    '		'Call LineFeed(Cart98, 2)
    '		If Me.OptAnal.Checked = True Then
    '			Call montaCart11(FrmRelatorio.VS)
    '		End If
    '		'Call montaGRIDtitulo("Recebimentos", Cart98, Me.fgridFiltro)
    '		'Call montaGRIDCampos("Total recebido no período", "Lista", "1", "Recedidos", Cart98, Me.fgridFiltro)
    '		'Call IniDoc(Cart98, False)
    '		'Me.cmdImprime.Enabled = True
    '		'Me.cmdVisual.Enabled = True
    '	End Sub

    '	Private Sub encheFiltro()
    '		Dim contaPesq As Short
    '		Dim valorA As String
    '		Dim valorB As Object
    '		Dim valorKW As String
    '		Dim contaKWlista As Short
    '		If irstNfTab.BOF = False And irstNfTab.EOF = False Then
    'contaKWh: 
    '			Call OnOffProcMon(True, "Analisando dados...", irstNfTab.RecordCount)
    '			If Me.chkSimples.CheckState = 1 And Me.OptAnal.Checked = True Then GoTo verDados
    '			If Me.OptAnal.Checked = True And Me.cmbKWh.Text = "NORMAL" Or Me.cmbKWh.Text = "" Then
    '				contaKWlista = contaKWlista + 1
    '				If contaKWlista < Me.cmbKWh.Items.Count Then
    '					If VB6.GetItemString(Me.cmbKWh, contaKWlista) = "NORMAL" Then
    '						GoTo PulaItem
    '					Else
    '						Me.cmbKWh.Tag = VB6.GetItemString(Me.cmbKWh, contaKWlista)
    '					End If
    '				Else
    '					GoTo Saida
    '				End If
    '			End If
    'verDados: 
    '			While irstNfTab.EOF = False
    '				contaPesq = pesqFiltro(irstNfTab.Fields("codclas").Value)
    '				If Me.OptAnal.Checked = True Then
    '					If Me.chkSimples.CheckState = 1 Then GoTo computa_item
    '					If Me.cmbKWh.Text = "NORMAL" Or Me.cmbKWh.Text = "" Then
    '						valorA = devolveAB(VB6.GetItemString(Me.cmbKWh, contaKWlista), "A")
    '						'UPGRADE_WARNING: Couldn't resolve default property of object valorB. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						valorB = devolveAB(VB6.GetItemString(Me.cmbKWh, contaKWlista), "B")
    '						'GoTo computa_item
    '					Else
    '						valorA = devolveAB((Me.cmbKWh).Text, "A")
    '						'UPGRADE_WARNING: Couldn't resolve default property of object valorB. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						valorB = devolveAB((Me.cmbKWh).Text, "B")
    '					End If
    '					'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '					valorKW = checaNulo(ChecaItensServ("0302010009", irstNfTab.Fields("itensserv").Value), True)
    '					'UPGRADE_WARNING: Couldn't resolve default property of object valorB. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '					If valorA = valorB Then
    '						If InStr(1, valorA, ">") > 0 Then
    '							valorA = Trim(Mid(valorA, 2, Len(valorA) - 1))
    '							If Val(valorKW) > Val(Mid(valorA, 2, Len(valorA) - 1)) Then 'KWhF
    '								GoTo computa_item
    '							Else
    '								GoTo PulaItem
    '							End If
    '						Else
    '							If Val(valorKW) < Val(valorA) Then 'KWhF
    '								GoTo computa_item
    '							Else
    '								GoTo PulaItem
    '							End If
    '						End If
    '					Else
    '						'UPGRADE_WARNING: Couldn't resolve default property of object valorB. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						If Val(valorKW) > Val(valorA) And Val(valorKW) <= Val(valorB) Then 'KWhF
    '							GoTo computa_item
    '						Else
    '							GoTo PulaItem
    '						End If
    '					End If
    'computa_item: 
    '					If contaPesq = 0 Then
    '						Me.fgridFiltro.Rows = Me.fgridFiltro.Rows + 1
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 1, irstNfTab.Fields("codclas").Value) ' CLASSE
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 2, "1") ' No.CONSUMIDORES
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 3, checaNulo(ChecaItensServ("0302010008", irstNfTab.Fields("itensserv").Value), True)) ' KWH CONSUMIDO
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 4, checaNulo(ChecaItensServ("0302010009", irstNfTab.Fields("itensserv").Value), True)) ' KWH FATURADO
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 5, "") ' KW FATURADO
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 6, checaNulo(ChecaItensServ("0302020008", irstNfTab.Fields("itensserv").Value), True)) ' CONSUMO
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 7, "") ' F.POTÊNCIA
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 8, "") ' DEMANDA TOTAL
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 9, checaNulo(ChecaItensServ("0302030009", irstNfTab.Fields("itensserv").Value), True)) ' ICMS
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 10, checaNulo(ChecaItensServ("0302990006", irstNfTab.Fields("itensserv").Value), True)) ' TAXA ILUM PUB. (CIP)
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 11, checaNulo(ChecaItensServ("0302070005", irstNfTab.Fields("itensserv").Value), True)) ' ECE
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 12, checaNulo(ChecaItensServ("0302030006", irstNfTab.Fields("itensserv").Value), True)) ' ICMS ECE
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 13, checaNulo(ChecaItensServ("0302050004", irstNfTab.Fields("itensserv").Value), True)) ' MULTA ECE
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 14, checaNulo(ChecaItensServ("0302070004", irstNfTab.Fields("itensserv").Value), True)) ' EAEEE
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 15, checaNulo(ChecaItensServ("0302030005", irstNfTab.Fields("itensserv").Value), True)) ' ICMS EAEEE
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 16, checaNulo(ChecaItensServ("0302050003", irstNfTab.Fields("itensserv").Value), True)) ' MULTA EAEEE
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 17, "") ' DIVERSOS
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 18, checaNulo(ChecaItensServ("0302050002", irstNfTab.Fields("itensserv").Value), True)) ' JUROS
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 19, "") ' CONVÊNIOS
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 20, "") ' SERV. TAXADOS
    '						Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 21, "") ' TOTAL
    '					Else
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 2, CStr(Val(Me.fgridFiltro.get_TextMatrix(contaPesq, 2)) + 1))
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 3, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 3), True)) + CDbl(checaNulo(ChecaItensServ("0302010008", irstNfTab.Fields("itensserv").Value), True)))) 'KWH CONSUMIDO
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 4, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 4), True)) + CDbl(checaNulo(ChecaItensServ("0302010009", irstNfTab.Fields("itensserv").Value), True)))) 'KWH FATURADO
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 5, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 5), True)) + CDbl(checaNulo(ChecaItensServ("0302010009", irstNfTab.Fields("itensserv").Value), True)))) 'KW FATURADO
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 6, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 6), True)) + CDbl(checaNulo(ChecaItensServ("0302020008", irstNfTab.Fields("itensserv").Value), True)))) 'CONSUMO
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 7, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 7), True)) + CDbl(checaNulo(ChecaItensServ("030201000X", irstNfTab.Fields("itensserv").Value), True)))) 'F.POTÊNCIA
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 8, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 8), True)) + CDbl(checaNulo(ChecaItensServ("030299000X", irstNfTab.Fields("itensserv").Value), True)))) 'DEMANDA TOT.
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 9, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 9), True)) + CDbl(checaNulo(ChecaItensServ("0302030009", irstNfTab.Fields("itensserv").Value), True)))) 'ICMS
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 10, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 10), True)) + CDbl(checaNulo(ChecaItensServ("0302990006", irstNfTab.Fields("itensserv").Value), True)))) 'ILUMINAÇÃO PUB. (CIP)
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 11, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 11), True)) + CDbl(checaNulo(ChecaItensServ("0302070005", irstNfTab.Fields("itensserv").Value), True)))) 'ECE
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 12, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 12), True)) + CDbl(checaNulo(ChecaItensServ("0302030006", irstNfTab.Fields("itensserv").Value), True)))) 'ICMS ECE
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 13, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 13), True)) + CDbl(checaNulo(ChecaItensServ("0302050004", irstNfTab.Fields("itensserv").Value), True)))) 'MULTA ECE
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 14, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 14), True)) + CDbl(checaNulo(ChecaItensServ("0302070004", irstNfTab.Fields("itensserv").Value), True)))) 'EAEEE
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 15, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 15), True)) + CDbl(checaNulo(ChecaItensServ("0302030005", irstNfTab.Fields("itensserv").Value), True)))) 'ICMS EAEEE
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 16, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 16), True)) + CDbl(checaNulo(ChecaItensServ("0302050003", irstNfTab.Fields("itensserv").Value), True)))) 'MULTA EAEEE
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 17, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 17), True)) + CDbl(checaNulo(ChecaItensServ("030205000X", irstNfTab.Fields("itensserv").Value), True)))) 'DIVERSOS
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 18, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 18), True)) + CDbl(checaNulo(ChecaItensServ("0302050002", irstNfTab.Fields("itensserv").Value), True)))) 'JUROS
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 19, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 19), True)) + CDbl(checaNulo(ChecaItensServ("030205000X", irstNfTab.Fields("itensserv").Value), True)))) 'CONVÊNIOS
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						Me.fgridFiltro.set_TextMatrix(contaPesq, 20, CStr(CDbl(checaNulo(Me.fgridFiltro.get_TextMatrix(contaPesq, 20), True)) + CDbl(checaNulo(ChecaItensServ("030205000X", irstNfTab.Fields("itensserv").Value), True)))) 'SERV. TAXADOS
    '					End If
    '				End If
    '				If Me.OptSin.Checked = True Then
    '					Me.fgridFiltro.Rows = Me.fgridFiltro.Rows + 1
    '					Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 1, irstNfTab.Fields("Zona").Value & irstNfTab.Fields("Livro").Value & irstNfTab.Fields("Conta").Value)
    '					Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 2, irstNfTab.Fields("mesano").Value)
    '					Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 3, irstNfTab.Fields("numNf").Value)
    '					Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 4, irstNfTab.Fields("ValorTot").Value)
    '					Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 5, irstNfTab.Fields("datavenc").Value)
    '					Me.fgridFiltro.set_TextMatrix(Me.fgridFiltro.Rows - 1, 6, irstNfTab.Fields("dataem").Value)
    '				End If
    '				encheFiltroDT((irstNfTab.Fields("itensserv").Value))
    'PulaItem: 
    '				irstNfTab.MoveNext()
    '				Call OnOffProcMon(False, "soma")
    '				System.Windows.Forms.Application.DoEvents()
    '			End While
    '			Me.fgridFiltro.Sort = 1
    '			Call OnOffProcMon(False)
    '			If Me.OptAnal.Checked = True And Me.cmbKWh.Text = "NORMAL" Or Me.cmbKWh.Text = "" Then
    '				irstNfTab.MoveFirst()
    '				Me.fgridFiltro.Rows = 1
    '				Me.fgridFiltroDT.Rows = 1
    '				frmProcessoMon.ProgressBar1.Value = 0
    '				GoTo contaKWh
    '			End If
    '		End If
    'Saida: 
    '		Call OnOffProcMon(False)
    '	End Sub
    Private Sub MontaFiltro()
        Try
            If Me.OptAnal.Checked = True Then
                Me.fgridFiltro.Clear()
                Me.fgridFiltro.Rows = 1
                Me.fgridFiltro.Cols = 22
                Me.fgridFiltro.set_ColWidth(0, 10)
                Me.fgridFiltro.set_ColWidth(1, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(2, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(3, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(4, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(5, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(6, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(7, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(8, (15 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(9, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(10, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(11, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(12, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(13, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(14, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(15, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(16, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(17, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(18, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(19, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(20, (10 * 100) + 240)
                Me.fgridFiltro.set_TextMatrix(0, 0, " ")
                Me.fgridFiltro.set_TextMatrix(0, 1, "SUB CLASSE .........:")
                Me.fgridFiltro.set_TextMatrix(0, 2, "No. CONS. ..........:")
                Me.fgridFiltro.set_TextMatrix(0, 3, "KWh CONSUMIDO ......:")
                Me.fgridFiltro.set_TextMatrix(0, 4, "KWh FATURADO .......:")
                Me.fgridFiltro.set_TextMatrix(0, 5, "KW FATURADO ........:")
                Me.fgridFiltro.set_TextMatrix(0, 6, "CONSUMO ..........R$:")
                Me.fgridFiltro.set_TextMatrix(0, 7, "F.POTÊNCIA .......R$:")
                Me.fgridFiltro.set_TextMatrix(0, 8, "DEMANDA TOT ......R$:")
                Me.fgridFiltro.set_TextMatrix(0, 9, "ICMS .............R$:")
                Me.fgridFiltro.set_TextMatrix(0, 10, "ILUM. PUB.(CIP)..R$:")
                Me.fgridFiltro.set_TextMatrix(0, 11, "ECE .............R$:")
                Me.fgridFiltro.set_TextMatrix(0, 12, "ICMS ECE ........R$:")
                Me.fgridFiltro.set_TextMatrix(0, 13, "MULTA ECE .......R$:")
                Me.fgridFiltro.set_TextMatrix(0, 14, "EAEEE ...........R$:")
                Me.fgridFiltro.set_TextMatrix(0, 15, "ICMS EAEEE ......R$:")
                Me.fgridFiltro.set_TextMatrix(0, 16, "MULTA EAEEE .....R$:")
                Me.fgridFiltro.set_TextMatrix(0, 17, "DIVERSOS ........R$:")
                Me.fgridFiltro.set_TextMatrix(0, 18, "JUROS ...........R$:")
                Me.fgridFiltro.set_TextMatrix(0, 19, "CONVÊNIOS .......R$:")
                Me.fgridFiltro.set_TextMatrix(0, 20, "SERV. TAXADOS ...R$:")
                Me.fgridFiltro.set_TextMatrix(0, 21, "TOTAL ...........R$:")
            End If
            If Me.OptSin.Checked = True Then
                Me.fgridFiltro.Clear()
                Me.fgridFiltro.Rows = 1
                Me.fgridFiltro.Cols = 7
                Me.fgridFiltro.set_ColWidth(0, 10)
                Me.fgridFiltro.set_ColWidth(1, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(2, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(3, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(4, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(5, (10 * 100) + 240)
                Me.fgridFiltro.set_ColWidth(6, (10 * 100) + 240)
                Me.fgridFiltro.set_TextMatrix(0, 0, " ")
                Me.fgridFiltro.set_TextMatrix(0, 1, "ZLC      ")
                Me.fgridFiltro.set_TextMatrix(0, 2, "MÊS E ANO")
                Me.fgridFiltro.set_TextMatrix(0, 3, "NF       ")
                Me.fgridFiltro.set_TextMatrix(0, 4, "VALOR    ")
                Me.fgridFiltro.set_TextMatrix(0, 5, "VENCTO   ")
                Me.fgridFiltro.set_TextMatrix(0, 6, "PAGTO    ")
            End If
        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: MontaFiltro" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try
    End Sub

    Private Sub MontaFiltroDT()
        Try
            Me.fgridFiltroDT.Clear()
            Me.fgridFiltroDT.Rows = 1
            Me.fgridFiltroDT.Cols = 7
            Me.fgridFiltroDT.set_ColWidth(0, (4 * 100))
            Me.fgridFiltroDT.set_ColWidth(1, (10 * 100) + 240)
            Me.fgridFiltroDT.set_ColWidth(2, (30 * 100) + 240)
            Me.fgridFiltroDT.set_ColWidth(3, (10 * 100) + 240)
            Me.fgridFiltroDT.set_TextMatrix(0, 0, "Tipo")
            Me.fgridFiltroDT.set_TextMatrix(0, 1, "Cód.")
            Me.fgridFiltroDT.set_TextMatrix(0, 2, "Descrição")
            Me.fgridFiltroDT.set_TextMatrix(0, 3, "Valor total")

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: MontaFiltroDT" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try
    End Sub

    '	Private Function pesqFiltro(ByRef qualServ As String) As Short
    '		'Verifica se o item já foi registrado
    '		Dim pesqServx As Short
    '		pesqServx = 0
    '		For ilngConta = 1 To Me.fgridFiltro.Rows - 1
    '			If Me.fgridFiltro.get_TextMatrix(ilngConta, 1) = qualServ Then
    '				pesqServx = ilngConta
    '				Exit For
    '			End If
    '		Next 
    '		pesqFiltro = pesqServx
    '	End Function

    '	Private Sub encheFiltroDT(ByRef itemDT As String)
    '		Dim contaPesq As Short
    '		Dim lrstAux As ADODB.Recordset
    '		lrstAux = New ADODB.Recordset
    '		Call Conectar("select num,descri,valor from `codigos` where num like '9040%' or num like '9080%' order by num", lrstAux)
    '		While lrstAux.EOF = False
    '			contaPesq = pesqFiltroDT(lrstAux.Fields("Num").Value)
    '			If contaPesq = 0 Then
    '				Me.fgridFiltroDT.Rows = Me.fgridFiltroDT.Rows + 1
    '				If Mid(lrstAux.Fields("Num").Value, 1, 4) = "9040" Then
    '					Me.fgridFiltroDT.set_TextMatrix(Me.fgridFiltroDT.Rows - 1, 0, "SVC")
    '				Else
    '					Me.fgridFiltroDT.set_TextMatrix(Me.fgridFiltroDT.Rows - 1, 0, "DIV")
    '				End If
    '				'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				Me.fgridFiltroDT.set_TextMatrix(Me.fgridFiltroDT.Rows - 1, 1, checaNulo(lrstAux.Fields("Num"))) ' Cód
    '				'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				Me.fgridFiltroDT.set_TextMatrix(Me.fgridFiltroDT.Rows - 1, 2, checaNulo(lrstAux.Fields("descri"))) ' Descrição
    '				'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				Me.fgridFiltroDT.set_TextMatrix(Me.fgridFiltroDT.Rows - 1, 3, checaNulo(lrstAux.Fields("valor"), True)) ' Valor
    '			Else
    '				'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				Me.fgridFiltroDT.set_TextMatrix(contaPesq, 3, CStr(CDbl(checaNulo(Me.fgridFiltroDT.get_TextMatrix(contaPesq, 3), True)) + CDbl(checaNulo(ChecaItensServ(lrstAux.Fields("Num").Value, itemDT), True)))) ' Serviço ou Taxa em análise
    '			End If
    '			lrstAux.MoveNext()
    '		End While
    '		Call lrstAux.Close()
    '		Me.fgridFiltroDT.Sort = 1
    '	End Sub

    '	Private Function pesqFiltroDT(ByRef qualServ As String) As Short
    '		'Verifica se o item já foi registrado
    '		Dim pesqServx As Short
    '		pesqServx = 0
    '		For ilngConta = 1 To Me.fgridFiltroDT.Rows - 1
    '			If Me.fgridFiltroDT.get_TextMatrix(ilngConta, 1) = qualServ Then
    '				pesqServx = ilngConta
    '				Exit For
    '			End If
    '		Next 
    '		pesqFiltroDT = pesqServx
    '	End Function

    '	Private Sub montaImpSintetico(ByVal VScart As AxVSVIEW6.AxVSPrinter)
    '		Dim sum_faturas As Double
    '		Dim sub_faturas As Double
    '		Dim ultimo_dia As String
    '		Dim primeiro_dia As String
    '		Dim lrstAux As ADODB.Recordset
    '		lrstAux = New ADODB.Recordset
    '		Dim temp As String
    '		Dim cod_cliente As Double
    '		Dim cod_cliente2 As Double
    '		Dim Cod_Str As String
    '		Dim Cod_Str2 As String
    '		Dim Cod_Clas As String
    '		Dim strfiltro2 As String
    '		sum_faturas = 0
    '		sub_faturas = 0
    '		strfiltro2 = "select * from `filtro2` order by ta,codclas"
    '		Call Conectar(strfiltro2, lrstAux)
    '		Dim tipo As Byte
    '		If lrstAux.RecordCount > 0 Then
    '			lrstAux.MoveLast()
    '			lrstAux.MoveFirst()

    '			Call OnOffProcMon(True, "Criando relatório...", lrstAux.RecordCount)

    '			tipo = 2


    '			Do While Not lrstAux.EOF


    '				VScart.MarginLeft = "25mm"


    '				If Me.OptGrupoBan.CheckState = 1 Then 'Bancos
    '					If Cod_Str2 <> lrstAux.Fields("banarrec").Value Then
    '						If Cod_Str2 <> "" Then
    '							sub_faturas = Imprimir_SubTotal(sub_faturas)
    '						End If

    '						VScart.MarginLeft = "15mm"
    '						VScart.CurrentY = VScart.CurrentY + 200
    '						VScart.Font = VB6.FontChangeBold(VScart.Font, True)
    '						VScart.AddTable(Medidas_Clientes, "Código do Banco " & lrstAux.Fields("banarrec").Value, "", &HFF8080, 0, False)
    '						Cod_Str2 = lrstAux.Fields("banarrec").Value
    '						temp = temp & lrstAux.Fields("cons_id").Value & "|"
    '						VScart.Font = VB6.FontChangeBold(VScart.Font, False)
    '					End If

    '				End If

    '				If Me.OptGrupoClas.CheckState = 1 Then 'Classe
    '					If Cod_Clas <> lrstAux.Fields("codclas").Value Then
    '						If Cod_Clas <> "" Then
    '							sub_faturas = Imprimir_SubTotal(sub_faturas)

    '						End If

    '						VScart.MarginLeft = "15mm"
    '						VScart.CurrentY = VScart.CurrentY + 200
    '						VScart.Font = VB6.FontChangeBold(VScart.Font, True)
    '						VScart.AddTable(Medidas_Clientes, "Classe " & lrstAux.Fields("codclas").Value, "", &H80C0FF, 0, False)
    '						Cod_Clas = lrstAux.Fields("codclas").Value
    '						temp = temp & lrstAux.Fields("cons_id").Value & "|"
    '						VScart.Font = VB6.FontChangeBold(VScart.Font, False)
    '					End If

    '				End If

    '				If Me.OptGrupoCli.CheckState = 1 Then 'Cliente
    '					If cod_cliente2 <> lrstAux.Fields("cons_id").Value Then
    '						If cod_cliente2 <> 0 Then
    '							sub_faturas = Imprimir_SubTotal(sub_faturas)

    '						End If

    '						VScart.MarginLeft = "15mm"
    '						VScart.CurrentY = VScart.CurrentY + 200
    '						VScart.Font = VB6.FontChangeBold(VScart.Font, True)
    '						VScart.AddTable(Medidas_Clientes, "Código do cliente " & lrstAux.Fields("cons_id").Value, "", &HFF80FF, 0, False)
    '						cod_cliente2 = lrstAux.Fields("cons_id").Value
    '						temp = temp & lrstAux.Fields("cons_id").Value & "|"
    '						VScart.Font = VB6.FontChangeBold(VScart.Font, False)
    '					End If

    '				End If

    '				Select Case OptAGIdent.Tag
    '					Case Is = CStr(1) 'Identificaçaõ
    '						If Cod_Str <> Mid(lrstAux.Fields("zlc").Value, 1, 5) Then
    '							If Cod_Str <> "" Then
    '								sub_faturas = Imprimir_SubTotal(sub_faturas)
    '							End If

    '							VScart.MarginLeft = "15mm"
    '							VScart.CurrentY = VScart.CurrentY + 200
    '							VScart.Font = VB6.FontChangeBold(VScart.Font, True)
    '							VScart.AddTable(Medidas_Clientes, "Zona\Livro :  ... " & Mid(lrstAux.Fields("Zlc").Value, 1, 5), "", &HE0E0E0, 0, False)
    '							Cod_Str = Mid(lrstAux.Fields("zlc").Value, 1, 5)
    '							temp = temp & lrstAux.Fields("cons_id").Value & "|"
    '							VScart.Font = VB6.FontChangeBold(VScart.Font, False)
    '						End If
    '					Case Is = CStr(2) 'vencimento
    '						If cod_cliente <> lrstAux.Fields("datavenc").Value Then
    '							If cod_cliente <> 0 Then
    '								sub_faturas = Imprimir_SubTotal(sub_faturas)
    '							End If

    '							VScart.MarginLeft = "15mm"
    '							VScart.CurrentY = VScart.CurrentY + 200
    '							VScart.Font = VB6.FontChangeBold(VScart.Font, True)

    '							VScart.AddTable(Medidas_Clientes, "Vencimento em  " & lrstAux.Fields("datavenc").Value, "", &HE0E0E0, 0, False)
    '							cod_cliente = lrstAux.Fields("datavenc").Value
    '							VScart.Font = VB6.FontChangeBold(VScart.Font, False)
    '							temp = temp & lrstAux.Fields("cons_id").Value & "|"

    '						End If

    '					Case Is = CStr(3) 'Data de Emissão
    '						If cod_cliente <> lrstAux.Fields("dataem").Value Then
    '							If cod_cliente <> 0 Then
    '								sub_faturas = Imprimir_SubTotal(sub_faturas)

    '							End If

    '							VScart.MarginLeft = "15mm"
    '							VScart.CurrentY = VScart.CurrentY + 200
    '							VScart.Font = VB6.FontChangeBold(VScart.Font, True)
    '							VScart.AddTable(Medidas_Clientes, "Emissão em " & lrstAux.Fields("dataem").Value, "", &HE0E0E0, 0, False)
    '							cod_cliente = lrstAux.Fields("dataem").Value
    '							temp = temp & lrstAux.Fields("cons_id").Value & "|"
    '							VScart.Font = VB6.FontChangeBold(VScart.Font, False)
    '						End If
    '					Case Is = CStr(4) 'Data de Pagamento
    '						If cod_cliente <> lrstAux.Fields("datapag").Value Then
    '							If cod_cliente <> 0 Then
    '								sub_faturas = Imprimir_SubTotal(sub_faturas)

    '							End If

    '							VScart.MarginLeft = "15mm"
    '							VScart.CurrentY = VScart.CurrentY + 200
    '							VScart.Font = VB6.FontChangeBold(VScart.Font, True)
    '							VScart.AddTable(Medidas_Clientes, "Pagamento em " & lrstAux.Fields("datapag").Value, "", &HE0E0E0, 0, False)
    '							cod_cliente = lrstAux.Fields("datapag").Value
    '							temp = temp & lrstAux.Fields("cons_id").Value & "|"
    '							VScart.Font = VB6.FontChangeBold(VScart.Font, False)
    '						End If

    '				End Select

    '				VScart.MarginLeft = "25mm"
    '				temp = Cabecalho_Lin1

    '				temp = temp & lrstAux.Fields("zlc").Value

    '				temp = temp & "|" & VB6.Format(lrstAux.Fields("numnf").Value, "000000")
    '				temp = temp & "|" & lrstAux.Fields("mesano").Value
    '				temp = temp & "|" & lrstAux.Fields("datavenc").Value
    '				temp = temp & "|" & lrstAux.Fields("dataem").Value
    '				temp = temp & "|" & VB6.Format(lrstAux.Fields("valortot").Value, "0.00")
    '				VScart.Table = temp



    '				sub_faturas = sub_faturas + lrstAux.Fields("valortot").Value


    '				lrstAux.MoveNext()



    '				Call OnOffProcMon(False, "soma")
    '				System.Windows.Forms.Application.DoEvents()
    '			Loop 
    '			sub_faturas = Imprimir_SubTotal(sub_faturas)
    '			Call OnOffProcMon(False)

    '		End If
    '		Call lrstAux.Close()
    '	End Sub

    '	Private Sub MontaCtPagar(ByVal VScart As AxVSVIEW6.AxVSPrinter)
    '		' Escreve_Situacao "Selecionando Dados ..."
    '		Dim ultimo_dia As String
    '		Dim primeiro_dia As String
    '		Dim temp As String
    '		Dim cod_cliente As Double
    '		Dim cod_cliente2 As Double
    '		Dim Cod_Str As String
    '		Dim Cod_Str2 As String
    '		Dim Cod_Clas As String
    '		Dim sum_faturas As Double
    '		Dim sub_faturas As Double

    '		sum_faturas = 0
    '		sub_faturas = 0


    '		Dim tipo As Byte
    '		If irstNfTab.BOF = False And irstNfTab.EOF = False Then
    '			irstNfTab.MoveLast()
    '			irstNfTab.MoveFirst()

    '			Call OnOffProcMon(True, "Criando relatório...", irstNfTab.RecordCount)

    '			tipo = 2


    '			Do While Not irstNfTab.EOF



    '				If Me.OptGrupoBan.CheckState = 1 Then 'Bancos
    '					If Cod_Str2 <> irstNfTab.Fields("banident").Value Then
    '						If Cod_Str2 <> "" Then
    '							' Imprimir_SubTotal
    '						End If

    '						VScart.MarginLeft = "15mm"
    '						VScart.CurrentY = VScart.CurrentY + 200
    '						VScart.Font = VB6.FontChangeBold(VScart.Font, True)
    '						VScart.AddTable(Medidas_Clientes, "Código do Banco " & irstNfTab.Fields("banident").Value, "", &HFF8080, 0, False)
    '						Cod_Str2 = irstNfTab.Fields("banident").Value
    '						temp = temp & irstNfTab.Fields("cons_id").Value & "|"
    '						VScart.Font = VB6.FontChangeBold(VScart.Font, False)
    '					End If

    '				End If

    '				If Me.OptGrupoClas.CheckState = 1 Then 'Classe
    '					If Cod_Clas <> irstNfTab.Fields("codclas").Value Then
    '						If Cod_Clas <> "" Then
    '							' Imprimir_SubTotal
    '						End If

    '						VScart.MarginLeft = "15mm"
    '						VScart.CurrentY = VScart.CurrentY + 200
    '						VScart.Font = VB6.FontChangeBold(VScart.Font, True)
    '						VScart.AddTable(Medidas_Clientes, "Classe " & irstNfTab.Fields("codclas").Value, "", &H80C0FF, 0, False)
    '						Cod_Clas = irstNfTab.Fields("codclas").Value
    '						temp = temp & irstNfTab.Fields("cons_id").Value & "|"
    '						VScart.Font = VB6.FontChangeBold(VScart.Font, False)
    '					End If

    '				End If

    '				If Me.OptGrupoCli.CheckState = 1 Then 'Cliente
    '					If cod_cliente2 <> irstNfTab.Fields("cons_id").Value Then
    '						If cod_cliente2 <> 0 Then
    '							' Imprimir_SubTotal
    '						End If

    '						VScart.MarginLeft = "15mm"
    '						VScart.CurrentY = VScart.CurrentY + 200
    '						VScart.Font = VB6.FontChangeBold(VScart.Font, True)
    '						VScart.AddTable(Medidas_Clientes, "Código do cliente " & irstNfTab.Fields("cons_id").Value, "", &HFF80FF, 0, False)
    '						cod_cliente2 = irstNfTab.Fields("cons_id").Value
    '						temp = temp & irstNfTab.Fields("cons_id").Value & "|"
    '						VScart.Font = VB6.FontChangeBold(VScart.Font, False)
    '					End If

    '				End If



    '				Select Case OptAGIdent.Tag
    '					Case Is = CStr(1) 'Identificaçaõ
    '						If Cod_Str <> (irstNfTab.Fields("zona").Value & irstNfTab.Fields("livro").Value) Then
    '							If Cod_Str <> "" Then
    '								' Imprimir_SubTotal
    '							End If

    '							VScart.MarginLeft = "15mm"
    '							VScart.CurrentY = VScart.CurrentY + 200
    '							VScart.Font = VB6.FontChangeBold(VScart.Font, True)
    '							VScart.AddTable(Medidas_Clientes, "Zona\Livro :  ... " & irstNfTab.Fields("Zona").Value & irstNfTab.Fields("livro").Value, "", &HE0E0E0, 0, False)
    '							Cod_Str = irstNfTab.Fields("zona").Value & irstNfTab.Fields("livro").Value
    '							temp = temp & irstNfTab.Fields("cons_id").Value & "|"
    '							VScart.Font = VB6.FontChangeBold(VScart.Font, False)
    '						End If
    '					Case Is = CStr(2) 'vencimento
    '						If cod_cliente <> irstNfTab.Fields("datavenc").Value Then
    '							If cod_cliente <> 0 Then
    '								' Imprimir_SubTotal
    '							End If

    '							VScart.MarginLeft = "15mm"
    '							VScart.CurrentY = VScart.CurrentY + 200
    '							VScart.Font = VB6.FontChangeBold(VScart.Font, True)

    '							VScart.AddTable(Medidas_Clientes, "Vencimento em  " & irstNfTab.Fields("datavenc").Value, "", &HE0E0E0, 0, False)
    '							cod_cliente = irstNfTab.Fields("datavenc").Value
    '							VScart.Font = VB6.FontChangeBold(VScart.Font, False)
    '							temp = temp & irstNfTab.Fields("cons_id").Value & "|"

    '						End If



    '						'  temp = temp & irstNfTab.Fields("cons_id") & "|"
    '						'  VScart.FontBold = False
    '						'
    '					Case Is = CStr(3) 'Data de Emissão
    '						If cod_cliente <> irstNfTab.Fields("dataem").Value Then
    '							If cod_cliente <> 0 Then
    '								' Imprimir_SubTotal
    '							End If

    '							VScart.MarginLeft = "15mm"
    '							VScart.CurrentY = VScart.CurrentY + 200
    '							VScart.Font = VB6.FontChangeBold(VScart.Font, True)
    '							VScart.AddTable(Medidas_Clientes, "Emissão em " & irstNfTab.Fields("dataem").Value, "", &HE0E0E0, 0, False)
    '							cod_cliente = irstNfTab.Fields("dataem").Value
    '							temp = temp & irstNfTab.Fields("cons_id").Value & "|"
    '							VScart.Font = VB6.FontChangeBold(VScart.Font, False)
    '						End If
    '					Case Is = CStr(4) 'Data de Pagamento
    '						If cod_cliente <> irstNfTab.Fields("datapag").Value Then
    '							If cod_cliente <> 0 Then
    '								' Imprimir_SubTotal
    '							End If

    '							VScart.MarginLeft = "15mm"
    '							VScart.CurrentY = VScart.CurrentY + 200
    '							VScart.Font = VB6.FontChangeBold(VScart.Font, True)
    '							VScart.AddTable(Medidas_Clientes, "Pagamento em " & irstNfTab.Fields("datapag").Value, "", &HE0E0E0, 0, False)
    '							cod_cliente = irstNfTab.Fields("datapag").Value
    '							temp = temp & irstNfTab.Fields("cons_id").Value & "|"
    '							VScart.Font = VB6.FontChangeBold(VScart.Font, False)
    '						End If

    '				End Select
    '				VScart.MarginLeft = "25mm"
    '				temp = Cabecalho_Lin1


    '				'If Me.OptAGvenc.Value = True Then
    '				'End If

    '				temp = temp & irstNfTab.Fields("zona").Value & irstNfTab.Fields("livro").Value & irstNfTab.Fields("conta").Value

    '				temp = temp & "|" & VB6.Format(irstNfTab.Fields("numnf").Value, "000000")
    '				temp = temp & "|" & irstNfTab.Fields("mesano").Value
    '				temp = temp & "|" & irstNfTab.Fields("datavenc").Value
    '				temp = temp & "|" & irstNfTab.Fields("dataem").Value
    '				temp = temp & "|" & VB6.Format(irstNfTab.Fields("valortot").Value, "0.00")
    '				VScart.Table = temp

    '				sub_faturas = sub_faturas + irstNfTab.Fields("valortot").Value
    '				irstNfTab.MoveNext()

    '				Call OnOffProcMon(False, "soma")
    '				System.Windows.Forms.Application.DoEvents()
    '			Loop 
    '			Call OnOffProcMon(False)
    '			'  Else
    '			'    Do While Not irstNfTab.EOF
    '			'      If cod_cliente <> irstNfTab.Fields("cons_id") Then
    '			'        If cod_cliente <> 0 Then
    '			'         ' Imprimir_SubTotal
    '			'        End If
    '			'        VScart.MarginLeft = "15mm"
    '			'        VScart.CurrentY = VScart.CurrentY + 200
    '			'        VScart.FontBold = True
    '			'        VScart.AddTable Medidas_Clientes, irstNfTab.Fields("cons_id") & " - " & irstNfTab.Fields("unid_id"), "", &HE0E0E0, 0, False
    '			'        VScart.FontBold = False
    '			'        cod_cliente = irstNfTab.Fields("cons_id")
    '			'      End If
    '			'      VScart.MarginLeft = "25mm"

    '			'      temp = Cabecalho_Lin1
    '			'      temp = temp & irstNfTab.Fields("cons_id") & "|"

    '			'     temp = temp & irstNfTab.Fields("zona") & irstNfTab.Fields("livro") & irstNfTab.Fields("conta")

    '			'      temp = temp & "|" & Format(irstNfTab.Fields("numnf"), "000000")
    '			'      temp = temp & "|" & irstNfTab.Fields("mesano")
    '			'      temp = temp & "|" & irstNfTab.Fields("datavenc")
    '			'      temp = temp & "|" & irstNfTab.Fields("datapag")
    '			'      temp = temp & "|" & Format(irstNfTab.Fields("valortot"), "###,###,##0.00")

    '			'   VScart.Table = temp

    '			'      sub_faturas = sub_faturas + irstNfTab.Fields("valortot")
    '			'      irstNfTab.MoveNext
    '			'      Call OnOffProcMon(False, "soma")
    '			'      DoEvents
    '			'    Loop
    '			'    Call OnOffProcMon(False)
    '			'  End If

    '			'Imprimir_SubTotal
    '			' Imprimir_Total
    '		End If
    '		' irstNfTab.Close

    '		'  Escreve_Situacao "Finalizando Relatório"
    '		' VScart.EndDoc
    '		'FrmRelatorio.Show
    '		' Set Pesquisa = Nothing
    '	End Sub
    Private Sub inibeFrame(ByRef FrameName As String, ByRef estado As Boolean)

        Try
            Select Case FrameName
                Case "FrameFat"

                    OptPeriodo.Enabled = estado
                    OptUniFat.Enabled = estado
                    OptVariasFat.Enabled = estado
                    Label4.Enabled = estado
                    Label5.Enabled = estado
                    Label6.Enabled = estado
                    Label7.Enabled = estado
                    Label8.Enabled = estado
                    txtNumFat.Enabled = estado
                    txtPeriodoIni.Enabled = estado
                    txtPeriodoFin.Enabled = estado
                    txtFatIni.Enabled = estado
                    txtFatFinal.Enabled = estado
                    If estado = False Then
                        txtNumFat.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                        txtPeriodoIni.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                        txtPeriodoFin.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                        txtFatIni.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                        txtFatFinal.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                        cmdProcFat.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                    Else

                        txtNumFat.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000005)
                        txtPeriodoIni.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000005)
                        txtPeriodoFin.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000005)
                        txtFatIni.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000005)
                        txtFatFinal.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000005)
                        cmdProcFat.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000005)

                    End If

                    FrameFat.Enabled = estado
                    FrameMesAno.Enabled = estado
                    FrameFatFaixa.Enabled = estado
                    cmdProcFat.Enabled = estado
                Case "FrameConsum"

                    FrameConsum.Enabled = estado
                    Label1.Enabled = estado
                    Label9.Enabled = estado
                    txtConsID.Enabled = estado
                    txtNome.Enabled = estado
                    cmdProcConsID.Enabled = estado
                    OptGrupoCli.Enabled = estado

                    If estado = False Then
                        txtConsID.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                        txtNome.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                        cmdProcConsID.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                    Else
                        txtConsID.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000005)
                        txtNome.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000005)
                        cmdProcConsID.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000005)
                    End If

                Case "FrameVenc"

                    FrameVenc.Enabled = estado
                    lblDias.Enabled = estado
                    cmbDias.Enabled = estado
                    Me.chkVencimento.Enabled = estado

                    If estado = False Then

                        cmbDias.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                    Else
                        'txtVencto.BackColor = &H80000005
                        cmbDias.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000005)
                    End If

                Case "FrameBan"
                    Me.FrameBan.Enabled = estado
                    Me.cmbBancos.Enabled = estado
                    Me.OptGrupoBan.Enabled = estado

                    If estado = False Then
                        cmbBancos.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                    Else
                        cmbBancos.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000005)
                    End If

                Case "FrameAGrupa"
                    FrameAGrupa.Enabled = estado
                    Me.OptAGIdent.Enabled = estado
                    Me.OptAGpag.Enabled = estado
                    Me.OptAGvenc.Enabled = estado


                Case "FrameOrdem"
                    Me.FrameOrdem.Enabled = estado
                    Me.OpOrfat.Enabled = estado
                    Me.OpOrNome.Enabled = estado
                    Me.OpOrpag.Enabled = estado
                    Me.OpOrVenc.Enabled = estado

                Case "FrameTitulos"

                    Me.FrameTitulos.Enabled = estado
                    Me.OptVencer.Enabled = estado
                    Me.OptVencidos.Enabled = estado

                Case "FrameClasse"
                    Me.FrameClasse.Enabled = estado
                    Me.OptGrupoClas.Enabled = estado
                    Me.cmbClasse.Enabled = estado
                    Me.lblClasse.Enabled = estado

                    If estado = False Then
                        cmbClasse.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                    Else
                        cmbClasse.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000005)
                    End If
                Case "FrameKWh"

                    Me.FrameKWh.Enabled = estado
                    Me.OptKWhC.Enabled = estado
                    Me.OptKWhF.Enabled = estado
                    Me.cmbKWh.Enabled = estado
                    Me.lblKWh.Enabled = estado
                    If estado = False Then
                        cmbKWh.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000004)
                    Else
                        cmbKWh.BackColor = System.Drawing.ColorTranslator.FromOle(&H80000005)
                    End If
            End Select

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: inibeFrame" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub

    '	Private Function devolveAB(ByRef Oque As String, ByRef Lado As String) As String
    '		Dim posA As Short
    '		Dim posB As Short
    '		Dim AcheiA As String
    '		AcheiA = Oque
    '		If Lado = "A" Then
    '			posA = InStr(1, UCase(Oque), "A")
    '			If posA > 0 Then
    '				AcheiA = Trim(Mid(Oque, 1, posA - 1))
    '			End If
    '		Else
    '			posA = InStr(1, UCase(Oque), "A")
    '			If posA > 0 Then
    '				AcheiA = Trim(Mid(Oque, posA + 1, Len(Oque) - posA))
    '			End If
    '		End If
    '		devolveAB = AcheiA
    '	End Function

    Private Sub criafiltro2()

        Try
            Dim strCriaFiltro As String
            Dim I As Integer
            strCriaFiltro = "DROP TABLE IF EXISTS filtro2"
            objExecAtualizaBancoDados.QUERY_NAME = strCriaFiltro
            repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

            strCriaFiltro = "create table filtro2(zlc varchar(11),ta varchar(6),mesano varchar(7),numnf double,valortot numeric(10,2),datavenc date,dataem date"
            strCriaFiltro = strCriaFiltro & ",banarrec int(11),cons_id int(11),codclas varchar(6),datapag date)"
            objExecAtualizaBancoDados.QUERY_NAME = strCriaFiltro
            repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

            If dtGlobal.Rows.Count > 0 Then
                Call BarraProgresso((Me.ProgressBarReaviso), (Me.lblPercReaviso), (Me.lblInfoReaviso), 0, dtGlobal.Rows.Count, " Populando tabelas Filtro2 ")
                For Each rowGlobal As DataRow In dtGlobal.Rows
                    I = I + 1
                    info.Text = "Processando: " & I
                    info.Refresh()
                    strCriaFiltro = "insert into filtro2 values('"
                    strCriaFiltro = strCriaFiltro & rowGlobal.Item("Zona") & rowGlobal.Item("Livro") & rowGlobal.Item("Conta") & "'"
                    strCriaFiltro = strCriaFiltro & ",'" & rowGlobal.Item("ta") & "'"
                    strCriaFiltro = strCriaFiltro & ",'" & rowGlobal.Item("mesano") & "'"
                    strCriaFiltro = strCriaFiltro & ",'" & rowGlobal.Item("numNf") & "'"
                    strCriaFiltro = strCriaFiltro & ",'" & Str(IIf(IsDBNull(rowGlobal.Item("valorliq")), rowGlobal.Item("ValorTot"), IIf(rowGlobal.Item("valorliq") = 0, rowGlobal.Item("ValorTot"), rowGlobal.Item("valorliq")))) & "'"
                    strCriaFiltro = strCriaFiltro & ",'" & VB6.Format(rowGlobal.Item("datavenc"), "yyyy-MM-dd") & "'"
                    strCriaFiltro = strCriaFiltro & ",'" & VB6.Format(rowGlobal.Item("dataem"), "yyyy-MM-dd") & "'"
                    strCriaFiltro = strCriaFiltro & ",'" & rowGlobal.Item("banarrec") & "'"
                    strCriaFiltro = strCriaFiltro & ",'" & rowGlobal.Item("cons_id") & "'"
                    strCriaFiltro = strCriaFiltro & ",'" & rowGlobal.Item("codclas") & "'"
                    strCriaFiltro = strCriaFiltro & ",'" & VB6.Format(rowGlobal.Item("datapag"), "yyyy-MM-dd") & "')"
                    objExecAtualizaBancoDados.QUERY_NAME = strCriaFiltro
                    repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)
                    'Call Executar(strCriaFiltro)
                    System.Windows.Forms.Application.DoEvents()
                    'irstNfTab.MoveNext()

                    Call BarraProgresso((Me.ProgressBarReaviso), (Me.lblPercReaviso), (Me.lblInfoReaviso), 1,  , " Populando Tabelas Filtro2 ")
                Next
            End If

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: criafiltro2" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub

    Private Sub CriaFiltro()
        Dim strCriaFiltro As String
        Dim I As Integer
        Dim strfiltro As String
        Dim Tab1 As String
        Dim tab2 As String

        Try

            Tab1 = "Filtro" & VB.Right(My.Computer.Name, 5)
            tab2 = "Filtrodt" & VB.Right(My.Computer.Name, 5)
            strCriaFiltro = "DROP TABLE IF EXISTS filtro" & VB.Right(My.Computer.Name, 5) & ""
            'Call Executar(strCriaFiltro)
            objExecAtualizaBancoDados.QUERY_NAME = strCriaFiltro
            repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

            strCriaFiltro = "create table filtro" & VB.Right(My.Computer.Name, 5) & " (classe varchar(6),ta varchar(6),tipouc varchar(2),kwhc int(10),kwhf int(10),kw double,consumo double,fp double,dematot double,icms double"
            strCriaFiltro = strCriaFiltro & ",cip double,ece double,icmsece double,multece double,eae double,icmseae double,multeae double,juros double"
            strCriaFiltro = strCriaFiltro & ",kwhP int(10),consponta double,kwhFP int(10),consFponta double,kwP int(10),demaponta double,kwFP int(10),demaFponta double"
            strCriaFiltro = strCriaFiltro & ",kwUponta int(10),ultraponta double,kwUfp int(10),ultraFponta double,mesano varchar(7),numnf double"
            strCriaFiltro = strCriaFiltro & ",KEY `KeyClas` (`classe`), KEY `KeyTipo` (`tipouc`))"
            'Call Executar(strCriaFiltro)
            objExecAtualizaBancoDados.QUERY_NAME = strCriaFiltro
            repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

            strCriaFiltro = "DROP TABLE IF EXISTS filtrodt" & VB.Right(My.Computer.Name, 5) & ""
            'Call Executar(strCriaFiltro)
            objExecAtualizaBancoDados.QUERY_NAME = strCriaFiltro
            repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

            strCriaFiltro = "create table filtrodt" & VB.Right(My.Computer.Name, 5) & " (classe varchar(6),ta varchar(6),tipouc varchar(2),cod varchar(20),valor double,kwhc int(10),valor9030 double,valor9040 double,valor9080 double,mesano varchar(7),numnf double,kwhf int(10)"
            strCriaFiltro = strCriaFiltro & ",KEY `KeyClas` (`classe`), KEY `KeyTipo` (`tipouc`),  KEY `KeyCod` (`cod`))"
            'Call Executar(strCriaFiltro)
            objExecAtualizaBancoDados.QUERY_NAME = strCriaFiltro
            repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

            If dtGlobal.Rows.Count > 0 Then
                Call BarraProgresso((Me.ProgressBarReaviso), (Me.lblPercReaviso), (Me.lblInfoReaviso), 0, dtGlobal.Rows.Count, " Populando tabelas ")
                I = 0
                For Each rowGlobal As DataRow In dtGlobal.Rows
                    I = I + 1
                    info.Text = "Processando: " & I & " de " & dtGlobal.Rows.Count
                    info.Refresh()
                    strCriaFiltro = "insert into filtro" & VB.Right(My.Computer.Name, 5) & " values ('"
                    strCriaFiltro = strCriaFiltro & rowGlobal.Item("codclas") & "','" & rowGlobal.Item("ta") & "','" & rowGlobal.Item("Tipouc") & "'"
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302010008", rowGlobal.Item("itensserv")))) & "'" ' KWH CONSUMIDO
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302010009", rowGlobal.Item("itensserv")))) & "'" ' KWH FATURADO
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302020015", rowGlobal.Item("itensserv")))) & "'" '  KW FATURADO
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302020008", rowGlobal.Item("itensserv")))) & "'" ' CONSUMO
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302060001", rowGlobal.Item("itensserv")))) & "'" '"'"  ' F.POTÊNCIA   - campo Ajuste do Receb.dbf
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302020017", rowGlobal.Item("itensserv")))) & "'" ' DEMANDA TOTAL
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302030009", rowGlobal.Item("itensserv")))) & "'" ' ICMS
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302990006", rowGlobal.Item("itensserv")))) & "'" ' TAXA ILUM PUB. (CIP)
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302070005", rowGlobal.Item("itensserv")))) & "'" ' ECE
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302030006", rowGlobal.Item("itensserv")))) & "'" ' ICMS ECE
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302050004", rowGlobal.Item("itensserv")))) & "'" ' MULTA ECE
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302070004", rowGlobal.Item("itensserv")))) & "'" ' EAEEE
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302030005", rowGlobal.Item("itensserv")))) & "'" ' ICMS EAEEE
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302050003", rowGlobal.Item("itensserv")))) & "'" ' MULTA EAEEE
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302050002", rowGlobal.Item("itensserv")))) & "'" ' JUROS
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302010010", rowGlobal.Item("itensserv")))) & "'" ' KWh Ponta
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302020010", rowGlobal.Item("itensserv")))) & "'" ' Consumo Ponta
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302010011", rowGlobal.Item("itensserv")))) & "'" ' KWh Fora Ponta
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302020011", rowGlobal.Item("itensserv")))) & "'" ' Consumo Fora Ponta
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302010021", rowGlobal.Item("itensserv")))) & "'" ' KW Ponta
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302020021", rowGlobal.Item("itensserv")))) & "'" ' Demanda Ponta
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302010025", rowGlobal.Item("itensserv")))) & "'" ' Kw Fora Ponta
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302020025", rowGlobal.Item("itensserv")))) & "'" ' Demanda Fora Ponta
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302010022", rowGlobal.Item("itensserv")))) & "'" ' Kw Ultrapassagem Ponta
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302020022", rowGlobal.Item("itensserv")))) & "'" ' Demanda Ultrapassagem Ponta
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302010026", rowGlobal.Item("itensserv")))) & "'" ' Kw Ultrapassagem Fora Ponta
                    strCriaFiltro = strCriaFiltro & ",'" & Str(CDbl(ChecaItensServ("0302020026", rowGlobal.Item("itensserv")))) & "'" ' Demanda Ultrapassagem Fora Ponta
                    strCriaFiltro = strCriaFiltro & ",'" & rowGlobal.Item("mesano") & "','" & rowGlobal.Item("numnf") & "')"
                    'Call Executar(strCriaFiltro)
                    objExecAtualizaBancoDados.QUERY_NAME = strCriaFiltro
                    repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

                    For IndCodServ = 1 To Len(Trim(rowGlobal.Item("itensserv")))
                        Call BuscaCodItem(IndCodServ, Trim(rowGlobal.Item("itensserv")))
                        If Mid(CodServ, 1, 4) = "9030" Or Mid(CodServ, 1, 4) = "9040" Or Mid(CodServ, 1, 4) = "9080" Then
                            strfiltro = "insert into filtrodt" & VB.Right(My.Computer.Name, 5) & "  values('" & rowGlobal.Item("codclas") & "','" & rowGlobal.Item("ta") & "','" & rowGlobal.Item("tipoUc") & "','" & CodServ & "','" & VlrCodServ & "','" & Val(ChecaItensServ("0302010008", rowGlobal.Item("itensserv"))) & "'"
                            'strfiltro = strfiltro & ",'" & CodServ & "','0','0'"
                            strfiltro = strfiltro & ",'0','0','0'"
                            strfiltro = strfiltro & ",'" & rowGlobal.Item("mesano") & "','" & rowGlobal.Item("numnf") & "','" & ChecaItensServ("0302010009", rowGlobal.Item("itensserv")) & "')"
                            objExecAtualizaBancoDados.QUERY_NAME = strfiltro
                            repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)
                        End If
                    Next

                    Call BarraProgresso((Me.ProgressBarReaviso), (Me.lblPercReaviso), (Me.lblInfoReaviso), 1,  , " Populando Tabelas ")
                    'Call OnOffProcMon(False, "Soma")
                    '  irstNfTab.MoveNext()
                    System.Windows.Forms.Application.DoEvents()
                Next
            End If

            'Call OnOffProcMon(False)

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: CriaFiltro" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try
    End Sub

    '	Private Sub montaSintetico()
    '		'GERAL = "S"
    '		FrmRelatorio.quem_chama = Me
    '		Call iniDoc((FrmRelatorio.VS), True)
    '		Call criafiltro2()
    '		Call montaImpSintetico(FrmRelatorio.VS)
    '		Call iniDoc((FrmRelatorio.VS), False)
    '		Me.cmdVisual.Enabled = True
    '		Call FrmRelatorio.Show()
    '	End Sub

    '	Private Sub montaImpSimples(ByVal VScart As AxVSVIEW6.AxVSPrinter)
    '		Dim strSimples As String
    '		Dim contaLinha As Short
    '		Dim Subtot As Object
    '		Dim Ecex As Double
    '		Dim ListClasseCons() As ClasseCons
    '		Dim contaCons As Short
    '		Dim SomaTotal As Double
    '		Dim lrstAux As ADODB.Recordset
    '		lrstAux = New ADODB.Recordset
    '		strSimples = "select distinct tipouc, count(tipouc) cons from `filtro" & VB.Right(My.Computer.Name, 5) & "` group by tipouc"
    '		Call Conectar(strSimples, lrstAux)
    '		If lrstAux.RecordCount > 0 Then
    '			ReDim ListClasseCons(lrstAux.RecordCount + 1)
    '			ListClasseCons(0).classe = "Todos"
    '			ListClasseCons(0).cons = lrstAux.RecordCount
    '			contaCons = 1
    '			While lrstAux.EOF = False
    '				ListClasseCons(contaCons).classe = lrstAux.Fields("tipouc").Value
    '				ListClasseCons(contaCons).cons = lrstAux.Fields("cons").Value
    '				contaCons = contaCons + 1
    '				lrstAux.MoveNext()
    '			End While
    '		End If
    '		Call lrstAux.Close()
    '		strSimples = "select distinct a.classe,sum(a.consumo) consumo ,a.dematot,a.fp,sum(a.kwhf) kwhf,sum(a.icms) icms,sum(a.cip) cip,sum(a.ece) ece,"
    '		strSimples = strSimples & "Sum(a.icmsece) icmsece,Sum(a.multece) multece,Sum(a.eae) eae,Sum(a.icmseae) icmseae,"
    '		strSimples = strSimples & "Sum(a.multeae) multeae,'' val9030,'' val9040,'' val9080,'' mesano,'' numnf,a.tipouc"
    '		strSimples = strSimples & " from `filtro" & VB.Right(My.Computer.Name, 5) & "` a group by a.tipouc"
    '		With VScart
    '			.MarginLeft = "10mm"
    '			.StartTable()
    '			.Font = VB6.FontChangeSize(.Font, 6) 'Tamanho do fonte
    '			Call Conectar(strSimples, lrstAux)
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcCols,  ,  ,  ,  , 17)
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcRows,  ,  ,  ,  , lrstAux.RecordCount + 5)
    '			.TableBorder = VSVIEW6.TableBorderSettings.tbAll
    '			For ilngConta = 1 To 17
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcColWidth,  , ilngConta,  ,  , "16mm")
    '			Next 
    '			For ilngConta = 1 To 17
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcAlign, 1, ilngConta,  ,  , VSVIEW6.TextAlignSettings.taCenterMiddle)
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcFontBold, 1, ilngConta,  ,  , True)
    '			Next 

    '			' .TableCell(tcText, 1, 18) = "CLASSE"
    '			' .TableCell(tcText, 1, 1) = "SUB CLASSE"
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 1,  ,  , "CLASSE")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 2,  ,  , "No. CONS.")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 3,  ,  , "KWh FAT")

    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 4,  ,  , "FORNE- CIMENTO")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 5,  ,  , "ICMS")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 6,  ,  , "ILUM. PÚBLICA")

    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 7,  ,  , "ECE")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 8,  ,  , "ICMS ECE")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 9,  ,  , "MULTA ECE")

    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 10,  ,  , "EAE")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 11,  ,  , "ICMS EAE")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 12,  ,  , "MULTA EAE")

    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 13,  ,  , "F. POTÊNCIA")

    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 14,  ,  , "CONVÊNIOS")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 15,  ,  , "DIVERSOS")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 16,  ,  , "TAXADOS")

    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 17,  ,  , "TOTAL")


    '			'UPGRADE_WARNING: Couldn't resolve default property of object Subtot. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			Subtot = 0
    '			Ecex = 0
    '			contaLinha = 2

    '			While lrstAux.EOF = False
    '				contaLinha = contaLinha + 1
    '				For ilngConta = 1 To 18
    '					'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '					.let_TableCell(VSVIEW6.TableCellSettings.tcAlign, contaLinha, ilngConta,  ,  , VSVIEW6.TextAlignSettings.taCenterMiddle)
    '				Next 
    '				'   .TableCell(tcText, contaLinha, 0) = lrstAux("tipouc")
    '				'  .TableCell(tcText, contaLinha, 1) = lrstAux("ta")
    '				'  .TableCell(tcText, contaLinha, 1) = lrstAux("classe")

    '				'  .TableCell(tcText, contaLinha, 2) = lrstAux("cons")
    '				'  For X = 1 To ListClasseCons(0).cons
    '				'      If Trim(ListClasseCons(X).classe) = lrstAux("classe") Then
    '				'        .TableCell(tcText, contaLinha, 2) = ListClasseCons(X).cons
    '				'        Exit For
    '				'      End If
    '				'  Next
    '				'   .TableCell(tcText, contaLinha, 0) = lrstAux("tipouc")
    '				'  .TableCell(tcText, contaLinha, 1) = lrstAux("ta")
    '				'  .TableCell(tcText, contaLinha, 1) = lrstAux("classe")

    '				' .TableCell(tcText, contaLinha, 1) = lrstAux("cons")
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 1,  ,  , lrstAux.Fields("tipouc"))
    '				For ilngConta = 1 To ListClasseCons(0).cons
    '					If Trim(ListClasseCons(ilngConta).classe) = lrstAux.Fields("tipouc").Value Then
    '						'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 2,  ,  , ListClasseCons(ilngConta).cons)
    '						Exit For
    '					End If
    '				Next 


    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 3,  ,  , lrstAux.Fields("kwhf"))
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 4,  ,  , VB6.Format(lrstAux.Fields("consumo").Value + lrstAux.Fields("dematot").Value + lrstAux.Fields("fp").Value, "0.00"))
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 5,  ,  , lrstAux.Fields("icms"))
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 6,  ,  , lrstAux.Fields("cip"))
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 7,  ,  , lrstAux.Fields("ece"))
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 8,  ,  , lrstAux.Fields("icmsece"))

    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 9,  ,  , lrstAux.Fields("multece"))
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 10,  ,  , lrstAux.Fields("eae"))
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 11,  ,  , lrstAux.Fields("icmseae"))
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 12,  ,  , lrstAux.Fields("multeae"))

    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 13,  ,  , lrstAux.Fields("fp"))
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 14,  ,  , VB6.Format(lrstAux.Fields("val9030").Value, "0.00")) 'Convênios
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 15,  ,  , VB6.Format(lrstAux.Fields("val9080").Value, "0.00")) 'Diversos
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 16,  ,  , VB6.Format(lrstAux.Fields("val9040").Value, "0.00")) 'Taxados
    '				SomaTotal = 0
    '				For ilngConta = 4 To 16
    '					'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '					SomaTotal = SomaTotal + checaNulo(.get_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, ilngConta), True)

    '				Next 

    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 17,  ,  , VB6.Format(SomaTotal, "0.00"))
    '				' .TableCell(tcText, contaLinha, 18) = lrstAux("tipouc")

    '				'Subtot = Subtot + lrstAux("valor")

    '				'    MsgBox lrstAux("classe") & "----" & lrstAux.RecordCount & "---" & irstNfTab.RecordCount & "---" & lrstAux("cons")

    '				lrstAux.MoveNext()

    '			End While

    '			.EndTable()
    '			Call lrstAux.Close()

    '		End With

    '	End Sub

    Private Sub montaSimplificado()
        ' FrmRelatorio.quem_chama = Me
        ' Call iniDoc((FrmRelatorio.VS), True, True)
        CriaFiltro()
        criafiltro2()
        'Call montaImpSimples(FrmRelatorio.VS)
        'Call FrmRelatorio.LineFeed(2)
        'Call detalhaDiversos(FrmRelatorio.VS, "DETALHAMENTO DOS CONVÊNIOS", "9030", True)
        'Call FrmRelatorio.LineFeed(2)
        'Call detalhaDiversos(FrmRelatorio.VS, "DETALHAMENTO DOS TAXADOS", "9040", False)
        'Call FrmRelatorio.LineFeed(2)
        'Call detalhaDiversos(FrmRelatorio.VS, "DETALHAMENTO DOS DIVERSOS", "9080", False)
        'Call iniDoc((FrmRelatorio.VS), False)
        'Me.cmdVisual.Enabled = True
        'FrmRelatorio.Show()
    End Sub

    '	Private Sub montaAnalitico()
    '		Dim ListClasse() As classeEtarifa
    '		Dim strMontaRel As String
    '		Dim strMontaRel_x As String
    '		Dim nconsX As Short
    '		Dim ValTax As Double
    '		Dim TotValTax As Double
    '		Dim ValCon As Double
    '		Dim TotValCon As Double
    '		Dim ValDiv As Double
    '		Dim TotValDiv As Double
    '		Dim Conta As Short
    '		Dim conta2 As Short
    '		Dim valorA As Object
    '		Dim valorB As String
    '		Dim valorLista As String
    '		Dim flagN As Boolean
    '		flagN = False
    '		FrmRelatorio.quem_chama = Me
    '		'GERAL = "S"
    '		Call iniDoc((FrmRelatorio.VS), True, True) 'Incio Documento
    '		Call OnOffProcMon(True, "Preparando dados para impressão...", Conta)
    '		CriaFiltro()
    '		'UPGRADE_WARNING: Lower bound of collection Me.LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
    '		If Me.LvClasses.Items.Item(1).Checked = True Then 'Todos
    '			Call Analitico_residen() 'Residencial
    '			Call Analitico_normal("4", 5,  , "Industrial ") 'Industrial
    '			Call Analitico_normal("1", 2,  , "Comercial (4)") 'Comercial
    '			Call Analitico_normal("7", 8,  , "Rural (5)") 'Rural
    '			Call Analitico_PP() 'Poder publico
    '			Call Analitico_total()
    '		Else

    '			'UPGRADE_WARNING: Lower bound of collection Me.LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
    '			If Me.LvClasses.Items.Item(2).Checked = True Then 'Comercial
    '				Call Analitico_normal("1", 2,  , "Comercial (4)")
    '			End If

    '			'UPGRADE_WARNING: Lower bound of collection Me.LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
    '			If Me.LvClasses.Items.Item(3).Checked = True Then 'Cons. Próprio
    '				Call Analitico_normal("2", 3,  , "Cons. Próprio")
    '			End If

    '			'UPGRADE_WARNING: Lower bound of collection Me.LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
    '			If Me.LvClasses.Items.Item(5).Checked = True Then 'Industrial
    '				Call Analitico_normal("4", 5,  , "Industrial")
    '			End If

    '			'UPGRADE_WARNING: Lower bound of collection Me.LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
    '			If Me.LvClasses.Items.Item(6).Checked = True Then 'Poder Público
    '				Call Analitico_PP()
    '				flagN = True
    '			End If

    '			'UPGRADE_WARNING: Lower bound of collection Me.LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
    '			If Me.LvClasses.Items.Item(7).Checked = True Then 'Residencial
    '				Call Analitico_residen()
    '				flagN = True
    '			End If

    '			'UPGRADE_WARNING: Lower bound of collection Me.LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
    '			If Me.LvClasses.Items.Item(8).Checked = True Then 'Rural
    '				Call Analitico_normal("7", 8,  , "Rural (5)")
    '			End If

    '			'UPGRADE_WARNING: Lower bound of collection Me.LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
    '			If Me.LvClasses.Items.Item(9).Checked = True Then 'Serviço Público
    '				Call Analitico_normal("8", 9,  , "Serviço Público")
    '			End If

    '		End If


    '		If flagN = False Then
    '			Call detalhaDiversos(FrmRelatorio.VS, "DETALHAMENTO DOS CONVÊNIOS", "9030", True)
    '			Call FrmRelatorio.LineFeed(2)
    '			Call detalhaDiversos(FrmRelatorio.VS, "DETALHAMENTO DOS TAXADOS", "9040", False)
    '			Call FrmRelatorio.LineFeed(2)
    '			Call detalhaDiversos(FrmRelatorio.VS, "DETALHAMENTO DOS DIVERSOS", "9080", False)
    '		End If


    'Call iniDoc((FrmRelatorio.VS), False) ' Fim do documento
    '		Call OnOffProcMon(False) 'Fim da preparação de impressão
    '		FrmRelatorio.Show()


    '	End Sub

    '	Private Sub Analitico_residen()
    '		Dim strMontaRel As String
    '		Dim strMontaRel_x As String
    '		strMontaRel = "select count(*) ncons,sum(kwhc) kwhc,sum(kwhf) kwhf,sum(kw) kw,sum(consumo) consumo ,sum(fp) fp,sum(dematot) dematot,sum(icms) icms"
    '		strMontaRel = strMontaRel & ",sum(cip) cip ,sum(ece) ece,sum(icmsece) icmsece ,sum(multece) multece ,sum(eae) eae,sum(icmseae) icmseae,sum(multeae) multeae,sum(juros) juros"
    '		strMontaRel = strMontaRel & ",sum(kwhP) kwhp,sum(consponta) consponta,sum(kwhFP) kwhfp,sum(consFponta) consfponta,sum(kwP) kwp,sum(demaponta) demaponta,sum(kwFP) kwfp,sum(demaFponta) demafponta"
    '		strMontaRel = strMontaRel & ",sum(kwUponta) kwuponta,sum(ultraponta) ultraponta,sum(kwUfp) kwufp,sum(ultraFponta) ultrafponta"
    '		If Me.chkSimples.CheckState = 0 Then
    '			'Residencial Normal
    '			strMontaRel_x = strMontaRel & " from `filtro" & VB.Right(My.Computer.Name, 5) & "` where tipouc='6' and classe='9101'"
    '			Call Analitico_KWh("6", 7, strMontaRel_x, "Residencial Normal (9101)")
    '			'Residencial Baixa renda
    '			strMontaRel_x = strMontaRel & " from `filtro" & VB.Right(My.Computer.Name, 5) & "` where tipouc='6' and classe='9102'"
    '			Call Analitico_KWh("6", 7, strMontaRel_x, "Residencial Baixa renda (9102)")
    '			'Residencial Baixa renda R246
    '			strMontaRel_x = strMontaRel & " from `filtro" & VB.Right(My.Computer.Name, 5) & "` where tipouc='6' and classe='9104'"
    '			Call Analitico_KWh("6", 7, strMontaRel_x, "Residencial Baixa renda R246 (9104)")
    '			'Residencial Baixa renda R485
    '			strMontaRel_x = strMontaRel & " from `filtro" & VB.Right(My.Computer.Name, 5) & "` where tipouc='6' and classe='9106'"
    '			Call Analitico_KWh("6", 7, strMontaRel_x, "Residencial Baixa renda R485 (9106)")
    '		End If
    '		'Total Residencial Normal e Baixa renda
    '		strMontaRel_x = strMontaRel & " from `filtro" & VB.Right(My.Computer.Name, 5) & "` where tipouc='6'"
    '		Call Analitico_KWh("6", 7, strMontaRel_x, "Total Residencial Normal e Baixa renda")
    '	End Sub

    '	Private Sub Analitico_total()
    '		'  Dim Medida As String
    '		'  Dim Dado As String
    '		'  Dim Medida2 As String
    '		'  Dim posi As String
    '		'  Dim posiText As String
    '		'  Dim vTotal As Double
    '		'  'Cart11.TableBorder = tbNone
    '		'  'Cart11.PaperSize = pprA4
    '		'  'Cart11.Orientation = orLandscape
    '		'  'Cart11.FontSize = 7
    '		'  vTotal = 0
    '		'  vTotal = checaNulo(irstNfTab("consumo"), True) + checaNulo(irstNfTab("fp"), True) + checaNulo(irstNfTab("dematot"), True) + checaNulo(irstNfTab("icms"), True)
    '		'  vTotal = vTotal + checaNulo(irstNfTab("cip"), True) + checaNulo(irstNfTab("ece"), True) + checaNulo(irstNfTab("icmsece"), True) + checaNulo(irstNfTab("multece"), True)
    '		'  vTotal = vTotal + checaNulo(irstNfTab("eae"), True) + checaNulo(irstNfTab("icmseae"), True) + checaNulo(irstNfTab("multeae"), True) + checaNulo(irstNfTab("juros"), True)
    '		'  'vTotal = vTotal + vDiv + vCon + vTax
    '		'  vTotal = vTotal + checaNulo(irstNfTab("consponta"), True) + checaNulo(irstNfTab("consfponta"), True) + checaNulo(irstNfTab("demaponta"), True) + checaNulo(irstNfTab("ultraponta"), True)
    '		'  vTotal = vTotal + checaNulo(irstNfTab("demafponta"), True) + checaNulo(irstNfTab("ultrafponta"), True)
    '		'  Medida = ">50mm|>20mm>|>27mm|>20mm|>30mm|>20mm|>27mm|>20mm|>27mm|>20mm;"
    '		'  Medida2 = ">20mm|<250mm"
    '		'  posi = "40mm"
    '		'  posiText = "45mm"
    '		'  'Cart11.CurrentX = posiText
    '		'  x$ = "0.00"
    '		'  'For k = 1 To irstNfTab.RecordCount
    '		'  y$ = Titu & Subtitu
    '		'  posi = CStr(K * 25 + 40) & "mm"
    '		'  'posiText = CStr(k * 15 + 47) & "mm"
    '		'  'Cart11.DrawLine "20mm", posi, "270mm", posi
    '		'  Cart11.CurrentX = posi
    '		'  Cart11.AddTable Medida2, "|" & y$, "", &HE0E0E0, 0, False
    '		'  Call FrmRelatorio.LineFeed(1)
    '		'  Dado = "No. DE CONSUMIDORES:|" & nconsK & "|CONSUMO.......R$:|" & Format(irstNfTab("consumo"), "0.00") & "|CIP..........R$:|" & Format(irstNfTab("cip"), "0.00") & "|EAE..........R$:|" & Format(irstNfTab("eae"), "0.00") & "|JUROS......R$:|" & Format(irstNfTab("juros"), "0.00") & ""
    '		'  Cart11.AddTable Medida, Dado, ""
    '		'  Dado = "Kwh CONSUMIDO......:|" & irstNfTab("kwhc") & "|F.POTENCIA....R$:|" & Format(irstNfTab("fp"), "0.00") & "|ENC.CAP.EMER.R$:|" & Format(arstAux("ece"), "0.00") & "|ICMS EAE ....R$:|" & Format(arstAux("icmseae"), "0.00") & "|CONVÊNIOS..R$:|" & Format(vCon, "0.00") & ""
    '		'  Cart11.AddTable Medida, Dado, ""
    '		'  Dado = "Kwh FATURADO.......:|" & arstAux("kwhf") & "|DEMANDA.....R$:|" & Format(arstAux("dematot"), "0.00") & "|ICMS ECE ....R$:|" & Format(arstAux("icmsece"), "0.00") & "|MULTA EAE....R$:|" & Format(arstAux("multeae"), "0.00") & "|SERV. TAX..R$:|" & Format(vTax, "0.00") & ""
    '		'  Cart11.AddTable Medida, Dado, ""
    '		'  Dado = "Kw FATURADO........:|" & arstAux("kw") & "|ICMS..........R$:|" & Format(arstAux("icms"), "0.00") & "|MULTA S/ ECE.R$:|" & Format(arstAux("multece"), "0.00") & "|DIVERSOS.....R$:|" & Format(vDiv, "0.00") & "|Total.....R$: |" & Format(vTotal, "0.00") & ""
    '		'  Cart11.AddTable Medida, Dado, ""
    '		'  'If Mid(ta, 3, 1) = "A" Then
    '		'  ''Somente grupo A
    '		'  If arstAux("kwhp") > 0 Or arstAux("kwhFp") > 0 Then
    '		'    Dado = "Kwh Ponta ........:|" & arstAux("kwhp") & "|CONS.PONTA..R$:|" & Format(arstAux("consponta"), "0.00") & "||||||"
    '		'    Cart11.AddTable Medida, Dado, ""
    '		'    Dado = "Kwh Ponta ........:|" & arstAux("kwhFp") & "|CONS.F.P....R$:|" & Format(arstAux("consFponta"), "0.00") & "||||||"
    '		'    Cart11.AddTable Medida, Dado, ""
    '		'    Dado = "Kw Ponta .........:|" & arstAux("kwp") & "|DEM.PONTA....R$:|" & Format(arstAux("demaponta"), "0.00")
    '		'    If arstAux("kwuponta") > 0 Then
    '		'      Dado = Dado & "|Kw ULT.PONTA|" & arstAux("kwuponta") & "|ULTR.PONTA.R$|" & Format(arstAux("ultraponta"), "0.00") & "||"
    '		'    Else
    '		'      Dado = Dado & "||||||"
    '		'    End If
    '		'    Cart11.AddTable Medida, Dado, ""
    '		'    Dado = "Kw F.Ponta .......:|" & arstAux("kwFp") & "|DEM.F.PONTA..R$:|" & Format(arstAux("demaFponta"), "0.00")
    '		'    If arstAux("kwUfp") > 0 Then
    '		'      Dado = Dado & "|Kw ULT.F.PONTA|" & arstAux("kwUfp") & "|ULTR.F.PONTA.R$|" & Format(arstAux("ultraFponta"), "0.00") & "||"
    '		'    Else
    '		'      Dado = Dado & "||||||"
    '		'    End If
    '		'    Cart11.AddTable Medida, Dado, ""
    '		'  End If
    '		'  Call FrmRelatorio.LineFeed(2)
    '		'  'Next
    '	End Sub

    '	Private Sub Analitico_PP()

    '		Dim strMontaRel As String
    '		Dim strMontaRel_x As String

    '		strMontaRel = "select count(*) ncons,sum(kwhc) kwhc,sum(kwhf) kwhf,sum(kw) kw,sum(consumo) consumo ,sum(fp) fp,sum(dematot) dematot,sum(icms) icms"
    '		strMontaRel = strMontaRel & ",sum(cip) cip ,sum(ece) ece,sum(icmsece) icmsece ,sum(multece) multece ,sum(eae) eae,sum(icmseae) icmseae,sum(multeae) multeae,sum(juros) juros"
    '		strMontaRel = strMontaRel & ",sum(kwhP) kwhp,sum(consponta) consponta,sum(kwhFP) kwhfp,sum(consFponta) consfponta,sum(kwP) kwp,sum(demaponta) demaponta,sum(kwFP) kwfp,sum(demaFponta) demafponta"
    '		strMontaRel = strMontaRel & ",sum(kwUponta) kwuponta,sum(ultraponta) ultraponta,sum(kwUfp) kwufp,sum(ultraFponta) ultrafponta"
    '		If Me.chkSimples.CheckState = 0 Then
    '			'Poder Público Municipal

    '			strMontaRel_x = strMontaRel & " from `filtro" & VB.Right(My.Computer.Name, 5) & "` where tipouc='5' and mid(classe,1,2)='61'"
    '			Call Analitico_normal("5", 6, strMontaRel_x, "Poder Público Municipal (61)")

    '			'Poder Público Estadual
    '			strMontaRel_x = strMontaRel & " from `filtro" & VB.Right(My.Computer.Name, 5) & "` where tipouc='5' and mid(classe,1,2)='62'"
    '			Call Analitico_normal("5", 6, strMontaRel_x, "Poder Público Estadual (62)")

    '			'Poder Público Federal
    '			strMontaRel_x = strMontaRel & " from `filtro" & VB.Right(My.Computer.Name, 5) & "` where tipouc='5' and mid(classe,1,2)='63'"
    '			Call Analitico_normal("5", 6, strMontaRel_x, "Poder Público Federal (63)")
    '		End If
    '		' Total Poder Público
    '		strMontaRel_x = strMontaRel & " from `filtro" & VB.Right(My.Computer.Name, 5) & "` where tipouc='5' and mid(classe,1,2) <> '64'"
    '		Call Analitico_normal("5", 6, strMontaRel_x, "Total Poder Público Municipal (61), Estadual (62), Federal (63)")

    '	End Sub

    '	Private Sub Analitico_normal(ByRef Tipouc As String, ByRef Opcao As Short, Optional ByRef strMontaRel As String = "", Optional ByRef strLinha As String = "")
    '		Dim strMontaRel3 As String
    '		Dim strMontaRel4 As String
    '		Dim strMontaRel5 As String
    '		Dim ValTax As Double
    '		Dim TotValTax As Double
    '		Dim ValCon As Double
    '		Dim TotValCon As Double
    '		Dim ValDiv As Double
    '		Dim TotValDiv As Double
    '		Dim lrstAux As ADODB.Recordset
    '		lrstAux = New ADODB.Recordset
    '		strMontaRel3 = "select sum(valor)taxados from `filtrodt" & VB.Right(My.Computer.Name, 5) & "` where tipouc='" & Tipouc & "' and cod like '9040%'"
    '		strMontaRel4 = "select sum(valor)convenios from `filtrodt" & VB.Right(My.Computer.Name, 5) & "` where tipouc='" & Tipouc & "' and cod like '9030%'"
    '		strMontaRel5 = "select sum(valor)diversos from `filtrodt" & VB.Right(My.Computer.Name, 5) & "` where tipouc='" & Tipouc & "' and cod like '9080%'"
    '		Call Conectar(strMontaRel3, lrstAux)
    '		If lrstAux.BOF = False And lrstAux.EOF = False Then
    '			'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			ValTax = checaNulo(lrstAux.Fields("taxados"), True)
    '			TotValTax = TotValTax + ValTax
    '		End If
    '		Call lrstAux.Close()
    '		Call Conectar(strMontaRel4, lrstAux)
    '		If lrstAux.BOF = False And lrstAux.EOF = False Then
    '			'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			ValCon = checaNulo(lrstAux.Fields("convenios"), True)
    '			TotValCon = TotValCon + ValCon
    '		End If
    '		Call lrstAux.Close()
    '		Call Conectar(strMontaRel5, lrstAux)
    '		If lrstAux.BOF = False And lrstAux.EOF = False Then
    '			'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			ValDiv = checaNulo(lrstAux.Fields("diversos"), True)
    '			TotValDiv = TotValDiv + ValDiv
    '		End If
    '		Call lrstAux.Close()
    '		If strMontaRel = "" Then
    '			strMontaRel = "select count(*) ncons,sum(kwhc) kwhc,sum(kwhf) kwhf,sum(kw) kw,sum(consumo) consumo ,sum(fp) fp,sum(dematot) dematot,sum(icms) icms"
    '			strMontaRel = strMontaRel & ",sum(cip) cip ,sum(ece) ece,sum(icmsece) icmsece ,sum(multece) multece ,sum(eae) eae,sum(icmseae) icmseae,sum(multeae) multeae,sum(juros) juros"
    '			strMontaRel = strMontaRel & ",sum(kwhP) kwhp,sum(consponta) consponta,sum(kwhFP) kwhfp,sum(consFponta) consfponta,sum(kwP) kwp,sum(demaponta) demaponta,sum(kwFP) kwfp,sum(demaFponta) demafponta"
    '			strMontaRel = strMontaRel & ",sum(kwUponta) kwuponta,sum(ultraponta) ultraponta,sum(kwUfp) kwufp,sum(ultraFponta) ultrafponta"
    '			strMontaRel = strMontaRel & " from `filtro" & VB.Right(My.Computer.Name, 5) & "` where tipouc='" & Tipouc & "'"
    '		End If
    '		If strLinha = "" Then
    '			'UPGRADE_WARNING: Lower bound of collection Me.LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
    '			'UPGRADE_WARNING: Lower bound of collection Me.LvClasses.ListItems() has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
    '			strLinha = Me.LvClasses.Items.Item(Opcao).SubItems(1).Text
    '		End If
    '		Call Conectar(strMontaRel, lrstAux)
    '		If lrstAux.BOF = False And lrstAux.EOF = False Then
    '			While lrstAux.EOF = False
    '				'GERAL = "S"
    '				Call montaImpAnalitico(FrmRelatorio.VS, "" & strLinha, "", lrstAux.Fields("ncons").Value, "", TotValTax, TotValCon, TotValDiv)
    '				lrstAux.MoveNext()
    '			End While
    '		End If
    '		Call lrstAux.Close()
    '	End Sub

    '	Private Sub Analitico_KWh(ByRef Tipouc As String, ByRef Opcao As Short, ByRef strMontaRel As String, Optional ByRef strKWhTitu As String = "")
    '		Dim strMontaRel_x As String
    '		Dim valorA As String
    '		Dim valorB As String
    '		Dim valorLista As String
    '		Dim Y As Integer
    '		For Y = 1 To Me.cmbKWh.Items.Count
    '			If Me.cmbKWh.Text = "NORMAL" Or Me.cmbKWh.Text = "" Then
    '				If VB6.GetItemString(Me.cmbKWh, Y) <> "NORMAL" And VB6.GetItemString(Me.cmbKWh, Y) <> "" Then
    '					valorA = devolveAB(VB6.GetItemString(Me.cmbKWh, Y), "A")
    '					valorB = devolveAB(VB6.GetItemString(Me.cmbKWh, Y), "B")
    '					valorLista = VB6.GetItemString(Me.cmbKWh, Y)
    '				Else
    '					GoTo Next_Y
    '				End If
    '			Else
    '				valorA = devolveAB((Me.cmbKWh).Text, "A")
    '				valorB = devolveAB((Me.cmbKWh).Text, "B")
    '				valorLista = Me.cmbKWh.Text
    '			End If
    '			If valorA = valorB And InStr(1, valorA, ">") > 0 Then
    '				valorA = Trim(Mid(valorA, 2, Len(valorA) - 1))
    '				strMontaRel_x = strMontaRel & " and kwhf > '" & valorA & "'"
    '			Else
    '				strMontaRel_x = strMontaRel & " and kwhf >'" & valorA & "' and kwhf <='" & valorB & "'"
    '			End If
    '			Call Analitico_normal(Tipouc, Opcao, strMontaRel_x, strKWhTitu & "  (" & VB6.GetItemString(Me.cmbKWh, Y) & " KWh)")
    'Next_Y: 
    '			System.Windows.Forms.Application.DoEvents()
    '		Next Y
    '	End Sub

    '	Private Sub Antigo_KWh()
    '		Dim strMontaRel As String
    '		Dim strMontaRel2 As String
    '		Dim strMontaRel3 As String
    '		Dim strMontaRel4 As String
    '		Dim strMontaRel5 As String
    '		Dim X As Short
    '		Dim Y As Short
    '		Dim valorA As String
    '		Dim valorB As String
    '		Dim valorLista As String
    '		Dim Conta As Integer
    '		Dim ValTax As Double
    '		Dim TotValTax As Double
    '		Dim ValCon As Double
    '		Dim TotValCon As Double
    '		Dim ValDiv As Double
    '		Dim TotValDiv As Double
    '		Dim nconsX As Integer
    '		Dim lrstAux As ADODB.Recordset
    '		lrstAux = New ADODB.Recordset
    '		X = 1
    'contaX: 
    '		For Y = 1 To Me.cmbKWh.Items.Count
    '			System.Windows.Forms.Application.DoEvents()
    '			If Me.cmbKWh.Text = "NORMAL" Or Me.cmbKWh.Text = "" Then
    '				If VB6.GetItemString(Me.cmbKWh, Y) <> "NORMAL" And VB6.GetItemString(Me.cmbKWh, Y) <> "" Then
    '					valorA = devolveAB(VB6.GetItemString(Me.cmbKWh, Y), "A")
    '					valorB = devolveAB(VB6.GetItemString(Me.cmbKWh, Y), "B")
    '					valorLista = VB6.GetItemString(Me.cmbKWh, Y)
    '				Else
    '					GoTo PulaLista
    '				End If
    '			Else
    '				valorA = devolveAB((Me.cmbKWh).Text, "A")
    '				valorB = devolveAB((Me.cmbKWh).Text, "B")
    '				valorLista = Me.cmbKWh.Text
    '			End If
    '			strMontaRel = "select distinct ta,classe from `filtro" & VB.Right(My.Computer.Name, 5) & "`  where kwhf >='" & valorA & "' and kwhf<='" & valorB & "' order by ta,classe"
    '			Call Conectar(strMontaRel, lrstAux)
    '			Conta = 1
    '			If lrstAux.RecordCount > 0 Then 'No. classes
    '				Dim ListClasse(lrstAux.RecordCount) As classeEtarifa
    '				While lrstAux.EOF = False
    '					ListClasse(Conta).classe = lrstAux.Fields("classe").Value
    '					ListClasse(Conta).ta = lrstAux.Fields("ta").Value
    '					Conta = Conta + 1
    '					lrstAux.MoveNext()
    '				End While
    '			End If
    '			Call lrstAux.Close()
    '			If Conta <= 1 Then GoTo PulaLista
    '			If X >= Conta Then GoTo PulaLista
    '			strMontaRel = "select count(*) ncons,sum(kwhc) kwhc,sum(kwhf) kwhf,sum(kw) kw,sum(consumo) consumo ,sum(fp) fp,sum(dematot) dematot,sum(icms) icms"
    '			strMontaRel = strMontaRel & ",sum(cip) cip ,sum(ece) ece,sum(icmsece) icmsece ,sum(multece) multece ,sum(eae) eae,sum(icmseae) icmseae,sum(multeae) multeae,sum(juros) juros"
    '			strMontaRel = strMontaRel & ",sum(kwhP) kwhp,sum(consponta) consponta,sum(kwhFP) kwhfp,sum(consFponta) consfponta,sum(kwP) kwp,sum(demaponta) demaponta,sum(kwFP) kwfp,sum(demaFponta) demafponta"
    '			strMontaRel = strMontaRel & ",sum(kwUponta) kwuponta,sum(ultraponta) ultraponta,sum(kwUfp) kwufp,sum(ultraFponta) ultrafponta"
    '			strMontaRel = strMontaRel & " from `filtro" & VB.Right(My.Computer.Name, 5) & "` where classe='" & ListClasse(X).classe & "'"
    '			strMontaRel2 = strMontaRel
    '			strMontaRel3 = "select sum(valor)taxados from `filtrodt" & VB.Right(My.Computer.Name, 5) & "` where classe='" & ListClasse(X).classe & "' and cod like '9040%'"
    '			strMontaRel4 = "select sum(valor)convenios from `filtrodt" & VB.Right(My.Computer.Name, 5) & "` where classe='" & ListClasse(X).classe & "' and cod like '9030%'"
    '			strMontaRel5 = "select sum(valor)diversos from `filtrodt" & VB.Right(My.Computer.Name, 5) & "` where classe='" & ListClasse(X).classe & "' and cod like '9080%'"
    '			If valorA = valorB Then
    '				If InStr(1, valorA, ">") > 0 Then
    '					valorA = Trim(Mid(valorA, 2, Len(valorA) - 1))
    '					If Me.OptKWhC.Checked = True Then
    '						strMontaRel = strMontaRel & " and kwhc > '" & valorA & "'"
    '						strMontaRel3 = strMontaRel3 & " and kwhc > '" & valorA & "'"
    '						strMontaRel4 = strMontaRel4 & " and kwhc > '" & valorA & "'"
    '						strMontaRel5 = strMontaRel5 & " and kwhc > '" & valorA & "'"
    '					Else
    '						strMontaRel = strMontaRel & " and kwhf > '" & valorA & "'"
    '						strMontaRel3 = strMontaRel3 & " and kwhf > '" & valorA & "'"
    '						strMontaRel4 = strMontaRel4 & " and kwhf > '" & valorA & "'"
    '						strMontaRel5 = strMontaRel5 & " and kwhf > '" & valorA & "'"
    '					End If
    '				Else
    '					If Me.OptKWhC.Checked = True Then
    '						strMontaRel = strMontaRel & " and kwhc <= '" & valorA & "'"
    '						strMontaRel3 = strMontaRel3 & " and kwhc <= '" & valorA & "'"
    '						strMontaRel4 = strMontaRel4 & " and kwhc <= '" & valorA & "'"
    '						strMontaRel5 = strMontaRel5 & " and kwhc <= '" & valorA & "'"
    '					Else
    '						strMontaRel = strMontaRel & " and kwhf <= '" & valorA & "'"
    '						strMontaRel3 = strMontaRel3 & " and kwhf <= '" & valorA & "'"
    '						strMontaRel4 = strMontaRel4 & " and kwhf <= '" & valorA & "'"
    '						strMontaRel5 = strMontaRel5 & " and kwhf <= '" & valorA & "'"
    '					End If
    '				End If
    '			Else
    '				If Me.OptKWhC.Checked = True Then
    '					strMontaRel = strMontaRel & " and kwhc >= '" & valorA & "' and kwhc < '" & valorB & "'"
    '					strMontaRel3 = strMontaRel3 & " and kwhc >= '" & valorA & "' and kwhc < '" & valorB & "'"
    '					strMontaRel4 = strMontaRel4 & " and kwhc >= '" & valorA & "' and kwhc < '" & valorB & "'"
    '					strMontaRel5 = strMontaRel5 & " and kwhc >= '" & valorA & "' and kwhc < '" & valorB & "'"
    '				Else
    '					strMontaRel = strMontaRel & " and kwhf >= '" & valorA & "' and kwhf < '" & valorB & "'"
    '					strMontaRel3 = strMontaRel3 & " and kwhf >= '" & valorA & "' and kwhf < '" & valorB & "'"
    '					strMontaRel4 = strMontaRel4 & " and kwhf >= '" & valorA & "' and kwhf < '" & valorB & "'"
    '					strMontaRel5 = strMontaRel5 & " and kwhf >= '" & valorA & "' and kwhf < '" & valorB & "'"
    '				End If
    '			End If
    '			Call Conectar(strMontaRel3, lrstAux)
    '			If lrstAux.RecordCount > 0 Then
    '				'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				ValTax = checaNulo(lrstAux.Fields("taxados"), True)
    '				TotValTax = TotValTax + ValTax
    '			End If
    '			Call lrstAux.Close()
    '			Call Conectar(strMontaRel4, lrstAux)
    '			If lrstAux.RecordCount > 0 Then
    '				'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				ValCon = checaNulo(lrstAux.Fields("convenios"), True)
    '				TotValCon = TotValCon + ValCon
    '			End If
    '			Call lrstAux.Close()
    '			Call Conectar(strMontaRel5, lrstAux)
    '			If lrstAux.RecordCount > 0 Then
    '				'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				ValDiv = checaNulo(lrstAux.Fields("diversos"), True)
    '				TotValDiv = TotValDiv + ValDiv
    '			End If
    '			Call lrstAux.Close()
    '			Call Conectar(strMontaRel, lrstAux)
    '			If lrstAux.RecordCount > 0 Then
    '				If lrstAux.Fields("ncons").Value > 0 Then
    '					nconsX = nconsX + lrstAux.Fields("ncons").Value
    '					'Call montaImpAnalitico(FrmRelatorio.VS, "Classe " & ListClasse(X).classe, " KWh (" & valorLista & ")", lrstAux("ncons"), ListClasse(X).ta, ValTax, ValCon, ValDiv)
    '				End If
    '			End If
    '			Call lrstAux.Close()
    '			If Me.cmbKWh.Text <> "NORMAL" Then Exit For
    '			System.Windows.Forms.Application.DoEvents()
    'PulaLista: 
    '		Next Y
    '		If nconsX > 0 Then
    '			Call Conectar(strMontaRel2, lrstAux)
    '			If lrstAux.RecordCount > 0 Then
    '				If lrstAux.Fields("ncons").Value > 0 Then
    '					'Call montaImpAnalitico(FrmRelatorio.VS, "Total da Classe " & ListClasse(X).classe, "", nconsX, ListClasse(X).ta, TotValTax, TotValCon, TotValDiv)
    '				End If
    '			End If
    '			Call lrstAux.Close()
    '		End If
    '		nconsX = 0
    '		TotValTax = 0
    '		'Next X
    '		X = X + 1
    '		If X < Conta Then GoTo contaX
    '	End Sub

    '	Private Sub montaImpAnalitico(ByVal Cart11 As AxVSVIEW6.AxVSPrinter, ByRef Titu As String, ByRef Subtitu As String, ByRef nconsK As Short, ByRef ta As String, ByRef vTax As Double, ByRef vCon As Double, ByRef vDiv As Double)
    '		Dim Medida As String
    '		Dim Dado As String
    '		Dim Medida2 As String
    '		Dim posi As String
    '		Dim posiText As String
    '		Dim vTotal As Double
    '		Dim X As String
    '		Dim Y As String
    '		Dim K As Integer
    '		'Cart11.TableBorder = tbNone
    '		'Cart11.PaperSize = pprA4
    '		'Cart11.Orientation = orLandscape
    '		Cart11.Font = VB6.FontChangeSize(Cart11.Font, 7)
    '		vTotal = 0
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(irstNfTab(icms), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(irstNfTab(dematot), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(irstNfTab(fp), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		vTotal = checaNulo(irstNfTab.Fields("consumo"), True) + checaNulo(irstNfTab.Fields("fp"), True) + checaNulo(irstNfTab.Fields("dematot"), True) + checaNulo(irstNfTab.Fields("icms"), True)
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(irstNfTab(multece), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(irstNfTab(icmsece), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(irstNfTab(ece), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		vTotal = vTotal + checaNulo(irstNfTab.Fields("cip"), True) + checaNulo(irstNfTab.Fields("ece"), True) + checaNulo(irstNfTab.Fields("icmsece"), True) + checaNulo(irstNfTab.Fields("multece"), True)
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(irstNfTab(juros), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(irstNfTab(multeae), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(irstNfTab(icmseae), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		vTotal = vTotal + checaNulo(irstNfTab.Fields("eae"), True) + checaNulo(irstNfTab.Fields("icmseae"), True) + checaNulo(irstNfTab.Fields("multeae"), True) + checaNulo(irstNfTab.Fields("juros"), True)
    '		vTotal = vTotal + vDiv + vCon + vTax
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(irstNfTab(ultraponta), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(irstNfTab(demaponta), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(irstNfTab(consfponta), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		vTotal = vTotal + checaNulo(irstNfTab.Fields("consponta"), True) + checaNulo(irstNfTab.Fields("consfponta"), True) + checaNulo(irstNfTab.Fields("demaponta"), True) + checaNulo(irstNfTab.Fields("ultraponta"), True)
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(irstNfTab(ultrafponta), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '		vTotal = vTotal + checaNulo(irstNfTab.Fields("demafponta"), True) + checaNulo(irstNfTab.Fields("ultrafponta"), True)
    '		Medida = ">50mm|>20mm>|>27mm|>20mm|>30mm|>20mm|>27mm|>20mm|>27mm|>20mm;"
    '		Medida2 = ">20mm|<250mm"
    '		posi = "40mm"
    '		posiText = "45mm"
    '		'Cart11.CurrentX = posiText
    '		X = "0.00"
    '		For K = 1 To irstNfTab.RecordCount
    '			Y = Titu & Subtitu
    '			posi = CStr(K * 25 + 40) & "mm"
    '			'posiText = CStr(k * 15 + 47) & "mm"
    '			'Cart11.DrawLine "20mm", posi, "270mm", posi
    '			Cart11.CurrentX = posi
    '			Cart11.AddTable(Medida2, "|" & Y, "", &HE0E0E0, 0, False)
    '			Call FrmRelatorio.LineFeed(1)
    '			Dado = "No. DE CONSUMIDORES:|" & nconsK & "|CONSUMO.......R$:|" & VB6.Format(irstNfTab.Fields("consumo").Value, "0.00") & "|CIP..........R$:|" & VB6.Format(irstNfTab.Fields("cip").Value, "0.00") & "|EAE..........R$:|" & VB6.Format(irstNfTab.Fields("eae").Value, "0.00") & "|JUROS......R$:|" & VB6.Format(irstNfTab.Fields("juros").Value, "0.00") & ""
    '			Cart11.AddTable(Medida, Dado, "")
    '			Dado = "Kwh CONSUMIDO......:|" & irstNfTab.Fields("kwhc").Value & "|F.POTENCIA....R$:|" & VB6.Format(irstNfTab.Fields("fp").Value, "0.00") & "|ENC.CAP.EMER.R$:|" & VB6.Format(irstNfTab.Fields("ece").Value, "0.00") & "|ICMS EAE ....R$:|" & VB6.Format(irstNfTab.Fields("icmseae").Value, "0.00") & "|CONVÊNIOS..R$:|" & VB6.Format(vCon, "0.00") & ""
    '			Cart11.AddTable(Medida, Dado, "")
    '			Dado = "Kwh FATURADO.......:|" & irstNfTab.Fields("kwhf").Value & "|DEMANDA.....R$:|" & VB6.Format(irstNfTab.Fields("dematot").Value, "0.00") & "|ICMS ECE ....R$:|" & VB6.Format(irstNfTab.Fields("icmsece").Value, "0.00") & "|MULTA EAE....R$:|" & VB6.Format(irstNfTab.Fields("multeae").Value, "0.00") & "|SERV. TAX..R$:|" & VB6.Format(vTax, "0.00") & ""
    '			Cart11.AddTable(Medida, Dado, "")
    '			Dado = "Kw FATURADO........:|" & irstNfTab.Fields("kw").Value & "|ICMS..........R$:|" & VB6.Format(irstNfTab.Fields("icms").Value, "0.00") & "|MULTA S/ ECE.R$:|" & VB6.Format(irstNfTab.Fields("multece").Value, "0.00") & "|DIVERSOS.....R$:|" & VB6.Format(vDiv, "0.00") & "|Total.....R$: |" & VB6.Format(vTotal, "0.00") & ""
    '			Cart11.AddTable(Medida, Dado, "")
    '			'If Mid(ta, 3, 1) = "A" Then
    '			''Somente grupo A
    '			If irstNfTab.Fields("kwhp").Value > 0 Or irstNfTab.Fields("kwhFp").Value > 0 Then
    '				Dado = "Kwh Ponta ........:|" & irstNfTab.Fields("kwhp").Value & "|CONS.PONTA..R$:|" & VB6.Format(irstNfTab.Fields("consponta").Value, "0.00") & "||||||"
    '				Cart11.AddTable(Medida, Dado, "")
    '				Dado = "Kwh Ponta ........:|" & irstNfTab.Fields("kwhFp").Value & "|CONS.F.P....R$:|" & VB6.Format(irstNfTab.Fields("consFponta").Value, "0.00") & "||||||"
    '				Cart11.AddTable(Medida, Dado, "")
    '				Dado = "Kw Ponta .........:|" & irstNfTab.Fields("kwp").Value & "|DEM.PONTA....R$:|" & VB6.Format(irstNfTab.Fields("demaponta").Value, "0.00")
    '				If irstNfTab.Fields("kwuponta").Value > 0 Then
    '					Dado = Dado & "|Kw ULT.PONTA|" & irstNfTab.Fields("kwuponta").Value & "|ULTR.PONTA.R$|" & VB6.Format(irstNfTab.Fields("ultraponta").Value, "0.00") & "||"
    '				Else
    '					Dado = Dado & "||||||"
    '				End If
    '				Cart11.AddTable(Medida, Dado, "")
    '				Dado = "Kw F.Ponta .......:|" & irstNfTab.Fields("kwFp").Value & "|DEM.F.PONTA..R$:|" & VB6.Format(irstNfTab.Fields("demaFponta").Value, "0.00")
    '				If irstNfTab.Fields("kwUfp").Value > 0 Then
    '					Dado = Dado & "|Kw ULT.F.PONTA|" & irstNfTab.Fields("kwUfp").Value & "|ULTR.F.PONTA.R$|" & VB6.Format(irstNfTab.Fields("ultraFponta").Value, "0.00") & "||"
    '				Else
    '					Dado = Dado & "||||||"
    '				End If
    '				Cart11.AddTable(Medida, Dado, "")
    '			End If
    '			Call FrmRelatorio.LineFeed(2)
    '		Next 
    '	End Sub

    '	Private Sub encheFiltroDT2(ByRef itemDT As String)
    '		Dim posA As Short
    '		Dim posB As Short
    '		Dim posC As Short
    '		Dim strfiltro As String
    '		Dim lrstAux As ADODB.Recordset
    '		lrstAux = New ADODB.Recordset
    '		strfiltro = "select num from `codigos` where num like '9040%' or num like '9030%' or num like '9080%'"
    '		Call Conectar(strfiltro, lrstAux)
    '		While lrstAux.EOF = False
    '			posA = InStr(1, itemDT, lrstAux.Fields("num").Value)
    '			If posA > 0 Then
    '				'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(ChecaItensServ(0302010008, itemDT), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(ChecaItensServ(lrstAux(num), itemDT), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				strfiltro = "insert into filtrodt" & VB.Right(My.Computer.Name, 5) & " values('" & irstNfTab.Fields("codclas").Value & "','" & irstNfTab.Fields("ta").Value & "','" & irstNfTab.Fields("tipoUc").Value & "','" & lrstAux.Fields("num").Value & "','" & checaNulo(ChecaItensServ(lrstAux.Fields("num").Value, itemDT), True) & "','" & checaNulo(ChecaItensServ("0302010008", itemDT), True) & "'"
    '				'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				strfiltro = strfiltro & ",'" & checaNulo(ChecaItensServ(lrstAux.Fields("num").Value, itemDT)) & "','0','0'"
    '				'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(ChecaItensServ(0302010009, itemDT), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				strfiltro = strfiltro & ",'" & irstNfTab.Fields("mesano").Value & "','" & irstNfTab.Fields("numnf").Value & "','" & checaNulo(ChecaItensServ("0302010009", itemDT), True) & "')"
    '				If Mid(lrstAux.Fields("num").Value, 1, 4) = "9030" Then
    '					'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '					strfiltro = strfiltro & ",'" & checaNulo(ChecaItensServ(lrstAux.Fields("num").Value, itemDT)) & "','0','0'"
    '				Else
    '					If Mid(lrstAux.Fields("num").Value, 1, 4) = "9040" Then
    '						'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '						strfiltro = strfiltro & ",'0','" & checaNulo(ChecaItensServ(lrstAux.Fields("num").Value, itemDT)) & "','0'"
    '					Else
    '						If Mid(lrstAux.Fields("num").Value, 1, 4) = "9080" Then
    '							'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '							strfiltro = strfiltro & ",'0','" & checaNulo(ChecaItensServ(lrstAux.Fields("num").Value, itemDT)) & "','0'"
    '						Else
    '							strfiltro = strfiltro & ",'0','0','0'"
    '						End If
    '					End If
    '				End If
    '				'UPGRADE_WARNING: Couldn't resolve default property of object checaNulo(ChecaItensServ(0302010009, itemDT), True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				strfiltro = strfiltro & ",'" & irstNfTab.Fields("mesano").Value & "','" & irstNfTab.Fields("numnf").Value & "','" & checaNulo(ChecaItensServ("0302010009", itemDT), True) & "')"
    '				myCmdC.CommandText = strfiltro
    '				myCmdC.Execute()
    '			End If
    '			lrstAux.MoveNext()
    '			System.Windows.Forms.Application.DoEvents()
    '		End While
    '		Call lrstAux.Close()
    '	End Sub

    Private Sub detalhaDiversos(ByRef Titu As String, ByRef Oque As String, ByRef estado As Boolean)
        Dim strDetalha As String
        Dim contaLinha As Short
        Dim Subtot As Double
        Dim Ecex As Double
        Dim lstrsql As String
        Dim bInserir As Boolean

        Try

            strDetalha = "select distinct a.cod cod,b.descri descri,sum(a.valor) valor from `filtrodt" & VB.Right(My.Computer.Name, 5) & "` a,codigos b"
            strDetalha = strDetalha & " where cod like '" & Oque & "%' and a.cod=b.num group by a.cod order by a.cod"
            objAtualizaBancoDados.QUERY_NAME = strDetalha
            dt = repositorioAtualizaBancosDados.Consultar(objAtualizaBancoDados)

            Subtot = 0
            Ecex = 0
            contaLinha = 2
            For Each row As DataRow In dt.Rows

                If Oque = "9040" Then
                    lstrsql = "INSERT INTO AUX_SERVICOS_TAXADOS" & VB.Right(My.Computer.Name, 5) & " SET "
                    lstrsql = lstrsql & "CODIGO = '" & row.Item("COD") & "' ,"
                    lstrsql = lstrsql & "DESCRICAO = '" & row.Item("DESCRI") & "' ,"
                    lstrsql = lstrsql & "VALOR = '" & row.Item("VALOR") & "'"
                    objExecAtualizaBancoDados.QUERY_NAME = lstrsql
                    repositorioAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

                ElseIf Oque = "9030" Then

                    lstrsql = "INSERT INTO AUX_CONVENIOS_DIVERSOS" & VB.Right(My.Computer.Name, 5) & " SET "
                    lstrsql = lstrsql & "CODIGO = '" & row.Item("COD") & "' ,"
                    lstrsql = lstrsql & "DESCRICAO = '" & row.Item("DESCRI") & "' ,"
                    lstrsql = lstrsql & "VALOR = '" & row.Item("VALOR") & "'"
                    objExecAtualizaBancoDados.QUERY_NAME = lstrsql
                    repositorioAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

                    bInserir = True

                ElseIf Oque = "9080" Then

                    lstrsql = "INSERT INTO AUX_CONVENIOS_DIVERSOS_2" & VB.Right(My.Computer.Name, 5) & " SET "
                    lstrsql = lstrsql & "CODIGO = '" & row.Item("COD") & "' ,"
                    lstrsql = lstrsql & "DESCRICAO = '" & row.Item("DESCRI") & "' ,"
                    lstrsql = lstrsql & "VALOR = '" & row.Item("VALOR") & "'"
                    objExecAtualizaBancoDados.QUERY_NAME = lstrsql
                    repositorioAtualizaBancosDados.Execute(objExecAtualizaBancoDados)


                End If

            Next

            'Call lrstAux.Close()

            Ecex = 0
            If estado And bInserir Then
                strDetalha = "select sum(multece) multaecetot from `filtro" & VB.Right(My.Computer.Name, 5) & "` "
                objAtualizaBancoDados.QUERY_NAME = strDetalha
                dt1 = repositorioAtualizaBancosDados.Consultar(objAtualizaBancoDados)

                If dt1.Rows.Count > 0 Then
                    For Each row1 As DataRow In dt1.Rows

                        Ecex = row1.Item("multaecetot")

                        lstrsql = ""
                        lstrsql = "Update AUX_CONVENIOS_DIVERSOS" & VB.Right(My.Computer.Name, 5) & "  SET multaece = '" & Ecex & "'"
                        objExecAtualizaBancoDados.QUERY_NAME = lstrsql
                        repositorioAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

                    Next
                Else
                    Ecex = 0
                End If

            End If


        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: detalhaDiversos" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try
    End Sub

    Private Sub frmImpFat_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
        Dim lstrsql As String

        Try

            objExecAtualizaBancoDados.QUERY_NAME = "drop table if exists AUX_SERVICOS_TAXADOS" & VB.Right(My.Computer.Name, 5)
            repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)


            objExecAtualizaBancoDados.QUERY_NAME = "drop table if exists AUX_CONVENIOS_DIVERSOS" & VB.Right(My.Computer.Name, 5)
            repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)


            objExecAtualizaBancoDados.QUERY_NAME = "drop table if exists AUX_CONVENIOS_DIVERSOS_2" & VB.Right(My.Computer.Name, 5)
            repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: frmImpFat_FormClosed" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try
    End Sub

    '	Private Function Imprimir_SubTotal(ByRef subfatura As Double) As Double
    '		Dim tempX As String
    '		tempX = ">106mm|>45mm;"
    '		tempX = tempX & "Sub-Total|" & subfatura
    '		FrmRelatorio.VS.Table = tempX
    '		Imprimir_SubTotal = 0
    '	End Function

    '	'UPGRADE_WARNING: Event OptVencer.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
    '	Private Sub OptVencer_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles OptVencer.CheckedChanged
    '		If eventSender.Checked Then
    '			chkVencimento.CheckState = System.Windows.Forms.CheckState.Unchecked
    '			chkVencimento.Enabled = False
    '			Call chkVencimento_CheckStateChanged(chkVencimento, New System.EventArgs())
    '		End If
    '	End Sub

    '	'------------------ fim MDS ------------------
    '	'UPGRADE_WARNING: Event OptVencidos.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
    '	Private Sub OptVencidos_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles OptVencidos.CheckedChanged
    '		If eventSender.Checked Then
    '			chkVencimento.CheckState = System.Windows.Forms.CheckState.Checked
    '			chkVencimento.Enabled = True
    '			Call chkVencimento_CheckStateChanged(chkVencimento, New System.EventArgs())
    '		End If
    '	End Sub

    '	Private Sub montaImpCart65(ByVal VScart As AxVSVIEW6.AxVSPrinter)
    '		Dim strCart65 As String
    '		Dim contaLinha As Short
    '		Dim Subtot As Double
    '		Dim Ecex As Double
    '		Dim total As Double
    '		Dim TotalN As Double
    '		Dim X As Integer
    '		Dim lrstAux As ADODB.Recordset
    '		lrstAux = New ADODB.Recordset
    '		strCart65 = "select distinct a.banarrec,b.nmbco,count(a.banarrec) cons,sum(a.valortot) valor from `filtro2` a,bancos b where a.banarrec = b.ban_id group by a. banarrec"
    '		With VScart
    '			.MarginLeft = "15mm"
    '			.StartTable()
    '			Call Conectar(strCart65, lrstAux)
    '			.Font = VB6.FontChangeSize(.Font, 8) 'Tamanho do fonte
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcCols,  ,  ,  ,  , 6)
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcRows,  ,  ,  ,  , lrstAux.RecordCount + 2)
    '			.TableBorder = VSVIEW6.TableBorderSettings.tbAll
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcColWidth,  , 1,  ,  , "15mm")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcColWidth,  , 2,  ,  , "75mm")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcColWidth,  , 3,  ,  , "35mm")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcColWidth,  , 4,  ,  , "15mm")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcColWidth,  , 5,  ,  , "20mm")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcColWidth,  , 6,  ,  , "15mm")
    '			For X = 1 To 6
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcAlign, 1, X,  ,  , VSVIEW6.TextAlignSettings.taCenterMiddle)
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcFontBold, 1, X,  ,  , True)
    '			Next 
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 1,  ,  , "Cód. Banco")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 2,  ,  , "Banco")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 3,  ,  , "Valor")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 4,  ,  , "REL %")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 5,  ,  , "No. SLIPS")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, 1, 6,  ,  , "REL. %")
    '			Subtot = 0
    '			Ecex = 0
    '			contaLinha = 1
    '			While lrstAux.EOF = False
    '				total = total + lrstAux.Fields("valor").Value
    '				TotalN = TotalN + lrstAux.Fields("cons").Value
    '				lrstAux.MoveNext()
    '			End While
    '			lrstAux.MoveFirst()
    '			While lrstAux.EOF = False
    '				contaLinha = contaLinha + 1
    '				For X = 1 To 2
    '					'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '					.let_TableCell(VSVIEW6.TableCellSettings.tcAlign, contaLinha, X,  ,  , VSVIEW6.TextAlignSettings.taCenterMiddle)
    '				Next 
    '				For X = 3 To 6
    '					'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '					.let_TableCell(VSVIEW6.TableCellSettings.tcAlign, contaLinha, X,  ,  , VSVIEW6.DrawTextAlignSettings.tadRight)
    '				Next 
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 1,  ,  , lrstAux.Fields("banarrec"))
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 2,  ,  , lrstAux.Fields("nmbco"))
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 3,  ,  , VB6.Format(lrstAux.Fields("valor").Value, "standard"))
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 4,  ,  , VB6.Format(lrstAux.Fields("valor").Value / (total * 0.01), "standard"))
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 5,  ,  , lrstAux.Fields("cons"))
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha, 6,  ,  , VB6.Format(lrstAux.Fields("cons").Value / (TotalN * 0.01), "standard"))
    '				lrstAux.MoveNext()
    '			End While
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcColSpan, contaLinha + 1, 1,  ,  , 2)
    '			For X = 1 To 6
    '				'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '				.let_TableCell(VSVIEW6.TableCellSettings.tcAlign, contaLinha + 1, X,  ,  , VSVIEW6.DrawTextAlignSettings.tadRight)
    '			Next 
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha + 1, 1,  ,  , " TOTAL")
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha + 1, 3,  ,  , VB6.Format(total, "standard"))
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha + 1, 4,  ,  , VB6.Format(total / (total * 0.01), "standard"))
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha + 1, 5,  ,  , TotalN)
    '			'UPGRADE_WARNING: Couldn't resolve default property of object VScart.TableCell(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
    '			.let_TableCell(VSVIEW6.TableCellSettings.tcText, contaLinha + 1, 6,  ,  , VB6.Format(TotalN / (TotalN * 0.01), "standard"))
    '			.EndTable()
    '			Call lrstAux.Close()
    '		End With

    '	End Sub

    Private Function queGrupoTitulo() As String
        Try
            strSubtitulo = "Faturamento - Mês:"
            If Me.txtMesano.Text <> "" Then
                strSubtitulo = strSubtitulo & Me.txtMesano.Text
            Else
                strSubtitulo = strSubtitulo & " Todos"
            End If
            If (Me.chkGrupoA.CheckState = 1 And chkGrupoB.CheckState = 1) Or (Me.chkGrupoA.CheckState = 0 And chkGrupoB.CheckState = 0) Then
                strSubtitulo = strSubtitulo & " - GRUPO A e B"
            Else
                If chkGrupoA.CheckState = 1 Then strSubtitulo = strSubtitulo & " - GRUPO A "
                If chkGrupoB.CheckState = 1 Then strSubtitulo = strSubtitulo & " - GRUPO B "
            End If
            queGrupoTitulo = strSubtitulo
        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: queGrupoTitulo" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Function
        End Try
    End Function

    Private Function queClasseSubTitulo2() As String
        Dim strClasses As String
        Dim X As Integer
        Try
            strSubTitulo2 = "CLASSE: "
            'UPGRADE_WARNING: Lower bound of collection Me.LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
            If Me.LvClasses.Items.Item(1).Checked = False Then
                For X = 1 To 9
                    'UPGRADE_WARNING: Lower bound of collection Me.LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
                    If Me.LvClasses.Items.Item(X).Checked = True Then
                        If strClasses <> "" And X < 9 Then strClasses = strClasses & ","
                        'strClasses = strClasses & Me.LvClasses.ListItems(X).SubItems(1)
                        'UPGRADE_WARNING: Lower bound of collection Me.LvClasses.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
                        strClasses = strClasses & Me.LvClasses.Items.Item(X).Text
                    End If
                Next X
            End If
            strSubTitulo2 = strSubTitulo2 & strClasses
            queClasseSubTitulo2 = strSubTitulo2
        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: OnOffProcMon" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Function
        End Try
    End Function
    Private Sub sCriaTabelaAuxiliar()

        Dim lstrsql As String

        Try

            objExecAtualizaBancoDados.QUERY_NAME = "drop table if exists AUX_SERVICOS_TAXADOS" & VB.Right(My.Computer.Name, 5)
            repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

            lstrsql = ""
            lstrsql = "create table AUX_SERVICOS_TAXADOS" & VB.Right(My.Computer.Name, 5) & "("
            lstrsql = lstrsql & "CODIGO VARCHAR(20),"
            lstrsql = lstrsql & "DESCRICAO VARCHAR(50),"
            lstrsql = lstrsql & "VALOR VARCHAR(20))"
            objExecAtualizaBancoDados.QUERY_NAME = lstrsql
            repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

            objExecAtualizaBancoDados.QUERY_NAME = "drop table if exists AUX_CONVENIOS_DIVERSOS" & VB.Right(My.Computer.Name, 5)
            repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

            lstrsql = ""
            lstrsql = "create table AUX_CONVENIOS_DIVERSOS" & VB.Right(My.Computer.Name, 5) & "("
            lstrsql = lstrsql & "CODIGO VARCHAR(20),"
            lstrsql = lstrsql & "DESCRICAO VARCHAR(50),"
            lstrsql = lstrsql & "MULTAECE VARCHAR(20),"
            lstrsql = lstrsql & "VALOR VARCHAR(20))"
            objExecAtualizaBancoDados.QUERY_NAME = lstrsql
            repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

            objExecAtualizaBancoDados.QUERY_NAME = "drop table if exists AUX_CONVENIOS_DIVERSOS_2" & VB.Right(My.Computer.Name, 5)
            repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

            lstrsql = ""
            lstrsql = "create table AUX_CONVENIOS_DIVERSOS_2" & VB.Right(My.Computer.Name, 5) & "("
            lstrsql = lstrsql & "CODIGO VARCHAR(20),"
            lstrsql = lstrsql & "DESCRICAO VARCHAR(50),"
            lstrsql = lstrsql & "VALOR VARCHAR(20))"
            objExecAtualizaBancoDados.QUERY_NAME = lstrsql
            repositorioExecAtualizaBancosDados.Execute(objExecAtualizaBancoDados)

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: sCriaTabelaAuxiliar" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub
    Private Sub lPrint(ByVal vNomeRPT As String)

        Dim dt As DataTable
        Dim dt_1 As DataTable
        Dim dt_2 As DataTable
        Dim dt_3 As DataTable
        Dim dc As DataColumn
        Dim ds As DataSet
        Dim lstrsql As String

        Dim bytBLOBData() As Byte

        Dim objEmpresa As New entidadeEmpresa
        Dim repositorioEmpresa As New repositorioEmpresa

        Dim vlist


        'Dim vlist

        'Dim objEmpresa As New entidadeEmpresa
        'Dim repositorioEmpresa As New repositorioEmpresa


        'vlist = repositorioEmpresa.Select(objEmpresa)

        'If vlist.Count <> 0 Then

        '	For Each objEmpresaFor As entidadeEmpresa In vlist

        '		bytBLOBData = objEmpresaFor.LOGOTIPO

        '	Next

        'End If

        Try
            Dim rpt As New ReportDocument()

            'rptConsumidorAVencer
            If vNomeRPT = "rptRelServicosTaxados" Then

                dt_3 = New DataTable()
                dt_3.Columns.Add("CODIGO", GetType(String))
                dt_3.Columns.Add("DESCRICAO", GetType(String))
                dt_3.Columns.Add("VALOR", GetType(String))

                ds = New DataSet

                lstrsql = ""
                lstrsql = "SELECT * FROM AUX_SERVICOS_TAXADOS" & VB.Right(My.Computer.Name, 5)
                objAtualizaBancoDados.QUERY_NAME = lstrsql
                dt = repositorioAtualizaBancosDados.Consultar(objAtualizaBancoDados)


                If dt.Rows.Count > 0 Then
                    For Each dr_1 As DataRow In dt.Rows

                        dt_3.Rows.Add(dr_1("CODIGO"),
                                          dr_1("DESCRICAO"),
                                          dr_1("VALOR"))

                    Next dr_1
                End If


                ds.Tables.Add(dt)
                ds.Tables(0).TableName = "REL_SERVICOS_TAXADOS"


                If ds.Tables(0).Rows.Count = 0 Then
                    MessageBox.Show("Não há registros para o relatório escolhido! ", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Exit Sub
                Else

                    rpt = New rptRelServicosTaxados


                    rpt.SetDataSource(ds)
                    rpt.SetParameterValue("nomeempresa", sNomeEmpresa)
                    rpt.SetParameterValue("enderecoempresa", sEnderecoEmpresa)
                    rpt.SetParameterValue("cepempresa", sCepEmpresa)
                    rpt.SetParameterValue("ufempresa", sUFempresa)
                    rpt.SetParameterValue("cidadeempresa", sCidadeEmpresa)
                    rpt.SetParameterValue("bairroempresa", sBairroEmpresa)
                    rpt.SetParameterValue("foneempresa", sFoneEmpresa)
                    rpt.SetParameterValue("websiteempresa", sWebEmpresa)
                    rpt.SetParameterValue("referente", "Referente a " & txtPeriodoIni.Text & " Até " & txtPeriodoFin.Text)
                    rpt.SetParameterValue("Classes", strSubTitulo2)
                    'rpt.SetParameterValue("Tipo", IIf(cmbOpcao.Text = "Geral", "Geral", "Munícipio"))
                    'rpt.SetParameterValue("MesAnoRef", Month(dtpMesAno.Value) & "/" & Year(dtpMesAno.Value))
                    ' rpt.SetParameterValue("NomeRel", "Grupo A - Período de: " & dtpIni.Value & " Até: " & dtpFim.Value)

                    frmViewRelatorios.rpt = rpt

                    frmViewRelatorios.CRViewer.Zoom((100))
                    frmViewRelatorios.Text = "Relatório"
                    frmViewRelatorios.ShowDialog()

                End If

            ElseIf vNomeRPT = "rptRelConveniosDiversos" Then


                dt_2 = New DataTable()
                dt_2.Columns.Add("CODIGO", GetType(String))
                dt_2.Columns.Add("DESCRICAO", GetType(String))
                dt_2.Columns.Add("MULTAECE", GetType(String))
                dt_2.Columns.Add("VALOR", GetType(String))

                dt_3 = New DataTable()
                dt_3.Columns.Add("CODIGO", GetType(String))
                dt_3.Columns.Add("DESCRICAO", GetType(String))
                dt_3.Columns.Add("VALOR", GetType(String))

                ds = New DataSet

                lstrsql = ""
                lstrsql = "SELECT * FROM AUX_CONVENIOS_DIVERSOS" & VB.Right(My.Computer.Name, 5)
                objAtualizaBancoDados.QUERY_NAME = lstrsql
                dt = repositorioAtualizaBancosDados.Consultar(objAtualizaBancoDados)


                If dt.Rows.Count > 0 Then
                    For Each dr_1 As DataRow In dt.Rows

                        dt_2.Rows.Add(dr_1("CODIGO"),
                                          dr_1("DESCRICAO"),
                                          dr_1("MULTAECE"),
                                          dr_1("VALOR"))

                    Next dr_1
                End If


                lstrsql = ""
                lstrsql = "SELECT * FROM AUX_CONVENIOS_DIVERSOS_2" & VB.Right(My.Computer.Name, 5)
                objAtualizaBancoDados.QUERY_NAME = lstrsql
                dt1 = repositorioAtualizaBancosDados.Consultar(objAtualizaBancoDados)

                If dt1.Rows.Count > 0 Then
                    For Each dr_1 As DataRow In dt1.Rows

                        dt_3.Rows.Add(dr_1("CODIGO"),
                                          dr_1("DESCRICAO"),
                                          dr_1("VALOR"))

                    Next dr_1
                End If


                ds.Tables.Add(dt)
                ds.Tables(0).TableName = "REL_CONVENIOS_DIVERSOS"

                ds.Tables.Add(dt1)
                ds.Tables(1).TableName = "REL_CONVENIOS_DIVERSOS_2"


                If ds.Tables(0).Rows.Count = 0 Then
                    MessageBox.Show("Não há registros para o relatório escolhido! ", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Exit Sub
                Else

                    rpt = New rptRelConveniosDiversos


                    rpt.SetDataSource(ds)
                    rpt.SetParameterValue("nomeempresa", sNomeEmpresa)
                    rpt.SetParameterValue("enderecoempresa", sEnderecoEmpresa)
                    rpt.SetParameterValue("cepempresa", sCepEmpresa)
                    rpt.SetParameterValue("ufempresa", sUFempresa)
                    rpt.SetParameterValue("cidadeempresa", sCidadeEmpresa)
                    rpt.SetParameterValue("bairroempresa", sBairroEmpresa)
                    rpt.SetParameterValue("foneempresa", sFoneEmpresa)
                    rpt.SetParameterValue("websiteempresa", sWebEmpresa)
                    rpt.SetParameterValue("referente", "Referente a " & txtPeriodoIni.Text & " Até " & txtPeriodoFin.Text)
                    rpt.SetParameterValue("Classes", strSubTitulo2)
                    'rpt.SetParameterValue("Tipo", IIf(cmbOpcao.Text = "Geral", "Geral", "Munícipio"))
                    'rpt.SetParameterValue("MesAnoRef", Month(dtpMesAno.Value) & "/" & Year(dtpMesAno.Value))
                    ' rpt.SetParameterValue("NomeRel", "Grupo A - Período de: " & dtpIni.Value & " Até: " & dtpFim.Value)

                    frmViewRelatorios.rpt = rpt

                    frmViewRelatorios.CRViewer.Zoom((100))
                    frmViewRelatorios.Text = "Relatório"
                    frmViewRelatorios.ShowDialog()

                End If

            End If
            Me.Cursor = System.Windows.Forms.Cursors.Default

        Catch ex As Exception
            MessageBox.Show("Ocorreu o Erro: " & Err.Description & " - Rotina: lPrint" & "", "Aviso de Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Exit Sub
        End Try

    End Sub
End Class