Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class frmCadRevDados
	Inherits System.Windows.Forms.Form
	Private iFrmQuemChama As System.Windows.Forms.Form
	Private ifrmLocalizar As frmLocalizadorGeralNovo
	Private istrTabela As String
	Private irstTabela As ADODB.Recordset
	'Controle do relatorio em VSPrinter
	Private fr As New FrmRelatorio
	
	'UPGRADE_WARNING: Event chkCancel.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 chkCancel_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkCancel.CheckStateChanged
		
		If Me.chkCancel.CheckState = 0 Then
			Me.dtpDataRev_Can.Enabled = False
		Else
			Me.dtpDataRev_Can.Enabled = True
		End If
		
	End Sub
	
	'UPGRADE_WARNING: Event chkRevisado.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 chkRevisado_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkRevisado.CheckStateChanged
		
		If Me.chkRevisado.CheckState = 0 Then
			Me.dtpDataRev_Can.Enabled = False
		Else
			Me.dtpDataRev_Can.Enabled = True
		End If
		
		
	End Sub
	
	Private Sub cmdRevisao_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdRevisao.Click
		
		Dim lrstAux As ADODB.Recordset
		Dim llngConta As Integer
		Dim lstrSql As String
		'CadRev_grupos
		Dim lstrIdGrupo As String
		Dim llngIdAgente As Integer
		Dim llngAno As Integer
		Dim ldtDtInicial As Date
		Dim ldtDtFinal As Date
		Dim ldtDtRev_Can As Date
		Dim lstrObservacao As String
		Dim lstrCancelado As String
		Dim lstrRevisado As String
		'
		Dim llngUnidId As Integer
		Dim llngConsId As Integer
		Dim lstrZona As String
		Dim lstrLivro As String
		Dim lstrConta As String
		
		lrstAux = New ADODB.Recordset
		
		If Me.mshDados1.Rows = 1 Then
			Call MsgBox("Precisa preencher a lista de registros para revisão, verifique", MsgBoxStyle.Information, gstrTituloMensagem)
			Me.cmdLocalizarCronograma.Focus()
			Exit Sub
		End If
		
		If Me.txtId.Text = "" Then
			Call MsgBox("Precisa preencher o codigo do grupo, verifique", MsgBoxStyle.Information, gstrTituloMensagem)
			Me.txtId.Focus()
			Exit Sub
		End If
		
		lstrIdGrupo = ""
		llngIdAgente = 0
		llngAno = 0
		ldtDtInicial = System.Date.FromOADate(0)
		ldtDtFinal = System.Date.FromOADate(0)
		ldtDtRev_Can = System.Date.FromOADate(0)
		lstrObservacao = ""
		lstrCancelado = "N"
		lstrRevisado = "N"
		
		lstrObservacao = Me.txtObs.Text
		
		If Me.chkCancel.CheckState = 1 Then
			lstrCancelado = "S"
			ldtDtRev_Can = CDate(VB6.Format(Me.dtpDataRev_Can._Value, "yyyy-mm-dd"))
		Else
			lstrCancelado = "N"
		End If
		If Me.chkRevisado.CheckState = 1 Then
			lstrRevisado = "S"
			ldtDtRev_Can = CDate(VB6.Format(Me.dtpDataRev_Can._Value, "yyyy-mm-dd"))
		Else
			lstrRevisado = "N"
		End If
		
		lstrSql = ""
		lstrSql = lstrSql & "SELECT * " & vbCrLf
		lstrSql = lstrSql & " FROM `cadrev_grupos` " & vbCrLf
		lstrSql = lstrSql & " WHERE `cadrev_grupos`.`id` = '" & Me.txtId.Text & "'" & vbCrLf
		Call Conectar(lstrSql, lrstAux)
		With lrstAux
			If .State = ADODB.ObjectStateEnum.adStateOpen Then
				If .RecordCount > 0 Then
					'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
					lstrIdGrupo = Trim(IIf(IsDbNull(.Fields("id").value), "", .Fields("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"'
					llngIdAgente = CInt(Trim(IIf(IsDbNull(.Fields("idagente").value), "0", .Fields("idagente").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"'
					llngAno = CInt(Trim(IIf(IsDbNull(.Fields("ano").value), "0", .Fields("ano").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"'
					ldtDtInicial = CDate(Trim(IIf(IsDbNull(.Fields("datainicial").value), "1900-01-01", .Fields("datainicial").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"'
					ldtDtFinal = CDate(Trim(IIf(IsDbNull(.Fields("datafinal").value), "1900-01-01", .Fields("datafinal").value)))
				End If
				Call .Close()
			End If
		End With
		If Me.mshDados1.Rows > 1 Then
			For llngConta = 1 To Me.mshDados1.Rows - 1
				With Me.mshDados1
					If .get_TextMatrix(llngConta, 17) = "X" Then
						
						llngConsId = 0
						llngUnidId = 0
						lstrZona = ""
						lstrLivro = ""
						lstrConta = ""
						
						llngConsId = CInt(.get_TextMatrix(llngConta, 6))
						llngUnidId = CInt(.get_TextMatrix(llngConta, 7))
						lstrZona = .get_TextMatrix(llngConta, 10)
						lstrLivro = .get_TextMatrix(llngConta, 11)
						lstrConta = .get_TextMatrix(llngConta, 12)
						
						lstrSql = ""
						lstrSql = lstrSql & "UPDATE `cadrev_dados` SET "
						lstrSql = lstrSql & "       `idgrupos`  = '" & lstrIdGrupo & "', "
						lstrSql = lstrSql & "       `idagente` = " & llngIdAgente & ", "
						lstrSql = lstrSql & "       `ano`    = " & llngAno & ","
						lstrSql = lstrSql & "       `data_inicial`  = '" & VB6.Format(ldtDtInicial, "yyyy-mm-dd") & "',"
						lstrSql = lstrSql & "       `data_final`  = '" & VB6.Format(ldtDtFinal, "yyyy-mm-dd") & "',"
						lstrSql = lstrSql & "       `observacao`  = '" & lstrObservacao & "',"
						lstrSql = lstrSql & "       `data_Rev_Can`  = '" & VB6.Format(ldtDtRev_Can, "yyyy-mm-dd") & "',"
						lstrSql = lstrSql & "       `cancelado`  = '" & lstrCancelado & "',"
						lstrSql = lstrSql & "       `revisado`  = '" & lstrRevisado & "'"
						lstrSql = lstrSql & " WHERE `consid`  = " & llngConsId & ""
						lstrSql = lstrSql & "   AND `unidid` = " & llngUnidId & ""
						lstrSql = lstrSql & "   AND `zona` = '" & lstrZona & "'"
						lstrSql = lstrSql & "   AND `livro` = '" & lstrLivro & "'"
						lstrSql = lstrSql & "   AND `conta` = '" & lstrConta & "'"
						Call Executar(lstrSql)
					End If
				End With
			Next llngConta
		End If
		Call cmdLocalizarCronograma_Click(cmdLocalizarCronograma, New System.EventArgs())
	End Sub
	
	Public Sub SetaCodigo(ByVal astrTabela As String, ByRef astrPriKey As String)
		Call mdlControleForms.ctrl_form_SetaCodigo(Me, astrTabela, istrTabela, astrPriKey, irstTabela)
	End Sub
	
	Private Sub cmdEnviarRev_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdEnviarRev.Click
		
		Dim lrstAux As ADODB.Recordset
		Dim llngConta As Integer
		Dim lstrSql As String
		
		Dim llngUnidId As Integer
		Dim llngConsId As Integer
		Dim strClasse As String
		Dim strMesAno As String
		Dim strZona As String
		Dim strLivro As String
		Dim strConta As String
		Dim strConsum As String
		Dim strGrupo As String
		Dim llngExiste As Integer
		
		lrstAux = New ADODB.Recordset
		
		llngExiste = 0
		
		If Me.mshDados.Rows > 1 Then
			For llngConta = 1 To Me.mshDados.Rows - 1
				With Me.mshDados
					If .get_TextMatrix(llngConta, 11) = "X" Then
						
						llngUnidId = 0
						llngConsId = 0
						strClasse = ""
						strMesAno = ""
						strZona = ""
						strLivro = ""
						strConta = ""
						strConsum = ""
						strGrupo = ""
						
						llngUnidId = CInt(.get_TextMatrix(llngConta, 0))
						llngConsId = CInt(.get_TextMatrix(llngConta, 1))
						strClasse = .get_TextMatrix(llngConta, 2)
						strMesAno = .get_TextMatrix(llngConta, 5)
						strZona = .get_TextMatrix(llngConta, 6)
						strLivro = .get_TextMatrix(llngConta, 7)
						strConta = .get_TextMatrix(llngConta, 8)
						strConsum = .get_TextMatrix(llngConta, 9)
						strGrupo = .get_TextMatrix(llngConta, 10)
						
						lstrSql = ""
						lstrSql = lstrSql & "SELECT * " & vbCrLf
						lstrSql = lstrSql & "  FROM `cadrev_dados` " & vbCrLf
						lstrSql = lstrSql & " WHERE `cadrev_dados`.`mesano` = '" & strMesAno & "'" & vbCrLf
						lstrSql = lstrSql & "   AND `cadrev_dados`.`zona` = '" & strZona & "'" & vbCrLf
						lstrSql = lstrSql & "   AND `cadrev_dados`.`livro` = '" & strLivro & "'" & vbCrLf
						lstrSql = lstrSql & "   AND `cadrev_dados`.`conta` = '" & strConta & "'" & vbCrLf
						Call Conectar(lstrSql, lrstAux)
						With lrstAux
							If .State = ADODB.ObjectStateEnum.adStateOpen Then
								If .RecordCount = 0 Then
									lstrSql = ""
									lstrSql = lstrSql & "INSERT INTO `cadrev_dados`  SET " & vbCrLf
									lstrSql = lstrSql & "            `cadrev_dados`.`classe` = " & strClasse & "," & vbCrLf
									lstrSql = lstrSql & "            `cadrev_dados`.`mesano`      = '" & strMesAno & "'," & vbCrLf
									lstrSql = lstrSql & "            `cadrev_dados`.`zona`      = '" & strZona & "'," & vbCrLf
									lstrSql = lstrSql & "            `cadrev_dados`.`livro`= '" & strLivro & "'," & vbCrLf
									lstrSql = lstrSql & "            `cadrev_dados`.`conta`= '" & strConta & "'," & vbCrLf
									lstrSql = lstrSql & "            `cadrev_dados`.`consid`= " & llngConsId & "," & vbCrLf
									lstrSql = lstrSql & "            `cadrev_dados`.`unidid`= " & llngUnidId & "," & vbCrLf
									lstrSql = lstrSql & "            `cadrev_dados`.`consumidor`= '" & strConsum & "'" & vbCrLf
									Call Executar(lstrSql)
								Else
									llngExiste = llngExiste + 1
								End If
								Call .Close()
							End If
						End With
					End If
				End With
			Next llngConta
		End If
		If llngExiste > 0 Then
			Call MsgBox("Existe registros que já foram enviados, Verifique!", MsgBoxStyle.Exclamation, gstrTituloMensagem)
		End If
		Call cmdLocalizarCronograma_Click(cmdLocalizarCronograma, New System.EventArgs())
	End Sub
	
	Private Sub cmdEstadosCadastrais_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdEstadosCadastrais.Click
		Dim lfrmAux As frmCadUniEstadosCadastrais
		lfrmAux = New frmCadUniEstadosCadastrais
		Call lfrmAux.SetaParametros(Me)
		Call lfrmAux.Show()
	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 cmdGrupos_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdGrupos.Click
		Dim lfrmAux As frmCadRevGrupos
		lfrmAux = New frmCadRevGrupos
		Call lfrmAux.SetaParametros(Me)
		Call lfrmAux.Show()
	End Sub
	
	Private Sub cmdGruposMensagens_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdGruposMensagens.Click
		Dim lfrmAux As frmCadUniGruposMensagens
		lfrmAux = New frmCadUniGruposMensagens
		Call lfrmAux.SetaParametros(Me)
		Call lfrmAux.Show()
	End Sub
	
	Private Sub cmdImprimir_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdImprimir.Click
		
		Call LigDes(False)
		fr.quem_chama = Me
		fr.VS.Font = VB6.FontChangeName(fr.VS.Font, "Arial")
		fr.VS.Font = VB6.FontChangeSize(fr.VS.Font, 7)
		fr.VS.TableBorder = VSVIEW6.TableBorderSettings.tbNone
		fr.VS.PageBorder = VSVIEW6.TableBorderSettings.tbNone
		fr.VS.Orientation = VSVIEW6.OrientationSettings.orLandscape
		fr.VS.PhysicalPage = True
		fr.VS.PaperSize = VSVIEW6.PaperSizeSettings.pprA4
		fr.VS.MarginTop = "7mm"
		fr.VS.MarginRight = "7mm"
		fr.VS.MarginLeft = "7mm"
		fr.VS.MarginBottom = "5mm"
		fr.VS.TextColor = System.Drawing.Color.Black
		fr.VS.BrushStyle = VSVIEW6.BrushStyleSettings.bsSolid
		fr.VS.MarginFooter = "0mm"
		fr.VS.MarginHeader = "0mm"
		fr.VS.Font = VB6.FontChangeBold(fr.VS.Font, False)
		fr.VS.StartDoc()
		
		Call MontaImpressao("Registros para Revisão Cadastral")
		Call LineFeed((fr.VS), 1)
		
		fr.VS.EndDoc()
		fr.Show()
		fr.VS.KillDoc()
		Call LigDes(True)
		
	End Sub
	
	Private Sub cmdLocalizarCronograma_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLocalizarCronograma.Click
		
		Dim lrstAux As ADODB.Recordset
		Dim lstrSql As String
		
		Dim llngId As Integer
		Dim llngIdAgente As Integer
		Dim llngAno As Integer
		Dim ldtDtInicial As Date
		Dim ldtDtFinal As Date
		Dim ldtDtCancel As Date
		Dim lstrObservacao As String
		Dim lstrMesAno As String
		Dim lstrCodClas As String
		Dim lstrZona As String
		Dim lstrLivro As String
		Dim lstrConta As String
		Dim llngConsId As Integer
		Dim llngUnidId As Integer
		Dim lstrConsum As String
		Dim lstrGrupo As String
		Dim lstrCancelado As String
		Dim lstrRevisado As String
		'
		Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
		'
		lrstAux = New ADODB.Recordset
		
		Me.lblInfo.Text = "Lendo registros, aguarde..."
		Call Me.lblInfo.Refresh()
		Call MontaGrade_Cronograma()
		
		lstrSql = ""
		lstrSql = lstrSql & "SELECT *" & vbCrLf
		lstrSql = lstrSql & " FROM `cadrev_dados` " & vbCrLf
		lstrSql = lstrSql & " WHERE `cadrev_dados`.`mesano` = '" & txtMesAno.Text & "'" & vbCrLf
		If Me.OptNRevisado.Checked = True Then
			lstrSql = lstrSql & " AND `cadrev_dados`.`revisado` = 'N'" & vbCrLf
		ElseIf Me.OptRevisado.Checked = True Then 
			lstrSql = lstrSql & " AND `cadrev_dados`.`revisado` = 'S'" & vbCrLf
		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)
					Me.mshDados1.Redraw = False
					While Not .EOF
						
						llngId = 0
						llngIdAgente = 0
						llngAno = 0
						ldtDtInicial = System.Date.FromOADate(0)
						ldtDtFinal = System.Date.FromOADate(0)
						ldtDtCancel = System.Date.FromOADate(0)
						lstrObservacao = ""
						llngConsId = 0
						llngUnidId = 0
						lstrMesAno = ""
						lstrCodClas = ""
						lstrZona = ""
						lstrLivro = ""
						lstrConta = ""
						lstrConsum = ""
						lstrGrupo = ""
						lstrCancelado = ""
						lstrRevisado = ""
						
						'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"'
						llngId = CInt(Trim(IIf(IsDbNull(.Fields("id").value), "0", .Fields("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"'
						llngIdAgente = CInt(VB6.Format(Trim(IIf(IsDbNull(.Fields("idagente").value), "0", .Fields("idagente").value)), "0000"))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						llngAno = CInt(VB6.Format(Trim(IIf(IsDbNull(.Fields("ano").value), "0", .Fields("ano").value)), "0000"))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						ldtDtInicial = CDate(VB6.Format(Trim(IIf(IsDbNull(.Fields("data_inicial").value), "01/01/1900", .Fields("data_inicial").value)), "dd/mm/yyyy"))
						'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"'
						ldtDtFinal = CDate(VB6.Format(Trim(IIf(IsDbNull(.Fields("data_final").value), "01/01/1900", .Fields("data_final").value)), "dd/mm/yyyy"))
						'ldtDtCancel = Strings.Format(Strings.Trim(IIf(IsNull(.Fields("data_cancelamento").value), "01/01/1900", .Fields("data_cancelamento").value)), "dd/mm/yyyy")
						'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"'
						lstrObservacao = Trim(IIf(IsDbNull(.Fields("observacao").value), "", .Fields("observacao").value))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						lstrMesAno = Trim(IIf(IsDbNull(.Fields("mesano").value), "", .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"'
						lstrCodClas = Trim(IIf(IsDbNull(.Fields("classe").value), "", .Fields("classe").value))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						lstrZona = Trim(IIf(IsDbNull(.Fields("zona").value), "", .Fields("zona").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"'
						lstrLivro = Trim(IIf(IsDbNull(.Fields("livro").value), "", .Fields("livro").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"'
						lstrConta = Trim(IIf(IsDbNull(.Fields("conta").value), "", .Fields("conta").value))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						llngConsId = CInt(Trim(IIf(IsDbNull(.Fields("consid").value), "0", .Fields("consid").value)))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						llngUnidId = CInt(Trim(IIf(IsDbNull(.Fields("unidId").value), "0", .Fields("unidId").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"'
						lstrConsum = Trim(IIf(IsDbNull(.Fields("consumidor").value), "", .Fields("consumidor").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"'
						lstrGrupo = Trim(IIf(IsDbNull(.Fields("idgrupos").value), "", .Fields("idgrupos").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"'
						lstrCancelado = Trim(IIf(IsDbNull(.Fields("cancelado").value), "", .Fields("cancelado").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"'
						lstrRevisado = Trim(IIf(IsDbNull(.Fields("revisado").value), "", .Fields("revisado").value))
						
						With Me.mshDados1
							.Rows = .Rows + 1
							'UPGRADE_ISSUE: VBControlExtender method mshDados1.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
							.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillRepeat
							'UPGRADE_ISSUE: VBControlExtender method mshDados1.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
							.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillSingle
							.set_TextMatrix(.Rows - 1, 0, llngId)
							.set_TextMatrix(.Rows - 1, 1, llngIdAgente)
							.set_TextMatrix(.Rows - 1, 2, llngAno)
							.set_TextMatrix(.Rows - 1, 3, ldtDtInicial)
							.set_TextMatrix(.Rows - 1, 4, ldtDtFinal)
							.set_TextMatrix(.Rows - 1, 5, lstrObservacao)
							.set_TextMatrix(.Rows - 1, 6, llngConsId)
							.set_TextMatrix(.Rows - 1, 7, llngUnidId)
							.set_TextMatrix(.Rows - 1, 8, lstrMesAno)
							.set_TextMatrix(.Rows - 1, 9, lstrCodClas)
							.set_TextMatrix(.Rows - 1, 10, lstrZona)
							.set_TextMatrix(.Rows - 1, 11, lstrLivro)
							.set_TextMatrix(.Rows - 1, 12, lstrConta)
							.set_TextMatrix(.Rows - 1, 13, lstrConsum)
							.set_TextMatrix(.Rows - 1, 14, lstrGrupo)
							.set_TextMatrix(.Rows - 1, 15, lstrCancelado)
							.set_TextMatrix(.Rows - 1, 16, lstrRevisado)
						End With
						Call .MoveNext()
						Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 1)
					End While
					With Me.mshDados1
						.Col = 1
						.Sort = MSFlexGridLib.SortSettings.flexSortGenericAscending
						.Redraw = True
					End With
					mshDados1.Enabled = True
				Else
					Call MsgBox("Não foi possível encontrar registros para a revisão!", MsgBoxStyle.Exclamation, gstrTituloMensagem)
					Me.lblInfo.Text = ""
					Call .Close()
					Me.Cursor = System.Windows.Forms.Cursors.Default
					Me.txtMesAno.Focus()
					Exit Sub
				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
		Me.Cursor = System.Windows.Forms.Cursors.Default
		Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 1)
	End Sub
	
	Private Sub cmdLocalizarFaturas_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLocalizarFaturas.Click
		
		Dim lstrCodClas As String
		Dim lstrNomClas As String
		Dim ldblNumNf As Double
		Dim lstrMesAno As String
		Dim lstrZona As String
		Dim lstrLivro As String
		Dim lstrConta As String
		Dim lstrNome As String
		Dim llngUnidId As Integer
		Dim llngConsId As Integer
		Dim lstrGrupo As String
		Dim lstrGrupoUnid As String
		Dim lstrSql As String
		
		Dim lrstAuxNf As ADODB.Recordset
		Dim lrstAuxUnid As ADODB.Recordset
		'
		Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
		'
		lrstAuxNf = New ADODB.Recordset
		lrstAuxUnid = New ADODB.Recordset
		
		Me.lblInfo.Text = "Lendo Faturas, aguarde..."
		Call Me.lblInfo.Refresh()
		Call MontaGrade_Faturas()
		
		lstrSql = ""
		lstrSql = lstrSql & "SELECT" & vbCrLf
		lstrSql = lstrSql & "       `numnf`, " & vbCrLf
		lstrSql = lstrSql & "       `mesano`, " & vbCrLf
		lstrSql = lstrSql & "       `cons_id`, " & vbCrLf
		lstrSql = lstrSql & "       `unid_id`, " & vbCrLf
		lstrSql = lstrSql & "       `zona`, " & vbCrLf
		lstrSql = lstrSql & "       `livro`, " & vbCrLf
		lstrSql = lstrSql & "       `conta`, " & vbCrLf
		lstrSql = lstrSql & "       `codclas`, " & vbCrLf
		lstrSql = lstrSql & "       `grupo` " & vbCrLf
		lstrSql = lstrSql & " FROM `nf` " & vbCrLf
		lstrSql = lstrSql & " WHERE `nf`.`mesano` = '" & Me.txtMesAno.Text & "'" & vbCrLf
		If chkRural.CheckState = 1 Then
			lstrSql = lstrSql & " AND left(`codclas`,2) IN (51, 52, 53, 54, 55, 56)" & vbCrLf 'RURAL
			lstrSql = lstrSql & " AND `nf`.`codclas` <> 5502" & vbCrLf 'RURAL
		ElseIf ChkRuralIrrig.CheckState = 1 Then 
			lstrSql = lstrSql & " AND left(`codclas`,4) IN (5502, 5701)" & vbCrLf 'RURAL IRRIGACAO\AQUICULTURA"
		ElseIf ChkAguaEsgSane.CheckState = 1 Then 
			lstrSql = lstrSql & " AND left(`codclas`,2) = 72" & vbCrLf 'SERV.PUB.AGUA,ESGOTO E SANEAM.
		Else
			lstrSql = lstrSql & " AND left(`codclas`,2) IN (51, 52, 53, 54, 55, 56, 57, 72)" & vbCrLf
		End If
		lstrSql = lstrSql & " ORDER BY `nf`.`conta` " & vbCrLf
		Call Conectar(lstrSql, lrstAuxNf)
		With lrstAuxNf
			If .State = ADODB.ObjectStateEnum.adStateOpen Then
				If .RecordCount > 0 Then
					Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 0, .RecordCount)
					Me.mshDados.Redraw = False
					While Not .EOF
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						llngUnidId = CInt(IIf(IsDbNull(.Fields("unid_id").value), 0, .Fields("unid_id").value))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						llngConsId = CInt(IIf(IsDbNull(.Fields("cons_id").value), 0, .Fields("cons_id").value))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						lstrZona = VB6.Format(Trim(IIf(IsDbNull(.Fields("zona").value), "0", .Fields("zona").value)), "000")
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						lstrLivro = VB6.Format(Trim(IIf(IsDbNull(.Fields("livro").value), "0", .Fields("livro").value)), "00")
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						lstrConta = VB6.Format(Trim(IIf(IsDbNull(.Fields("conta").value), "0", .Fields("conta").value)), "000000")
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						lstrGrupo = 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"'
						ldblNumNf = CDbl(IIf(IsDbNull(.Fields("numnf").value), 0, .Fields("numnf").value))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						lstrMesAno = Trim(IIf(IsDbNull(.Fields("mesano").value), "", .Fields("mesano").value))
						lstrGrupoUnid = "unid" & LCase(lstrGrupo)
						
						lstrSql = ""
						lstrSql = lstrSql & "SELECT" & vbCrLf
						lstrSql = lstrSql & "       `nome`, `clas` " & vbCrLf
						lstrSql = lstrSql & " FROM `" & lstrGrupoUnid & "` " & vbCrLf
						lstrSql = lstrSql & " WHERE `" & lstrGrupoUnid & "`.`unid_id`  = '" & llngUnidId & "' " & vbCrLf
						Call Conectar(lstrSql, lrstAuxUnid)
						With lrstAuxUnid
							If lrstAuxUnid.State = ADODB.ObjectStateEnum.adStateOpen Then
								If lrstAuxUnid.RecordCount > 0 Then
									'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
									lstrNome = Trim(IIf(IsDbNull(lrstAuxUnid.Fields("nome").value), "", lrstAuxUnid.Fields("nome").value))
									'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
									lstrCodClas = VB6.Format(IIf(IsDbNull(lrstAuxUnid.Fields("clas").value), "0", lrstAuxUnid.Fields("clas").value), "0000")
									Select Case VB.Left(lstrCodClas, 2)
										Case Is = "51"
											lstrNomClas = "Rural"
										Case Is = "52"
											lstrNomClas = "Coop.Eletr.Rural"
										Case Is = "53"
											lstrNomClas = "Ind.Rural"
										Case Is = "54"
											lstrNomClas = "Colet.Rural"
										Case Is = "55"
											If lstrCodClas = "5502" Then
												lstrNomClas = "Rural Irrigação"
											Else
												lstrNomClas = "Rural"
											End If
										Case Is = "56"
											lstrNomClas = "Rural Esc.Agrotec."
										Case Is = "57"
											lstrNomClas = "Rural Aquicultura"
										Case Is = "72"
											lstrNomClas = "Serv.Pub.Agua,Esgoto e Saneam."
									End Select
								End If
								Call lrstAuxUnid.Close()
							End If
						End With
						With Me.mshDados
							.Rows = .Rows + 1
							'UPGRADE_ISSUE: VBControlExtender method mshDados.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
							.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillRepeat
							'UPGRADE_ISSUE: VBControlExtender method mshDados.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
							.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillSingle
							.set_TextMatrix(.Rows - 1, 0, llngUnidId)
							.set_TextMatrix(.Rows - 1, 1, llngConsId)
							.set_TextMatrix(.Rows - 1, 2, lstrCodClas)
							.set_TextMatrix(.Rows - 1, 3, lstrNomClas)
							.set_TextMatrix(.Rows - 1, 4, ldblNumNf)
							.set_TextMatrix(.Rows - 1, 5, lstrMesAno)
							.set_TextMatrix(.Rows - 1, 6, lstrZona)
							.set_TextMatrix(.Rows - 1, 7, lstrLivro)
							.set_TextMatrix(.Rows - 1, 8, lstrConta)
							.set_TextMatrix(.Rows - 1, 9, lstrNome)
							.set_TextMatrix(.Rows - 1, 10, lstrGrupo)
						End With
						Call .MoveNext()
						Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 1)
					End While
					With Me.mshDados
						.Col = 1
						.Sort = MSFlexGridLib.SortSettings.flexSortGenericAscending
						.Redraw = True
					End With
					mshDados.Enabled = True
				Else
					Call MsgBox("Não foi possível encontrar registros conforme os filtros selecionados!", MsgBoxStyle.Exclamation, gstrTituloMensagem)
				End If
				Call .Close()
			End If
		End With
		'UPGRADE_NOTE: Object lrstAuxNf may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
		lrstAuxNf = Nothing
		'UPGRADE_NOTE: Object lrstAuxUnid 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"'
		lrstAuxUnid = Nothing
		Me.Cursor = System.Windows.Forms.Cursors.Default
		Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 1)
		
	End Sub
	
	Private Sub cmdLocalizarGrupos_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLocalizarGrupos.Click
		
		Call ifrmLocalizar.Show()
		Call ifrmLocalizar.SetParametros("cadrev_grupos", Me.Text, Me)
		
	End Sub
	
	Public Sub SetaParametros(ByRef afrmQuemChama As System.Windows.Forms.Form)
		iFrmQuemChama = afrmQuemChama
		iFrmQuemChama.Enabled = False
	End Sub
	
	Private Sub cmdMarcaCronograma_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdMarcaCronograma.Click
		Dim llngRow As Integer
		Call LigDes(False)
		With Me.mshDados1
			For llngRow = 1 To .Rows - 1
				If .get_TextMatrix(llngRow, .Cols - 1) = "" Then
					.set_TextMatrix(llngRow, .Cols - 1, "X")
					'UPGRADE_ISSUE: VBControlExtender method mshDados1.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
					.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillRepeat
					.Row = llngRow
					.Col = .FixedCols
					.ColSel = .Cols - 1
					.CellBackColor = System.Drawing.SystemColors.Window
					'UPGRADE_ISSUE: VBControlExtender method mshDados1.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
					.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillSingle
				End If
			Next llngRow
		End With
		Call LigDes(True)
	End Sub
	
	Private Sub cmdMarcaFaturas_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdMarcaFaturas.Click
		Dim llngRow As Integer
		Call LigDes(False)
		With Me.mshDados
			For llngRow = 1 To .Rows - 1
				If .get_TextMatrix(llngRow, .Cols - 1) = "" Then
					.set_TextMatrix(llngRow, .Cols - 1, "X")
					'UPGRADE_ISSUE: VBControlExtender method mshDados.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
					.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillRepeat
					.Row = llngRow
					.Col = .FixedCols
					.ColSel = .Cols - 1
					.CellBackColor = System.Drawing.SystemColors.Window
					'UPGRADE_ISSUE: VBControlExtender method mshDados.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
					.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillSingle
				End If
			Next llngRow
		End With
		Call LigDes(True)
	End Sub
	
	Private Sub cmdMensagem_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdMensagem.Click
		Dim lfrmAux As frmCadUniMensagens
		lfrmAux = New frmCadUniMensagens
		Call lfrmAux.SetaParametros(Me)
		Call lfrmAux.Show()
	End Sub
	
	Private Sub cmdMotivosValidacoes_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdMotivosValidacoes.Click
		Dim lfrmAux As frmCadUniMotivosCadastrais
		lfrmAux = New frmCadUniMotivosCadastrais
		Call lfrmAux.SetaParametros(Me)
		Call lfrmAux.Show()
	End Sub
	
	Private Sub cmdTiposMensagens_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdTiposMensagens.Click
		Dim lfrmAux As frmCadUniTiposMensagens
		lfrmAux = New frmCadUniTiposMensagens
		Call lfrmAux.SetaParametros(Me)
		Call lfrmAux.Show()
	End Sub
	
	Private Sub frmCadRevDados_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		Call mdlControleForms.ctrl_form_FormKeyPress(Me, KeyAscii)
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub frmCadRevDados_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		Call CenterForm(Me)
		Me.txtMesAno.Text = VB6.Format(BuscaDataBD, "mm/yyyy")
		Me.dtpDataRev_Can._Value = BuscaDataBD
		
		istrTabela = "cadrev_grupos"
		irstTabela = New ADODB.Recordset
		ifrmLocalizar = New frmLocalizadorGeralNovo
		
	End Sub
	Private Sub LigDes(ByVal ablnModo As Boolean)
		Me.cmdFechar.Enabled = ablnModo
		Me.cmdRevisao.Enabled = ablnModo
		Me.cmdEstadosCadastrais.Enabled = ablnModo
		Me.cmdGrupos.Enabled = ablnModo
		Me.cmdGruposMensagens.Enabled = ablnModo
		Me.cmdMensagem.Enabled = ablnModo
		Me.cmdMotivosValidacoes.Enabled = ablnModo
		Me.cmdTiposMensagens.Enabled = ablnModo
		Me.cmdLocalizarFaturas.Enabled = ablnModo
		Me.cmdLocalizarCronograma.Enabled = ablnModo
		Me.cmdMarcaFaturas.Enabled = ablnModo
		Me.cmdMarcaCronograma.Enabled = ablnModo
		Me.txtMesAno.Enabled = ablnModo
	End Sub
	
	Private Sub MontaGrade_Faturas()
		With Me.mshDados
			.Rows = 1
			.Clear()
			.Redraw = False
			.set_TextMatrix(0, 0, "UnidId")
			.set_TextMatrix(0, 1, "ConsId")
			.set_TextMatrix(0, 2, "Classe")
			.set_TextMatrix(0, 3, "Desc. Classe")
			.set_TextMatrix(0, 4, "NF Num")
			.set_TextMatrix(0, 5, "Mes/Ano")
			.set_TextMatrix(0, 6, "Z")
			.set_TextMatrix(0, 7, "L")
			.set_TextMatrix(0, 8, "C")
			.set_TextMatrix(0, 9, "Consumidor")
			.set_TextMatrix(0, 10, "Grupo")
			.set_ColWidth(0, 0)
			.set_ColWidth(1, 0)
			.set_ColWidth(2, 750)
			.set_ColWidth(3, 1800)
			.set_ColWidth(4, 700)
			.set_ColWidth(5, 700)
			.set_ColWidth(6, 600)
			.set_ColWidth(7, 600)
			.set_ColWidth(8, 700)
			.set_ColWidth(9, 4000)
			.set_ColWidth(10, 600)
			''.ColWidth(11) = 700
			''.ColWidth(12) = 700
			.set_ColAlignment(2, 1)
			.set_ColAlignment(5, 1)
			.set_ColAlignment(6, 3)
			.set_ColAlignment(7, 3)
			.set_ColAlignment(8, 3)
			.set_ColAlignment(9, 1)
			.set_ColAlignment(10, 3)
			.Redraw = True
		End With
		System.Windows.Forms.Application.DoEvents()
	End Sub
	Private Sub MontaGrade_Cronograma()
		With Me.mshDados1
			.Rows = 1
			.Clear()
			.Redraw = False
			.set_TextMatrix(0, 0, "Id")
			.set_TextMatrix(0, 1, "IdAgente")
			.set_TextMatrix(0, 2, "Ano")
			.set_TextMatrix(0, 3, "Dt Inicial")
			.set_TextMatrix(0, 4, "Dt Final")
			.set_TextMatrix(0, 5, "Observação")
			.set_TextMatrix(0, 6, "consid")
			.set_TextMatrix(0, 7, "unidId")
			.set_TextMatrix(0, 8, "MêsAno")
			.set_TextMatrix(0, 9, "Classe")
			.set_TextMatrix(0, 10, "Z")
			.set_TextMatrix(0, 11, "L")
			.set_TextMatrix(0, 12, "C")
			.set_TextMatrix(0, 13, "Consumidor")
			.set_TextMatrix(0, 14, "IdGrupo")
			.set_TextMatrix(0, 15, "Cancel.")
			.set_TextMatrix(0, 16, "Revis.")
			.set_ColWidth(0, 0)
			.set_ColWidth(1, 0)
			.set_ColWidth(2, 500)
			.set_ColWidth(3, 1100)
			.set_ColWidth(4, 1100)
			.set_ColWidth(5, 1800)
			.set_ColWidth(6, 0)
			.set_ColWidth(7, 0)
			.set_ColWidth(8, 700)
			.set_ColWidth(9, 700)
			.set_ColWidth(10, 500)
			.set_ColWidth(11, 600)
			.set_ColWidth(12, 700)
			.set_ColWidth(13, 2800)
			.set_ColWidth(14, 700)
			.set_ColWidth(15, 700)
			.set_ColWidth(16, 700)
			.set_ColAlignment(9, 1)
			.set_ColAlignment(10, 3)
			.set_ColAlignment(11, 3)
			.set_ColAlignment(12, 3)
			.set_ColAlignment(13, 1)
			.set_ColAlignment(15, 3)
			.set_ColAlignment(16, 3)
			
			''.ColAlignment(10) = 3
			.Redraw = True
		End With
		System.Windows.Forms.Application.DoEvents()
	End Sub
	
	
	Private Sub mshDados_DblClick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mshDados.DblClick
		With Me.mshDados
			If .get_TextMatrix(.RowSel, .Cols - 1) = "X" Then
				.set_TextMatrix(.RowSel, .Cols - 1, "")
				'UPGRADE_ISSUE: VBControlExtender method mshDados.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
				.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillRepeat
				.Row = .RowSel
				.Col = .FixedCols
				.ColSel = .Cols - 1
				.CellBackColor = System.Drawing.SystemColors.Window
				'UPGRADE_ISSUE: VBControlExtender method mshDados.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
				.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillSingle
			Else
				.set_TextMatrix(.RowSel, .Cols - 1, "X")
				'UPGRADE_ISSUE: VBControlExtender method mshDados.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
				.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillRepeat
				.Row = .RowSel
				.Col = .FixedCols
				.ColSel = .Cols - 1
				.CellBackColor = System.Drawing.Color.Red
				'UPGRADE_ISSUE: VBControlExtender method mshDados.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
				.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillSingle
			End If
		End With
	End Sub
	
	Private Sub mshDados1_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mshDados1.ClickEvent
		With Me.mshDados1
			If .get_TextMatrix(.RowSel, .Cols - 1) = "X" Then
				.set_TextMatrix(.RowSel, .Cols - 1, "")
				'UPGRADE_ISSUE: VBControlExtender method mshDados1.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
				.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillRepeat
				.Row = .RowSel
				.Col = .FixedCols
				.ColSel = .Cols - 1
				.CellBackColor = System.Drawing.SystemColors.Window
				'UPGRADE_ISSUE: VBControlExtender method mshDados1.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
				.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillSingle
			Else
				.set_TextMatrix(.RowSel, .Cols - 1, "X")
				'UPGRADE_ISSUE: VBControlExtender method mshDados1.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
				.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillRepeat
				.Row = .RowSel
				.Col = .FixedCols
				.ColSel = .Cols - 1
				.CellBackColor = System.Drawing.Color.Red
				'UPGRADE_ISSUE: VBControlExtender method mshDados1.FillStyle was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
				.FillStyle = MSFlexGridLib.FillStyleSettings.flexFillSingle
			End If
		End With
	End Sub
	
	Private Sub txtMesAno_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtMesAno.Enter
		txtMesAno.SelectionStart = 0
		txtMesAno.SelectionLength = Len(txtMesAno.Text)
	End Sub
	
	Private Sub txtMesAno_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtMesAno.Leave
		txtMesAno.Text = ValidaMesAno(txtMesAno.Text)
		If Len(Trim(txtMesAno.Text)) < 1 Then
			MsgBox("Mês/ano inválidos!", MsgBoxStyle.Exclamation, gstrTituloMensagem)
			txtMesAno.Focus()
		End If
	End Sub
	
	Private Sub MontaImpressao(ByRef pstrTit1Cab As String)
		Dim llngConta As Integer
		Dim lstrTemp As String
		Dim lstrTamCol As String
		
		Dim llngId As Integer
		Dim llngIdAgente As Integer
		Dim llngAno As Integer
		Dim ldtDtInicial As Date
		Dim ldtDtFinal As Date
		Dim lstrObservacao As String
		Dim lstrMesAno As String
		Dim lstrCodClas As String
		Dim lstrZona As String
		Dim lstrLivro As String
		Dim lstrConta As String
		Dim llngConsId As Integer
		Dim llngUnidId As Integer
		Dim lstrConsum As String
		Dim lstrGrupo As String
		Dim lstrCancelado As String
		Dim lstrRevisado As String
		
		Call Cabecalho_Relatorio((fr.VS), pstrTit1Cab, "", "3", False, "")
		fr.VS.MarginLeft = "7mm"
		
		fr.VS.Font = VB6.FontChangeName(fr.VS.Font, "Arial")
		fr.VS.Font = VB6.FontChangeSize(fr.VS.Font, 7)
		fr.VS.Font = VB6.FontChangeBold(fr.VS.Font, True)
		lstrTamCol = "^15mm |<10mm  |<15mm     |<15mm   |<40mm              |^15mm  |^12mm  |^12mm|^9mm|<12mm|<80mm      |^12mm  |^15mm    |^15mm;"
		lstrTemp = "IdAgente|Ano    |Dt Inicial|Dt Final|Observação         |Mês/Ano|Classe |Zona |Livro|Conta|Consumidor|IdGrupo|Cancelado|Revisado"
		fr.VS.Table = lstrTamCol & lstrTemp
		fr.VS.Font = VB6.FontChangeBold(fr.VS.Font, False)
		Call LineFeed((fr.VS), 1)
		
		If Me.mshDados1.Rows > 1 Then
			For llngConta = 1 To Me.mshDados1.Rows - 1
				With Me.mshDados1
					llngIdAgente = CInt(.get_TextMatrix(llngConta, 1))
					llngAno = CInt(.get_TextMatrix(llngConta, 2))
					ldtDtInicial = CDate(.get_TextMatrix(llngConta, 3))
					ldtDtFinal = CDate(.get_TextMatrix(llngConta, 4))
					lstrObservacao = .get_TextMatrix(llngConta, 5)
					lstrMesAno = .get_TextMatrix(llngConta, 8)
					lstrCodClas = .get_TextMatrix(llngConta, 9)
					lstrZona = .get_TextMatrix(llngConta, 10)
					lstrLivro = .get_TextMatrix(llngConta, 11)
					lstrConta = .get_TextMatrix(llngConta, 12)
					lstrConsum = .get_TextMatrix(llngConta, 13)
					lstrGrupo = .get_TextMatrix(llngConta, 14)
					lstrCancelado = .get_TextMatrix(llngConta, 15)
					lstrRevisado = .get_TextMatrix(llngConta, 16)
					
					lstrTemp = llngIdAgente & "|" & llngAno & "|" & VB6.Format(ldtDtInicial, "dd/mm/yyyy") & "|" & VB6.Format(ldtDtFinal, "dd/mm/yyyy") & "|" & lstrObservacao & "|" & lstrMesAno & "|" & lstrCodClas & "|" & lstrZona & "|" & lstrLivro & "|" & lstrConta & "|" & lstrConsum & "|" & lstrGrupo & "|" & lstrCancelado & "|" & lstrRevisado
					fr.VS.Table = lstrTamCol & lstrTemp
					
					If fr.VS.CurrentLine > 830 Then
						fr.VS.NewPage()
						fr.VS.CurrentLine = 1
						Call Cabecalho_Relatorio((fr.VS), pstrTit1Cab, "", "3", False, "")
						fr.VS.MarginLeft = "7mm"
						fr.VS.Font = VB6.FontChangeName(fr.VS.Font, "Arial")
						fr.VS.Font = VB6.FontChangeSize(fr.VS.Font, 7)
						fr.VS.Font = VB6.FontChangeBold(fr.VS.Font, True)
						lstrTamCol = "^15mm |<10mm  |<15mm     |<15mm   |<40mm             |^15mm  |^12mm  |^12mm|^9mm |<12mm|<80mm      |^12mm  |^15mm    |^15mm;"
						lstrTemp = "IdAgente|Ano    |Dt Inicial|Dt Final|Observação        |Mês/Ano|Classe |Zona |Livro|Conta|Consumidor |IdGrupo|Cancelado|Revisado"
						fr.VS.Table = lstrTamCol & lstrTemp
						fr.VS.Font = VB6.FontChangeBold(fr.VS.Font, False)
						Call LineFeed((fr.VS), 1)
					End If
				End With
			Next llngConta
			
			fr.VS.MarginLeft = "7mm"
			fr.VS.Font = VB6.FontChangeName(fr.VS.Font, "Arial")
			fr.VS.Font = VB6.FontChangeSize(fr.VS.Font, 9)
			fr.VS.Font = VB6.FontChangeBold(fr.VS.Font, True)
			lstrTamCol = ">272mm;"
			lstrTemp = "Total de Registros: " & llngConta - 1
			fr.VS.Table = lstrTamCol & lstrTemp
			Call LineFeed((fr.VS), 1)
			
		End If
	End Sub
End Class