Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class frmRelReavisos
	Inherits System.Windows.Forms.Form
	Private frmAuxiliar As FrmRelatorio
	Private istrCabecA As String
	Private istrCabecB As String
	Private istrTamCol As String
	Private istrCabecG As String
	Private istrTabela As String
	
	'UPGRADE_WARNING: Event chkDesconsiderar.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 chkDesconsiderar_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkDesconsiderar.CheckStateChanged
		Me.dtpDesconsiderar.Enabled = (Me.chkDesconsiderar.CheckState = 1)
	End Sub
	
	'UPGRADE_WARNING: Event chkFaturas.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 chkFaturas_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkFaturas.CheckStateChanged
		Me.dtpMesAno.Enabled = (Me.chkFaturas.CheckState = 1)
	End Sub
	
	Private Sub cmdBaixaReavisos_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdBaixaReavisos.Click
		frmBaixaReavisos.Show()
	End Sub
	
	Private Sub cmdImprimir_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdImprimir.Click
		Dim lstrAux As String
		Dim lstrSql As String
		Dim lblnVerifica As Boolean
		If Me.dtpInicial.Enabled Then
			If CDate(Me.dtpInicial.value) > CDate(Me.dtpFinal.value) Then
				Call MsgBox("A data inicial não pode ser maior que a data final!", MsgBoxStyle.Information, gstrTituloMensagem)
				Call dtpInicial.Focus()
				Exit Sub
			End If
		End If
		Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
		frmAuxiliar = New FrmRelatorio
		If Me.opbSemReaviso.Checked Then
			istrCabecA = "Listagem das Faturas "
		Else
			istrCabecA = "Listagem dos Reavisos com a situação "
		End If
		With frmAuxiliar
			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
			If Me.opbReaviso.Checked Then
				lstrSql = ""
				lstrSql = lstrSql & " WHERE `concorte`.`sit` = ""R"" "
				lstrSql = lstrSql & "   AND `concorte`.`datareav` <= """ & VB6.Format(Me.dtpFinal.value, "yyyy-MM-dd") & """ "
				istrCabecB = Me.opbReaviso.Text & " até " & VB6.Format(Me.dtpFinal.value, "dd/mm/yyyy")
				lstrAux = "REAVISO"
			ElseIf Me.opbEntregue.Checked Then 
				lstrSql = ""
				lstrSql = lstrSql & " WHERE `concorte`.`sit` = ""E"" "
				lstrSql = lstrSql & "   AND `concorte`.`dataentrega` BETWEEN """ & VB6.Format(Me.dtpInicial.value, "yyyy-MM-dd") & """ "
				lstrSql = lstrSql & "                                    AND """ & VB6.Format(Me.dtpFinal.value, "yyyy-MM-dd") & """ "
				istrCabecB = Me.opbEntregue.Text & " no período de " & VB6.Format(Me.dtpInicial.value, "dd/mm/yyyy") & " até " & VB6.Format(Me.dtpFinal.value, "dd/mm/yyyy")
				lstrAux = "ENTREGA"
			ElseIf Me.opbCortado.Checked Then 
				lstrSql = ""
				lstrSql = lstrSql & " WHERE 1 =1 " '`concorte`.`sit` = ""C"" "
				lstrSql = lstrSql & "   AND `concorte`.`datacorte` BETWEEN """ & VB6.Format(Me.dtpInicial.value & " 00:00:01", "yyyy-MM-dd hh:mm:ss") & """ "
				lstrSql = lstrSql & "                                  AND """ & VB6.Format(Me.dtpFinal.value & " 23:59:59", "yyyy-MM-dd  hh:mm:ss") & """ "
				istrCabecB = Me.opbCortado.Text & " no período de " & VB6.Format(Me.dtpInicial.value, "dd/mm/yyyy") & " até " & VB6.Format(Me.dtpFinal.value, "dd/mm/yyyy")
				lstrAux = "CORTE"
			ElseIf Me.opbPrazo.Checked Then 
				lstrSql = ""
				lstrSql = lstrSql & " WHERE `concorte`.`sit` = ""E"" "
				lstrSql = lstrSql & "   AND `concorte`.`prazoreav` <= """ & VB6.Format(Me.dtpFinal.value, "yyyy-MM-dd") & """ "
				istrCabecB = Me.opbPrazo.Text & " até " & VB6.Format(Me.dtpFinal.value, "dd/mm/yyyy")
				lstrAux = "PRAZO"
			ElseIf Me.opbSemReaviso.Checked Then 
				lstrSql = lstrSql & " WHERE `nf`.`flgst`    = """" "
				lstrSql = lstrSql & "   AND `nf`.`datavenc` <= """ & VB6.Format(Me.dtpFinal.value, "yyyy-MM-dd") & """ "
				If Me.chkDesconsiderar.CheckState = 1 Then
					lstrSql = lstrSql & " AND `nf`.`mesano` <> '" & VB6.Format(Me.dtpDesconsiderar.value, "mm/yyyy") & "' "
				End If
				lstrSql = lstrSql & "   AND NOT EXISTS(SELECT * FROM `concorte` WHERE `concorte`.`numnf` = `nf`.`numnf` AND `concorte`.`mesano` = `nf`.`mesano`) "
				istrCabecB = Me.opbSemReaviso.Text & " com Vencimento até " & VB6.Format(Me.dtpFinal.value, "dd/mm/yyyy")
				lstrAux = "SITUAÇÃO"
			End If
			If Me.chkCortados.CheckState = 1 Or Me.chkLigados.CheckState = 1 Or Me.chkDesligados.CheckState = 1 Or Me.chkDesativados.CheckState = 1 Then
				lstrSql = lstrSql & " AND IFNULL(IFNULL(`unidb`.`situacao`,`unida`.`situacao`),'L') IN("
				If Me.chkCortados.CheckState = 1 Then
					lstrSql = lstrSql & "'C',"
				End If
				If Me.chkLigados.CheckState = 1 Then
					lstrSql = lstrSql & "'L',"
				End If
				If Me.chkDesligados.CheckState = 1 Then
					lstrSql = lstrSql & "'D',"
				End If
				If Me.chkDesativados.CheckState = 1 Then
					lstrSql = lstrSql & "'I' "
				End If
				lstrSql = VB.Left(lstrSql, Len(lstrSql) - 1) & ")"
			End If
			istrTamCol = "<5mm|<22mm|^18mm|<115mm|>20mm|^16mm|^20mm|^20mm|>20mm|>22mm;"
			istrCabecG = "|IDENTIF.|ROTA|NOME|FATURA|REF|" & lstrAux & "|VECTO|MEDIDOR|VALOR"
			Call .VS.StartDoc()
			lblnVerifica = ImprimeRelatorio(lstrSql)
			Call .VS.EndDoc()
			If lblnVerifica Then
				Call .Show()
			Else
				Call MsgBox("Não foi encontrado nenhum dado para imprimir, favor verifique as opções!", MsgBoxStyle.Information, gstrTituloMensagem)
				Call .VS.KillDoc()
				Me.lblInfo.Text = ""
			End If
		End With
		Me.lblInfo.Text = Me.lblInfo.Text & "...Concluído...."
		Me.Cursor = System.Windows.Forms.Cursors.Default
		System.Windows.Forms.Application.DoEvents()
	End Sub
	
	Public Function CabecaRel() As Object
		With frmAuxiliar
			Call Cabecalho_Relatorio(.VS, istrCabecA, istrCabecB, "3")
			'Call LineFeed(.VS, 1)
			.VS.Font = VB6.FontChangeBold(.VS.Font, True)
			.VS.BrushColor = System.Drawing.Color.White
			.VS.Font = VB6.FontChangeSize(.VS.Font, 8)
			.VS.Table = istrTamCol & istrCabecG
			.VS.Font = VB6.FontChangeBold(.VS.Font, False)
			Call LineFeed(.VS, 1)
		End With
	End Function
	
	Private Function ImprimeRelatorio(ByVal astrSql As String) As Boolean
		Dim lstrZLC As String
		Dim llngDCId As Integer
		Dim llngUCId As Integer
		Dim lstrRota As String
		Dim lstrNome As String
		Dim ldblNumNf As Double
		Dim lstrMesAno As String
		Dim ldteReaviso As Date
		Dim ldtePrazo As Date
		Dim ldteEntrega As Date
		Dim ldteCorte As Date
		Dim ldteVecto As Date
		Dim lstrMedidor As String
		Dim ldblValor As Double
		Dim lintZebra As Short
		Dim llngQtde As Integer
		Dim ldblTVlr As Double
		Dim lstrSituacao As String
		Dim lblnContinua As Boolean
		Dim lstrSitAux As String
		Dim lblnRetorno As Boolean
		Dim lstrSql As String
		Dim lrstConsulta As ADODB.Recordset
		lrstConsulta = New ADODB.Recordset
		lblnContinua = True
		lstrSitAux = ""
		lstrSql = ""
		If Me.opbSemReaviso.Checked Then
			lstrSql = lstrSql & "SELECT `nf`.`zona`, "
			lstrSql = lstrSql & "       `nf`.`livro`, "
			lstrSql = lstrSql & "       `nf`.`conta`, "
			lstrSql = lstrSql & "       `nf`.`cons_id`, "
			lstrSql = lstrSql & "       `nf`.`unid_id`, "
			lstrSql = lstrSql & "       IFNULL(IFNULL(`unida`.`cons_id`,`unidb`.`cons_id`),`consum`.`consreg`) `cons_id_uc`, "
			lstrSql = lstrSql & "       `nf`.`rota`, "
			lstrSql = lstrSql & "       IFNULL(IFNULL(`unida`.`nome`,`unidb`.`nome`),`consum`.`nome`) `nome`, "
			lstrSql = lstrSql & "       `consum`.`nome` `nome_c`, "
			lstrSql = lstrSql & "       `nf`.`numnf`, "
			lstrSql = lstrSql & "       `nf`.`mesano`, "
			lstrSql = lstrSql & "       '1900-01-01' `datareav`, "
			lstrSql = lstrSql & "       '1900-01-01' `prazoreav`, "
			lstrSql = lstrSql & "       '1900-01-01' `dataentrega`, "
			lstrSql = lstrSql & "       '1900-01-01' `datacorte`, "
			lstrSql = lstrSql & "       `nf`.`datavenc`, "
			lstrSql = lstrSql & "       IFNULL(IFNULL(`unida`.`eletr`,`unidb`.`num`),'') `medidor`, "
			lstrSql = lstrSql & "       `nf`.`valortot` `valor`, "
			lstrSql = lstrSql & "       IFNULL(IFNULL(`unidb`.`situacao`,`unida`.`situacao`),'L') AS `situacao_uc` "
			lstrSql = lstrSql & "  FROM `nf` "
			lstrSql = lstrSql & " LEFT JOIN `unidb` ON(`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`.`zona` = `nf`.`zona` AND `unida`.`livro` = `nf`.`livro` AND `unida`.`conta` = `nf`.`conta` AND `nf`.`grupo` = 'A') "
			lstrSql = lstrSql & " LEFT JOIN `consum` ON(`consum`.`consreg` = `nf`.`cons_id`) "
			lstrSql = lstrSql & astrSql
			lstrSql = lstrSql & " ORDER BY right(`nf`.`rota`,6) ASC "
			Me.lblInfo.Text = " Buscando as faturas...."
		Else
			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 & "       IFNULL(IFNULL(`unida`.`cons_id`,`unidb`.`cons_id`),`consum`.`consreg`) `cons_id_uc`, "
			lstrSql = lstrSql & "       `concorte`.`rota`, "
			lstrSql = lstrSql & "       `concorte`.`nome`, "
			lstrSql = lstrSql & "       `consum`.`nome` `nome_c`, "
			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`.`datavenc`, "
			lstrSql = lstrSql & "       `concorte`.`medidor`, "
			lstrSql = lstrSql & "       `concorte`.`valor`, "
			lstrSql = lstrSql & "       IFNULL(IFNULL(`unidb`.`situacao`,`unida`.`situacao`),'L') AS `situacao_uc` "
			lstrSql = lstrSql & "  FROM `concorte` "
			lstrSql = lstrSql & " LEFT JOIN `unidb` ON(`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`.`zona` = `concorte`.`zona` AND `unida`.`livro` = `concorte`.`livro` AND `unida`.`conta` = `concorte`.`conta` AND MID(`concorte`.`ta`,3,1) = 'A') "
			lstrSql = lstrSql & " LEFT JOIN `consum` ON(`consum`.`consreg` = `concorte`.`cons_id`) "
			lstrSql = lstrSql & astrSql
			If Me.chkFaturas.CheckState = 1 Then
				lstrSql = lstrSql & " AND `concorte`.`mesano` = '" & VB6.Format(Me.dtpMesAno.value, "mm/yyyy") & "' "
			End If
			If Me.chkDesconsiderar.CheckState = 1 Then
				lstrSql = lstrSql & " AND `concorte`.`mesano` <> '" & VB6.Format(Me.dtpDesconsiderar.value, "mm/yyyy") & "' "
			End If
			lstrSql = lstrSql & " ORDER BY right(`concorte`.`rota`,6) ASC "
			Me.lblInfo.Text = " Buscando os dados dos reavisos...."
		End If
		
		Call Me.lblInfo.Refresh()
		Call Conectar(lstrSql, lrstConsulta)
		lintZebra = 1
		With lrstConsulta
			If .RecordCount > 0 Then
				lblnRetorno = True
				llngQtde = .RecordCount
				Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 0, llngQtde)
				ldblTVlr = 0
				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"'
					lstrSituacao = IIf(IsDbNull(.Fields("situacao_uc").value), "L", .Fields("situacao_uc").value)
					lstrSitAux = ""
					If Me.chkLigados.CheckState = System.Windows.Forms.CheckState.Checked Then
						lstrSitAux = lstrSitAux & "L"
					End If
					If Me.chkDesligados.CheckState = System.Windows.Forms.CheckState.Checked Then
						lstrSitAux = lstrSitAux & "D"
					End If
					If Me.chkCortados.CheckState = System.Windows.Forms.CheckState.Checked Then
						lstrSitAux = lstrSitAux & "C"
					End If
					If Me.chkDesativados.CheckState = System.Windows.Forms.CheckState.Checked Then
						lstrSitAux = lstrSitAux & "I"
					End If
					lblnContinua = (CInt(InStr(1, lstrSitAux, lstrSituacao)) > 0)
					If lblnContinua 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"'
						lstrZLC = VB6.Format(IIf(IsDbNull(.Fields("zona").value), "0", .Fields("zona").value), "000") & "." & VB6.Format(IIf(IsDbNull(.Fields("livro").value), "0", .Fields("livro").value), "00") & "." & VB6.Format(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"'
						lstrRota = VB6.Format(IIf(IsDbNull(.Fields("rota").value), "0", .Fields("rota").value), "00000000")
						lstrRota = VB.Left(lstrRota, 4) & "." & VB.Right(lstrRota, 4)
						'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"'
						llngDCId = 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"'
						llngUCId = IIf(IsDbNull(.Fields("cons_id_uc").value), 0, .Fields("cons_id_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"'
						lstrNome = IIf(IsDbNull(.Fields("nome").value), "", .Fields("nome").value)
						If Me.opbSemReaviso.Checked Then
							If llngDCId <> llngUCId 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"'
								lstrNome = "(Trans.Tit.) " & IIf(IsDbNull(.Fields("nome_c").value), "", .Fields("nome_c").value)
							End If
						End If
						'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 = IIf(IsDbNull(.Fields("mesano").value), "", .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"'
						ldteReaviso = 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"'
						ldtePrazo = 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"'
						ldteEntrega = 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"'
						ldteCorte = 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"'
						ldteVecto = 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"'
						lstrMedidor = IIf(IsDbNull(.Fields("medidor").value), "", .Fields("medidor").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"'
						ldblValor = CDbl(IIf(IsDbNull(.Fields("valor").value), 0, .Fields("valor").value))
						
						ldblTVlr = ldblTVlr + ldblValor
						istrTabela = ""
						istrTabela = istrTabela & "|"
						istrTabela = istrTabela & lstrZLC & "|"
						istrTabela = istrTabela & lstrRota & "|"
						istrTabela = istrTabela & lstrNome & "|"
						istrTabela = istrTabela & ldblNumNf & "|"
						istrTabela = istrTabela & lstrMesAno & "|"
						'datas
						If Me.opbReaviso.Checked Then
							istrTabela = istrTabela & VB6.Format(ldteReaviso, "dd/mm/yyyy") & "|"
						ElseIf Me.opbEntregue.Checked Then 
							istrTabela = istrTabela & VB6.Format(ldteEntrega, "dd/mm/yyyy") & "|"
						ElseIf Me.opbCortado.Checked Then 
							istrTabela = istrTabela & VB6.Format(ldteCorte, "dd/mm/yyyy") & "|"
						ElseIf Me.opbPrazo.Checked Then 
							istrTabela = istrTabela & VB6.Format(ldtePrazo, "dd/mm/yyyy") & "|"
						ElseIf Me.opbSemReaviso.Checked Then 
							istrTabela = istrTabela & lstrSituacao & "|"
						End If
						istrTabela = istrTabela & VB6.Format(ldteVecto, "dd/mm/yyyy") & "|"
						istrTabela = istrTabela & lstrMedidor & "|"
						istrTabela = istrTabela & VB6.Format(ldblValor, "Standard")
						
						If lintZebra = 0 Then
							frmAuxiliar.VS.PenStyle = VSVIEW6.PenStyleSettings.psTransparent
							frmAuxiliar.VS.BrushColor = System.Drawing.ColorTranslator.FromOle(&HE0E0E0) '&H808080 'vbGrayed
							'UPGRADE_ISSUE: VBControlExtender method frmAuxiliar.VS.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
							frmAuxiliar.VS.DrawRectangle("12mm", frmAuxiliar.VS.CurrentY, "285mm", frmAuxiliar.VS.CurrentY + 180)
							frmAuxiliar.VS.BrushColor = System.Drawing.Color.White
							frmAuxiliar.VS.PenStyle = VSVIEW6.PenStyleSettings.psSolid
							lintZebra = 1
						Else
							lintZebra = 0
						End If
						frmAuxiliar.VS.Table = istrTamCol & istrTabela
					End If
					Call .MoveNext()
					System.Windows.Forms.Application.DoEvents()
					Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 1)
				End While
				Call LineFeed((frmAuxiliar.VS), 1)
				frmAuxiliar.VS.Font = VB6.FontChangeBold(frmAuxiliar.VS.Font, True)
				istrTabela = "|" & "TOTAL" & "|" & llngQtde & "|||||||" & VB6.Format(ldblTVlr, "Standard")
				frmAuxiliar.VS.Table = istrTamCol & istrTabela
				frmAuxiliar.VS.Font = VB6.FontChangeBold(frmAuxiliar.VS.Font, False)
			End If
			If .State = 1 Then Call .Close()
		End With
		'UPGRADE_NOTE: Object lrstConsulta 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"'
		lrstConsulta = Nothing
		ImprimeRelatorio = lblnRetorno
	End Function
	
	Private Sub dtpInicial_Change(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles dtpInicial.Change
		Me.dtpFinal.value = CDate(UltimoDiaMes((Me.dtpInicial.Month), (Me.dtpInicial.Year)) & "/" & VB6.Format(Me.dtpInicial.value, "mm/yyyy"))
	End Sub
	
	Private Sub dtpInicial_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles dtpInicial.ClickEvent
		Call dtpInicial_Change(dtpInicial, New System.EventArgs())
	End Sub
	
	Private Sub frmRelReavisos_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		Me.dtpInicial.value = CDate(VB6.Format(BuscaDataBD, "dd/MM/yyyy"))
		Me.dtpFinal.value = CDate(UltimoDiaMes((Me.dtpInicial.Month), (Me.dtpInicial.Year)) & "/" & VB6.Format(Me.dtpInicial.value, "mm/yyyy"))
		'UPGRADE_WARNING: Couldn't resolve default property of object Me.dtpInicial.value. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		Me.dtpMesAno.value = Me.dtpInicial.value
		'UPGRADE_WARNING: Couldn't resolve default property of object Me.dtpInicial.value. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
		Me.dtpDesconsiderar._Value = Me.dtpInicial.value
		Call LigDesDatas()
	End Sub
	
	'UPGRADE_WARNING: Event opbCortado.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub opbCortado_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles opbCortado.CheckedChanged
		If eventSender.Checked Then
			Call LigDesDatas()
		End If
	End Sub
	
	'UPGRADE_WARNING: Event opbEntregue.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub opbEntregue_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles opbEntregue.CheckedChanged
		If eventSender.Checked Then
			Call LigDesDatas()
		End If
	End Sub
	
	'UPGRADE_WARNING: Event opbPrazo.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub opbPrazo_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles opbPrazo.CheckedChanged
		If eventSender.Checked Then
			Call LigDesDatas()
		End If
	End Sub
	
	'UPGRADE_WARNING: Event opbReaviso.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub opbReaviso_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles opbReaviso.CheckedChanged
		If eventSender.Checked Then
			Call LigDesDatas()
		End If
	End Sub
	
	Private Sub LigDesDatas()
		If Me.opbCortado.Checked Or Me.opbEntregue.Checked Then
			Me.dtpInicial.Enabled = True
		Else
			Me.dtpInicial.Enabled = False
		End If
		If Me.opbSemReaviso.Checked Then
			Me.lblAux(2).Text = "Vecto:"
		Else
			Me.lblAux(2).Text = "Final:"
		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
	
	'UPGRADE_WARNING: Event opbSemReaviso.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub opbSemReaviso_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles opbSemReaviso.CheckedChanged
		If eventSender.Checked Then
			Call LigDesDatas()
		End If
	End Sub
End Class