Option Strict Off
Option Explicit On
Module mdlOrdemServico
	Public Sub ReimprimirOS(ByVal astrProtocolo As String, ByRef acrpOS As AxCrystal.AxCrystalReport, ByRef acrpCarga As AxCrystal.AxCrystalReport, ByRef acrpCroqui As AxCrystal.AxCrystalReport, Optional ByVal alngCod As Integer = 0)
		'Dados da ordem de serviço
		Dim lstrSolServ_Zona As String
		Dim lstrSolServ_Livro As String
		Dim lstrSolServ_Conta As String
		Dim lstrSolServ_Rota As String
		Dim lstrSolServ_Grupo As String
		Dim lstrSolServ_Padrao As String
		Dim llngSolServ_SeqOs As Integer
		Dim llngSolServ_UnidId As Integer
		Dim lstrSolServ_NomeSol As String
		Dim lstrSolServ_CpfCnpj As String
		Dim lstrSolServ_DocSol As String
		Dim lstrSolServ_TelSol As String
		Dim lstrSolServ_DddTel As String
		Dim lstrSolServ_Celular As String
		Dim lstrSolServ_DddCel As String
		Dim lstrSolServ_PontoRefer As String
		Dim lstrSolServ_DescrServ As String
		Dim lstrSolServ_Prioridade As String
		Dim lstrSolServ_Regiao As String
		Dim lstrSolServ_ItensServ As String
		Dim ldteSolServ_Solicitacao As Date
		Dim lstrSolServ_HoraSol As String
		'Dados da unidade consumidora
		Dim lstrUnidade_Zona As String
		Dim lstrUnidade_Livro As String
		Dim lstrUnidade_Conta As String
		Dim lstrUnidade_Rota As String
		Dim lstrUnidade_Nome As String
		Dim lstrUnidade_CpfCnpj As String
		Dim lstrUnidade_InsEst As String
		Dim lstrUnidade_Rg As String
		Dim lstrUnidade_Endereco As String
		Dim lstrUnidade_Numero As String
		Dim lstrUnidade_Complemento As String
		Dim lstrUnidade_Quadra As String
		Dim lstrUnidade_Lote As String
		Dim lstrUnidade_Bairro As String
		Dim lstrUnidade_Municip As String
		Dim lstrUnidade_Fase As String
		Dim lstrUnidade_Classe As String
		Dim lstrUnidade_Ta As String
		Dim lstrUnidade_Situacao As String
		Dim llngUnidade_UnidId As Integer
		Dim llngUnidade_ConsId As Integer
		Dim lstrUnidade_TpLigacao As String
		Dim lstrUnidade_Medidor As String
		Dim lstrUnidade_FaseLig As String
		Dim llngUnidade_Medidor As Integer
		Dim lstrUnidade_Trafo As String
		'Dados da classe
		Dim lstrClasse_Descricao As String
		'Dados da descrição do código de serviço
		Dim lstrCodigos_Descricao As String
		'Controle vizinho eletrico
		Dim lstrUnidade_NomeAnt As String
		Dim lstrUnidade_MediAnt As String
		Dim lstrUnidade_NomePos As String
		Dim lstrUnidade_MediPos As String
		
		Dim lstrCriterio As String
		Dim lstrSql As String
		Dim lrstAux As ADODB.Recordset
		lrstAux = New ADODB.Recordset
		
		
		
		' ----- Apaga os dados da tabela temporária
		If Left(astrProtocolo, 2) <> "NO" Then
			lstrSql = "DELETE FROM temp_os WHERE nm_usuario = """ & gstrNmEstacao & """ "
		Else
			lstrSql = "DELETE FROM temp_ligacao WHERE nm_usuario = """ & gstrNmEstacao & """ "
		End If
		Call Executar(lstrSql)
		
		' ----- Busca os dados da tabela SolServ (solicitaçao de serviço)
		lstrSql = ""
		lstrSql = lstrSql & "SELECT `solserv`.`protocolo`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`cod`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`zlc`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`unid`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`unid_id`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`padrao`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`nomesol`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`cpf`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`docsol`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`telsol`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`dddtelsol`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`celsol`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`dddcelsol`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`ponto_refer`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`descr_serv`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`prioridade`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`zona_solic`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`itensserv`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`data_soli`, " & vbCrLf
		lstrSql = lstrSql & "       `solserv`.`hora_soli` " & vbCrLf
		lstrSql = lstrSql & "  FROM `solserv` " & vbCrLf
		lstrSql = lstrSql & " WHERE `solserv`.`protocolo` = '" & astrProtocolo & "' "
		If alngCod > 0 Then
			lstrSql = lstrSql & "   AND `solserv`.`cod` = " & alngCod & " "
		End If
		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"'
					lstrSolServ_Zona = Trim(IIf(IsDbNull(.Fields("zlc").value), "99999999999", .Fields("zlc").value))
					lstrSolServ_Livro = Mid(lstrSolServ_Zona, 3, 2)
					lstrSolServ_Conta = Right(lstrSolServ_Zona, 6)
					lstrSolServ_Zona = Left(lstrSolServ_Zona, 3)
					lstrSolServ_Rota = "99999999"
					'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"'
					lstrSolServ_Grupo = UCase(Left(Trim(IIf(IsDbNull(.Fields("unid").value), "B", .Fields("unid").value)), 1))
					'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"'
					lstrSolServ_Padrao = Trim(IIf(IsDbNull(.Fields("padrao").value), "Padrão", .Fields("padrao").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"'
					llngSolServ_SeqOs = CInt(IIf(IsDbNull(.Fields("cod").value), 0, .Fields("cod").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"'
					llngSolServ_UnidId = 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"'
					lstrSolServ_NomeSol = Trim(IIf(IsDbNull(.Fields("nomesol").value), "", .Fields("nomesol").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"'
					lstrSolServ_CpfCnpj = Str_Retira(Trim(IIf(IsDbNull(.Fields("cpf").value), "", .Fields("cpf").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"'
					lstrSolServ_DocSol = Trim(IIf(IsDbNull(.Fields("docsol").value), "", .Fields("docsol").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"'
					lstrSolServ_TelSol = Trim(IIf(IsDbNull(.Fields("telsol").value), "", .Fields("telsol").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"'
					lstrSolServ_DddTel = Trim(IIf(IsDbNull(.Fields("dddtelsol").value), "", .Fields("dddtelsol").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"'
					lstrSolServ_Celular = Trim(IIf(IsDbNull(.Fields("celsol").value), "", .Fields("celsol").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"'
					lstrSolServ_DddCel = Trim(IIf(IsDbNull(.Fields("dddcelsol").value), "", .Fields("dddcelsol").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"'
					lstrSolServ_PontoRefer = Trim(IIf(IsDbNull(.Fields("ponto_refer").value), "", .Fields("ponto_refer").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"'
					lstrSolServ_DescrServ = Trim(IIf(IsDbNull(.Fields("descr_serv").value), "", .Fields("descr_serv").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"'
					lstrSolServ_Prioridade = Trim(IIf(IsDbNull(.Fields("prioridade").value), "N", .Fields("prioridade").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"'
					lstrSolServ_Regiao = Trim(IIf(IsDbNull(.Fields("zona_solic").value), "U", .Fields("zona_solic").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"'
					lstrSolServ_ItensServ = Trim(IIf(IsDbNull(.Fields("itensserv").value), "0000000000?0;", .Fields("itensserv").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"'
					ldteSolServ_Solicitacao = CDate(IIf(IsDbNull(.Fields("data_soli").value), "1900-01-01", .Fields("data_soli").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"'
					lstrSolServ_HoraSol = Trim(IIf(IsDbNull(.Fields("hora_soli").value), "00:00:00", .Fields("hora_soli").value))
				End If
				Call .Close()
			End If
		End With
		' ----- FIM Busca os dados da tabela SolServ (solicitaçao de serviço)
		' ----- Busca dados da UndA ou UnidB
		lstrSql = ""
		lstrSql = lstrSql & "SELECT `unidade`.`zona`, "
		lstrSql = lstrSql & "       `unidade`.`livro`, "
		lstrSql = lstrSql & "       `unidade`.`conta`, "
		lstrSql = lstrSql & "       `unidade`.`rota`, "
		lstrSql = lstrSql & "       `unidade`.`nome`, "
		lstrSql = lstrSql & "       `unidade`.`cpf_cnpj`, "
		lstrSql = lstrSql & "       `unidade`.`insc`, "
		lstrSql = lstrSql & "       `unidade`.`rg`, "
		lstrSql = lstrSql & "       `unidade`.`end`, "
		lstrSql = lstrSql & "       `unidade`.`numero`, "
		lstrSql = lstrSql & "       `unidade`.`complement`, "
		lstrSql = lstrSql & "       `unidade`.`quadra`, "
		lstrSql = lstrSql & "       `unidade`.`lote`, "
		lstrSql = lstrSql & "       `unidade`.`bairro`, "
		lstrSql = lstrSql & "       `unidade`.`cidade`, "
		lstrSql = lstrSql & "       `unidade`.`fase`, "
		lstrSql = lstrSql & "       `unidade`.`clas`, "
		lstrSql = lstrSql & "       `unidade`.`ta`, "
		lstrSql = lstrSql & "       `unidade`.`situacao`, "
		lstrSql = lstrSql & "       `unidade`.`unid_id`, "
		lstrSql = lstrSql & "       `unidade`.`cons_id`, "
		lstrSql = lstrSql & "       `unidade`.`tp_ligacao`, "
		lstrSql = lstrSql & "       `unidade`.`instal`, "
		lstrSql = lstrSql & "       `unidade`.`idmedidor`, "
		If lstrSolServ_Grupo = "B" Then
			lstrSql = lstrSql & "       `unidade`.`num` AS `medidor`, "
			lstrSql = lstrSql & "       `unidade`.`faselig` AS `faselig` "
		Else
			lstrSql = lstrSql & "       `unidade`.`eletr` AS `medidor`, "
			lstrSql = lstrSql & "       'ABCN' AS `faselig` "
		End If
		lstrSql = lstrSql & "FROM `unid" & LCase(lstrSolServ_Grupo) & "` AS `unidade` "
		lstrSql = lstrSql & "WHERE `unidade`.`unid_id`  = " & llngSolServ_UnidId & " "
		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"'
					lstrUnidade_Zona = 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"'
					lstrUnidade_Livro = 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"'
					lstrUnidade_Conta = 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"'
					lstrUnidade_Rota = Trim(IIf(IsDbNull(.Fields("rota").value), "", .Fields("rota").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"'
					lstrUnidade_Nome = Trim(IIf(IsDbNull(.Fields("nome").value), "", .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"'
					lstrUnidade_CpfCnpj = Trim(IIf(IsDbNull(.Fields("cpf_cnpj").value), "", .Fields("cpf_cnpj").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"'
					lstrUnidade_InsEst = Trim(IIf(IsDbNull(.Fields("insc").value), "", .Fields("insc").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"'
					lstrUnidade_Rg = Trim(IIf(IsDbNull(.Fields("rg").value), "", .Fields("rg").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"'
					lstrUnidade_Endereco = Trim(IIf(IsDbNull(.Fields("end").value), "", .Fields("end").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"'
					lstrUnidade_Numero = Trim(IIf(IsDbNull(.Fields("numero").value), "", .Fields("numero").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"'
					lstrUnidade_Complemento = Trim(IIf(IsDbNull(.Fields("complement").value), "", .Fields("complement").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"'
					lstrUnidade_Quadra = Trim(IIf(IsDbNull(.Fields("quadra").value), "", .Fields("quadra").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"'
					lstrUnidade_Lote = Trim(IIf(IsDbNull(.Fields("lote").value), "", .Fields("lote").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"'
					lstrUnidade_Bairro = Trim(IIf(IsDbNull(.Fields("bairro").value), "", .Fields("bairro").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"'
					lstrUnidade_Municip = Trim(IIf(IsDbNull(.Fields("cidade").value), "", .Fields("cidade").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"'
					lstrUnidade_Fase = Trim(IIf(IsDbNull(.Fields("fase").value), "M", .Fields("fase").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"'
					lstrUnidade_Classe = Trim(IIf(IsDbNull(.Fields("clas").value), "0000", .Fields("clas").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"'
					lstrUnidade_Ta = Trim(IIf(IsDbNull(.Fields("ta").value), "01B100", .Fields("ta").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"'
					lstrUnidade_Situacao = Trim(IIf(IsDbNull(.Fields("situacao").value), "L", .Fields("situacao").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"'
					llngUnidade_UnidId = 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"'
					llngUnidade_ConsId = 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"'
					lstrUnidade_TpLigacao = Trim(IIf(IsDbNull(.Fields("tp_ligacao").value), "A", .Fields("tp_ligacao").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"'
					lstrUnidade_Medidor = Trim(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"'
					lstrUnidade_FaseLig = Trim(IIf(IsDbNull(.Fields("faselig").value), "AN", .Fields("faselig").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"'
					llngUnidade_Medidor = CInt(IIf(IsDbNull(.Fields("idmedidor").value), "0", .Fields("idmedidor").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"'
					lstrUnidade_Trafo = Trim(IIf(IsDbNull(.Fields("instal").value), "0000", .Fields("instal").value))
					If lstrUnidade_InsEst = "" Then lstrUnidade_InsEst = lstrUnidade_Rg
				Else
					lstrUnidade_Zona = lstrSolServ_Zona
					lstrUnidade_Livro = lstrSolServ_Livro
					lstrUnidade_Conta = lstrSolServ_Conta
					lstrUnidade_Rota = lstrSolServ_Rota
					lstrUnidade_Nome = lstrSolServ_NomeSol
					lstrUnidade_CpfCnpj = lstrSolServ_CpfCnpj
					lstrUnidade_InsEst = lstrSolServ_DocSol
					lstrUnidade_Rg = ""
					lstrUnidade_Endereco = lstrSolServ_PontoRefer
					lstrUnidade_Numero = ""
					lstrUnidade_Complemento = ""
					lstrUnidade_Quadra = ""
					lstrUnidade_Lote = ""
					lstrUnidade_Bairro = ""
					lstrUnidade_Municip = ""
					lstrUnidade_Fase = ""
					lstrUnidade_Classe = ""
					lstrUnidade_Ta = ""
					lstrUnidade_Situacao = ""
					llngUnidade_UnidId = 0
					llngUnidade_ConsId = 0
					lstrUnidade_TpLigacao = ""
					lstrUnidade_Medidor = ""
					lstrUnidade_FaseLig = ""
					llngUnidade_Medidor = 0
					lstrUnidade_Trafo = "0000"
				End If
				Call .Close()
			End If
		End With
		' ----- FIM Busca dados da UndA ou UnidB
		' ----- Busca a descrição da classe
		lstrSql = ""
		lstrSql = lstrSql & "SELECT `classe`.`codigo`, "
		lstrSql = lstrSql & "       `classe`.`descricao` "
		lstrSql = lstrSql & "  FROM `classe` "
		lstrSql = lstrSql & " WHERE `classe`.`codigo` = '" & lstrUnidade_Classe & "' "
		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"'
					lstrClasse_Descricao = Trim(IIf(IsDbNull(.Fields("descricao").value), "Atividade não encontrada", .Fields("descricao").value))
				End If
				Call .Close()
			End If
		End With
		' ----- Fim Busca a descrição da classe
		' ----- Busca a descrição do Serviço Solicitado
		lstrSql = ""
		lstrSql = lstrSql & "SELECT `codigos`.`num`, "
		lstrSql = lstrSql & "       `codigos`.`descri` "
		lstrSql = lstrSql & "  FROM `codigos` "
		lstrSql = lstrSql & " WHERE `codigos`.`num` = '" & Left(lstrSolServ_ItensServ, 10) & "' "
		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"'
					lstrCodigos_Descricao = Trim(IIf(IsDbNull(.Fields("descri").value), "Solicitação não encontrada", .Fields("descri").value))
				End If
				Call .Close()
			End If
		End With
		' ----- Fim Busca a descrição do Serviço Solicitado
		If Left(astrProtocolo, 2) <> "OE" Then
			' ----- Busca Consumidor Anterior e Posterior
			lstrSql = ""
			lstrSql = lstrSql & "SELECT  "
			lstrSql = lstrSql & "       `unidade`.`nome`, "
			If lstrSolServ_Grupo = "B" Then
				lstrSql = lstrSql & "       `unidade`.`num` AS `medidor` "
			Else
				lstrSql = lstrSql & "       `unidade`.`eletr` AS `medidor` "
			End If
			lstrSql = lstrSql & "  FROM `unid" & LCase(lstrSolServ_Grupo) & "` AS `unidade` "
			lstrSql = lstrSql & " WHERE RIGHT(`unidade`.`rota`, 6) in(" & CDbl(Right(lstrUnidade_Rota, 6)) - 1 & " , " & CDbl(Right(lstrUnidade_Rota, 6)) + 1 & ") "
			lstrSql = lstrSql & " ORDER BY RIGHT(rota, 6) ASC"
			Call Conectar(lstrSql, lrstAux)
			With lrstAux
				If .State = ADODB.ObjectStateEnum.adStateOpen Then
					If .RecordCount > 0 Then
						' ----- Pega o Anterior
						'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"'
						lstrUnidade_NomeAnt = Trim(IIf(IsDbNull(.Fields("nome").value), "", .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"'
						lstrUnidade_MediAnt = Trim(IIf(IsDbNull(.Fields("medidor").value), "", .Fields("medidor").value))
						' ----- Pega o Posterior
						If .RecordCount > 1 Then
							Call .MoveNext()
							'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"'
							lstrUnidade_NomePos = Trim(IIf(IsDbNull(.Fields("nome").value), "", .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"'
							lstrUnidade_MediPos = Trim(IIf(IsDbNull(.Fields("medidor").value), "", .Fields("medidor").value))
						End If
					End If
					Call .Close()
				End If
			End With
			' ----- Fim Busca Consumidor Anterior e Posterior
		Else
			lstrUnidade_NomeAnt = ""
			lstrUnidade_MediAnt = ""
			lstrUnidade_NomePos = ""
			lstrUnidade_MediPos = ""
		End If
		If Left(astrProtocolo, 2) <> "NO" Then
			lstrSql = "INSERT INTO temp_os SET "
			lstrSql = lstrSql & "            nm_usuario     = """ & gstrNmEstacao & """, "
			lstrSql = lstrSql & "            protocolo      = """ & astrProtocolo & """, "
			lstrSql = lstrSql & "            zona           = """ & lstrUnidade_Zona & """, "
			lstrSql = lstrSql & "            livro          = """ & lstrUnidade_Livro & """, "
			lstrSql = lstrSql & "            conta          = """ & lstrUnidade_Conta & """, "
			lstrSql = lstrSql & "            rota           = """ & lstrUnidade_Rota & """, "
			lstrSql = lstrSql & "            unid_id        = """ & llngSolServ_UnidId & """, "
			lstrSql = lstrSql & "            nome           = """ & lstrUnidade_Nome & """, "
			lstrSql = lstrSql & "            endereco       = """ & Right(lstrUnidade_Endereco & IIf(lstrUnidade_Numero <> "", ", " & lstrUnidade_Numero, "") & IIf(lstrUnidade_Complemento <> "", " - " & lstrUnidade_Complemento, "") & IIf(lstrUnidade_Quadra <> "", " Q: " & lstrUnidade_Quadra, "") & IIf(lstrUnidade_Lote <> "", " L: " & lstrUnidade_Lote, ""), 255) & """, "
			lstrSql = lstrSql & "            bairro         = """ & lstrUnidade_Bairro & """, "
			lstrSql = lstrSql & "            cidade         = """ & lstrUnidade_Municip & """, "
			lstrSql = lstrSql & "            telefone       = """ & lstrSolServ_TelSol & """, "
			lstrSql = lstrSql & "            telefone_ddd   = """ & lstrSolServ_DddTel & """, "
			lstrSql = lstrSql & "            celular        = """ & lstrSolServ_Celular & """, "
			lstrSql = lstrSql & "            celular_ddd    = """ & lstrSolServ_DddCel & """, "
			lstrSql = lstrSql & "            cpf            = """ & lstrUnidade_CpfCnpj & ""","
			lstrSql = lstrSql & "            ie             = """ & lstrUnidade_InsEst & """, "
			lstrSql = lstrSql & "            ponto_refer    = """ & lstrSolServ_PontoRefer & """, "
			lstrSql = lstrSql & "            medidor        = """ & lstrUnidade_Medidor & """, "
			lstrSql = lstrSql & "            classe         = """ & lstrUnidade_Classe & """, "
			lstrSql = lstrSql & "            ta             = """ & lstrUnidade_Ta & """, "
			lstrSql = lstrSql & "            fase           = """ & lstrUnidade_Fase & """, "
			lstrSql = lstrSql & "            faselig        = """ & lstrUnidade_FaseLig & """, "
			lstrSql = lstrSql & "            atividade      = """ & lstrClasse_Descricao & """, "
			lstrSql = lstrSql & "            servsol        = """ & lstrCodigos_Descricao & """,  "
			lstrSql = lstrSql & "            descr_serv     = """ & lstrSolServ_DescrServ & """, "
			lstrSql = lstrSql & "            prioridade     = """ & lstrSolServ_Prioridade & """, "
			lstrSql = lstrSql & "            zona_serv      = """ & lstrSolServ_Regiao & """ , "
			lstrSql = lstrSql & "            atendente      = """ & gstrUsuario_Nome & """, "
			lstrSql = lstrSql & "            data_soli      = """ & VB6.Format(ldteSolServ_Solicitacao, "yyyy-MM-dd") & """, "
			lstrSql = lstrSql & "            hora_soli      = """ & VB6.Format(lstrSolServ_HoraSol, "hh:mm:ss") & """, "
			lstrSql = lstrSql & "            nome_soli      = """ & lstrSolServ_NomeSol & """, "
			lstrSql = lstrSql & "            rg_soli        = """ & lstrSolServ_DocSol & """, "
			lstrSql = lstrSql & "            situacao       = """ & lstrUnidade_Situacao & """, "
			lstrSql = lstrSql & "            nomeant        = """ & lstrUnidade_NomeAnt & """, "
			lstrSql = lstrSql & "            medant         = """ & lstrUnidade_MediAnt & """, "
			lstrSql = lstrSql & "            nomepos        = """ & lstrUnidade_NomePos & """, "
			lstrSql = lstrSql & "            medpos         = """ & lstrUnidade_MediPos & ""","
			lstrSql = lstrSql & "            padrao         = """ & lstrSolServ_Padrao & """, "
			lstrSql = lstrSql & "            tp_ligacao     = """ & lstrUnidade_TpLigacao & """, "
			lstrSql = lstrSql & "            instal         = """ & lstrUnidade_Trafo & """, "
			lstrSql = lstrSql & "            idmedidor      = """ & llngUnidade_Medidor & """, "
			lstrSql = lstrSql & "            seq            = """ & llngSolServ_SeqOs & """ "
			Call Executar(lstrSql)
		Else
			Call ImprimeSolicitacao(llngUnidade_ConsId, llngUnidade_UnidId, astrProtocolo, lstrSolServ_Grupo, lstrClasse_Descricao)
		End If
		' ----- Chama o relatório em Crystal Reports
		With acrpOS
			If Left(astrProtocolo, 2) = "NO" Then
				lstrCriterio = "{temp_ligacao.nm_usuario} = """ & gstrNmEstacao & """"
				.ReportFileName = My.Application.Info.DirectoryPath & "\" & LeConfig("DIR_RPT") & LeConfig("MOVIMENTACAO_CAD")
			Else
				lstrCriterio = "{temp_os.nm_usuario} = """ & gstrNmEstacao & """ "
				.ReportFileName = My.Application.Info.DirectoryPath & "\" & LeConfig("DIR_RPT") & LeConfig("REL_OS")
			End If
			.DiscardSavedData = True
			.WindowState = Crystal.WindowStateConstants.crptMaximized
			.WindowControlBox = True
			.WindowControls = True
			.WindowShowPrintSetupBtn = True
			.WindowShowCloseBtn = True
			.WindowShowSearchBtn = True
			.SelectionFormula = lstrCriterio
			.WindowTitle = "Vizualização da ordem de serviço"
			.Destination = Crystal.DestinationConstants.crptToWindow
			.Action = 0
		End With
		With acrpCarga
			If Left(astrProtocolo, 2) = "NO" Then
				lstrCriterio = "{temp_ligacao.nm_usuario} = """ & gstrNmEstacao & """"
				.ReportFileName = My.Application.Info.DirectoryPath & "\" & LeConfig("DIR_RPT") & LeConfig("MOVIMENTACAO_CAD_CARGA")
			Else
				.ReportFileName = My.Application.Info.DirectoryPath & "\" & LeConfig("DIR_RPT") & LeConfig("REL_OS_CARGA")
				lstrCriterio = "{temp_os.nm_usuario} = """ & gstrNmEstacao & """ "
			End If
			.DiscardSavedData = True
			.WindowState = Crystal.WindowStateConstants.crptMaximized
			.WindowControlBox = True
			.WindowControls = True
			.WindowShowPrintSetupBtn = True
			.WindowShowCloseBtn = True
			.WindowShowSearchBtn = True
			.SelectionFormula = lstrCriterio
			.WindowTitle = "Vizualização da ordem de serviço - carga instalada"
			.Destination = Crystal.DestinationConstants.crptToWindow
			.Action = 0
		End With
		' ----- Chama o report de movimentaçao de cadastro
		If PegaFlgMedidorServico(Left(lstrSolServ_ItensServ, 10)) Then
			With acrpCroqui
				.ReportFileName = My.Application.Info.DirectoryPath & "\" & LeConfig("DIR_RPT") & LeConfig("FICHA_MEDIDOR")
				.DiscardSavedData = True
				.WindowState = Crystal.WindowStateConstants.crptMaximized
				.WindowControlBox = True
				.WindowControls = True
				.SelectionFormula = "{solserv.protocolo} = """ & astrProtocolo & """ AND {solserv.cod} = " & alngCod & " "
				.WindowShowPrintSetupBtn = True
				.WindowShowCloseBtn = True
				.WindowShowSearchBtn = True
				.WindowTitle = "Dados do Medidor"
				.Destination = Crystal.DestinationConstants.crptToWindow
				.Action = 0
			End With
		End If
		' ----- Fim Chama o relatório em Crystal Reports
	End Sub
	
	
	Private Sub ImprimeSolicitacao(ByVal alngConsId As Integer, ByVal alngUnidId As Integer, ByVal astrProtocolo As String, ByVal astrGrupo As String, ByVal astrDescClasse As String)
		'Consumidor e UC
		Dim lstrZona As String
		Dim lstrLivro As String
		Dim lstrConta As String
		Dim lstrNome As String
		Dim lstrClasse As String
		Dim lstrNmClasse As String
		Dim lstrSubclasse As String
		Dim lstrGrTar As String
		Dim lstrFase As String
		Dim lstrDiaVenc As String
		Dim lstrTensao As String
		Dim lstrDisjuntor As String
		Dim lstrArea As String
		Dim lstrNascto As String
		Dim lstrCip As String
		Dim ldblCarga As Double
		Dim lstrTelefone As String
		Dim lstrDDDTel As String
		Dim lstrCelular As String
		Dim lstrDDDCel As String
		Dim lstrCpfCnpj As String
		Dim lstrRg As String
		Dim lstrInsc As String
		Dim lstrNmPai As String
		Dim lstrNmMae As String
		Dim lstrEndUc As String
		Dim lstrNumUc As String
		Dim lstrComUc As String
		Dim lstrBaiUc As String
		Dim lstrCidUc As String
		Dim lstrCepUc As String
		Dim lstrUfUc As String
		Dim lstrDisUc As String
		Dim lstrQuaUc As String
		Dim lstrLotUc As String
		Dim lstrEndEnt As String
		Dim lstrNumEnt As String
		Dim lstrComEnt As String
		Dim lstrBaiEnt As String
		Dim lstrCidEnt As String
		Dim lstrCepEnt As String
		Dim lstrUfEnt As String
		Dim lstrDisEnt As String
		Dim lstrMedidor As String
		Dim llngMedidor As Integer
		Dim lstrTrafo As String
		'OS
		Dim ldteSolicit As Date
		Dim ldteHoraSol As Date
		Dim lstrTpServico As String
		Dim lstrAtendente As String
		Dim lstrNmSolicit As String
		Dim lstrDocSolic As String
		Dim lstrSitSolic As String
		Dim llngSequencia As Integer
		'Regras de ICMS
		Dim ldblAliq1 As Double
		Dim ldblAliq2 As Double
		Dim ldblLimResid As Double
		Dim ldblLimRural As Double
		Dim lstrRegrasIcm As String
		'Carga
		Dim lstrLinCarga As String
		'Consultas
		Dim lstrSql As String
		Dim lstrCriterio As String
		Dim lrstConsum As ADODB.Recordset
		Dim lrstUnidade As ADODB.Recordset
		Dim lrstSolServ As ADODB.Recordset
		
		lrstConsum = New ADODB.Recordset
		lrstUnidade = New ADODB.Recordset
		lrstSolServ = New ADODB.Recordset
		
		ldblLimResid = CDbl(LeConfig("LIMITE_RESIDENCIAL"))
		ldblLimRural = CDbl(LeConfig("LIMITE_RURAL"))
		
		lstrSql = "SELECT * " & "  FROM consum " & " WHERE consreg = " & alngConsId & " " & " LIMIT 1 "
		Call Conectar(lstrSql, lrstConsum)
		If lrstConsum.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"'
			lstrDDDTel = IIf(IsDbNull(lrstConsum.Fields("dddtel").value), "", lrstConsum.Fields("dddtel").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"'
			lstrTelefone = IIf(IsDbNull(lrstConsum.Fields("telefone").value), "", lrstConsum.Fields("telefone").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"'
			lstrDDDCel = IIf(IsDbNull(lrstConsum.Fields("dddcel").value), "", lrstConsum.Fields("dddcel").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"'
			lstrCelular = IIf(IsDbNull(lrstConsum.Fields("cel").value), "", lrstConsum.Fields("cel").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"'
			lstrNascto = IIf(IsDbNull(lrstConsum.Fields("dt_nascto").value), "", lrstConsum.Fields("dt_nascto").value)
			lstrSql = "SELECT * " & "  FROM unid" & LCase(astrGrupo) & " WHERE cons_id = " & alngConsId & " " & "   AND unid_id = " & alngUnidId & " " & " LIMIT 1 "
			Call Conectar(lstrSql, lrstUnidade)
			If lrstUnidade.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"'
				lstrZona = IIf(IsDbNull(lrstUnidade.Fields("zona").value), "000", lrstUnidade.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 = IIf(IsDbNull(lrstUnidade.Fields("livro").value), "00", lrstUnidade.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 = IIf(IsDbNull(lrstUnidade.Fields("conta").value), "000000", lrstUnidade.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"'
				lstrNome = IIf(IsDbNull(lrstUnidade.Fields("nome").value), "", lrstUnidade.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"'
				lstrEndUc = IIf(IsDbNull(lrstUnidade.Fields("end").value), "", lrstUnidade.Fields("end").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"'
				lstrNumUc = IIf(IsDbNull(lrstUnidade.Fields("numero").value), "", lrstUnidade.Fields("numero").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"'
				lstrComUc = IIf(IsDbNull(lrstUnidade.Fields("complement").value), "", lrstUnidade.Fields("complement").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"'
				lstrBaiUc = IIf(IsDbNull(lrstUnidade.Fields("bairro").value), "", lrstUnidade.Fields("bairro").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"'
				lstrCidUc = IIf(IsDbNull(lrstUnidade.Fields("cidade").value), "", lrstUnidade.Fields("cidade").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"'
				lstrCepUc = IIf(IsDbNull(lrstUnidade.Fields("cep").value), "", lrstUnidade.Fields("cep").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"'
				lstrUfUc = IIf(IsDbNull(lrstUnidade.Fields("uf").value), "", lrstUnidade.Fields("uf").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"'
				lstrDisUc = IIf(IsDbNull(lrstUnidade.Fields("distrito").value), "", lrstUnidade.Fields("distrito").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"'
				lstrQuaUc = IIf(IsDbNull(lrstUnidade.Fields("quadra").value), "", lrstUnidade.Fields("quadra").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"'
				lstrLotUc = IIf(IsDbNull(lrstUnidade.Fields("lote").value), "", lrstUnidade.Fields("lote").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"'
				lstrEndEnt = IIf(IsDbNull(lrstUnidade.Fields("end_entrega").value), "", lrstUnidade.Fields("end_entrega").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"'
				lstrNumEnt = IIf(IsDbNull(lrstUnidade.Fields("num_entrega").value), "", lrstUnidade.Fields("num_entrega").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"'
				lstrComEnt = IIf(IsDbNull(lrstUnidade.Fields("compl_entrega").value), "", lrstUnidade.Fields("compl_entrega").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"'
				lstrBaiEnt = IIf(IsDbNull(lrstUnidade.Fields("bai_entrega").value), "", lrstUnidade.Fields("bai_entrega").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"'
				lstrCidEnt = IIf(IsDbNull(lrstUnidade.Fields("cid_entrega").value), "", lrstUnidade.Fields("cid_entrega").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"'
				lstrCepEnt = IIf(IsDbNull(lrstUnidade.Fields("cep_entrega").value), "", lrstUnidade.Fields("cep_entrega").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"'
				lstrUfEnt = IIf(IsDbNull(lrstUnidade.Fields("uf_entrega").value), "", lrstUnidade.Fields("uf_entrega").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"'
				lstrDisEnt = IIf(IsDbNull(lrstUnidade.Fields("dis_entrega").value), "", lrstUnidade.Fields("dis_entrega").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"'
				lstrCpfCnpj = IIf(IsDbNull(lrstConsum.Fields("cgc").value), "", lrstConsum.Fields("cgc").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"'
				lstrRg = IIf(IsDbNull(lrstConsum.Fields("rg").value), "", lrstConsum.Fields("rg").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"'
				lstrInsc = IIf(IsDbNull(lrstConsum.Fields("insc").value), "", lrstConsum.Fields("insc").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"'
				lstrNmPai = IIf(IsDbNull(lrstConsum.Fields("nomepai").value), "", lrstConsum.Fields("nomepai").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"'
				lstrNmMae = IIf(IsDbNull(lrstConsum.Fields("nomemae").value), "", lrstConsum.Fields("nomemae").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(lrstUnidade.Fields("num").value), "", lrstUnidade.Fields("num").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"'
				llngMedidor = CInt(IIf(IsDbNull(lrstUnidade.Fields("idmedidor").value), 0, lrstUnidade.Fields("idmedidor").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"'
				lstrTrafo = IIf(IsDbNull(lrstUnidade.Fields("instal").value), "0000", lrstUnidade.Fields("instal").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"'
				lstrClasse = IIf(IsDbNull(lrstUnidade.Fields("clas").value), "0000", lrstUnidade.Fields("clas").value)
				ldblAliq2 = MdCalculosGrupoB.Aliquota_ICMS(gstrEmpresa_UF, 9999999, lstrClasse, gDtBcoDados)
				Select Case Left(lstrClasse, 1)
					Case Is < CStr(4)
						lstrNmClasse = "INDUSTRIAL"
						lstrRegrasIcm = "Industrial " & ldblAliq2 & "%"
					Case Is = CStr(4)
						lstrNmClasse = "COMERCIAL"
						lstrRegrasIcm = "Comercial " & ldblAliq2 & "%"
					Case Is = CStr(5)
						lstrNmClasse = "RURAL"
						ldblAliq1 = MdCalculosGrupoB.Aliquota_ICMS(gstrEmpresa_UF, ldblLimRural, lstrClasse, gDtBcoDados)
						lstrRegrasIcm = "Rural até " & ldblLimRural & " kWh: " & ldblAliq1 & "%, Acima : " & ldblAliq2 & "%."
					Case Is = CStr(6)
						If CDbl(Left(lstrClasse, 2)) = 61 Then
							lstrNmClasse = "PODER PÚBLICO MUNICIPAL"
							lstrRegrasIcm = "Poder Publico Municipal: " & ldblAliq2 & "%"
						ElseIf CDbl(Left(lstrClasse, 2)) = 62 Then 
							lstrNmClasse = "PODER PÚBLICO ESTADUAL"
							lstrRegrasIcm = "Poder Publico Estdual: Isento "
						ElseIf CDbl(Left(lstrClasse, 2)) = 63 Then 
							lstrNmClasse = "PODER PÚBLICO FEDERAL"
							lstrRegrasIcm = "Poder Publico Federal: " & ldblAliq2 & "%"
						ElseIf CDbl(Left(lstrClasse, 2)) = 64 Then 
							lstrNmClasse = "ILUMINAÇÃO PÚBLICA"
							lstrRegrasIcm = "Iluminação  " & ldblAliq2 & "%"
						End If
					Case Is = CStr(7)
						lstrNmClasse = "SERVIÇO PÚBLICO"
						lstrRegrasIcm = "Serviço Publico " & ldblAliq2 & "%"
					Case Is = CStr(8)
						lstrNmClasse = "CONSUMO PRÓPRIO"
						lstrRegrasIcm = "Consumo Próprio " & ldblAliq2 & "%"
					Case Is = CStr(9)
						lstrNmClasse = "RESIDENCIAL"
						ldblAliq1 = MdCalculosGrupoB.Aliquota_ICMS(gstrEmpresa_UF, ldblLimResid, lstrClasse, gDtBcoDados)
						lstrRegrasIcm = "Residencial até " & ldblLimResid & " kWh: " & ldblAliq1 & "%, Acima : " & ldblAliq2 & "%."
				End Select
				lstrSubclasse = astrDescClasse
				'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"'
				lstrGrTar = Mid(IIf(IsDbNull(lrstUnidade.Fields("ta").value), "01B1", lrstUnidade.Fields("ta").value), 3, 2)
				'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
				lstrFase = IIf(IsDbNull(lrstUnidade.Fields("fase").value), "M", lrstUnidade.Fields("fase").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"'
				lstrDiaVenc = VB6.Format(IIf(IsDbNull(lrstUnidade.Fields("diavenc").value), "0", lrstUnidade.Fields("diavenc").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"'
				lstrTensao = IIf(IsDbNull(lrstUnidade.Fields("tensao").value), "", lrstUnidade.Fields("tensao").value)
				If astrGrupo = "B" 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"'
					lstrDisjuntor = IIf(IsDbNull(lrstUnidade.Fields("disjuntor").value), "", lrstUnidade.Fields("disjuntor").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"'
					lstrArea = IIf(IsDbNull(lrstUnidade.Fields("area").value), "", lrstUnidade.Fields("area").value)
				Else
					lstrDisjuntor = ""
					lstrArea = ""
				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"'
				lstrCip = IIf(IsDbNull(lrstUnidade.Fields("ilum").value), "N", lrstUnidade.Fields("ilum").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"'
				ldblCarga = IIf(IsDbNull(lrstUnidade.Fields("carga").value), 0, lrstUnidade.Fields("carga").value)
				lstrSql = "SELECT * " & "  FROM solserv " & " WHERE protocolo = """ & astrProtocolo & """ " & " LIMIT 1 "
				Call Conectar(lstrSql, lrstSolServ)
				If lrstSolServ.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"'
					llngSequencia = IIf(IsDbNull(lrstSolServ.Fields("cod").value), 0, lrstSolServ.Fields("cod").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"'
					ldteSolicit = IIf(IsDbNull(lrstSolServ.Fields("data_soli").value), "", lrstSolServ.Fields("data_soli").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"'
					ldteHoraSol = IIf(IsDbNull(lrstSolServ.Fields("hora_soli").value), "", lrstSolServ.Fields("hora_soli").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"'
					lstrTpServico = IIf(IsDbNull(lrstSolServ.Fields("descr_serv").value), "", lrstSolServ.Fields("descr_serv").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"'
					lstrAtendente = IIf(IsDbNull(lrstSolServ.Fields("atendente").value), "", lrstSolServ.Fields("atendente").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"'
					lstrNmSolicit = IIf(IsDbNull(lrstSolServ.Fields("nomesol").value), "", lrstSolServ.Fields("nomesol").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"'
					lstrDocSolic = IIf(IsDbNull(lrstSolServ.Fields("docsol").value), "", lrstSolServ.Fields("docsol").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"'
					lstrSitSolic = IIf(IsDbNull(lrstSolServ.Fields("sit").value), "A", lrstSolServ.Fields("sit").value)
					lstrLinCarga = ""
					lstrSql = "DELETE FROM temp_ligacao WHERE nm_usuario     = """ & gstrNmEstacao & """ "
					Call Executar(lstrSql)
					lstrSql = ""
					lstrSql = lstrSql & "INSERT INTO temp_ligacao "
					lstrSql = lstrSql & "        SET nm_usuario     = """ & gstrNmEstacao & """, "
					lstrSql = lstrSql & "            zona           = """ & lstrZona & """, "
					lstrSql = lstrSql & "            livro          = """ & lstrLivro & """, "
					lstrSql = lstrSql & "            conta          = """ & lstrConta & """, "
					lstrSql = lstrSql & "            unid_id        = """ & alngUnidId & """, "
					lstrSql = lstrSql & "            nome           = """ & lstrNome & """, "
					lstrSql = lstrSql & "            endereco       = """ & lstrEndUc & """, "
					lstrSql = lstrSql & "            numero         = """ & lstrNumUc & """, "
					lstrSql = lstrSql & "            complem        = """ & lstrComUc & ""","
					lstrSql = lstrSql & "            bairro         = """ & lstrBaiUc & """, "
					lstrSql = lstrSql & "            cidade         = """ & lstrCidUc & """, "
					lstrSql = lstrSql & "            cep            = """ & lstrCepUc & """, "
					lstrSql = lstrSql & "            telefone       = """ & lstrDDDTel & "-" & lstrTelefone & "     " & lstrDDDCel & "-" & lstrCelular & """, "
					lstrSql = lstrSql & "            cpf            = """ & lstrCpfCnpj & ""","
					lstrSql = lstrSql & "            ie             = """ & IIf(Len(lstrCpfCnpj) = 14, lstrInsc, lstrRg) & """, "
					lstrSql = lstrSql & "            filiacao       = """ & lstrNmPai & " - " & lstrNmMae & """, "
					lstrSql = lstrSql & "            datanasc       = """ & VB6.Format(IIf(Len(lstrNascto) > 0, lstrNascto, "0000-00-00"), "yyyy-MM-dd") & """, "
					lstrSql = lstrSql & "            classe         = """ & lstrNmClasse & """, "
					lstrSql = lstrSql & "            subclasse      = """ & lstrSubclasse & """, "
					lstrSql = lstrSql & "            ta             = """ & lstrGrTar & """, "
					lstrSql = lstrSql & "            fase           = """ & lstrFase & """, "
					lstrSql = lstrSql & "            tensao         = """ & lstrTensao & """, "
					lstrSql = lstrSql & "            diavenc        = """ & lstrDiaVenc & """, "
					lstrSql = lstrSql & "            disjuntor      = """ & lstrDisjuntor & """, "
					lstrSql = lstrSql & "            area           = """ & lstrArea & """, "
					lstrSql = lstrSql & "            aliqicms       = """ & lstrRegrasIcm & """, "
					lstrSql = lstrSql & "            IlumPublica    = """ & IIf(lstrCip = "N", "NORMAL", "NÃO COBRAR ") & """, "
					lstrSql = lstrSql & "            nrnis          = """ & " " & """, "
					lstrSql = lstrSql & "            equip_instalado = """ & lstrLinCarga & """, "
					lstrSql = lstrSql & "            carga           = """ & Replace(CStr(ldblCarga), ",", ".") & """, "
					lstrSql = lstrSql & "            endent         = """ & lstrEndEnt & """, "
					lstrSql = lstrSql & "            nrent          = """ & lstrNumEnt & """, "
					lstrSql = lstrSql & "            bairroent      = """ & lstrBaiEnt & """, "
					lstrSql = lstrSql & "            cidadeent      = """ & lstrCidEnt & """, "
					lstrSql = lstrSql & "            cepent         = """ & lstrCepEnt & """, "
					lstrSql = lstrSql & "            complement     = """ & lstrComEnt & ""","
					lstrSql = lstrSql & "            seq            = """ & llngSequencia & """, "
					lstrSql = lstrSql & "            protocolo      = """ & astrProtocolo & """, "
					lstrSql = lstrSql & "            data_soli      = """ & VB6.Format(ldteSolicit, "yyyy-MM-dd") & """, "
					lstrSql = lstrSql & "            horapedido     = """ & VB6.Format(ldteHoraSol, "HH:MM:SS") & """, "
					lstrSql = lstrSql & "            servsol        = """ & lstrTpServico & """, "
					lstrSql = lstrSql & "            descr_serv     = """ & "---" & """, "
					lstrSql = lstrSql & "            nome_soli      = """ & IIf(Len(lstrNmSolicit) > 0, lstrNmSolicit, lstrNome) & """, "
					lstrSql = lstrSql & "            rg_soli        = """ & IIf(Len(lstrNmSolicit) > 0, " ", lstrDocSolic) & """, "
					lstrSql = lstrSql & "            situacao       = """ & lstrSitSolic & """, "
					lstrSql = lstrSql & "            medidor       = """ & lstrMedidor & """, "
					lstrSql = lstrSql & "            instal        = """ & lstrTrafo & """, "
					lstrSql = lstrSql & "            idmedidor     = """ & llngMedidor & """, "
					lstrSql = lstrSql & "            atendente      = """ & gstrUsuario_Nome & """ "
					Call Executar(lstrSql)
				End If
				If lrstSolServ.State = 1 Then lrstSolServ.Close()
			End If
			If lrstUnidade.State = 1 Then lrstUnidade.Close()
		End If
		If lrstConsum.State = 1 Then lrstConsum.Close()
		'UPGRADE_NOTE: Object lrstSolServ 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"'
		lrstSolServ = Nothing
		'UPGRADE_NOTE: Object lrstUnidade 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"'
		lrstUnidade = Nothing
		'UPGRADE_NOTE: Object lrstConsum 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"'
		lrstConsum = Nothing
	End Sub
	
	Public Function PegaFlgMedidorServico(ByVal astrCodigo As String) As Boolean
		Dim lblnRet As Boolean
		Dim lstrFme As String
		Dim lstrSql As String
		Dim lrstAux As ADODB.Recordset
		lrstAux = New ADODB.Recordset
		lstrSql = ""
		lstrSql = lstrSql & "  SELECT `codigos`.`num`, "
		lstrSql = lstrSql & "         `codigos`.`descri`, "
		lstrSql = lstrSql & "         `codigos`.`flgmedidor` "
		lstrSql = lstrSql & "    FROM `codigos` "
		lstrSql = lstrSql & "   WHERE `codigos`.`num` = '" & astrCodigo & "' "
		lstrSql = lstrSql & "     AND `situacao` = 'A' AND `flgproc` = 'O' "
		lstrSql = lstrSql & "   LIMIT 0, 1 "
		Call Conectar(lstrSql, lrstAux)
		With lrstAux
			If .State = ADODB.ObjectStateEnum.adStateOpen Then
				If .RecordCount > 0 Then
					'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
					lstrFme = Trim(IIf(IsDbNull(.Fields("flgmedidor").value), "N", .Fields("flgmedidor").value))
					lblnRet = (lstrFme = "S")
				Else
					lblnRet = False
				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
		PegaFlgMedidorServico = lblnRet
	End Function
End Module