Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class frmRelReavisosEstatistico
	Inherits System.Windows.Forms.Form
	Private ifrmAux As FrmRelatorio
	Private istrTam As String
	Private istrTaC As String
	Private istrCab As String
	Private istrTab As String
	
	'UPGRADE_WARNING: Event chkCortados.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 chkCortados_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkCortados.CheckStateChanged
		If Me.chkCortados.CheckState = 0 Then
			If Me.chkDesligados.CheckState = 0 Then
				Me.chkLigados.CheckState = System.Windows.Forms.CheckState.Checked
			End If
		End If
	End Sub
	
	'UPGRADE_WARNING: Event chkDesligados.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 chkDesligados_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkDesligados.CheckStateChanged
		If Me.chkDesligados.CheckState = 0 Then
			If Me.chkCortados.CheckState = 0 Then
				Me.chkLigados.CheckState = System.Windows.Forms.CheckState.Checked
			End If
		End If
	End Sub
	
	'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
			Me.chkGrupoB.CheckState = System.Windows.Forms.CheckState.Checked
		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
			Me.chkGrupoA.CheckState = System.Windows.Forms.CheckState.Checked
		End If
	End Sub
	
	'UPGRADE_WARNING: Event chkLigados.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 chkLigados_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkLigados.CheckStateChanged
		If Me.chkLigados.CheckState = 0 Then
			If Me.chkDesligados.CheckState = 0 Then
				Me.chkCortados.CheckState = System.Windows.Forms.CheckState.Checked
			End If
		End If
	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 llngRow As Integer
		Dim llngCol As Integer
		Dim lintCtrl As Short
		Dim lstrBai As String 'Bairro
		Dim lstrGru As String 'Grupo
		Dim lstrSit As String 'Situação do Reaviso
		Dim lstrSUc As String 'Situação da unidade consumidora
		'
		Dim ldteRea As Date
		Dim ldteEnt As Date
		Dim ldtePrz As Date
		Dim ldteCor As Date
		Dim ldtePgo As Date
		Dim ldtePed As Date
		Dim ldteVco As Date
		Dim ldteBas As Date
		Dim ldteIni As Date
		Dim ldteFim As Date
		'
		Dim llngEnt As Integer 'Qtde de Reavisos Entregues
		Dim llngNet As Integer 'Qtde de Reavisos Não Entregues
		Dim llngCor As Integer 'Qtde de Reavisos Suspendidos
		Dim llngPnp As Integer 'Pagos no prazo
		Dim llngPfp As Integer 'Pagos fora do prazo
		Dim llngPen As Integer 'Pagos Entregues
		Dim llngPne As Integer 'Pagos Não Entregues
		Dim llngAne As Integer 'Em Aberto Não Entregues
		Dim llngSpg As Integer 'Suspensos pagos
		Dim llngSea As Integer 'Suspensos em aberto
		Dim llngVec As Integer 'Qtde Reavisos Vencidos
		Dim llngAvc As Integer 'Qtde Reavisos a Vencer
		'
		Dim ldblVlr As Double 'Valor do Reaviso
		Dim ldblVlrTot As Double
		Dim ldblVlrLiq As Double
		'
		Dim lstrSql As String
		Dim lblnAux As Boolean
		Dim lrstAux As ADODB.Recordset
		lrstAux = New ADODB.Recordset
		Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
		Call LigDes(False)
		Call MontaGrade()
		Me.mfgDados.Redraw = False
		Me.mfgUnidades.Redraw = False
		lintCtrl = 0
		'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"'
		ldteBas = Me.dtpBase.value
		ldteIni = CDate("01/" & VB6.Format(Me.dtpMesAno.value, "mm/yyyy"))
		ldteFim = CDate(UltimoDiaMes((Me.dtpMesAno.Month), (Me.dtpMesAno.Year)) & "/" & VB6.Format(Me.dtpMesAno.value, "mm/yyyy"))
		lstrSql = ""
		lstrSql = lstrSql & "    SELECT `concorte`.`zona`, "
		lstrSql = lstrSql & "           `concorte`.`livro`, "
		lstrSql = lstrSql & "           `concorte`.`conta`, "
		lstrSql = lstrSql & "           `concorte`.`cons_id`, "
		lstrSql = lstrSql & "           `concorte`.`unid_id`, "
		lstrSql = lstrSql & "           `concorte`.`rota`, "
		lstrSql = lstrSql & "           `concorte`.`nome`, "
		lstrSql = lstrSql & "           `concorte`.`numnf`, "
		lstrSql = lstrSql & "           `concorte`.`mesano`, "
		lstrSql = lstrSql & "           `concorte`.`datareav`, "
		lstrSql = lstrSql & "           `concorte`.`prazoreav`, "
		lstrSql = lstrSql & "           `concorte`.`dataentrega`, "
		lstrSql = lstrSql & "           `concorte`.`datacorte`, "
		lstrSql = lstrSql & "           `concorte`.`datapag`, "
		lstrSql = lstrSql & "           `concorte`.`dataprazo`, "
		lstrSql = lstrSql & "           `concorte`.`datavenc`, "
		lstrSql = lstrSql & "           `concorte`.`medidor`, "
		lstrSql = lstrSql & "           `concorte`.`valor`, "
		lstrSql = lstrSql & "           `concorte`.`sit`, "
		lstrSql = lstrSql & "           IFNULL(IFNULL(`unidb`.`bairro`,`unida`.`bairro`),'não definido') AS `bairro_uc`, "
		lstrSql = lstrSql & "           IFNULL(IFNULL(`unidb`.`situacao`,`unida`.`situacao`),'I') AS `situacao_uc` "
		lstrSql = lstrSql & "      FROM `concorte` "
		lstrSql = lstrSql & " LEFT JOIN `unidb` ON(`unidb`.`unid_id` = `concorte`.`unid_id` AND `unidb`.`zona` = `concorte`.`zona` AND `unidb`.`livro` = `concorte`.`livro` AND `unidb`.`conta` = `concorte`.`conta` AND MID(`concorte`.`ta`, 3, 1) = 'B') "
		lstrSql = lstrSql & " LEFT JOIN `unida` ON(`unida`.`unid_id` = `concorte`.`unid_id` AND `unida`.`zona` = `concorte`.`zona` AND `unida`.`livro` = `concorte`.`livro` AND `unida`.`conta` = `concorte`.`conta` AND MID(`concorte`.`ta`, 3, 1) = 'A') "
		lstrSql = lstrSql & "     WHERE `concorte`.`mesano` = '" & VB6.Format(Me.dtpMesAno.value, "mm/yyyy") & "' "
		'lstrSql = lstrSql & "     WHERE `concorte`.`datareav` BETWEEN '" & Strings.Format(ldteIni, "yyyy-MM-dd") & "' AND '" & Strings.Format(ldteFim, "yyyy-MM-dd") & "' "
		If Me.chkGrupoA.CheckState = 1 And Me.chkGrupoB.CheckState = 0 Then
			lstrSql = lstrSql & "       AND MID(`concorte`.`ta`, 3, 1) = 'A'"
		ElseIf Me.chkGrupoA.CheckState = 0 And Me.chkGrupoB.CheckState = 1 Then 
			lstrSql = lstrSql & "       AND MID(`concorte`.`ta`, 3, 1) = 'B'"
		End If
		Call Conectar(lstrSql, lrstAux)
		With lrstAux
			If .State = ADODB.ObjectStateEnum.adStateOpen Then
				If .RecordCount > 0 Then
					Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 0, .RecordCount)
					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"'
						'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"'
						lstrBai = Trim(IIf(IsDbNull(.Fields("bairro_uc").value), "", .Fields("bairro_uc").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"'
						ldteRea = CDate(IIf(IsDbNull(.Fields("datareav").value), "1900-01-01", .Fields("datareav").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"'
						ldteEnt = CDate(IIf(IsDbNull(.Fields("dataentrega").value), "1900-01-01", .Fields("dataentrega").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"'
						ldtePrz = CDate(IIf(IsDbNull(.Fields("prazoreav").value), "1900-01-01", .Fields("prazoreav").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"'
						ldteCor = CDate(IIf(IsDbNull(.Fields("datacorte").value), "1900-01-01", .Fields("datacorte").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"'
						ldtePgo = CDate(IIf(IsDbNull(.Fields("datapag").value), "1900-01-01", .Fields("datapag").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"'
						ldtePed = CDate(IIf(IsDbNull(.Fields("dataprazo").value), "1900-01-01", .Fields("dataprazo").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"'
						ldteVco = CDate(IIf(IsDbNull(.Fields("datavenc").value), "1900-01-01", .Fields("datavenc").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"'
						ldblVlr = CDbl(IIf(IsDbNull(.Fields("valor").value), 0, .Fields("valor").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"'
						lstrSit = Trim(IIf(IsDbNull(.Fields("sit").value), "R", .Fields("sit").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"'
						lstrSUc = Trim(IIf(IsDbNull(.Fields("situacao_uc").value), "I", .Fields("situacao_uc").value))
						If ldtePed > ldtePrz Then ldtePrz = ldtePed
						llngEnt = IIf(ldteEnt <> CDate("01/01/1900"), 1, 0)
						llngNet = IIf((llngEnt = 0), 1, 0)
						llngCor = IIf(ldteCor <> CDate("01/01/1900"), 1, 0)
						llngPnp = IIf((ldtePgo <> CDate("01/01/1900") And ldtePgo <= ldtePrz), 1, 0)
						llngPfp = IIf((ldtePgo <> CDate("01/01/1900") And ldtePgo > ldtePrz), 1, 0)
						llngPen = IIf((ldtePgo <> CDate("01/01/1900") And llngEnt = 1), 1, 0)
						llngPne = IIf((ldtePgo <> CDate("01/01/1900") And llngEnt = 0), 1, 0)
						llngAne = IIf((llngPne = 0 And llngNet = 1), 1, 0)
						llngSpg = IIf(((llngPnp + llngPfp > 0) And llngCor = 1), 1, 0)
						llngSea = IIf(((llngPnp + llngPfp = 0) And llngCor = 1), 1, 0)
						llngVec = IIf((ldtePrz <> CDate("01/01/1900") And ldtePrz < ldteBas And lstrSit = "E"), 1, 0)
						llngAvc = IIf((ldtePrz <> CDate("01/01/1900") And ldtePrz >= ldteBas And lstrSit = "E"), 1, 0)
						lblnAux = True
						Select Case lstrSUc
							Case Is = "L"
								lblnAux = (Me.chkLigados.CheckState = 1)
							Case Is = "D"
								lblnAux = (Me.chkDesligados.CheckState = 1)
							Case Is = "C"
								lblnAux = (Me.chkCortados.CheckState = 1)
							Case Is = "I"
								lblnAux = (Me.chkDesativados.CheckState = 1)
							Case Else
								lblnAux = False
						End Select
						If lblnAux Then
							Call AdicionaGrade(lstrBai, 1, llngEnt, llngNet, llngCor, llngPnp, llngPfp, llngPen, llngPne, llngAne, llngSpg, llngSea, llngVec, llngAvc, ldblVlr)
						End If
						Call .MoveNext()
						Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 1)
					End While
				End If
				Call .Close()
			End If
		End With
		'Busca das unidades por municipio
		lstrSql = ""
		lstrSql = lstrSql & "    SELECT `nf`.`numnf`, "
		lstrSql = lstrSql & "           `nf`.`mesano`, "
		lstrSql = lstrSql & "           `nf`.`mesano_ref`, "
		lstrSql = lstrSql & "           `nf`.`zona`, "
		lstrSql = lstrSql & "           `nf`.`livro`, "
		lstrSql = lstrSql & "           `nf`.`conta`, "
		lstrSql = lstrSql & "           `nf`.`cons_id`, "
		lstrSql = lstrSql & "           `nf`.`unid_id`, "
		lstrSql = lstrSql & "           `nf`.`rota`, "
		lstrSql = lstrSql & "           `nf`.`codclas`, "
		lstrSql = lstrSql & "           `nf`.`grupo`, "
		lstrSql = lstrSql & "           `nf`.`flgst`, "
		lstrSql = lstrSql & "           `nf`.`ta`, "
		lstrSql = lstrSql & "           `nf`.`valortot`, "
		lstrSql = lstrSql & "           `nf`.`valorliq`, "
		lstrSql = lstrSql & "           IFNULL(IFNULL(`unidb`.`bairro`,`unida`.`bairro`),'não definido') AS `bairro_uc` "
		lstrSql = lstrSql & "      FROM `nf` "
		lstrSql = lstrSql & " LEFT JOIN `unidb` ON(`unidb`.`unid_id` = `nf`.`unid_id` AND `unidb`.`zona` = `nf`.`zona` AND `unidb`.`livro` = `nf`.`livro` AND `unidb`.`conta` = `nf`.`conta` AND `nf`.`grupo` = 'B') "
		lstrSql = lstrSql & " LEFT JOIN `unida` ON(`unida`.`unid_id` = `nf`.`unid_id` AND `unida`.`zona` = `nf`.`zona` AND `unida`.`livro` = `nf`.`livro` AND `unida`.`conta` = `nf`.`conta` AND `nf`.`grupo` = 'A') "
		lstrSql = lstrSql & "     WHERE `nf`.`mesano` = '" & VB6.Format(Me.dtpMesAno.value, "mm/yyyy") & "' "
		If Me.chkGrupoA.CheckState = 1 And Me.chkGrupoB.CheckState = 0 Then
			lstrSql = lstrSql & "       AND `nf`.`grupo` = 'A'"
		ElseIf Me.chkGrupoA.CheckState = 0 And Me.chkGrupoB.CheckState = 1 Then 
			lstrSql = lstrSql & "       AND `nf`.`grupo` = 'B'"
		End If
		Call Conectar(lstrSql, lrstAux)
		With lrstAux
			If .State = ADODB.ObjectStateEnum.adStateOpen Then
				If .RecordCount > 0 Then
					Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 0, .RecordCount)
					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"'
						'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"'
						lstrBai = Trim(IIf(IsDbNull(.Fields("bairro_uc").value), "", .Fields("bairro_uc").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"'
						lstrGru = Trim(IIf(IsDbNull(.Fields("grupo").value), "B", .Fields("grupo").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"'
						ldblVlrTot = 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"'
						'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"'
						ldblVlrLiq = CDbl(IIf(IsDbNull(.Fields("valorliq").value), 0, .Fields("valorliq").value))
						ldblVlr = IIf(ldblVlrLiq > 0, ldblVlrLiq, ldblVlrTot)
						Call AdicionaGradeUnidades(lstrBai, lstrGru, ldblVlr)
						Call .MoveNext()
						Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 1)
					End While
				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
		
		'Totaliza Grade
		With Me.mfgUnidades
			If .Rows > 1 Then
				.Col = 0
				.Sort = MSFlexGridLib.SortSettings.flexSortGenericAscending
				.Redraw = True
				.Rows = .Rows + 1
				.set_TextMatrix(.Rows - 1, 0, "TOTAL")
				For llngRow = 1 To .Rows - 2
					.set_TextMatrix(llngRow, 1, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngRow, 1)), .get_TextMatrix(llngRow, 1), 0), 0))
					.set_TextMatrix(llngRow, 2, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngRow, 2)), .get_TextMatrix(llngRow, 2), 0), 0))
					.set_TextMatrix(llngRow, 4, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngRow, 4)), .get_TextMatrix(llngRow, 4), 0), 2))
					.set_TextMatrix(llngRow, 5, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngRow, 5)), .get_TextMatrix(llngRow, 5), 0), 2))
					.set_TextMatrix(llngRow, 3, FormatNumber(CDbl(IIf(IsNumeric(.get_TextMatrix(llngRow, 1)), .get_TextMatrix(llngRow, 1), 0)) + CDbl(IIf(IsNumeric(.get_TextMatrix(llngRow, 2)), .get_TextMatrix(llngRow, 2), 0)), 0))
					.set_TextMatrix(llngRow, 6, FormatNumber(CDbl(IIf(IsNumeric(.get_TextMatrix(llngRow, 4)), .get_TextMatrix(llngRow, 4), 0)) + CDbl(IIf(IsNumeric(.get_TextMatrix(llngRow, 5)), .get_TextMatrix(llngRow, 5), 0)), 2))
					For llngCol = 1 To .Cols - 1
						If llngCol < 4 Then
							.set_TextMatrix(.Rows - 1, llngCol, FormatNumber(CDbl(IIf(IsNumeric(.get_TextMatrix(.Rows - 1, llngCol)), .get_TextMatrix(.Rows - 1, llngCol), 0)) + CDbl(IIf(IsNumeric(.get_TextMatrix(llngRow, llngCol)), .get_TextMatrix(llngRow, llngCol), 0)), 0))
						Else
							.set_TextMatrix(.Rows - 1, llngCol, FormatNumber(CDbl(IIf(IsNumeric(.get_TextMatrix(.Rows - 1, llngCol)), .get_TextMatrix(.Rows - 1, llngCol), 0)) + CDbl(IIf(IsNumeric(.get_TextMatrix(llngRow, llngCol)), .get_TextMatrix(llngRow, llngCol), 0)), 2))
						End If
					Next llngCol
				Next llngRow
			End If
		End With
		With Me.mfgDados
			.Col = 0
			.Sort = MSFlexGridLib.SortSettings.flexSortGenericAscending
			.Redraw = True
			If .Rows > 1 Then
				.Rows = .Rows + 1
				.set_TextMatrix(.Rows - 1, 0, "TOTAL")
				For llngRow = 1 To .Rows - 2
					For llngCol = 1 To .Cols - 1
						If llngCol <= 13 Then
							.set_TextMatrix(.Rows - 1, llngCol, FormatNumber(CDbl(IIf(IsNumeric(.get_TextMatrix(.Rows - 1, llngCol)), .get_TextMatrix(.Rows - 1, llngCol), 0)) + CDbl(IIf(IsNumeric(.get_TextMatrix(llngRow, llngCol)), .get_TextMatrix(llngRow, llngCol), 0)), 0))
						Else
							.set_TextMatrix(.Rows - 1, llngCol, FormatNumber(CDbl(IIf(IsNumeric(.get_TextMatrix(.Rows - 1, llngCol)), .get_TextMatrix(.Rows - 1, llngCol), 0)) + CDbl(IIf(IsNumeric(.get_TextMatrix(llngRow, llngCol)), .get_TextMatrix(llngRow, llngCol), 0)), 2))
						End If
					Next llngCol
				Next llngRow
				'Monta Cabeçalho
				istrTam = "<2mm|<42mm"
				istrTaC = "<2mm|<42mm"
				istrCab = "|" & .get_TextMatrix(0, 0)
				For llngCol = 1 To .Cols - 1
					If llngCol <= 13 Then
						istrCab = istrCab & "|" & .get_TextMatrix(0, llngCol)
						istrTam = istrTam & "|>18mm"
						istrTaC = istrTaC & "|^18mm"
					End If
				Next llngCol
				istrTam = istrTam & ";"
				istrTaC = istrTaC & ";"
				'Inicia a impressão
				With ifrmAux
					Call .VS.KillDoc()
					.quem_chama = Me
					.VS.Font = VB6.FontChangeName(.VS.Font, "Arial")
					.VS.TableBorder = VSVIEW6.TableBorderSettings.tbNone
					.VS.PageBorder = VSVIEW6.TableBorderSettings.tbNone
					.VS.Orientation = VSVIEW6.OrientationSettings.orLandscape
					.VS.PhysicalPage = True
					.VS.PaperSize = VSVIEW6.PaperSizeSettings.pprA4
					.VS.MarginTop = "7mm"
					.VS.MarginRight = "7mm"
					.VS.MarginLeft = "7mm"
					.VS.MarginBottom = "5mm"
					.VS.TextColor = System.Drawing.Color.Black
					.VS.BrushStyle = VSVIEW6.BrushStyleSettings.bsSolid
					Call .VS.StartDoc()
				End With
				'Primeira Página
				With ifrmAux
					.VS.Font = VB6.FontChangeSize(.VS.Font, 10)
					.VS.Font = VB6.FontChangeBold(.VS.Font, True)
					.VS.Table = "^298mm;Quantidade de Reavisos"
					Call LineFeed(.VS, 1)
					.VS.Font = VB6.FontChangeSize(.VS.Font, 7)
					.VS.Table = istrTaC & istrCab
					.VS.Font = VB6.FontChangeBold(.VS.Font, False)
					Call LineFeed(.VS, 1)
				End With
				For llngRow = 1 To .Rows - 1
					istrTab = ""
					For llngCol = 0 To 13
						istrTab = istrTab & "|" & .get_TextMatrix(llngRow, llngCol)
					Next llngCol
					With ifrmAux
						If lintCtrl = 1 Then
							.VS.PenStyle = VSVIEW6.PenStyleSettings.psTransparent
							.VS.BrushColor = System.Drawing.ColorTranslator.FromOle(&HE0E0E0)
							'UPGRADE_ISSUE: VBControlExtender method ifrmAux.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.DrawRectangle("10mm", .VS.CurrentY, "285mm", .VS.CurrentY + 165)
							.VS.BrushColor = System.Drawing.Color.White
							.VS.PenStyle = VSVIEW6.PenStyleSettings.psSolid
							lintCtrl = 0
						Else
							lintCtrl = 1
						End If
						.VS.Table = istrTam & istrTab
					End With
				Next llngRow
				With ifrmAux
					Call LineFeed(.VS, 1)
					.VS.Table = "<2mm|298mm;|" & Me.mfgDados.get_TextMatrix(0, 1) & " = ( " & Me.mfgDados.get_TextMatrix(0, 2) & " + " & Me.mfgDados.get_TextMatrix(0, 3) & " )"
					.VS.Table = "<2mm|298mm;|" & Me.mfgDados.get_TextMatrix(0, 1) & " = ( " & Me.mfgDados.get_TextMatrix(0, 5) & " + " & Me.mfgDados.get_TextMatrix(0, 6) & " + " & Me.mfgDados.get_TextMatrix(0, 9) & " + " & Me.mfgDados.get_TextMatrix(0, 11) & " + " & Me.mfgDados.get_TextMatrix(0, 12) & " + " & Me.mfgDados.get_TextMatrix(0, 13) & " )"
					.VS.Table = "<2mm|298mm;|" & Me.mfgDados.get_TextMatrix(0, 1) & " = ( " & Me.mfgDados.get_TextMatrix(0, 7) & " + " & Me.mfgDados.get_TextMatrix(0, 8) & " + " & Me.mfgDados.get_TextMatrix(0, 9) & " + " & Me.mfgDados.get_TextMatrix(0, 11) & " + " & Me.mfgDados.get_TextMatrix(0, 12) & " + " & Me.mfgDados.get_TextMatrix(0, 13) & " )"
					.VS.Table = "<2mm|298mm;|" & Me.mfgDados.get_TextMatrix(0, 2) & " = ( " & Me.mfgDados.get_TextMatrix(0, 7) & " + " & Me.mfgDados.get_TextMatrix(0, 11) & " + " & Me.mfgDados.get_TextMatrix(0, 12) & " + " & Me.mfgDados.get_TextMatrix(0, 13) & " )"
					.VS.Table = "<2mm|298mm;|" & Me.mfgDados.get_TextMatrix(0, 3) & " = ( " & Me.mfgDados.get_TextMatrix(0, 8) & " + " & Me.mfgDados.get_TextMatrix(0, 9) & " )"
					.VS.Table = "<2mm|298mm;|" & Me.mfgDados.get_TextMatrix(0, 4) & " = ( " & Me.mfgDados.get_TextMatrix(0, 10) & " + " & Me.mfgDados.get_TextMatrix(0, 11) & " )"
					'Segunda Página
					Call .VS.NewPage()
					lintCtrl = 0
					.VS.Font = VB6.FontChangeSize(.VS.Font, 10)
					.VS.Font = VB6.FontChangeBold(.VS.Font, True)
					.VS.Table = "^298mm;Valores dos Reavisos"
					Call LineFeed(.VS, 1)
					.VS.Font = VB6.FontChangeSize(.VS.Font, 7)
					.VS.Table = istrTaC & istrCab
					.VS.Font = VB6.FontChangeBold(.VS.Font, False)
					Call LineFeed(.VS, 1)
				End With
				For llngRow = 1 To .Rows - 1
					istrTab = ""
					istrTab = istrTab & "|" & .get_TextMatrix(llngRow, 0) 'Bairro
					For llngCol = 14 To .Cols - 1
						istrTab = istrTab & "|" & .get_TextMatrix(llngRow, llngCol)
					Next llngCol
					With ifrmAux
						If lintCtrl = 1 Then
							.VS.PenStyle = VSVIEW6.PenStyleSettings.psTransparent
							.VS.BrushColor = System.Drawing.ColorTranslator.FromOle(&HE0E0E0)
							'UPGRADE_ISSUE: VBControlExtender method ifrmAux.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.DrawRectangle("10mm", .VS.CurrentY, "285mm", .VS.CurrentY + 165)
							.VS.BrushColor = System.Drawing.Color.White
							.VS.PenStyle = VSVIEW6.PenStyleSettings.psSolid
							lintCtrl = 0
						Else
							lintCtrl = 1
						End If
						.VS.Table = istrTam & istrTab
					End With
				Next llngRow
				'Faturas
				With Me.mfgUnidades
					'Monta Cabeçalho
					istrTam = "<15mm|<55mm"
					istrTaC = "<15mm|<55mm"
					istrCab = "|" & .get_TextMatrix(0, 0)
					For llngCol = 1 To .Cols - 1
						istrCab = istrCab & "|" & .get_TextMatrix(0, llngCol)
						istrTam = istrTam & "|>30mm"
						istrTaC = istrTaC & "|^30mm"
					Next llngCol
					istrTam = istrTam & ";"
					istrTaC = istrTaC & ";"
					With ifrmAux
						Call LineFeed(.VS, 1)
						.VS.Table = "<2mm|298mm;|" & Me.mfgDados.get_TextMatrix(0, 1) & " = ( " & Me.mfgDados.get_TextMatrix(0, 2) & " + " & Me.mfgDados.get_TextMatrix(0, 3) & " )"
						.VS.Table = "<2mm|298mm;|" & Me.mfgDados.get_TextMatrix(0, 1) & " = ( " & Me.mfgDados.get_TextMatrix(0, 5) & " + " & Me.mfgDados.get_TextMatrix(0, 6) & " + " & Me.mfgDados.get_TextMatrix(0, 9) & " + " & Me.mfgDados.get_TextMatrix(0, 11) & " + " & Me.mfgDados.get_TextMatrix(0, 12) & " + " & Me.mfgDados.get_TextMatrix(0, 13) & " )"
						.VS.Table = "<2mm|298mm;|" & Me.mfgDados.get_TextMatrix(0, 1) & " = ( " & Me.mfgDados.get_TextMatrix(0, 7) & " + " & Me.mfgDados.get_TextMatrix(0, 8) & " + " & Me.mfgDados.get_TextMatrix(0, 9) & " + " & Me.mfgDados.get_TextMatrix(0, 11) & " + " & Me.mfgDados.get_TextMatrix(0, 12) & " + " & Me.mfgDados.get_TextMatrix(0, 13) & " )"
						.VS.Table = "<2mm|298mm;|" & Me.mfgDados.get_TextMatrix(0, 2) & " = ( " & Me.mfgDados.get_TextMatrix(0, 7) & " + " & Me.mfgDados.get_TextMatrix(0, 11) & " + " & Me.mfgDados.get_TextMatrix(0, 12) & " + " & Me.mfgDados.get_TextMatrix(0, 13) & " )"
						.VS.Table = "<2mm|298mm;|" & Me.mfgDados.get_TextMatrix(0, 3) & " = ( " & Me.mfgDados.get_TextMatrix(0, 8) & " + " & Me.mfgDados.get_TextMatrix(0, 9) & " )"
						.VS.Table = "<2mm|298mm;|" & Me.mfgDados.get_TextMatrix(0, 4) & " = ( " & Me.mfgDados.get_TextMatrix(0, 10) & " + " & Me.mfgDados.get_TextMatrix(0, 11) & " )"
						'Terceira Página
						Call .VS.NewPage()
						lintCtrl = 0
						.VS.Font = VB6.FontChangeSize(.VS.Font, 10)
						.VS.Font = VB6.FontChangeBold(.VS.Font, True)
						.VS.Table = "^298mm;Quantidade e valores por grupo das Faturas"
						.VS.Font = VB6.FontChangeSize(.VS.Font, 7)
						.VS.Table = istrTaC & istrCab
						.VS.Font = VB6.FontChangeBold(.VS.Font, False)
						Call LineFeed(.VS, 1)
					End With
					For llngRow = 1 To .Rows - 1
						istrTab = "|"
						istrTab = istrTab & .get_TextMatrix(llngRow, 0) & "|" 'Bairro
						istrTab = istrTab & .get_TextMatrix(llngRow, 1) & "|" 'Reavisos
						istrTab = istrTab & .get_TextMatrix(llngRow, 2) & "|" 'Entregues
						istrTab = istrTab & .get_TextMatrix(llngRow, 3) & "|" 'Suspensos
						istrTab = istrTab & .get_TextMatrix(llngRow, 4) & "|" 'Pagos no Prazo
						istrTab = istrTab & .get_TextMatrix(llngRow, 5) & "|" 'Pagos Fora Prazo
						istrTab = istrTab & .get_TextMatrix(llngRow, 6) & "|" 'Pagos Entregues
						With ifrmAux
							If lintCtrl = 1 Then
								.VS.PenStyle = VSVIEW6.PenStyleSettings.psTransparent
								.VS.BrushColor = System.Drawing.ColorTranslator.FromOle(&HE0E0E0)
								'UPGRADE_ISSUE: VBControlExtender method ifrmAux.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.DrawRectangle("23mm", .VS.CurrentY, "256mm", .VS.CurrentY + 165)
								.VS.BrushColor = System.Drawing.Color.White
								.VS.PenStyle = VSVIEW6.PenStyleSettings.psSolid
								lintCtrl = 0
							Else
								lintCtrl = 1
							End If
							.VS.Table = istrTam & istrTab
						End With
					Next llngRow
				End With
				With ifrmAux
					Call .VS.EndDoc()
					Call .Show()
				End With
			End If
		End With
		Me.Cursor = System.Windows.Forms.Cursors.Default
		Call LigDes(True)
	End Sub
	
	Private Sub AdicionaGrade(ByVal astrBairro As String, ByVal alngReavisos As Integer, ByVal alngEntregues As Integer, ByVal alngNaoEntregues As Integer, ByVal alngSuspensos As Integer, ByVal alngPagosNoPrazo As Integer, ByVal alngPagosForaPrazo As Integer, ByVal alngPagosEntregues As Integer, ByVal alngPagosNaoEntregues As Integer, ByVal alngEmAbertoNaoEntregues As Object, ByVal alngSuspensosPago As Integer, ByVal alngSuspensosEmAberto As Integer, ByVal alngVencidos As Integer, ByVal alngAVencer As Integer, ByVal adblValor As Double)
		Dim llngRow As Integer
		Dim llngPos As Integer
		llngPos = 0
		With Me.mfgDados
			'Busca a linha da grid que tem a informacao
			For llngRow = 1 To .Rows - 1
				If .get_TextMatrix(llngRow, 0) = astrBairro Then
					llngPos = llngRow
					llngRow = .Rows - 1
				End If
			Next llngRow
			If llngPos = 0 Then
				.Rows = .Rows + 1
				llngPos = (.Rows - 1)
				.set_TextMatrix(llngPos, 0, astrBairro) 'Bairro
				With Me.mfgUnidades
					.Rows = .Rows + 1
					.set_TextMatrix(llngPos, 0, astrBairro)
				End With
			End If
			.set_TextMatrix(llngPos, 1, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 1)), .get_TextMatrix(llngPos, 1), 0) + alngReavisos, 0)) 'Qtde Reavisos
			.set_TextMatrix(llngPos, 2, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 2)), .get_TextMatrix(llngPos, 2), 0) + alngEntregues, 0)) 'Qtde Entregues
			.set_TextMatrix(llngPos, 3, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 3)), .get_TextMatrix(llngPos, 3), 0) + alngNaoEntregues, 0)) 'Qtde Não Entregues
			.set_TextMatrix(llngPos, 4, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 4)), .get_TextMatrix(llngPos, 4), 0) + alngSuspensos, 0)) 'Qtde Suspensos
			.set_TextMatrix(llngPos, 5, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 5)), .get_TextMatrix(llngPos, 5), 0) + alngPagosNoPrazo, 0)) 'Qtde Pagos No Prazo
			.set_TextMatrix(llngPos, 6, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 6)), .get_TextMatrix(llngPos, 6), 0) + alngPagosForaPrazo, 0)) 'Qtde Pagos Fora Prazo
			.set_TextMatrix(llngPos, 7, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 7)), .get_TextMatrix(llngPos, 7), 0) + alngPagosEntregues, 0)) 'Qtde Pagos Entregues
			.set_TextMatrix(llngPos, 8, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 8)), .get_TextMatrix(llngPos, 8), 0) + alngPagosNaoEntregues, 0)) 'Qtde Pagos Não Entregues
			'UPGRADE_WARNING: Couldn't resolve default property of object alngEmAbertoNaoEntregues. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			.set_TextMatrix(llngPos, 9, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 9)), .get_TextMatrix(llngPos, 9), 0) + alngEmAbertoNaoEntregues, 0)) 'Qtde Aberto Não Entregues
			.set_TextMatrix(llngPos, 10, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 10)), .get_TextMatrix(llngPos, 10), 0) + alngSuspensosPago, 0)) 'Qtde Suspensos Pagos
			.set_TextMatrix(llngPos, 11, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 11)), .get_TextMatrix(llngPos, 11), 0) + alngSuspensosEmAberto, 0)) 'Qtde Suspensos Em Aberto
			.set_TextMatrix(llngPos, 12, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 12)), .get_TextMatrix(llngPos, 12), 0) + alngVencidos, 0)) 'Qtde Vencidos
			.set_TextMatrix(llngPos, 13, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 13)), .get_TextMatrix(llngPos, 13), 0) + alngAVencer, 0)) 'Qtde A Vencer
			.set_TextMatrix(llngPos, 14, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 14)), .get_TextMatrix(llngPos, 14), 0) + adblValor, 2)) 'Reavisos
			.set_TextMatrix(llngPos, 15, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 15)), .get_TextMatrix(llngPos, 15), 0) + IIf(alngEntregues = 1, adblValor, 0), 2)) 'Entregues
			.set_TextMatrix(llngPos, 16, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 16)), .get_TextMatrix(llngPos, 16), 0) + alngNaoEntregues, 2)) 'Não Entregues
			.set_TextMatrix(llngPos, 17, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 17)), .get_TextMatrix(llngPos, 17), 0) + IIf(alngSuspensos = 1, adblValor, 0), 2)) 'Suspensos
			.set_TextMatrix(llngPos, 18, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 18)), .get_TextMatrix(llngPos, 18), 0) + IIf(alngPagosNoPrazo = 1, adblValor, 0), 2)) 'Pagos no Prazo
			.set_TextMatrix(llngPos, 19, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 19)), .get_TextMatrix(llngPos, 19), 0) + IIf(alngPagosForaPrazo = 1, adblValor, 0), 2)) 'Pagos Fora do Prazo
			.set_TextMatrix(llngPos, 20, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 20)), .get_TextMatrix(llngPos, 20), 0) + IIf(alngPagosEntregues = 1, adblValor, 0), 2)) 'Pagos Entregues
			.set_TextMatrix(llngPos, 21, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 21)), .get_TextMatrix(llngPos, 21), 0) + IIf(alngPagosNaoEntregues = 1, adblValor, 0), 2)) 'Pagos Não Entregues
			'UPGRADE_WARNING: Couldn't resolve default property of object alngEmAbertoNaoEntregues. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			.set_TextMatrix(llngPos, 22, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 22)), .get_TextMatrix(llngPos, 22), 0) + IIf(alngEmAbertoNaoEntregues = 1, adblValor, 0), 2)) 'Em Aberto Não Entregues
			.set_TextMatrix(llngPos, 23, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 23)), .get_TextMatrix(llngPos, 23), 0) + IIf(alngSuspensosPago = 1, adblValor, 0), 2)) 'Suspensos Pagos
			.set_TextMatrix(llngPos, 24, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 24)), .get_TextMatrix(llngPos, 24), 0) + IIf(alngSuspensosEmAberto = 1, adblValor, 0), 2)) 'Suspensos em Aberto
			.set_TextMatrix(llngPos, 25, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 25)), .get_TextMatrix(llngPos, 25), 0) + IIf(alngVencidos = 1, adblValor, 0), 2)) 'Vencidos
			.set_TextMatrix(llngPos, 26, FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, 26)), .get_TextMatrix(llngPos, 26), 0) + IIf(alngAVencer = 1, adblValor, 0), 2)) 'A Vencer
		End With
	End Sub
	
	Private Sub AdicionaGradeUnidades(ByVal astrBairro As String, ByVal astrGrupo As String, ByVal adblValor As Double)
		Dim llngRow As Integer
		Dim llngPos As Integer
		llngPos = 0
		With Me.mfgUnidades
			'Busca a linha da grid que tem a informacao
			For llngRow = 1 To .Rows - 1
				If .get_TextMatrix(llngRow, 0) = astrBairro Then
					llngPos = llngRow
					llngRow = .Rows - 1
				End If
			Next llngRow
			If llngPos = 0 Then
				.Rows = .Rows + 1
				llngPos = (.Rows - 1)
				.set_TextMatrix(llngPos, 0, astrBairro) 'Bairro
			End If
			.set_TextMatrix(llngPos, IIf(astrGrupo = "A", 1, 2), FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, IIf(astrGrupo = "A", 1, 2))), .get_TextMatrix(llngPos, IIf(astrGrupo = "A", 1, 2)), 0) + 1, 0)) 'Qtde Faturas
			.set_TextMatrix(llngPos, IIf(astrGrupo = "A", 4, 5), FormatNumber(IIf(IsNumeric(.get_TextMatrix(llngPos, IIf(astrGrupo = "A", 4, 5))), .get_TextMatrix(llngPos, IIf(astrGrupo = "A", 4, 5)), 0) + adblValor, 2)) 'Valor Faturas
		End With
	End Sub
	
	Private Sub MontaGrade()
		Dim llngCol As Integer
		With Me.mfgDados
			Call .Clear()
			.Rows = 1
			.set_TextMatrix(0, 0, "Bairro")
			'Quantidades
			.set_TextMatrix(0, 1, "Reavisos")
			.set_TextMatrix(0, 2, "Entregues")
			.set_TextMatrix(0, 3, "Não entregues")
			.set_TextMatrix(0, 4, "Suspensos")
			.set_TextMatrix(0, 5, "Pagos no prazo")
			.set_TextMatrix(0, 6, "Pagos fora prazo")
			.set_TextMatrix(0, 7, "Pagos entregues")
			.set_TextMatrix(0, 8, "Pagos não entregues")
			.set_TextMatrix(0, 9, "Abertos não entregues")
			.set_TextMatrix(0, 10, "Suspensos pagos")
			.set_TextMatrix(0, 11, "Suspensos em aberto")
			.set_TextMatrix(0, 12, "Vencidos")
			.set_TextMatrix(0, 13, "A vencer")
			'Valores
			For llngCol = 1 To 13
				.set_TextMatrix(0, 13 + llngCol, .get_TextMatrix(0, llngCol))
			Next llngCol
		End With
		With Me.mfgUnidades
			Call .Clear()
			.Rows = 1
			.set_TextMatrix(0, 0, "Bairro")
			.set_TextMatrix(0, 1, "Qtde Grupo A")
			.set_TextMatrix(0, 2, "Qtde Grupo B")
			.set_TextMatrix(0, 3, "Total Grupo")
			.set_TextMatrix(0, 4, "Valor Grupo A")
			.set_TextMatrix(0, 5, "Valor Grupo B")
			.set_TextMatrix(0, 6, "Total Grupo")
		End With
	End Sub
	
	Private Sub dtpMesAno_Change(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles dtpMesAno.Change
		Dim lblnRet As Boolean
		lblnRet = True
		Me.dtpBase.value = CDate("10/" & VB6.Format(System.Date.FromOADate(CDate(UltimoDiaMes((Me.dtpMesAno.Month), (Me.dtpMesAno.Year)) & "/" & VB6.Format(Me.dtpMesAno.value, "mm/yyyy")).ToOADate + 1), "mm/yyyy"))
		If WeekDay(Me.dtpBase.value, FirstDayOfWeek.Sunday) = 1 Then 'domingo
			Me.dtpBase.value = Me.dtpBase.value + 1
		ElseIf WeekDay(Me.dtpBase.value, FirstDayOfWeek.Sunday) = 7 Then  'sabado
			Me.dtpBase.value = Me.dtpBase.value + 2
		End If
		While lblnRet
			lblnRet = VerificaFeriado(Me.dtpBase.value)
			If lblnRet Then
				Me.dtpBase.value = Me.dtpBase.value + 1
			End If
		End While
	End Sub
	
	Private Sub dtpMesAno_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles dtpMesAno.ClickEvent
		Call dtpMesAno_Change(dtpMesAno, New System.EventArgs())
	End Sub
	
	Private Sub frmRelReavisosEstatistico_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.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii = System.Windows.Forms.Keys.Escape Then 
			Call cmdFechar_Click(cmdFechar, New System.EventArgs())
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub frmRelReavisosEstatistico_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		Call CenterForm(Me)
		Me.dtpMesAno.value = BuscaDataBD
		ifrmAux = New FrmRelatorio
	End Sub
	
	Public Function CabecaRel() As Object
		Dim lstrAux As String
		lstrAux = ""
		lstrAux = lstrAux & "Situação atual da U.C.("
		If Me.chkLigados.CheckState = 1 Then
			lstrAux = lstrAux & "Ligados, "
		End If
		If Me.chkDesligados.CheckState = 1 Then
			lstrAux = lstrAux & "Desligados, "
		End If
		If Me.chkCortados.CheckState = 1 Then
			lstrAux = lstrAux & "Suspendidos, "
		End If
		If Me.chkDesativados.CheckState = 1 Then
			lstrAux = lstrAux & "Desativados, "
		End If
		lstrAux = VB.Left(lstrAux, CInt(Len(lstrAux)) - 2) & ") - Grupo ("
		If Me.chkGrupoA.CheckState = 1 Then
			lstrAux = lstrAux & "A, "
		End If
		If Me.chkGrupoB.CheckState = 1 Then
			lstrAux = lstrAux & "B, "
		End If
		lstrAux = VB.Left(lstrAux, CInt(Len(lstrAux)) - 2) & ")"
		With ifrmAux
			.VS.Font = VB6.FontChangeBold(.VS.Font, True)
			Call Cabecalho_Relatorio(.VS, "Listagem Estátistico dos Reavisos Emitidos", "No período de " & VB6.Format(Me.dtpMesAno.value, "mm/yyyy") & " - Data Base " & VB6.Format(Me.dtpBase.value, "dd/mm/yyyy"), "3",  , lstrAux)
			.VS.CurrentLine = 0
			.VS.BrushColor = System.Drawing.Color.White
		End With
	End Function
	
	Private Sub LigDes(ByVal ablnModo As Boolean)
		Me.chkLigados.Enabled = ablnModo
		Me.chkDesligados.Enabled = ablnModo
		Me.chkCortados.Enabled = ablnModo
		Me.chkDesativados.Enabled = ablnModo
		Me.chkGrupoA.Enabled = ablnModo
		Me.chkGrupoB.Enabled = ablnModo
		Me.dtpMesAno.Enabled = ablnModo
		Me.cmdImprimir.Enabled = ablnModo
		Me.cmdFechar.Enabled = ablnModo
		Me.dtpBase.Enabled = ablnModo
		System.Windows.Forms.Application.DoEvents()
	End Sub
End Class