Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class FrmPDD
	Inherits System.Windows.Forms.Form
	Private ifrAuxiliar As FrmRelatorio
	Private istrClasseCabec As String
	
	'UPGRADE_WARNING: Event chkComercial.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 chkComercial_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkComercial.CheckStateChanged
		With Me.txtLimiteComercial
			.Enabled = (Me.chkComercial.Enabled And Me.chkComercial.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			If .Enabled Then Call .Focus()
		End With
	End Sub
	
	'UPGRADE_WARNING: Event chkConsumoProprio.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 chkConsumoProprio_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkConsumoProprio.CheckStateChanged
		With Me.txtLimiteConsumoProprio
			.Enabled = (Me.chkConsumoProprio.Enabled And Me.chkConsumoProprio.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			If .Enabled Then Call .Focus()
		End With
	End Sub
	
	'UPGRADE_WARNING: Event chkIluminacaoPublica.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 chkIluminacaoPublica_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkIluminacaoPublica.CheckStateChanged
		With Me.txtLimiteIluminacaoPublica
			.Enabled = (Me.chkIndustrial.Enabled And Me.chkIndustrial.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			If .Enabled Then Call .Focus()
		End With
	End Sub
	
	'UPGRADE_WARNING: Event chkIndustrial.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 chkIndustrial_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkIndustrial.CheckStateChanged
		With Me.txtLimiteIndustrial
			.Enabled = (Me.chkIndustrial.Enabled And Me.chkIndustrial.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			If .Enabled Then Call .Focus()
		End With
	End Sub
	
	'UPGRADE_WARNING: Event chkPoderPublico.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 chkPoderPublico_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkPoderPublico.CheckStateChanged
		With Me.txtLimitePoderPublico
			.Enabled = (Me.chkPoderPublico.Enabled And Me.chkPoderPublico.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			If .Enabled Then Call .Focus()
		End With
	End Sub
	
	'UPGRADE_WARNING: Event chkResidencial.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 chkResidencial_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkResidencial.CheckStateChanged
		With Me.txtLimiteResidencial
			.Enabled = (Me.chkResidencial.Enabled And Me.chkResidencial.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			If .Enabled Then Call .Focus()
		End With
	End Sub
	
	'UPGRADE_WARNING: Event chkResidencialBxRenda.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 chkResidencialBxRenda_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkResidencialBxRenda.CheckStateChanged
		With Me.txtLimiteResidencialBxRenda
			.Enabled = (Me.chkResidencialBxRenda.Enabled And Me.chkResidencialBxRenda.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			If .Enabled Then Call .Focus()
		End With
	End Sub
	
	'UPGRADE_WARNING: Event chkRural.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 chkRural_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkRural.CheckStateChanged
		With Me.txtLimiteRural
			.Enabled = (Me.chkRural.Enabled And Me.chkRural.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			If .Enabled Then Call .Focus()
		End With
	End Sub
	
	'UPGRADE_WARNING: Event chkServicoPublico.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 chkServicoPublico_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkServicoPublico.CheckStateChanged
		With Me.txtLimiteServicoPublico
			.Enabled = (Me.chkServicoPublico.Enabled And Me.chkServicoPublico.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			If .Enabled Then Call .Focus()
		End With
	End Sub
	
	'UPGRADE_WARNING: Event cmbOpcao.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 cmbOpcao.Change was upgraded to cmbOpcao.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 cmbOpcao_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmbOpcao.TextChanged
		With Me.txtResTol
			.Enabled = (Me.cmbOpcao.SelectedIndex = 0)
			.Text = IIf(.Enabled, "000", "000")
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			If .Enabled And .Visible Then Call .Focus()
		End With
		Call MontaGrade()
	End Sub
	
	'UPGRADE_WARNING: Event cmbOpcao.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 cmbOpcao_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmbOpcao.SelectedIndexChanged
		Call DesLigBotoes(True)
		Call cmbOpcao_TextChanged(cmbOpcao, New System.EventArgs())
	End Sub
	
	Private Sub cmdAnalisar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdAnalisar.Click
		Dim ldblTolerancia As Double
		Dim lstrOrdImp As String
		Dim lstrCodClas As String
		Dim lstrNomClas As String
		Dim ldblDias As Double
		Dim ldblNumNF As Double
		Dim lstrMesAno As String
		Dim lstrZona As String
		Dim lstrLivro As String
		Dim lstrConta As String
		Dim lstrNome As String
		Dim ldteVenc As Date
		Dim ldblValorTot As Double
		Dim llngUnidId As Integer
		Dim llngConsId As Integer
		Dim lstrFlgSt As String
		Dim lstrTa As String
		Dim lstrGrupo As String
		Dim lstrSituacao As String
		Dim lblnReserva As Boolean
		Dim lblnContinua As Boolean
		Dim lstrSql As String
		Dim lngConta As Integer
		Dim lrstAuxNf As ADODB.Recordset
		Dim lrstAuxRe As ADODB.Recordset
		'
		Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
		Call DesLigBotoes(False)
		'
		lrstAuxNf = New ADODB.Recordset
		lrstAuxRe = New ADODB.Recordset
		'
		lblnReserva = False
		lblnContinua = True
		'
		Me.lblInfo.Text = " Lendo Faturas, aguarde..."
		Call Me.lblInfo.Refresh()
		Call MontaGrade()
		lstrSql = ""
		lstrSql = lstrSql & "SELECT" & vbCrLf
		lstrSql = lstrSql & "       `numnf`, " & vbCrLf
		lstrSql = lstrSql & "       `mesano`, " & vbCrLf
		lstrSql = lstrSql & "       `mesano_ref`, " & vbCrLf
		lstrSql = lstrSql & "       `cons_id`, " & vbCrLf
		lstrSql = lstrSql & "       `unid_id`, " & vbCrLf
		lstrSql = lstrSql & "       `zona`, " & vbCrLf
		lstrSql = lstrSql & "       `livro`, " & vbCrLf
		lstrSql = lstrSql & "       `conta`, " & vbCrLf
		lstrSql = lstrSql & "       `codclas`, " & vbCrLf
		lstrSql = lstrSql & "       `datavenc`, " & vbCrLf
		lstrSql = lstrSql & "       `datapag`, " & vbCrLf
		lstrSql = lstrSql & "       `valortot`, " & vbCrLf
		lstrSql = lstrSql & "       `grupo`, " & vbCrLf
		lstrSql = lstrSql & "       `flgst`, " & vbCrLf
		lstrSql = lstrSql & "       `ta` " & vbCrLf
		lstrSql = lstrSql & "  FROM `nf` " & vbCrLf
		lstrSql = lstrSql & " WHERE `nf`.`datavenc` <= '" & VB6.Format(Me.dtpBase.value, "yyyy-MM-dd") & "' " & vbCrLf
		lstrSql = lstrSql & "   AND (`nf`.`datapag` = '0000-00-00' OR `nf`.`datapag` > '" & VB6.Format(Me.dtpBase.value, "yyyy-MM-dd") & "') " & vbCrLf
		If Me.cmbOpcao.SelectedIndex = 0 Then
			If Me.chkJudice.CheckState = 1 Then
				lstrSql = lstrSql & " AND (`nf`.`flgst` NOT IN('C','R') OR (`nf`.`flgst` = 'C' AND `nf`.`datast` > '" & VB6.Format(Me.dtpBase.value, "yyyy-MM-dd") & "')) " & vbCrLf
			Else
				lstrSql = lstrSql & " AND (`nf`.`flgst` NOT IN('C','R','J') OR (`nf`.`flgst` = 'C' AND `nf`.`datast` > '" & VB6.Format(Me.dtpBase.value, "yyyy-MM-dd") & "')) " & vbCrLf
			End If
		ElseIf Me.cmbOpcao.SelectedIndex = 1 Then 
			lstrSql = lstrSql & " AND `nf`.`flgst` = 'R' " & vbCrLf
		End If
		Call Conectar(lstrSql, lrstAuxNf)
		With lrstAuxNf
			If .State = ADODB.ObjectStateEnum.adStateOpen Then
				If .RecordCount > 0 Then
					Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 0, .RecordCount)
					Me.mfgDados.Redraw = False
					While Not .EOF
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						lstrCodClas = VB6.Format(Trim(IIf(IsDbNull(.Fields("codclas").value), "0", .Fields("codclas").value)), "0000")
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						ldblNumNF = CDbl(IIf(IsDbNull(.Fields("numnf").value), 0, .Fields("numnf").value))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						lstrMesAno = Trim(IIf(IsDbNull(.Fields("mesano").value), "00/0000", .Fields("mesano").value))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						lstrZona = VB6.Format(Trim(IIf(IsDbNull(.Fields("zona").value), "0", .Fields("zona").value)), "000")
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						lstrLivro = VB6.Format(Trim(IIf(IsDbNull(.Fields("livro").value), "0", .Fields("livro").value)), "00")
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						lstrConta = VB6.Format(Trim(IIf(IsDbNull(.Fields("conta").value), "0", .Fields("conta").value)), "000000")
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						ldteVenc = CDate(IIf(IsDbNull(.Fields("datavenc").value), "1951-01-01", .Fields("datavenc").value))
						'UPGRADE_WARNING: DateDiff behavior may be different. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6B38EC3F-686D-4B2E-B5A5-9E8E7A762E32"'
						ldblDias = DateDiff(Microsoft.VisualBasic.DateInterval.Day, ldteVenc, Me.dtpBase.value)
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						ldblValorTot = CDbl(IIf(IsDbNull(.Fields("valortot").value), 0, .Fields("valortot").value))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						llngUnidId = CInt(IIf(IsDbNull(.Fields("unid_id").value), 0, .Fields("unid_id").value))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						llngConsId = CInt(IIf(IsDbNull(.Fields("cons_id").value), 0, .Fields("cons_id").value))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						lstrFlgSt = Trim(IIf(IsDbNull(.Fields("flgst").value), "", .Fields("flgst").value))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						lstrTa = Mid(Trim(IIf(IsDbNull(.Fields("ta").value), "00B1", .Fields("ta").value)), 3, 2)
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						lstrGrupo = Trim(IIf(IsDbNull(.Fields("grupo").value), "B", .Fields("grupo").value))
						lstrSql = ""
						lstrSql = lstrSql & "SELECT `numnf`,`mesano`,`zona`,`livro`,`conta`,`datares` " & vbCrLf
						lstrSql = lstrSql & "  FROM `reserva` " & vbCrLf
						lstrSql = lstrSql & " WHERE `numnf`    =  " & ldblNumNF & " " & vbCrLf
						lstrSql = lstrSql & "   AND `mesano`   = '" & lstrMesAno & "' " & vbCrLf
						lstrSql = lstrSql & "   AND `zona`     = '" & lstrZona & "' " & vbCrLf
						lstrSql = lstrSql & "   AND `livro`    = '" & lstrLivro & "' " & vbCrLf
						lstrSql = lstrSql & "   AND `conta`    = '" & lstrConta & "' " & vbCrLf
						lstrSql = lstrSql & "   AND `datares` <= '" & VB6.Format(Me.dtpBase.value, "yyyy-MM-dd") & "' "
						Call Conectar(lstrSql, lrstAuxRe)
						With lrstAuxRe
							If .State = ADODB.ObjectStateEnum.adStateOpen Then
								lblnReserva = (.RecordCount > 0)
								Call .Close()
							End If
						End With
						Select Case VB.Left(lstrCodClas, 1)
							Case Is = "9"
								If VB.Right(lstrCodClas, 2) = "02" Or VB.Right(lstrCodClas, 2) = "04" Or VB.Right(lstrCodClas, 2) = "05" Or VB.Right(lstrCodClas, 2) = "06" Then
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									ldblTolerancia = CDbl(IIf(IsNumeric(Me.txtLimiteResidencialBxRenda.Text), Me.txtLimiteResidencialBxRenda.Text, 0))
									lstrOrdImp = "01"
									lstrNomClas = "Resid. Bx.Renda"
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									If CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0)) <> 0 Then
										'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
										ldblTolerancia = ldblTolerancia + CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0))
									End If
									lblnContinua = (Me.chkResidencialBxRenda.CheckState = 1 And ldblDias > ldblTolerancia)
								Else
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									ldblTolerancia = CDbl(IIf(IsNumeric(Me.txtLimiteResidencial.Text), Me.txtLimiteResidencial.Text, 0))
									lstrOrdImp = "02"
									lstrNomClas = "Residencial"
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									If CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0)) <> 0 Then
										'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
										ldblTolerancia = ldblTolerancia + CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0))
									End If
									lblnContinua = (Me.chkResidencial.CheckState = 1 And ldblDias > ldblTolerancia)
								End If
							Case Is = "0"
								'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								ldblTolerancia = CDbl(IIf(IsNumeric(Me.txtLimiteIndustrial.Text), Me.txtLimiteIndustrial.Text, 0))
								lstrOrdImp = "03"
								lstrNomClas = "Industrial"
								'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								If CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0)) <> 0 Then
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									ldblTolerancia = ldblTolerancia + CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0))
								End If
								lblnContinua = (Me.chkIndustrial.CheckState = 1 And ldblDias > ldblTolerancia)
							Case Is = "1"
								'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								ldblTolerancia = CDbl(IIf(IsNumeric(Me.txtLimiteIndustrial.Text), Me.txtLimiteIndustrial.Text, 0))
								lstrOrdImp = "03"
								lstrNomClas = "Industrial"
								'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								If CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0)) <> 0 Then
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									ldblTolerancia = ldblTolerancia + CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0))
								End If
								lblnContinua = (Me.chkIndustrial.CheckState = 1 And ldblDias > ldblTolerancia)
							Case Is = "2"
								'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								ldblTolerancia = CDbl(IIf(IsNumeric(Me.txtLimiteIndustrial.Text), Me.txtLimiteIndustrial.Text, 0))
								lstrOrdImp = "03"
								lstrNomClas = "Industrial"
								'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								If CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0)) <> 0 Then
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									ldblTolerancia = ldblTolerancia + CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0))
								End If
								lblnContinua = (Me.chkIndustrial.CheckState = 1 And ldblDias > ldblTolerancia)
							Case Is = "3"
								'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								ldblTolerancia = CDbl(IIf(IsNumeric(Me.txtLimiteIndustrial.Text), Me.txtLimiteIndustrial.Text, 0))
								lstrOrdImp = "03"
								lstrNomClas = "Industrial"
								'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								If CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0)) <> 0 Then
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									ldblTolerancia = ldblTolerancia + CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0))
								End If
								lblnContinua = (Me.chkIndustrial.CheckState = 1 And ldblDias > ldblTolerancia)
							Case Is = "4"
								'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								ldblTolerancia = CDbl(IIf(IsNumeric(Me.txtLimiteComercial.Text), Me.txtLimiteComercial.Text, 0))
								lstrOrdImp = "04"
								lstrNomClas = "Comercial"
								'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								If CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0)) <> 0 Then
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									ldblTolerancia = ldblTolerancia + CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0))
								End If
								lblnContinua = (Me.chkComercial.CheckState = 1 And ldblDias > ldblTolerancia)
							Case Is = "5"
								'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								ldblTolerancia = CDbl(IIf(IsNumeric(Me.txtLimiteRural.Text), Me.txtLimiteRural.Text, 0))
								lstrOrdImp = "05"
								lstrNomClas = "Rural"
								'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								If CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0)) <> 0 Then
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									ldblTolerancia = ldblTolerancia + CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0))
								End If
								lblnContinua = (Me.chkRural.CheckState = 1 And ldblDias > ldblTolerancia)
							Case Is = "6"
								If VB.Left(lstrCodClas, 2) = "61" Then
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									ldblTolerancia = CDbl(IIf(IsNumeric(Me.txtLimitePoderPublico.Text), Me.txtLimitePoderPublico.Text, 0))
									lstrOrdImp = "06"
									lstrNomClas = "P. Púb. Municipal"
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									If CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0)) <> 0 Then
										'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
										ldblTolerancia = ldblTolerancia + CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0))
									End If
									lblnContinua = (Me.chkPoderPublico.CheckState = 1 And ldblDias > ldblTolerancia)
								ElseIf VB.Left(lstrCodClas, 2) = "62" Then 
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									ldblTolerancia = CDbl(IIf(IsNumeric(Me.txtLimitePoderPublico.Text), Me.txtLimitePoderPublico.Text, 0))
									lstrOrdImp = "07"
									lstrNomClas = "P. Púb. Estadual"
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									If CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0)) <> 0 Then
										'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
										ldblTolerancia = ldblTolerancia + CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0))
									End If
									lblnContinua = (Me.chkPoderPublico.CheckState = 1 And ldblDias > ldblTolerancia)
								ElseIf VB.Left(lstrCodClas, 2) = "63" Then 
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									ldblTolerancia = CDbl(IIf(IsNumeric(Me.txtLimitePoderPublico.Text), Me.txtLimitePoderPublico.Text, 0))
									lstrOrdImp = "08"
									lstrNomClas = "P. Púb. Federal"
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									If CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0)) <> 0 Then
										'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
										ldblTolerancia = ldblTolerancia + CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0))
									End If
									lblnContinua = (Me.chkPoderPublico.CheckState = 1 And ldblDias > ldblTolerancia)
								ElseIf VB.Left(lstrCodClas, 2) = "64" Then 
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									ldblTolerancia = CDbl(IIf(IsNumeric(Me.txtLimiteIluminacaoPublica.Text), Me.txtLimiteIluminacaoPublica.Text, 0))
									lstrOrdImp = "09"
									lstrNomClas = "Iluminação Púb."
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									If CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0)) <> 0 Then
										'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
										ldblTolerancia = ldblTolerancia + CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0))
									End If
									lblnContinua = (Me.chkIluminacaoPublica.CheckState = 1 And ldblDias > ldblTolerancia)
								End If
							Case Is = "7"
								'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								ldblTolerancia = CDbl(IIf(IsNumeric(Me.txtLimiteServicoPublico.Text), Me.txtLimiteServicoPublico.Text, 0))
								lstrOrdImp = "10"
								lstrNomClas = "Serviço Público"
								'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								If CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0)) <> 0 Then
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									ldblTolerancia = ldblTolerancia + CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0))
								End If
								lblnContinua = (Me.chkServicoPublico.CheckState = 1 And ldblDias > ldblTolerancia)
							Case Is = "8"
								'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								ldblTolerancia = CDbl(IIf(IsNumeric(Me.txtLimiteConsumoProprio.Text), Me.txtLimiteConsumoProprio.Text, 0))
								lstrOrdImp = "12"
								lstrNomClas = "Consumo Próprio"
								'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								If CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0)) <> 0 Then
									'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									ldblTolerancia = ldblTolerancia + CDbl(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0))
								End If
								lblnContinua = (Me.chkConsumoProprio.CheckState = 1 And ldblDias > ldblTolerancia)
							Case Else
								ldblTolerancia = 0
								lstrOrdImp = "13"
								lstrNomClas = "Indefinido"
								lblnContinua = False
						End Select
						If lstrTa = "AL" Then
							lstrOrdImp = "11"
							lstrNomClas = "Consumidor Livre"
						End If
						If Not lblnReserva Then
							If lblnContinua Then
								lstrNome = RetornaNomeConsumidor(lstrZona, lstrLivro, lstrConta, llngUnidId, llngConsId, lstrGrupo, lstrSituacao)
								If lstrSituacao = "L" Then
									lblnContinua = (Me.chkLigados.CheckState = System.Windows.Forms.CheckState.Checked)
								ElseIf lstrSituacao = "D" Then 
									lblnContinua = (Me.chkDesligados.CheckState = System.Windows.Forms.CheckState.Checked)
								ElseIf lstrSituacao = "C" Then 
									lblnContinua = (Me.chkCortados.CheckState = System.Windows.Forms.CheckState.Checked)
								ElseIf lstrSituacao = "I" Then 
									lblnContinua = (Me.chkDesativados.CheckState = System.Windows.Forms.CheckState.Checked)
								Else
									lblnContinua = True
								End If
								If lblnContinua Then
									With Me.mfgDados
										.Rows = .Rows + 1
										'UPGRADE_ISSUE: VBControlExtender method mfgDados.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
										.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillRepeat
										If lstrFlgSt = "R" Then
											.Row = .Rows - 1
											.Col = 0
											.ColSel = .Cols - 1
											.CellForeColor = System.Drawing.ColorTranslator.FromOle(&HFF) 'Vermelho
										ElseIf lstrFlgSt = "J" Then 
											.Row = .Rows - 1
											.Col = 0
											.ColSel = .Cols - 1
											.CellForeColor = System.Drawing.ColorTranslator.FromOle(&H808080) 'Cinza
										ElseIf ((lstrNome = "NOME NÃO ENCONTRADO") Or (lstrNome = "EM BRANCO")) Then 
											.Row = .Rows - 1
											.Col = 0
											.ColSel = .Cols - 1
											.CellForeColor = System.Drawing.ColorTranslator.FromOle(&HFF0000) 'Azul
										Else
											.Row = .Rows - 1
											.Col = 0
											.ColSel = .Cols - 1
											.CellForeColor = System.Drawing.ColorTranslator.FromOle(&H80000008) 'Normal
										End If
										'UPGRADE_ISSUE: VBControlExtender method mfgDados.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
										.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillSingle
										.set_TextMatrix(.Rows - 1, 0, ldblTolerancia)
										.set_TextMatrix(.Rows - 1, 1, lstrOrdImp)
										.set_TextMatrix(.Rows - 1, 2, lstrNomClas)
										.set_TextMatrix(.Rows - 1, 3, ldblNumNF)
										.set_TextMatrix(.Rows - 1, 4, lstrMesAno)
										.set_TextMatrix(.Rows - 1, 5, lstrZona)
										.set_TextMatrix(.Rows - 1, 6, lstrLivro)
										.set_TextMatrix(.Rows - 1, 7, lstrConta)
										.set_TextMatrix(.Rows - 1, 8, lstrNome)
										.set_TextMatrix(.Rows - 1, 9, VB6.Format(ldteVenc, "dd/mm/yyyy"))
										.set_TextMatrix(.Rows - 1, 10, ldblDias)
										.set_TextMatrix(.Rows - 1, 11, VB6.Format(ldblValorTot, "#,##0.00"))
										.set_TextMatrix(.Rows - 1, 12, lstrFlgSt)
										If lstrFlgSt = "J" Then
											'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
											Me.lblQtdeFaturasJudice.Text = CStr(CInt(IIf(IsNumeric(Me.lblQtdeFaturasJudice.Text), Me.lblQtdeFaturasJudice.Text, 0)) + 1)
										Else
											'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
											Me.lblQtdeFaturas.Text = CStr(CInt(IIf(IsNumeric(Me.lblQtdeFaturas.Text), Me.lblQtdeFaturas.Text, 0)) + 1)
										End If
									End With
								End If
							End If
						End If
						Call .MoveNext()
						Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 1)
					End While
					With Me.mfgDados
						.Col = 1
						.Sort = MSFlexGridLib.SortSettings.flexSortGenericAscending
						.Redraw = True
						Me.lblQtdeFaturasTotal.Text = CStr(.Rows - 1)
					End With
				End If
				Call .Close()
			End If
		End With
		'UPGRADE_NOTE: Object lrstAuxNf may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
		lrstAuxNf = Nothing
		'UPGRADE_NOTE: Object lrstAuxRe may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
		lrstAuxRe = Nothing
		Me.Cursor = System.Windows.Forms.Cursors.Default
		Call DesLigBotoes(True)
		Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 2)
	End Sub
	
	Private Sub cmdFechar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdFechar.Click
		Call Me.Close()
	End Sub
	
	Private Sub cmdImprimir_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdImprimir.Click
		Dim lstrTable As String
		Dim llngConta As Integer
		Dim lstrZona As String
		Dim lstrLivro As String
		Dim lstrConta As String
		Dim lstrNome As String
		Dim ldteVencto As Date
		Dim ldblValor As Double
		Dim ldblVlrTotal As Double
		Dim llngQtdTotal As Integer
		Dim llngDias As Integer
		Dim lstrClasse As String
		'UPGRADE_WARNING: Lower bound of array lstrClas was changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="0F1C9BE1-AF9D-476E-83B1-17D43BECFF20"'
		Dim lstrClas(20) As String
		'UPGRADE_WARNING: Lower bound of array ldblTotal was changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="0F1C9BE1-AF9D-476E-83B1-17D43BECFF20"'
		Dim ldblTotal(20) As Double
		'UPGRADE_WARNING: Lower bound of array lngTotal was changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="0F1C9BE1-AF9D-476E-83B1-17D43BECFF20"'
		Dim lngTotal(20) As Integer
		Dim lstrMesAno As String
		Dim llngPagina As Integer
		'
		If Me.mfgDados.Rows > 1 Then
			istrClasseCabec = "Cons. da classe " & mfgDados.get_TextMatrix(1, 2) & " venc. a mais de " & mfgDados.get_TextMatrix(1, 0) & " dias"
			lstrClasse = istrClasseCabec
			With ifrAuxiliar
				.quem_chama = Me
				.VS.Font = VB6.FontChangeName(.VS.Font, "Arial")
				.VS.Font = VB6.FontChangeSize(.VS.Font, 9)
				.VS.TableBorder = VSVIEW6.TableBorderSettings.tbNone
				.VS.PageBorder = VSVIEW6.TableBorderSettings.tbNone
				.VS.ShowGuides = VSVIEW6.ShowGuideSettings.gdShow
				.VS.Orientation = VSVIEW6.OrientationSettings.orPortrait
				.VS.PhysicalPage = True
				.VS.PaperSize = VSVIEW6.PaperSizeSettings.pprA4
				.VS.MarginTop = "7mm"
				.VS.MarginRight = "7mm"
				.VS.MarginLeft = "7mm"
				.VS.MarginBottom = "5mm"
				.VS.MarginFooter = "0mm"
				.VS.MarginHeader = "0mm"
				.VS.TextColor = System.Drawing.Color.Black
				.VS.BrushStyle = VSVIEW6.BrushStyleSettings.bsSolid
				.VS.Font = VB6.FontChangeBold(.VS.Font, False)
				.VS.StartDoc()
				Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 0, Me.mfgDados.Rows - 1)
				For llngConta = 1 To Me.mfgDados.Rows - 1
					istrClasseCabec = "Cons. da classe " & mfgDados.get_TextMatrix(llngConta, 2) & " venc. a mais de " & mfgDados.get_TextMatrix(llngConta, 0) & " dias"
					If istrClasseCabec <> lstrClasse Then
						'UPGRADE_ISSUE: VBControlExtender method ifrAuxiliar.VS.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
						Call .VS.DrawLine("8mm", .VS.CurrentY + 100, "202mm", .VS.CurrentY + 100)
						Call LineFeed(.VS, 1)
						lstrTable = ""
						lstrTable = lstrTable & "<40mm|>20mm<|75mm|<40mm|>20mm;Total de Débitos: |"
						lstrTable = lstrTable & llngQtdTotal
						lstrTable = lstrTable & "||Valor Total: |"
						lstrTable = lstrTable & VB6.Format(ldblVlrTotal, "Standard")
						.VS.Table = lstrTable
						ldblVlrTotal = 0
						llngQtdTotal = 0
						lstrClasse = istrClasseCabec
						If llngPagina = .VS.CurrentPage Then
							.VS.NewPage()
						End If
					End If
					With mfgDados
						lstrMesAno = .get_TextMatrix(llngConta, 4)
						lstrZona = .get_TextMatrix(llngConta, 5)
						lstrLivro = .get_TextMatrix(llngConta, 6)
						lstrConta = .get_TextMatrix(llngConta, 7)
						lstrNome = VB.Left(.get_TextMatrix(llngConta, 8), 40)
						ldteVencto = CDate(.get_TextMatrix(llngConta, 9))
						llngDias = CInt(.get_TextMatrix(llngConta, 10))
						ldblValor = CDbl(.get_TextMatrix(llngConta, 11))
					End With
					llngPagina = .VS.CurrentPage
					lstrTable = ""
					lstrTable = lstrTable & "<25mm|<90mm|^20mm|>15mm|>15mm|>30mm;"
					lstrTable = lstrTable & lstrZona & "." & lstrLivro & "." & lstrConta
					lstrTable = lstrTable & "|" & lstrNome
					lstrTable = lstrTable & "|" & VB6.Format(ldteVencto, "dd/mm/yyyy")
					lstrTable = lstrTable & "|" & lstrMesAno
					lstrTable = lstrTable & "|" & llngDias
					lstrTable = lstrTable & "|" & VB6.Format(ldblValor, "Standard")
					.VS.Table = lstrTable
					ldblVlrTotal = ldblVlrTotal + ldblValor
					llngQtdTotal = llngQtdTotal + 1
					With Me.mfgDados
						lstrClas(CInt(.get_TextMatrix(llngConta, 1))) = .get_TextMatrix(llngConta, 2)
						ldblTotal(CInt(.get_TextMatrix(llngConta, 1))) = ldblTotal(CInt(.get_TextMatrix(llngConta, 1))) + ldblValor
						lngTotal(CInt(.get_TextMatrix(llngConta, 1))) = lngTotal(CInt(.get_TextMatrix(llngConta, 1))) + 1
					End With
					Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 1)
				Next llngConta
				'UPGRADE_ISSUE: VBControlExtender method ifrAuxiliar.VS.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
				Call .VS.DrawLine("8mm", .VS.CurrentY + 100, "202mm", .VS.CurrentY + 100)
				Call LineFeed(.VS, 1)
				lstrTable = ""
				lstrTable = lstrTable & "<40mm|>20mm<|75mm|<40mm|>20mm;"
				lstrTable = lstrTable & "Total de Débitos: |" & llngQtdTotal
				lstrTable = lstrTable & "||Valor Total: |" & VB6.Format(ldblVlrTotal, "Standard")
				.VS.Table = lstrTable
				istrClasseCabec = "Resumo dos Totais Apurados"
				.VS.NewPage()
				ifrAuxiliar.VS.Table = "<30mm|<70mm|>30mm|>30mm;|Classe|Qtde|Valor"
				'UPGRADE_ISSUE: VBControlExtender method ifrAuxiliar.VS.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
				Call ifrAuxiliar.VS.DrawLine("8mm", ifrAuxiliar.VS.CurrentY + 100, "202mm", ifrAuxiliar.VS.CurrentY + 100)
				Call LineFeed((ifrAuxiliar.VS), 1)
				ldblVlrTotal = 0
				llngQtdTotal = 0
				For llngConta = 1 To 20
					If Len(Trim(lstrClas(llngConta))) > 0 Then
						lstrTable = ""
						lstrTable = lstrTable & "<30mm|<70mm|>30mm|>30mm;"
						lstrTable = lstrTable & "|" & lstrClas(llngConta)
						lstrTable = lstrTable & "|" & lngTotal(llngConta)
						lstrTable = lstrTable & "|" & VB6.Format(ldblTotal(llngConta), "Standard")
						.VS.Table = lstrTable
						.VS.PenStyle = VSVIEW6.PenStyleSettings.psDot
						'UPGRADE_ISSUE: VBControlExtender method ifrAuxiliar.VS.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
						Call .VS.DrawLine("38mm", .VS.CurrentY + 10, "166mm", .VS.CurrentY + 10)
						.VS.PenStyle = VSVIEW6.PenStyleSettings.psSolid
						ldblVlrTotal = ldblVlrTotal + ldblTotal(llngConta)
						llngQtdTotal = llngQtdTotal + lngTotal(llngConta)
					End If
				Next llngConta
				'UPGRADE_ISSUE: VBControlExtender method ifrAuxiliar.VS.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
				Call .VS.DrawLine("38mm", .VS.CurrentY + 10, "166mm", .VS.CurrentY + 10)
				lstrTable = ""
				lstrTable = lstrTable & "<30mm|<70mm|>30mm|>30mm;"
				lstrTable = lstrTable & "|Total"
				lstrTable = lstrTable & "|" & llngQtdTotal
				lstrTable = lstrTable & "|" & VB6.Format(ldblVlrTotal, "Standard")
				.VS.Table = lstrTable
				.VS.PenStyle = VSVIEW6.PenStyleSettings.psDot
				'UPGRADE_ISSUE: VBControlExtender method ifrAuxiliar.VS.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
				Call .VS.DrawLine("38mm", .VS.CurrentY + 10, "166mm", .VS.CurrentY + 10)
				.VS.PenStyle = VSVIEW6.PenStyleSettings.psSolid
				Call .VS.EndDoc()
				Call .Show()
			End With
		End If
	End Sub
	
	Private Sub cmdRegistrar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdRegistrar.Click
		Dim lblnContinua As Boolean
		lblnContinua = True
		Call DesLigBotoes(False)
		'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		If CInt(IIf(IsNumeric(Me.lblQtdeFaturas.Text), Me.lblQtdeFaturas.Text, 0)) > 0 Or Me.chkBaixaJudice.CheckState = System.Windows.Forms.CheckState.Checked Then
			If Me.cmbOpcao.SelectedIndex = 0 Then
				If MsgBox("Deseja realmente transportar os " & IIf(Me.chkBaixaJudice.CheckState = System.Windows.Forms.CheckState.Checked, VB6.Format(CInt(IIf(IsNumeric(Me.lblQtdeFaturasJudice.Text), Me.lblQtdeFaturasJudice.Text, 0)) + CInt(IIf(IsNumeric(Me.lblQtdeFaturas.Text), Me.lblQtdeFaturas.Text, 0)), "#,##0"), VB6.Format(Me.lblQtdeFaturas.Text, "#,##0")) & " registros de nota fiscal para reserva, com data da baixa em " & VB6.Format(Me.dtpBase.value, "dd/mm/yyyy") & "?", MsgBoxStyle.Question + MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2, gstrTituloMensagem) = MsgBoxResult.Yes Then
					'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					If CInt(IIf(IsNumeric(Me.txtResTol.Text), Me.txtResTol.Text, 0)) = 0 Then
						lblnContinua = (MsgBox("Você não informou a quantidade de dias a mais de tolerância!" & vbCrLf & "Deseja continuar mesmo assim?", MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2, gstrTituloMensagem) = MsgBoxResult.Yes)
					End If
					If lblnContinua Then
						Me.lblInfo.Text = " Transportando Faturas para Reserva.."
						Call Me.lblInfo.Refresh()
						Call LancaPDD()
						Me.lblInfo.Text = " Pronto...!"
						Call Me.lblInfo.Refresh()
					End If
				End If
			ElseIf Me.cmbOpcao.SelectedIndex = 1 Then 
				If MsgBox("Deseja realmente Retornar todos estes registros da Reserva?", MsgBoxStyle.Question + MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2, gstrTituloMensagem) = MsgBoxResult.Yes Then
					Me.lblInfo.Text = " Retornando Faturas da Reserva.."
					Call Me.lblInfo.Refresh()
					Call RetornaPDD()
					Me.lblInfo.Text = " Pronto...!"
					Call Me.lblInfo.Refresh()
				End If
			End If
		Else
			Call MsgBox("Não existe nostas fiscais para " & VB6.GetItemString(Me.cmbOpcao, Me.cmbOpcao.SelectedIndex) & "!", MsgBoxStyle.Information, gstrTituloMensagem)
		End If
		Call DesLigBotoes(True)
		If Not lblnContinua Then Call Me.txtResTol.Focus()
	End Sub
	
	Private Sub cmdRetirar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdRetirar.Click
		With Me.mfgDados
			If .RowSel > 0 Then
				If .get_TextMatrix(.RowSel, 12) = "J" Then
					'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					If CInt(IIf(IsNumeric(Me.lblQtdeFaturasJudice.Text), Me.lblQtdeFaturasJudice.Text, 0)) > 0 Then
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						Me.lblQtdeFaturasJudice.Text = CStr(CInt(IIf(IsNumeric(Me.lblQtdeFaturasJudice.Text), Me.lblQtdeFaturasJudice.Text, 0)) - 1)
					End If
				Else
					'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					If CInt(IIf(IsNumeric(Me.lblQtdeFaturas.Text), Me.lblQtdeFaturas.Text, 0)) > 0 Then
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						Me.lblQtdeFaturas.Text = CStr(CInt(IIf(IsNumeric(Me.lblQtdeFaturas.Text), Me.lblQtdeFaturas.Text, 0)) - 1)
					End If
				End If
				If .Rows > 2 Then
					Call .RemoveItem(.RowSel)
				Else
					.Rows = 1
				End If
			End If
			Me.lblQtdeFaturasTotal.Text = CStr(.Rows - 1)
		End With
	End Sub
	
	Private Sub FrmPDD_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Escape Then
			Call cmdFechar_Click(cmdFechar, New System.EventArgs())
		ElseIf KeyAscii = System.Windows.Forms.Keys.Return Then 
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub FrmPDD_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		Dim lstrFaixa As String
		Dim lintPos As Short
		Dim lstrSql As String
		Dim lrstAux As ADODB.Recordset
		lrstAux = New ADODB.Recordset
		'
		Me.txtResTol.Text = "000"
		With Me.cmbOpcao
			Call .Items.Add("Transportar Consumidores p/ Reserva")
			Call .Items.Add("Retornar Consumidores da Reserva")
			.SelectedIndex = 0
		End With
		'Monta as faixas de dias das classes
		lstrFaixa = Trim(LeConfig("PDD_LIMITES"))
		If lstrFaixa <> "" And lstrFaixa <> "-1" Then
			lintPos = 1
			Me.txtLimiteResidencial.Text = Mid(lstrFaixa, lintPos, 3)
			lintPos = InStr(lintPos, lstrFaixa, ";") + 1
			Me.txtLimiteIndustrial.Text = Mid(lstrFaixa, lintPos, 3)
			lintPos = InStr(lintPos, lstrFaixa, ";") + 1
			Me.txtLimiteComercial.Text = Mid(lstrFaixa, lintPos, 3)
			lintPos = InStr(lintPos, lstrFaixa, ";") + 1
			Me.txtLimiteRural.Text = Mid(lstrFaixa, lintPos, 3)
			lintPos = InStr(lintPos, lstrFaixa, ";") + 1
			Me.txtLimitePoderPublico.Text = Mid(lstrFaixa, lintPos, 3)
			lintPos = InStr(lintPos, lstrFaixa, ";") + 1
			Me.txtLimiteIluminacaoPublica.Text = Mid(lstrFaixa, lintPos, 3)
			lintPos = InStr(lintPos, lstrFaixa, ";") + 1
			Me.txtLimiteConsumoProprio.Text = Mid(lstrFaixa, lintPos, 3)
			lintPos = InStr(lintPos, lstrFaixa, ";") + 1
			Me.txtLimiteServicoPublico.Text = Mid(lstrFaixa, lintPos, 3)
			lintPos = InStr(lintPos, lstrFaixa, ";") + 1
			Me.txtLimiteResidencialBxRenda.Text = Mid(lstrFaixa, lintPos, 3)
		End If
		Me.dtpBase.value = BuscaDataBD
		'UPGRADE_WARNING: Couldn't resolve default property of object Me.dtpBase.value. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		Me.dtpBaixa.value = Me.dtpBase.value
		Call DesLigBotoes(True)
		ifrAuxiliar = New FrmRelatorio
		Call MontaGrade()
		lstrSql = ""
		lstrSql = lstrSql & "SELECT * "
		lstrSql = lstrSql & "  FROM bancos "
		lstrSql = lstrSql & " WHERE nmbco LIKE '%RESERVA%' "
		lstrSql = lstrSql & " LIMIT 0, 1"
		Call Conectar(lstrSql, lrstAux)
		With lrstAux
			If .State = ADODB.ObjectStateEnum.adStateOpen Then
				If .RecordCount > 0 Then
					'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
					Me.lblCodigoBanco.Text = CStr(CInt(IIf(IsDbNull(.Fields("ban_id").value), 0, .Fields("ban_id").value)))
					'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
					Me.lblDescricaoBanco.Text = " " & Trim(IIf(IsDbNull(.Fields("nmbco").value), "", .Fields("nmbco").value))
				End If
				Call .Close()
			End If
		End With
		'UPGRADE_NOTE: Object lrstAux may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
		lrstAux = Nothing
	End Sub
	
	Private Sub FrmPDD_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
		'UPGRADE_NOTE: Object ifrAuxiliar may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
		ifrAuxiliar = Nothing
	End Sub
	
	Private Sub txtLimiteComercial_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimiteComercial.Enter
		With Me.txtLimiteComercial
			.SelectionStart = 0
			.SelectionLength = Len(.Text)
		End With
	End Sub
	
	Private Sub txtLimiteComercial_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtLimiteComercial.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then 
			KeyAscii = 0
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub txtLimiteComercial_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimiteComercial.Leave
		With Me.txtLimiteComercial
			.Text = VB6.Format(.Text, "000")
		End With
	End Sub
	
	Private Sub txtLimiteConsumoProprio_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimiteConsumoProprio.Enter
		With Me.txtLimiteConsumoProprio
			.SelectionStart = 0
			.SelectionLength = Len(.Text)
		End With
	End Sub
	
	Private Sub txtLimiteConsumoProprio_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtLimiteConsumoProprio.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then 
			KeyAscii = 0
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub txtLimiteConsumoProprio_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimiteConsumoProprio.Leave
		With Me.txtLimiteConsumoProprio
			.Text = VB6.Format(.Text, "000")
		End With
	End Sub
	
	Private Sub txtLimiteIluminacaoPublica_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimiteIluminacaoPublica.Enter
		With Me.txtLimiteIluminacaoPublica
			.SelectionStart = 0
			.SelectionLength = Len(.Text)
		End With
	End Sub
	
	Private Sub txtLimiteIluminacaoPublica_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtLimiteIluminacaoPublica.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then 
			KeyAscii = 0
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub txtLimiteIluminacaoPublica_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimiteIluminacaoPublica.Leave
		With Me.txtLimiteIluminacaoPublica
			.Text = VB6.Format(.Text, "000")
		End With
	End Sub
	
	Private Sub txtLimiteIndustrial_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimiteIndustrial.Enter
		With Me.txtLimiteIndustrial
			.SelectionStart = 0
			.SelectionLength = Len(.Text)
		End With
	End Sub
	
	Private Sub txtLimiteIndustrial_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtLimiteIndustrial.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then 
			KeyAscii = 0
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub txtLimiteIndustrial_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimiteIndustrial.Leave
		With Me.txtLimiteIndustrial
			.Text = VB6.Format(.Text, "000")
		End With
	End Sub
	
	Private Sub txtLimitePoderPublico_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimitePoderPublico.Enter
		With Me.txtLimitePoderPublico
			.SelectionStart = 0
			.SelectionLength = Len(.Text)
		End With
	End Sub
	
	Private Sub txtLimitePoderPublico_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtLimitePoderPublico.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then 
			KeyAscii = 0
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub txtLimitePoderPublico_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimitePoderPublico.Leave
		With Me.txtLimitePoderPublico
			.Text = VB6.Format(.Text, "000")
		End With
	End Sub
	
	Private Sub txtLimiteResidencial_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimiteResidencial.Enter
		With Me.txtLimiteResidencial
			.SelectionStart = 0
			.SelectionLength = Len(.Text)
		End With
	End Sub
	
	Private Sub txtLimiteResidencial_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtLimiteResidencial.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then 
			KeyAscii = 0
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub txtLimiteResidencial_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimiteResidencial.Leave
		With Me.txtLimiteResidencial
			.Text = VB6.Format(.Text, "000")
		End With
	End Sub
	
	Private Sub txtLimiteResidencialBxRenda_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimiteResidencialBxRenda.Enter
		With Me.txtLimiteResidencialBxRenda
			.SelectionStart = 0
			.SelectionLength = Len(.Text)
		End With
	End Sub
	
	Private Sub txtLimiteResidencialBxRenda_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtLimiteResidencialBxRenda.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then 
			KeyAscii = 0
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub txtLimiteResidencialBxRenda_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimiteResidencialBxRenda.Leave
		With Me.txtLimiteResidencialBxRenda
			.Text = VB6.Format(.Text, "000")
		End With
	End Sub
	
	Private Sub txtLimiteRural_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimiteRural.Enter
		With Me.txtLimiteRural
			.SelectionStart = 0
			.SelectionLength = Len(.Text)
		End With
	End Sub
	
	Private Sub txtLimiteRural_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtLimiteRural.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then 
			KeyAscii = 0
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub txtLimiteRural_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimiteRural.Leave
		With Me.txtLimiteRural
			.Text = VB6.Format(.Text, "000")
		End With
	End Sub
	
	Private Sub txtLimiteServicoPublico_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimiteServicoPublico.Enter
		With Me.txtLimiteServicoPublico
			.SelectionStart = 0
			.SelectionLength = Len(.Text)
		End With
	End Sub
	
	Private Sub txtLimiteServicoPublico_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtLimiteServicoPublico.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then 
			KeyAscii = 0
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub txtLimiteServicoPublico_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLimiteServicoPublico.Leave
		With Me.txtLimiteServicoPublico
			.Text = VB6.Format(.Text, "000")
		End With
	End Sub
	
	Private Sub txtResTol_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtResTol.Enter
		With Me.txtResTol
			.SelectionStart = 0
			.SelectionLength = CInt(Len(.Text))
		End With
	End Sub
	
	Private Sub txtResTol_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles txtResTol.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii <> System.Windows.Forms.Keys.Back And (KeyAscii < System.Windows.Forms.Keys.D0 Or KeyAscii > System.Windows.Forms.Keys.D9) Then 
			KeyAscii = 0
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub txtResTol_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtResTol.Leave
		With Me.txtResTol
			If CInt(Len(Trim(.Text))) = 0 Then
				.Text = "0"
			End If
			.Text = VB6.Format(.Text, "000")
		End With
	End Sub
	
	Public Function CabecaRel() As Object
		Dim lstrSituacao As String
		lstrSituacao = ""
		If Me.chkLigados.CheckState = System.Windows.Forms.CheckState.Checked Then
			lstrSituacao = lstrSituacao & "Ligados"
		ElseIf Me.chkDesligados.CheckState = System.Windows.Forms.CheckState.Checked Then 
			lstrSituacao = lstrSituacao & IIf(Trim(lstrSituacao) <> "", ",", "") & "Desligados"
		ElseIf Me.chkDesativados.CheckState = System.Windows.Forms.CheckState.Checked Then 
			lstrSituacao = lstrSituacao & IIf(Trim(lstrSituacao) <> "", ",", "") & "Desativados"
		ElseIf Me.chkCortados.CheckState = System.Windows.Forms.CheckState.Checked Then 
			lstrSituacao = lstrSituacao & IIf(Trim(lstrSituacao) <> "", ",", "") & "Cortados"
		End If
		If Trim(lstrSituacao) <> "" Then
			lstrSituacao = "(" & lstrSituacao & ")"
		End If
		With ifrAuxiliar
			Call Cabecalho_Relatorio(.VS, "Relatório de Provisão de Devedores Duvidosos - PDD", "em " & Me.dtpBase.value & " - " & lstrSituacao, "4", True, istrClasseCabec)
			Call LineFeed(.VS, 3)
			If istrClasseCabec <> "Resumo dos Totais Apurados" Then
				.VS.Table = "<25mm|<90mm|^20mm|>15mm|>15mm|>30mm;Identificação|Nome|Vencimento|Mês Ref|Dias|Valor"
				'UPGRADE_ISSUE: VBControlExtender method ifrAuxiliar.VS.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
				Call .VS.DrawLine("8mm", .VS.CurrentY + 100, "202mm", .VS.CurrentY + 100)
				Call LineFeed(.VS, 1)
			End If
		End With
	End Function
	
	Private Sub MontaGrade()
		Me.lblQtdeFaturas.Text = CStr(0)
		Me.lblQtdeFaturasJudice.Text = CStr(0)
		Me.lblQtdeFaturasTotal.Text = CStr(0)
		With Me.mfgDados
			.Rows = 1
			.Clear()
			.Redraw = False
			.set_TextMatrix(0, 0, "Tolerância")
			.set_TextMatrix(0, 1, "Ordem")
			.set_TextMatrix(0, 2, "Classe")
			.set_TextMatrix(0, 3, "NF Num")
			.set_TextMatrix(0, 4, "Mes/Ano")
			.set_TextMatrix(0, 5, "Z")
			.set_TextMatrix(0, 6, "L")
			.set_TextMatrix(0, 7, "C")
			.set_TextMatrix(0, 8, "Consumidor")
			.set_TextMatrix(0, 9, "Vencimento")
			.set_TextMatrix(0, 10, "Dias")
			.set_TextMatrix(0, 11, "Valor")
			.set_TextMatrix(0, 12, "Flag Situação NF")
			.set_ColWidth(0, 0)
			.set_ColWidth(1, 0)
			.set_ColWidth(2, 1600)
			.set_ColWidth(3, 750)
			.set_ColWidth(4, 700)
			.set_ColWidth(5, 370)
			.set_ColWidth(6, 270)
			.set_ColWidth(7, 650)
			.set_ColWidth(8, 4500)
			.set_ColWidth(9, 1000)
			.set_ColWidth(10, 500)
			.set_ColWidth(11, 1000)
			.set_ColWidth(12, 0)
			.set_ColAlignment(2, 1)
			.set_ColAlignment(5, 3)
			.set_ColAlignment(6, 3)
			.set_ColAlignment(7, 3)
			.set_ColAlignment(9, 3)
			.set_ColAlignment(11, 7)
			.Redraw = True
		End With
		System.Windows.Forms.Application.DoEvents()
	End Sub
	
	Private Function RetornaNomeConsumidor(ByVal astrZona As String, ByVal astrLivro As String, ByVal astrConta As String, ByVal alngUnidId As Integer, ByVal alngConsId As Integer, ByVal astrGrupo As String, Optional ByRef astrSituacao As String = "") As String
		Dim lstrNome As String
		Dim lstrSql As String
		Dim lrstAux As ADODB.Recordset
		lrstAux = New ADODB.Recordset
		astrSituacao = "L"
		lstrNome = ""
		lstrSql = ""
		lstrSql = lstrSql & "SELECT `unid_id`, `zona`, `livro`, `conta`, `nome`, `situacao` " & vbCrLf
		lstrSql = lstrSql & "  FROM `unid" & LCase(astrGrupo) & "` " & vbCrLf
		lstrSql = lstrSql & " WHERE `unid_id` = " & alngUnidId & vbCrLf
		lstrSql = lstrSql & "   AND `cons_id` = " & alngConsId
		lstrSql = lstrSql & "   AND `zona`    = " & astrZona
		lstrSql = lstrSql & "   AND `livro`   = " & astrLivro
		lstrSql = lstrSql & "   AND `conta`   = " & astrConta
		Call Conectar(lstrSql, lrstAux)
		With lrstAux
			If .State = ADODB.ObjectStateEnum.adStateOpen Then
				If .RecordCount > 0 Then
					'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
					'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					lstrNome = Trim(IIf(IsDbNull(.Fields("nome").value), "EM BRANCO", .Fields("nome").value))
					'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
					'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					astrSituacao = Trim(IIf(IsDbNull(.Fields("situacao").value), "L", .Fields("situacao").value))
				End If
				Call .Close()
			End If
		End With
		If CInt(Len(lstrNome)) = 0 Then
			lstrSql = ""
			lstrSql = lstrSql & "SELECT `consreg`, `nome` " & vbCrLf
			lstrSql = lstrSql & "  FROM `consum` " & vbCrLf
			lstrSql = lstrSql & " WHERE `consreg` = " & alngConsId
			Call Conectar(lstrSql, lrstAux)
			With lrstAux
				If .State = ADODB.ObjectStateEnum.adStateOpen Then
					If .RecordCount > 0 Then
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						lstrNome = Trim(IIf(IsDbNull(.Fields("nome").value), "EM BRANCO", .Fields("nome").value))
					Else
						lstrNome = "NOME NÃO ENCONTRADO"
					End If
					Call .Close()
				End If
			End With
		End If
		'UPGRADE_NOTE: Object lrstAux may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
		lrstAux = Nothing
		RetornaNomeConsumidor = lstrNome
	End Function
	
	Private Sub LancaPDD()
		Dim ldblNumNF As Double
		Dim lstrMesAno As String
		Dim llngConta As Integer
		Dim lstrFlgSt As String
		Dim lstrSql As String
		Dim llngAux As Integer
		'
		Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
		llngAux = 0
		With Me.mfgDados
			Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 0, .Rows - 1)
			For llngConta = 1 To .Rows - 1
				'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				ldblNumNF = CDbl(IIf(IsNumeric(.get_TextMatrix(llngConta, 3)), .get_TextMatrix(llngConta, 3), 0))
				lstrMesAno = Trim(.get_TextMatrix(llngConta, 4))
				lstrFlgSt = .get_TextMatrix(llngConta, 12)
				lstrSql = ""
				lstrSql = lstrSql & "UPDATE `nf` " & vbCrLf
				lstrSql = lstrSql & "   SET `flgst`    = 'R', " & vbCrLf
				lstrSql = lstrSql & "       `datapag`  = '" & VB6.Format(Me.dtpBaixa.value, "yyyy-MM-dd") & "', " & vbCrLf
				lstrSql = lstrSql & "       `banarrec` =  " & CInt(IIf(IsNumeric(Me.lblCodigoBanco.Text), Me.lblCodigoBanco.Text, 0)) & ", " & vbCrLf
				lstrSql = lstrSql & "       `banident` = '" & Trim(Me.lblDescricaoBanco.Text) & "' " & vbCrLf
				lstrSql = lstrSql & " WHERE `numnf` =  " & ldblNumNF & " " & vbCrLf
				lstrSql = lstrSql & "   AND `mesano`= '" & lstrMesAno & "' " & vbCrLf
				lstrSql = lstrSql & "   AND `flgst` NOT IN('R','C','P'"
				If Me.chkBaixaJudice.CheckState = System.Windows.Forms.CheckState.Unchecked Then
					lstrSql = lstrSql & ",'J') "
				Else
					lstrSql = lstrSql & ") "
				End If
				If Executar(lstrSql) Then
					If lstrFlgSt <> "J" Or Me.chkBaixaJudice.CheckState = System.Windows.Forms.CheckState.Checked Then
						llngAux = llngAux + 1
					End If
				End If
				Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 1)
			Next llngConta
			Call MsgBox(llngAux & " notas fiscais transportadas para reserva com sucesso!", MsgBoxStyle.Information, gstrTituloMensagem)
			Call .Clear()
			.Rows = 1
		End With
		Me.Cursor = System.Windows.Forms.Cursors.Default
	End Sub
	
	Private Sub RetornaPDD()
		Dim ldblNumNF As Double
		Dim lstrMesAno As String
		Dim llngConta As Integer
		Dim lstrSql As String
		Dim llngAux As Integer
		'
		Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
		llngAux = 0
		With Me.mfgDados
			Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 0, .Rows - 1)
			For llngConta = 1 To .Rows - 1
				'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				ldblNumNF = CDbl(IIf(IsNumeric(.get_TextMatrix(llngConta, 3)), .get_TextMatrix(llngConta, 3), 0))
				lstrMesAno = Trim(.get_TextMatrix(llngConta, 4))
				If ldblNumNF > 0 Then
					lstrSql = ""
					lstrSql = lstrSql & "UPDATE `nf` " & vbCrLf
					lstrSql = lstrSql & "   SET `flgst`    = '', " & vbCrLf
					lstrSql = lstrSql & "       `datapag`  = '0000-00-00', " & vbCrLf
					lstrSql = lstrSql & "       `banarrec` = (banco_fatur + 0) " & vbCrLf
					lstrSql = lstrSql & " WHERE `numnf`  = " & ldblNumNF & " " & vbCrLf
					lstrSql = lstrSql & "   AND `mesano` = '" & lstrMesAno & "' " & vbCrLf
					lstrSql = lstrSql & "   AND `flgst`  = 'R' "
					If Executar(lstrSql) Then
						llngAux = llngAux + 1
					End If
				End If
				Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 1)
			Next llngConta
			Call MsgBox(llngAux & " notas fiscais retornadas da reserva com sucesso!", MsgBoxStyle.Information, gstrTituloMensagem)
			Call .Clear()
			.Rows = 1
		End With
		Me.Cursor = System.Windows.Forms.Cursors.Default
	End Sub
	
	Private Sub DesLigBotoes(ByVal ablnModo As Boolean)
		Me.cmdAnalisar.Enabled = ablnModo
		Me.cmdFechar.Enabled = ablnModo
		'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		Me.cmdImprimir.Enabled = IIf(Me.mfgDados.Rows > 1, ablnModo, False)
		'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		Me.cmdRegistrar.Enabled = IIf(Me.mfgDados.Rows > 1, ablnModo, False)
		'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		Me.cmdRetirar.Enabled = IIf(Me.mfgDados.Rows > 1, ablnModo, False)
		Me.dtpBase.Enabled = ablnModo
		Me.cmbOpcao.Enabled = ablnModo
		With Me.txtResTol
			.Enabled = ablnModo
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
		End With
		Me.chkComercial.Enabled = ablnModo
		Me.chkConsumoProprio.Enabled = ablnModo
		Me.chkIluminacaoPublica.Enabled = ablnModo
		Me.chkIndustrial.Enabled = ablnModo
		Me.chkJudice.Enabled = ablnModo
		Me.chkPoderPublico.Enabled = ablnModo
		Me.chkResidencial.Enabled = ablnModo
		Me.chkResidencialBxRenda.Enabled = ablnModo
		Me.chkRural.Enabled = ablnModo
		Me.chkServicoPublico.Enabled = ablnModo
		Me.chkLigados.Enabled = ablnModo
		Me.chkDesativados.Enabled = ablnModo
		Me.chkDesligados.Enabled = ablnModo
		Me.chkCortados.Enabled = ablnModo
		With Me.txtLimiteComercial
			.Enabled = (Me.chkComercial.Enabled And Me.chkComercial.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
		End With
		With Me.txtLimiteConsumoProprio
			.Enabled = (Me.chkConsumoProprio.Enabled And Me.chkConsumoProprio.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
		End With
		With Me.txtLimiteIluminacaoPublica
			.Enabled = (Me.chkIndustrial.Enabled And Me.chkIndustrial.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
		End With
		With Me.txtLimiteIndustrial
			.Enabled = (Me.chkIndustrial.Enabled And Me.chkIndustrial.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
		End With
		With Me.txtLimitePoderPublico
			.Enabled = (Me.chkPoderPublico.Enabled And Me.chkPoderPublico.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
		End With
		With Me.txtLimiteResidencial
			.Enabled = (Me.chkResidencial.Enabled And Me.chkResidencial.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
		End With
		With Me.txtLimiteResidencialBxRenda
			.Enabled = (Me.chkResidencialBxRenda.Enabled And Me.chkResidencialBxRenda.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
		End With
		With Me.txtLimiteRural
			.Enabled = (Me.chkRural.Enabled And Me.chkRural.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
		End With
		With Me.txtLimiteServicoPublico
			.Enabled = (Me.chkServicoPublico.Enabled And Me.chkServicoPublico.CheckState = 1)
			.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Enabled, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
		End With
		System.Windows.Forms.Application.DoEvents()
	End Sub
End Class