Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class frmRelFaturasPorAgrupamento
	Inherits System.Windows.Forms.Form
	Private istrTamCol As String
	Private istrCabCol As String
	'UPGRADE_ISSUE: FrmRelatorio object was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6B85A2A7-FE9F-4FBE-AA0C-CF11AC86A305"'
	Private ifrmRelFaturasPorAgrupamento As FrmRelatorio
	
	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 Conectar As Object
		Dim psSolid As Object
		Dim psTransparent As Object
		Dim bsSolid As Object
		Dim pprA4 As Object
		Dim orLandscape As Object
		Dim gdShow As Object
		Dim tbNone As Object
		Dim BarraProgresso As Object
		Dim gstrDataBase As Object
		Dim adodb As Object
		Dim lstrAux As String
		Dim lintAux As Short
		Dim lstrTab As String
		Dim lintCtr As Short
		Dim llngAgrupa As Integer
		Dim lstrAgrupa As String
		Dim lstrZona As String
		Dim lstrLivro As String
		Dim lstrConta As String
		Dim ldblNumNf As Double
		Dim lstrRota As String
		Dim lstrGrupo As String
		Dim lstrEmail As String
		Dim lstrNome As String
		Dim llngConsId As Integer
		Dim llngConsIdu As Integer
		Dim lstrSql As String
		Dim lrstAux As adodb.Recordset
		lrstAux = New adodb.Recordset
		Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
		Me.txtMesAno.Enabled = False
		Me.cmdImprimir.Enabled = False
		Me.cmdFechar.Enabled = False
		Me.lsvAgrupa.Enabled = False
		'
		lstrSql = ""
		lstrSql = lstrSql & "SELECT `nf`.*, "
		lstrSql = lstrSql & "       IFNULL(`unidb`.`nome`,`unida`.`nome`) `nome_u`, "
		lstrSql = lstrSql & "       IFNULL(`unidb`.`cons_id`,`unida`.`cons_id`) `cons_id_u`, "
		lstrSql = lstrSql & "       `consum`.`nome` `nome_c`, "
		lstrSql = lstrSql & "       `consum`.`email` `email_c`, "
		lstrSql = lstrSql & "       IFNULL(`agrupa`.`descricao`,'') `descricao_agrupa` "
		'UPGRADE_WARNING: Couldn't resolve default property of object gstrDataBase. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		lstrSql = lstrSql & "  FROM " & gstrDataBase & ".`nf` "
		'UPGRADE_WARNING: Couldn't resolve default property of object gstrDataBase. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		lstrSql = lstrSql & " LEFT JOIN " & gstrDataBase & ".`unidb` ON(`unidb`.`unid_id` = `nf`.`unid_id` AND `nf`.`grupo` = 'B') "
		'UPGRADE_WARNING: Couldn't resolve default property of object gstrDataBase. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		lstrSql = lstrSql & " LEFT JOIN " & gstrDataBase & ".`unida` ON(`unida`.`unid_id` = `nf`.`unid_id` AND `nf`.`grupo` = 'A') "
		'UPGRADE_WARNING: Couldn't resolve default property of object gstrDataBase. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		lstrSql = lstrSql & " LEFT JOIN " & gstrDataBase & ".`consum` ON(`consum`.`consreg` = `nf`.`cons_id`) "
		'UPGRADE_WARNING: Couldn't resolve default property of object gstrDataBase. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		lstrSql = lstrSql & " LEFT JOIN " & gstrDataBase & ".`agrupa` ON((`agrupa`.`codigo`+0) = (`nf`.`agrupa`+0)) "
		lstrSql = lstrSql & " WHERE `nf`.`mesano` = '" & Me.txtMesAno.Text & "' "
		'Filtra Por agrupamento
		lstrAux = ""
		With Me.lsvAgrupa
			If .Items.Count > 0 Then
				'UPGRADE_WARNING: Lower bound of collection Me.lsvAgrupa.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
				If .Items.Item(1).Checked = False Then
					For lintAux = 2 To .Items.Count
						'UPGRADE_WARNING: Lower bound of collection Me.lsvAgrupa.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
						If .Items.Item(lintAux).Checked = True Then
							'UPGRADE_WARNING: Lower bound of collection Me.lsvAgrupa.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
							'UPGRADE_WARNING: Lower bound of collection Me.lsvAgrupa.ListItems() has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
							lstrAux = lstrAux & "'" & CInt(.Items.Item(lintAux).SubItems(1).Text) & "',"
						End If
					Next lintAux
					If Len(Trim(lstrAux)) > 0 Then
						lstrSql = lstrSql & " AND `nf`.`agrupa`+0 IN ( " & VB.Left(lstrAux, Len(lstrAux) - 1) & ")"
					End If
				End If
			End If
		End With
		lstrSql = lstrSql & " ORDER BY `nf`.`agrupa` ASC, `nf`.`rota_quatro` ASC "
		'UPGRADE_WARNING: Couldn't resolve default property of object Conectar(lstrSql, lrstAux, True, True). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		If Conectar(lstrSql, lrstAux, True, True) Then
			With lrstAux
				'UPGRADE_WARNING: Couldn't resolve default property of object adodb.ObjectStateEnum. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.State. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				If .State = adodb.ObjectStateEnum.adStateOpen Then
					'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.RecordCount. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					If .RecordCount > 0 Then
						'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.RecordCount. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						Call BarraProgresso(Me.ProgressBar, Me.lblPerc, Me.lblInfo, 0, .RecordCount)
						istrTamCol = ">15mm |<19mm        |<10mm|^10mm|<80mm|<100mm|<70mm;"
						istrCabCol = "Fatura|Identificador|Rota |Grupo|Nome |Email |Agrupamento"
						With ifrmRelFaturasPorAgrupamento
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.quem_chama. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.quem_chama = Me
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.FontName = "Arial"
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'UPGRADE_WARNING: Couldn't resolve default property of object tbNone. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.TableBorder = tbNone
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'UPGRADE_WARNING: Couldn't resolve default property of object tbNone. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.PageBorder = tbNone
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'UPGRADE_WARNING: Couldn't resolve default property of object gdShow. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.ShowGuides = gdShow
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'UPGRADE_WARNING: Couldn't resolve default property of object orLandscape. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.Orientation = orLandscape
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.PhysicalPage = True
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'UPGRADE_WARNING: Couldn't resolve default property of object pprA4. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.PaperSize = pprA4
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.MarginTop = "7mm"
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.MarginRight = "7mm"
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.MarginLeft = "7mm"
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.MarginBottom = "5mm"
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.MarginFooter = "0mm"
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.MarginHeader = "0mm"
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.TextColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'UPGRADE_WARNING: Couldn't resolve default property of object bsSolid. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.BrushStyle = bsSolid
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.FontBold = False
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.FontSize = 7
							'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							.VS.StartDoc()
						End With
						'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.EOF. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						While Not .EOF
							'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.Fields. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'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"'
							llngAgrupa = CInt(IIf(IsDbNull(.Fields("agrupa").Value), 0, .Fields("agrupa").Value))
							'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.Fields. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'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"'
							lstrAgrupa = Trim(IIf(IsDbNull(.Fields("descricao_agrupa").Value), "", .Fields("descricao_agrupa").Value))
							'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.Fields. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'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: Couldn't resolve default property of object lrstAux.Fields. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'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 = Trim(IIf(IsDbNull(.Fields("zona").Value), "", .Fields("zona").Value))
							'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.Fields. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'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 = Trim(IIf(IsDbNull(.Fields("livro").Value), "", .Fields("livro").Value))
							'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.Fields. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'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 = Trim(IIf(IsDbNull(.Fields("conta").Value), "", .Fields("conta").Value))
							'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.Fields. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'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"'
							lstrRota = Trim(IIf(IsDbNull(.Fields("rota_quatro").Value), "", .Fields("rota_quatro").Value))
							'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.Fields. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'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))
							'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.Fields. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'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"'
							lstrNome = Trim(IIf(IsDbNull(.Fields("nome_u").Value), "", .Fields("nome_u").Value))
							'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.Fields. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'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"'
							lstrEmail = Replace(LCase(Trim(IIf(IsDbNull(.Fields("email_c").Value), "", .Fields("email_c").Value))), ";", " / ")
							'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.Fields. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'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 = IIf(IsDbNull(.Fields("cons_id").Value), 0, .Fields("cons_id").Value)
							'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.Fields. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							'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"'
							llngConsIdu = IIf(IsDbNull(.Fields("cons_id_u").Value), 0, .Fields("cons_id_u").Value)
							If llngConsIdu <> llngConsId Then
								'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.Fields. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								'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"'
								lstrNome = IIf(IsDbNull(.Fields("nome_c").Value), "", .Fields("nome_c").Value)
							End If
							lstrTab = ""
							lstrTab = lstrTab & ldblNumNf & "|"
							lstrTab = lstrTab & lstrZona & "." & lstrLivro & "." & lstrConta & "|"
							lstrTab = lstrTab & lstrRota & "|"
							lstrTab = lstrTab & lstrGrupo & "|"
							lstrTab = lstrTab & VB.Left(lstrNome, 52) & "|"
							lstrTab = lstrTab & lstrEmail & "|"
							lstrTab = lstrTab & llngAgrupa & " - " & VB.Left(lstrAgrupa, 30)
							With ifrmRelFaturasPorAgrupamento
								If lintCtr = 1 Then
									'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									'UPGRADE_WARNING: Couldn't resolve default property of object psTransparent. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									.VS.PenStyle = psTransparent
									'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									.VS.BrushColor = &HE0E0E0
									'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									Call .VS.DrawRectangle("8mm", .VS.CurrentY, "288mm", .VS.CurrentY + 165)
									'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									.VS.BrushColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White)
									'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									'UPGRADE_WARNING: Couldn't resolve default property of object psSolid. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
									.VS.PenStyle = psSolid
									lintCtr = 0
								Else
									lintCtr = 1
								End If
								'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
								.VS.Table = istrTamCol & lstrTab
							End With
							Call BarraProgresso(Me.ProgressBar, Me.lblPerc, Me.lblInfo, 1)
							'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.MoveNext. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
							Call .MoveNext()
						End While
					End If
					With ifrmRelFaturasPorAgrupamento
						'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						.VS.EndDoc()
						'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.Show. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						.Show()
					End With
					'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.Close. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					Call .Close()
				End If
			End With
		End If
		Me.Cursor = System.Windows.Forms.Cursors.Default
		Me.txtMesAno.Enabled = True
		Me.cmdImprimir.Enabled = True
		Me.cmdFechar.Enabled = True
		Me.lsvAgrupa.Enabled = True
	End Sub
	
	Private Sub frmRelFaturasPorAgrupamento_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		Dim SendKeysA As Object
		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 frmRelFaturasPorAgrupamento_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		Dim BuscaDataBD As Object
		Dim LeConfig As Object
		Dim CenterForm As Object
		Call CenterForm(Me)
		ifrmRelFaturasPorAgrupamento = New FrmRelatorio
		Call CarregaAgrupamento()
		With Me.txtMesAno
			'UPGRADE_WARNING: Couldn't resolve default property of object LeConfig(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			.Text = LeConfig("MESANOFATURAMENTO")
			If Len(Trim(.Text)) < 1 Then
				'UPGRADE_WARNING: Couldn't resolve default property of object BuscaDataBD. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				.Text = VB6.Format(BuscaDataBD, "MM/yyyy")
			End If
		End With
	End Sub
	
	Private Sub frmRelFaturasPorAgrupamento_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
		'UPGRADE_NOTE: Object ifrmRelFaturasPorAgrupamento 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"'
		ifrmRelFaturasPorAgrupamento = Nothing
	End Sub
	
	Private Sub lsvAgrupa_ItemCheck(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.ItemCheckEventArgs) Handles lsvAgrupa.ItemCheck
		Dim aItem As System.Windows.Forms.ListViewItem = lsvAgrupa.Items(eventArgs.Index)
		Dim lintIdx As Short
		With Me.lsvAgrupa
			If aItem.Text = "Marcar Todas" Then
				For lintIdx = 1 To .Items.Count
					'UPGRADE_WARNING: Lower bound of collection Me.lsvAgrupa.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
					.Items.Item(lintIdx).Checked = .Items.Item(1).Checked
				Next lintIdx
			Else
				If aItem.Checked = False Then
					'UPGRADE_WARNING: Lower bound of collection Me.lsvAgrupa.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
					.Items.Item(1).Checked = False
				End If
			End If
		End With
	End Sub
	
	Private Sub txtMesAno_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtMesAno.Enter
		With Me.txtMesAno
			.SelectionStart = 0
			.SelectionLength = Len(.Text)
		End With
		
	End Sub
	
	Private Sub txtMesAno_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtMesAno.Leave
		Dim gstrTituloMensagem As Object
		Dim ValidaMesAno As Object
		With Me.txtMesAno
			'UPGRADE_WARNING: Couldn't resolve default property of object ValidaMesAno(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			.Text = ValidaMesAno(.Text)
			If Len(Trim(.Text)) < 1 Then
				'UPGRADE_WARNING: Couldn't resolve default property of object gstrTituloMensagem. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				Call MsgBox("Mês/ano inválidos!", MsgBoxStyle.Exclamation, gstrTituloMensagem)
				Call .Focus()
			End If
		End With
	End Sub
	
	Private Sub CarregaAgrupamento()
		Dim Conectar As Object
		Dim adodb As Object
		Dim lstrCod As String
		Dim lstrDes As String
		Dim lstrSql As String
		Dim lrstAux As adodb.Recordset
		lrstAux = New adodb.Recordset
		' ----- Monta as colunas na ListView de rotas
		With Me.lsvAgrupa
			Call .Items.Clear()
			Call .Columns.Clear()
			If .Columns.Count <= 1 Then
				Call .Columns.Add("", "Agrupa", CInt(VB6.TwipsToPixelsX(4790)))
				Call .Columns.Add("Código", CInt(VB6.TwipsToPixelsX(700)), System.Windows.Forms.HorizontalAlignment.Right)
			End If
		End With
		' ----- Busca as rotas
		lstrSql = ""
		lstrSql = lstrSql & "SELECT `codigo`, " & vbCrLf
		lstrSql = lstrSql & "       `descricao`"
		lstrSql = lstrSql & "  FROM `agrupa` " & vbCrLf
		lstrSql = lstrSql & " ORDER BY `codigo`+0 ASC"
		Call Conectar(lstrSql, lrstAux)
		' ----- Insere os dados na ListView de rotas
		With lrstAux
			'UPGRADE_WARNING: Couldn't resolve default property of object adodb.ObjectStateEnum. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.State. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			If .State = adodb.ObjectStateEnum.adStateOpen Then
				'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.RecordCount. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				If .RecordCount > 0 Then
					With Me.lsvAgrupa
						Call .Items.Add("Marcar Todas")
						'UPGRADE_WARNING: Lower bound of collection Me.lsvAgrupa.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
						Call .Items.Item(.Items.Count).SubItems.Add("")
					End With
					'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.EOF. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					While Not .EOF
						'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.Fields. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						'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"'
						lstrCod = CStr(Val(IIf(IsDbNull(.Fields("codigo").Value), "1", .Fields("codigo").Value)))
						'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.Fields. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						'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"'
						lstrDes = Trim(IIf(IsDbNull(.Fields("descricao").Value), "", .Fields("descricao").Value))
						With Me.lsvAgrupa
							Call .Items.Add(lstrDes)
							'UPGRADE_WARNING: Lower bound of collection Me.lsvAgrupa.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
							Call .Items.Item(.Items.Count).SubItems.Add(lstrCod)
						End With
						'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.MoveNext. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						Call .MoveNext()
					End While
				End If
				'UPGRADE_WARNING: Couldn't resolve default property of object lrstAux.Close. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				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
		'UPGRADE_WARNING: Lower bound of collection Me.lsvAgrupa.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
		Me.lsvAgrupa.Items.Item(1).Checked = True
		'UPGRADE_WARNING: Lower bound of collection Me.lsvAgrupa.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
		Call lsvAgrupa_ItemCheck(lsvAgrupa, New System.Windows.Forms.ItemCheckEventArgs(Me.lsvAgrupa.Items.Item(1).Index, System.Windows.Forms.CheckState.Indeterminate, Me.lsvAgrupa.Items.Item(1).Checked))
		System.Windows.Forms.Application.DoEvents()
	End Sub
	
	Public Function CabecaRel() As Object
		Dim LineFeed As Object
		Dim Cabecalho_Relatorio As Object
		Dim lstrAux As String
		Dim lintIdx As Short
		With ifrmRelFaturasPorAgrupamento
			'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			Call Cabecalho_Relatorio(.VS, "LISTAGEM DAS FATURAS POR AGRUPAMENTO ", "Mês/Ano: " & Me.txtMesAno.Text, "3", False, "")
			'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			.VS.FontSize = 7
			'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			Call LineFeed(.VS, 3)
			'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			.VS.Table = istrTamCol & istrCabCol
			'UPGRADE_WARNING: Couldn't resolve default property of object ifrmRelFaturasPorAgrupamento.VS. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			.VS.CurrentY = .VS.CurrentY + 100
		End With
	End Function
End Class