Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class FrmSolicAbert
	Inherits System.Windows.Forms.Form
	
	Private strSql As String
	Private strfiltro As String
	Private istrTamCol As String
	Private istrCabCol As String
	Private ifrmSServ As FrmRelatorio
	
	Private Sub FormaGridSS()
		Dim lintAux As Short
		With msfgSolServ
			Call .Clear()
			.Rows = 1
			.set_ColWidth(0, 1200)
			.set_ColWidth(1, 0)
			.set_ColWidth(2, 1400)
			.set_ColWidth(3, 1200)
			.set_ColWidth(4, 3050)
			.set_ColWidth(5, 1000)
			.set_ColWidth(6, 2900)
			For lintAux = 7 To 42
				.set_ColWidth(lintAux, 0)
			Next lintAux
			.set_TextMatrix(0, 0, "Identificação")
			.set_TextMatrix(0, 1, "Código")
			.set_TextMatrix(0, 2, "Protocolo")
			.set_TextMatrix(0, 3, "Data Solicitação")
			.set_TextMatrix(0, 4, "Descrição do Serviço")
			.set_TextMatrix(0, 5, "Valor (R$)")
			.set_TextMatrix(0, 6, "Consumidor")
			.set_TextMatrix(0, 7, "Unid_ID")
			.set_TextMatrix(0, 8, "Grupo")
			.set_TextMatrix(0, 9, "Data Conclusão")
			.set_TextMatrix(0, 10, "Hora Solicitação")
			.set_TextMatrix(0, 11, "Hora Conclusão")
			.set_TextMatrix(0, 12, "Prioridade")
			.set_TextMatrix(0, 13, "Feito Por")
			.set_TextMatrix(0, 14, "Região")
			.set_TextMatrix(0, 15, "Situação")
			.set_TextMatrix(0, 16, "Descrição Serviço")
			.set_TextMatrix(0, 17, "Nome Unidade")
			.set_TextMatrix(0, 18, "Fase")
			.set_TextMatrix(0, 19, "Classe")
			'Endereço da U.C.
			.set_TextMatrix(0, 20, "UF")
			.set_TextMatrix(0, 21, "CEP")
			.set_TextMatrix(0, 22, "Cidade")
			.set_TextMatrix(0, 23, "Distrito")
			.set_TextMatrix(0, 24, "Bairro")
			.set_TextMatrix(0, 25, "Endereco")
			.set_TextMatrix(0, 26, "Número")
			.set_TextMatrix(0, 27, "Complemento")
			'Outros Dados
			.set_TextMatrix(0, 28, "Documento Sol.")
			.set_TextMatrix(0, 29, "DDD Tel.Sol.")
			.set_TextMatrix(0, 30, "Telefone Sol.")
			.set_TextMatrix(0, 31, "DDD Cel.Sol.")
			.set_TextMatrix(0, 32, "Celular Sol.")
			.set_TextMatrix(0, 33, "Ponto Refer.")
			.set_TextMatrix(0, 34, "Atendente")
			.set_TextMatrix(0, 35, "Executado")
			.set_TextMatrix(0, 36, "Cpf Sol.")
			.set_TextMatrix(0, 37, "Cód. Exec.")
			.set_TextMatrix(0, 38, "Padrão")
			.set_TextMatrix(0, 39, "Tp. Ligação")
			.set_TextMatrix(0, 40, "Cód. O.S. de Origem")
			.set_TextMatrix(0, 41, "Motivo")
			.set_TextMatrix(0, 42, "Cód.Ramal")
		End With
		System.Windows.Forms.Application.DoEvents()
	End Sub
	
	Private Sub FormaGridRC()
		With msfgReclam
			.Rows = 1
			.set_ColWidth(0, 0)
			.set_ColWidth(1, 1200)
			.set_ColWidth(2, 1000)
			.set_ColWidth(3, 2925)
			.set_ColWidth(4, 900)
			.set_ColWidth(5, 1150)
			.set_ColWidth(6, 700)
			.set_ColWidth(7, 3000)
			.set_TextMatrix(0, 0, "Código")
			.set_TextMatrix(0, 1, "Protocolo")
			.set_TextMatrix(0, 2, "Data Ped.")
			.set_TextMatrix(0, 3, "Tipo")
			.set_TextMatrix(0, 4, "Prioridade")
			.set_TextMatrix(0, 5, "Feito Por")
			.set_TextMatrix(0, 6, "Região")
			.set_TextMatrix(0, 7, "Consumidor")
		End With
	End Sub
	
	Private Sub EncheGridSS()
		Dim lintIdx As Short
		Dim llngSeqProt As Integer
		Dim lstrProtocolo As String
		Dim lstrZLC As String
		Dim ldteSolicitacao As Date
		Dim lstrHoraSoli As String
		Dim lstrNomeSolicit As String
		Dim llngUnidId As Integer
		Dim lstrGrupo As String
		Dim ldteSolucao As Date
		Dim lstrHoraSolu As String
		Dim lstrPrioridade As String
		Dim lstrFeitoPor As String
		Dim lstrRegiao As String
		Dim lstrSituacao As String
		Dim lstrDescServ As String
		Dim lstrNomeUc As String
		Dim lstrFaseUc As String
		Dim lstrZonaUc As String
		Dim lstrLivroUc As String
		Dim lstrContaUc As String
		Dim lstrClasUc As String
		Dim lstrUfUc As String
		Dim lstrCepUc As String
		Dim lstrCidUc As String
		Dim lstrDisUc As String
		Dim lstrBaiUc As String
		Dim lstrEndUc As String
		Dim lstrNumUc As String
		Dim lstrComUc As String
		Dim lstrItensserv As String
		Dim lstrCodigo As String
		Dim ldblValor As Double
		Dim lstrValor As String
		Dim lintConta As Short
		Dim lstrSql As String
		Dim lstrFiltro As String
		Dim lstrFiltro2 As String
		Dim lrstConsulta As ADODB.Recordset
		Dim llngPosI As Integer
		Dim llngPosF As Integer
		'****************
		Dim lstrOsDocSol As String
		Dim lstrOsDddTelSol As String
		Dim lstrOsTelSol As String
		Dim lstrOsDddCelSol As String
		Dim lstrOsCelSol As String
		Dim lstrOsPontoRefer As String
		Dim lstrOsAtendente As String
		Dim lstrOsExecutado As String
		Dim lstrOsCpf As String
		Dim llngOsCodExecutor As Integer
		Dim lstrOsPadrao As String
		Dim lstrOsTpLigacao As String
		Dim llngOsCodOsOrigem As Integer
		Dim lstrOsTxtMotivo As String
		'****************
		
		lrstConsulta = New ADODB.Recordset
		lstrFiltro2 = ""
		' ----- Monta o Filtro
		If Me.opbAbertos.Checked Then
			lstrFiltro = "sit = ""A"" "
		ElseIf Me.opbEncerrados.Checked Then 
			lstrFiltro = "sit = ""F"" "
		ElseIf Me.opbCancelados.Checked Then 
			lstrFiltro = "sit = ""C"" "
		ElseIf Me.opbTodos.Checked Then 
			lstrFiltro = "1 = ""1"" "
		End If
		If Me.chkAux(0).CheckState = 1 Then
			With Me.cmbExec
				If VB6.GetItemData(Me.cmbExec, .SelectedIndex) <> 9999 Then ' Diferente de "TODOS"
					lstrFiltro = lstrFiltro & " AND cod_executor = " & VB6.GetItemData(Me.cmbExec, .SelectedIndex)
				End If
			End With
		End If
		If Me.chkAux(1).CheckState = 1 Then
			If Len(Trim(Me.txtZona.Text)) > 0 And Len(Trim(Me.txtLivro.Text)) > 0 And Len(Trim(Me.txtConta.Text)) > 0 Then
				lstrFiltro = lstrFiltro & " AND IFNULL(unidb.zona,unida.zona) = """ & Me.txtZona.Text & """ "
				lstrFiltro = lstrFiltro & " AND IFNULL(unidb.livro,unida.livro) = """ & Me.txtLivro.Text & """ "
				lstrFiltro = lstrFiltro & " AND IFNULL(unidb.conta,unida.conta) = """ & Me.txtConta.Text & """ "
				lstrFiltro = lstrFiltro & " AND solserv.unid_id = " & CInt(Me.lblUnidId.Text) & " "
				lstrFiltro = lstrFiltro & " AND solserv.unid = '" & Trim(Me.lblGrupo.Text) & "' "
			End If
		End If
		If Me.chkAux(2).CheckState = 1 Then
			If Len(Trim(Me.txtNomeSol.Text)) > 0 Then
				lstrFiltro = lstrFiltro & " AND solserv.nomesol like ""%" & Me.txtNomeSol.Text & "%"" "
			End If
		End If
		If Me.chkAux(3).CheckState = 1 Then
			If Me.opbEncerrados.Checked Then
				lstrFiltro = lstrFiltro & " AND (solserv.datasolu BETWEEN """ & VB6.Format(Me.dtpSolIni.value, "yyyy-MM-dd") & """ AND """ & VB6.Format(Me.dtpSolFim.value, "yyyy-MM-dd") & """) "
			Else
				lstrFiltro = lstrFiltro & " AND (solserv.data_soli BETWEEN """ & VB6.Format(Me.dtpSolIni.value, "yyyy-MM-dd") & """ AND """ & VB6.Format(Me.dtpSolFim.value, "yyyy-MM-dd") & """) "
			End If
		End If
		If Me.chkAux(4).CheckState = 1 Then
			If Len(Trim(Me.txtNrProtocolo.Text)) > 0 Then
				lstrFiltro = lstrFiltro & " AND solserv.protocolo like ""%" & Me.txtNrProtocolo.Text & "%"" "
			End If
		End If
		If Me.chkAux(5).CheckState = 1 Then
			If Len(Trim(Me.txtSeqOs.Text)) > 0 Then
				lstrFiltro = lstrFiltro & " AND solserv.cod = " & Me.txtSeqOs.Text & " "
			End If
		End If
		If Me.chkAux(6).CheckState = 1 Then
			lstrFiltro = lstrFiltro & " AND solserv.prioridade = """ & VB.Left(VB6.GetItemString(Me.cmbPriori, Me.cmbPriori.SelectedIndex), 1) & """ "
		End If
		If Me.chkAux(7).CheckState = 1 Then
			lstrFiltro = lstrFiltro & " AND solserv.solicit_meio = """ & VB.Left(VB6.GetItemString(Me.cmbSolicit, Me.cmbSolicit.SelectedIndex), 1) & """ "
		End If
		If Me.chkAux(8).CheckState = 1 Then
			lstrFiltro = lstrFiltro & " AND solserv.zona_solic = """ & VB.Left(VB6.GetItemString(Me.cmbRegiao, Me.cmbRegiao.SelectedIndex), 1) & """ "
		End If
		If Me.chkAux(9).CheckState = 1 Then
			With Me.lvsServico
				'UPGRADE_WARNING: Lower bound of collection Me.lvsServico.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
				If .Items.Item(1).Checked = False Then
					For lintConta = 1 To .Items.Count
						'UPGRADE_WARNING: Lower bound of collection Me.lvsServico.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
						If .Items.Item(lintConta).Checked Then
							'UPGRADE_WARNING: Lower bound of collection Me.lvsServico.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
							'UPGRADE_WARNING: Lower bound of collection Me.lvsServico.ListItems.Item().ListSubItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
							lstrFiltro2 = lstrFiltro2 & .Items.Item(lintConta).SubItems.Item(1).Text & ", "
						End If
					Next lintConta
					If Len(Trim(lstrFiltro2)) > 0 Then
						lstrFiltro2 = " AND LEFT(itensserv,10) IN(" & VB.Left(lstrFiltro2, Len(lstrFiltro2) - 2) & ") "
					End If
				End If
			End With
		End If
		lstrSql = ""
		lstrSql = lstrSql & "   SELECT `solserv`.`cod`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`protocolo`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`zlc`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`data_soli`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`hora_soli`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`itensserv`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`nomesol`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`unid_id`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`unid`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`datasolu`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`horasolu`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`prioridade`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`solicit_meio`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`zona_solic`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`sit`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`descr_serv`, " & vbCrLf
		'***************
		lstrSql = lstrSql & "          `solserv`.`docsol`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`dddtelsol`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`telsol`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`dddcelsol`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`celsol`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`ponto_refer`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`atendente`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`executado`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`cpf`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`cod_executor`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`padrao`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`tp_ligacao`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`cod_os_origem`, " & vbCrLf
		lstrSql = lstrSql & "          `solserv`.`txt_motivo`, "
		'***************
		lstrSql = lstrSql & "          IFNULL(`unidb`.`nome`, `unida`.`nome`) AS `nomeuc`, " & vbCrLf
		lstrSql = lstrSql & "          IFNULL(`unidb`.`fase`, `unida`.`fase`) As `faseuc`, " & vbCrLf
		lstrSql = lstrSql & "          IFNULL(`unidb`.`clas`, `unida`.`clas`) As `clasuc`, " & vbCrLf
		lstrSql = lstrSql & "          IFNULL(`unidb`.`zona`, `unida`.`zona`) AS `zonauc`, " & vbCrLf
		lstrSql = lstrSql & "          IFNULL(`unidb`.`livro`, `unida`.`livro`) AS `livrouc`, " & vbCrLf
		lstrSql = lstrSql & "          IFNULL(`unidb`.`conta`, `unida`.`conta`) AS `contauc`, " & vbCrLf
		lstrSql = lstrSql & "          IFNULL(`unidb`.`uf`, `unida`.`uf`) AS `ufuc`, " & vbCrLf
		lstrSql = lstrSql & "          IFNULL(`unidb`.`cep`, `unida`.`cep`) AS `cepuc`, " & vbCrLf
		lstrSql = lstrSql & "          IFNULL(`unidb`.`cidade`, `unida`.`cidade`) AS `cidadeuc`, " & vbCrLf
		lstrSql = lstrSql & "          IFNULL(`unidb`.`distrito`, `unida`.`distrito`) AS `distritouc`, " & vbCrLf
		lstrSql = lstrSql & "          IFNULL(`unidb`.`bairro`, `unida`.`bairro`) AS `bairrouc`, " & vbCrLf
		lstrSql = lstrSql & "          IFNULL(`unidb`.`end`, `unida`.`end`) AS `enduc`, " & vbCrLf
		lstrSql = lstrSql & "          IFNULL(`unidb`.`numero`, `unida`.`numero`) AS `numerouc`, " & vbCrLf
		lstrSql = lstrSql & "          IFNULL(`unidb`.`complement`, `unida`.`complement`) AS `complementuc` " & vbCrLf
		lstrSql = lstrSql & "     FROM `solserv` " & vbCrLf
		lstrSql = lstrSql & "LEFT JOIN `unidb` ON(`unidb`.`unid_id` = `solserv`.`unid_id` AND `solserv`.`unid` = 'B') " & vbCrLf
		lstrSql = lstrSql & "LEFT JOIN `unida` ON(`unida`.`unid_id` = `solserv`.`unid_id` AND `solserv`.`unid` = 'A') " & vbCrLf
		lstrSql = lstrSql & " WHERE " & lstrFiltro & lstrFiltro2
		Call Conectar(lstrSql, lrstConsulta)
		With lrstConsulta
			If .RecordCount > 0 Then
				Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 0, .RecordCount)
				While Not .EOF
					'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
					llngSeqProt = 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"'
					lstrProtocolo = Trim(IIf(IsDbNull(.Fields("protocolo").value), "", .Fields("protocolo").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"'
					lstrZLC = IIf(IsDbNull(.Fields("zlc").value), "", .Fields("zlc").value)
					lstrZLC = VB.Left(lstrZLC, 3) & "." & Mid(lstrZLC, 4, 2) & "." & VB.Right(lstrZLC, 6)
					'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"'
					lstrZonaUc = Trim(IIf(IsDbNull(.Fields("zonauc").value), "", .Fields("zonauc").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"'
					lstrLivroUc = Trim(IIf(IsDbNull(.Fields("livrouc").value), "", .Fields("livrouc").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"'
					lstrContaUc = Trim(IIf(IsDbNull(.Fields("contauc").value), "", .Fields("contauc").value))
					If lstrZonaUc <> "" Then
						lstrZLC = lstrZonaUc & "." & lstrLivroUc & "." & lstrContaUc
					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"'
					lstrOsDocSol = 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"'
					lstrOsDddTelSol = 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"'
					lstrOsTelSol = 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"'
					lstrOsDddCelSol = 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"'
					lstrOsCelSol = 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"'
					lstrOsPontoRefer = 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"'
					lstrOsAtendente = Trim(IIf(IsDbNull(.Fields("atendente").value), "", .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"'
					lstrOsExecutado = Trim(IIf(IsDbNull(.Fields("executado").value), "", .Fields("executado").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"'
					lstrOsCpf = 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"'
					llngOsCodExecutor = CInt(IIf(IsDbNull(.Fields("cod_executor").value), 0, .Fields("cod_executor").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"'
					lstrOsPadrao = Trim(IIf(IsDbNull(.Fields("padrao").value), "", .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"'
					lstrOsTpLigacao = Trim(IIf(IsDbNull(.Fields("tp_ligacao").value), "", .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"'
					llngOsCodOsOrigem = CInt(IIf(IsDbNull(.Fields("cod_os_origem").value), 0, .Fields("cod_os_origem").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"'
					lstrOsTxtMotivo = Trim(IIf(IsDbNull(.Fields("txt_motivo").value), "", .Fields("txt_motivo").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 = Trim(IIf(IsDbNull(.Fields("ufuc").value), "", .Fields("ufuc").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 = Trim(IIf(IsDbNull(.Fields("cepuc").value), "", .Fields("cepuc").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 = Trim(IIf(IsDbNull(.Fields("cidadeuc").value), "", .Fields("cidadeuc").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 = Trim(IIf(IsDbNull(.Fields("distritouc").value), "", .Fields("distritouc").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 = Trim(IIf(IsDbNull(.Fields("bairrouc").value), "", .Fields("bairrouc").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 = Trim(IIf(IsDbNull(.Fields("enduc").value), "", .Fields("enduc").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 = Trim(IIf(IsDbNull(.Fields("numerouc").value), "", .Fields("numerouc").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 = Trim(IIf(IsDbNull(.Fields("complementuc").value), "", .Fields("complementuc").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"'
					ldteSolicitacao = 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"'
					lstrHoraSoli = VB6.Format(IIf(IsDbNull(.Fields("hora_soli").value), "", .Fields("hora_soli").value), "HH:MM:SS")
					'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"'
					lstrNomeSolicit = 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"'
					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"'
					lstrGrupo = Trim(IIf(IsDbNull(.Fields("unid").value), "B", .Fields("unid").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"'
					ldteSolucao = IIf(IsDbNull(.Fields("datasolu").value), "1900-01-01", .Fields("datasolu").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"'
					lstrHoraSolu = VB6.Format(IIf(IsDbNull(.Fields("horasolu").value), "", .Fields("horasolu").value), "HH:MM:SS")
					If ldteSolucao = CDate("01/01/1900") Then lstrHoraSolu = ""
					'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"'
					lstrPrioridade = Trim(IIf(IsDbNull(.Fields("prioridade").value), "N", .Fields("prioridade").value))
					With Me.cmbPriori
						For lintIdx = 0 To .Items.Count - 1
							If VB.Left(VB6.GetItemString(Me.cmbPriori, lintIdx), 1) = lstrPrioridade Then
								lstrPrioridade = VB6.GetItemString(Me.cmbPriori, lintIdx)
							End If
						Next lintIdx
					End With
					'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"'
					lstrFeitoPor = Trim(IIf(IsDbNull(.Fields("solicit_meio").value), "P", .Fields("solicit_meio").value))
					With Me.cmbSolicit
						For lintIdx = 0 To .Items.Count - 1
							If VB.Left(VB6.GetItemString(Me.cmbSolicit, lintIdx), 1) = lstrFeitoPor Then
								lstrFeitoPor = VB6.GetItemString(Me.cmbSolicit, lintIdx)
							End If
						Next lintIdx
					End With
					'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"'
					lstrRegiao = Trim(IIf(IsDbNull(.Fields("zona_solic").value), "U", .Fields("zona_solic").value))
					With Me.cmbRegiao
						For lintIdx = 0 To .Items.Count - 1
							If VB.Left(VB6.GetItemString(Me.cmbRegiao, lintIdx), 1) = lstrRegiao Then
								lstrRegiao = VB6.GetItemString(Me.cmbRegiao, lintIdx)
							End If
						Next lintIdx
					End With
					'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
					lstrSituacao = Trim(IIf(IsDbNull(.Fields("sit").value), "A", .Fields("sit").value))
					If lstrSituacao = "A" Then
						lstrSituacao = "Aberta"
					ElseIf lstrSituacao = "C" Then 
						lstrSituacao = "Cancelada"
					ElseIf lstrSituacao = "F" Then 
						lstrSituacao = "Finalizada"
					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"'
					lstrDescServ = 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"'
					lstrNomeUc = Trim(IIf(IsDbNull(.Fields("nomeuc").value), "", .Fields("nomeuc").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"'
					lstrFaseUc = Trim(IIf(IsDbNull(.Fields("faseuc").value), "M", .Fields("faseuc").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"'
					lstrClasUc = Trim(IIf(IsDbNull(.Fields("clasuc").value), "9101", .Fields("clasuc").value))
					If VB.Left(lstrClasUc, 1) = "9" Then
						lstrClasUc = "Residencial"
					ElseIf CDbl(VB.Left(lstrClasUc, 1)) + 0 < 4 Then 
						lstrClasUc = "Industrial"
					ElseIf VB.Left(lstrClasUc, 1) = "4" Then 
						lstrClasUc = "Comercial"
					ElseIf VB.Left(lstrClasUc, 1) = "5" Then 
						lstrClasUc = "Rural"
					ElseIf VB.Left(lstrClasUc, 1) = "7" Then 
						lstrClasUc = "Serviço Público"
					ElseIf VB.Left(lstrClasUc, 1) = "8" Then 
						lstrClasUc = "Consumo Próprio"
					ElseIf VB.Left(lstrClasUc, 2) = "61" Then 
						lstrClasUc = "Poder Público Municipal"
					ElseIf VB.Left(lstrClasUc, 2) = "62" Then 
						lstrClasUc = "Poder Público Estadual"
					ElseIf VB.Left(lstrClasUc, 2) = "63" Then 
						lstrClasUc = "Poder Público Federal"
					ElseIf VB.Left(lstrClasUc, 2) = "64" Then 
						lstrClasUc = "Iluminação Pública"
					Else
						lstrClasUc = "(nenhuma classe)"
					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"'
					lstrItensserv = Trim(IIf(IsDbNull(.Fields("itensserv").value), "", .Fields("itensserv").value))
					llngPosI = InStr(1, lstrItensserv, "?")
					llngPosF = InStr(1, lstrItensserv, ";")
					lstrCodigo = VB.Left(lstrItensserv, llngPosI - 1)
					lstrValor = (Mid(lstrItensserv, llngPosI + 1, (llngPosF - 1) - llngPosI))
					If IsNumeric(lstrValor) Then
						ldblValor = CDbl(lstrValor)
					Else
						ldblValor = Val(lstrValor)
					End If
					'ldblValor = (Mid(lstrItensserv, llngPosI + 1, (llngPosF - 1) - llngPosI))
					With Me.msfgSolServ
						.Rows = .Rows + 1
						.set_TextMatrix(.Rows - 1, 0, lstrZLC)
						.set_TextMatrix(.Rows - 1, 1, llngSeqProt)
						.set_TextMatrix(.Rows - 1, 2, lstrProtocolo)
						.set_TextMatrix(.Rows - 1, 3, VB6.Format(ldteSolicitacao, "dd/mm/yyyy"))
						.set_TextMatrix(.Rows - 1, 6, lstrNomeSolicit)
						.set_TextMatrix(.Rows - 1, 4, BuscaDescriCod(lstrCodigo))
						.set_TextMatrix(.Rows - 1, 5, FormatNumber(ldblValor, 2))
						.set_TextMatrix(.Rows - 1, 7, llngUnidId)
						.set_TextMatrix(.Rows - 1, 8, lstrGrupo)
						If ldteSolucao <> CDate("01/01/1900") Then
							.set_TextMatrix(.Rows - 1, 9, VB6.Format(ldteSolucao, "dd/mm/yyyy"))
						Else
							.set_TextMatrix(.Rows - 1, 9, "")
						End If
						.set_TextMatrix(.Rows - 1, 10, lstrHoraSoli)
						.set_TextMatrix(.Rows - 1, 11, lstrHoraSolu)
						.set_TextMatrix(.Rows - 1, 12, lstrPrioridade)
						.set_TextMatrix(.Rows - 1, 13, lstrFeitoPor)
						.set_TextMatrix(.Rows - 1, 14, lstrRegiao)
						.set_TextMatrix(.Rows - 1, 15, lstrSituacao)
						.set_TextMatrix(.Rows - 1, 16, lstrDescServ)
						.set_TextMatrix(.Rows - 1, 17, lstrNomeUc)
						.set_TextMatrix(.Rows - 1, 18, lstrFaseUc)
						.set_TextMatrix(.Rows - 1, 19, lstrClasUc)
						.set_TextMatrix(.Rows - 1, 20, lstrUfUc)
						.set_TextMatrix(.Rows - 1, 21, lstrCepUc)
						.set_TextMatrix(.Rows - 1, 22, lstrCidUc)
						.set_TextMatrix(.Rows - 1, 23, lstrDisUc)
						.set_TextMatrix(.Rows - 1, 24, lstrBaiUc)
						.set_TextMatrix(.Rows - 1, 25, lstrEndUc)
						.set_TextMatrix(.Rows - 1, 26, lstrNumUc)
						.set_TextMatrix(.Rows - 1, 27, lstrComUc)
						'***************
						.set_TextMatrix(.Rows - 1, 28, lstrOsDocSol)
						.set_TextMatrix(.Rows - 1, 29, lstrOsDddTelSol)
						.set_TextMatrix(.Rows - 1, 30, lstrOsTelSol)
						.set_TextMatrix(.Rows - 1, 31, lstrOsDddCelSol)
						.set_TextMatrix(.Rows - 1, 32, lstrOsCelSol)
						.set_TextMatrix(.Rows - 1, 33, lstrOsPontoRefer)
						.set_TextMatrix(.Rows - 1, 34, lstrOsAtendente)
						.set_TextMatrix(.Rows - 1, 35, lstrOsExecutado)
						.set_TextMatrix(.Rows - 1, 36, lstrOsCpf)
						.set_TextMatrix(.Rows - 1, 37, llngOsCodExecutor)
						.set_TextMatrix(.Rows - 1, 38, lstrOsPadrao)
						.set_TextMatrix(.Rows - 1, 39, lstrOsTpLigacao)
						.set_TextMatrix(.Rows - 1, 40, llngOsCodOsOrigem)
						.set_TextMatrix(.Rows - 1, 41, lstrOsTxtMotivo)
						.set_TextMatrix(.Rows - 1, 42, BuscaIdRamal(lstrZonaUc, lstrLivroUc, lstrContaUc))
						'***************
					End With
					Call .MoveNext()
					Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 1)
				End While
			End If
			If .State = 1 Then Call .Close()
		End With
		'UPGRADE_NOTE: Object lrstConsulta may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
		lrstConsulta = Nothing
	End Sub
	
	Private Function BuscaDescriCod(ByVal astrCodigo As String) As String
		Dim lstrSql As String
		Dim lrstConsulta As ADODB.Recordset
		lrstConsulta = New ADODB.Recordset
		lstrSql = "SELECT descri " & "  FROM codigos " & " WHERE num = """ & astrCodigo & """"
		Call Conectar(lstrSql, lrstConsulta)
		With lrstConsulta
			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"'
				BuscaDescriCod = IIf(IsDbNull(.Fields("descri").value), "", .Fields("descri").value)
			Else
				BuscaDescriCod = ""
			End If
			If .State = 1 Then Call .Close()
		End With
		'UPGRADE_NOTE: Object lrstConsulta may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
		lrstConsulta = Nothing
	End Function
	Private Sub EncheTipoServicos()
		Dim llstItens As System.Windows.Forms.ListViewItem
		Dim lstrCodigo As String
		Dim lstrDescricao As String
		Dim lstrSql As String
		Dim lrstConsulta As ADODB.Recordset
		lrstConsulta = New ADODB.Recordset
		With Me.lvsServico
			Call .Items.Clear()
			If .Columns.Count <= 1 Then
				Call .Columns.Add("", "Descrição", CInt(VB6.TwipsToPixelsX(3500)))
				Call .Columns.Add("", "Código", CInt(VB6.TwipsToPixelsX(0)))
			End If
		End With
		llstItens = Me.lvsServico.Items.Add("Marcar Todos")
		'UPGRADE_WARNING: Lower bound of collection llstItens has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
		If llstItens.SubItems.Count > 1 Then
			llstItens.SubItems(1).Text = "0000000000"
		Else
			llstItens.SubItems.Insert(1, New System.Windows.Forms.ListViewItem.ListViewSubItem(Nothing, "0000000000"))
		End If
		'UPGRADE_WARNING: Lower bound of collection Me.lvsServico.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
		Me.lvsServico.Items.Item(1).Checked = True
		lstrSql = "SELECT num, descri " & "  FROM codigos " & " WHERE (LEFT(num, 4) = ""9040"" OR LEFT(num, 4) = ""9050"")" & "   AND RIGHT(num,1) <> ""0"" " & "GROUP BY descri " & "ORDER BY descri ASC, LEFT(num,4) ASC "
		Call Conectar(lstrSql, lrstConsulta)
		With lrstConsulta
			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"'
				lstrCodigo = IIf(IsDbNull(.Fields("num").value), "0", .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"'
				lstrDescricao = IIf(IsDbNull(.Fields("descri").value), "0", .Fields("descri").value)
				llstItens = Me.lvsServico.Items.Add(lstrDescricao)
				'UPGRADE_WARNING: Lower bound of collection llstItens has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
				If llstItens.SubItems.Count > 1 Then
					llstItens.SubItems(1).Text = lstrCodigo
				Else
					llstItens.SubItems.Insert(1, New System.Windows.Forms.ListViewItem.ListViewSubItem(Nothing, lstrCodigo))
				End If
				'UPGRADE_WARNING: Lower bound of collection Me.lvsServico.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
				Me.lvsServico.Items.Item(Me.lvsServico.Items.Count).Checked = True
				Call .MoveNext()
			End While
			If .State = 1 Then Call .Close()
		End With
		'UPGRADE_NOTE: Object lrstConsulta may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
		lrstConsulta = Nothing
	End Sub
	Private Sub EncheGridRC()
		Dim rsConsulta As ADODB.Recordset
		Dim llRow As Integer
		Dim lsTpRecla As String
		Dim lsPrioridade As String
		Dim lsOrigem As String
		Dim lsRegiao As String
		
		rsConsulta = New ADODB.Recordset
		
		' ----- Monta o Filtro
		
		strfiltro = "(resolvida = 0 or resolvida = 3)"
		If VB6.GetItemData(cmbExec, cmbExec.SelectedIndex) <> 9999 Then ' Diferente de "TODOS"
			strfiltro = strfiltro & " AND cod_executor = " & VB6.GetItemData(cmbExec, cmbExec.SelectedIndex)
		End If
		If Len(Trim(txtZona.Text)) > 0 Then
			strfiltro = strfiltro & " AND zona = """ & txtZona.Text & """"
		End If
		If Len(Trim(txtLivro.Text)) > 0 Then
			strfiltro = strfiltro & " AND livro = """ & txtLivro.Text & """"
		End If
		If Len(Trim(txtConta.Text)) > 0 Then
			strfiltro = strfiltro & " AND conta = """ & txtConta.Text & """"
		End If
		
		strSql = "SELECT protocolo, dt_solicitacao, tipo_reclamacao, prioridade, origem, regiao, nome " & "FROM reclamacao " & "WHERE  " & strfiltro & ""
		Call Conectar(strSql, rsConsulta)
		
		llRow = 1
		
		If rsConsulta.RecordCount > 0 Then
			Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 0, rsConsulta.RecordCount)
			While Not rsConsulta.EOF
				msfgReclam.Rows = rsConsulta.RecordCount + 1
				msfgReclam.set_TextMatrix(llRow, 1, rsConsulta.Fields("protocolo").Value & "")
				msfgReclam.set_TextMatrix(llRow, 2, VB6.Format(rsConsulta.Fields("dt_solicitacao").Value & "", "dd/mm/yyyy"))
				Select Case rsConsulta.Fields("tipo_reclamacao").Value
					Case 0
						lsTpRecla = "IF:Interrupção do Fornecimento de Energia Elétrica"
					Case 1
						lsTpRecla = "NT:Nivel de Tensão do Fornecimento de Energia Elétrica"
					Case 2
						lsTpRecla = "FP:Serviços Fora do Prazo Regularmentares ou Convencionados Contratualmente"
					Case 3
						lsTpRecla = "VC:Valores Cobrado na Conta"
					Case 4
						lsTpRecla = "CN:Contas Não Entregues"
					Case 5
						lsTpRecla = "SF:Suspensão do Fornecimento"
					Case 6
						lsTpRecla = "DE: Danos Elétricos"
					Case 7
						lsTpRecla = "OU: Outros"
				End Select
				
				msfgReclam.set_TextMatrix(llRow, 3, lsTpRecla)
				
				Select Case rsConsulta.Fields("prioridade").Value
					Case 0
						lsPrioridade = "Urgente"
					Case 1
						lsPrioridade = "Normal"
				End Select
				
				msfgReclam.set_TextMatrix(llRow, 4, lsPrioridade)
				
				Select Case rsConsulta.Fields("origem").Value
					Case 0
						lsOrigem = "Pessoalmente"
					Case 1
						lsOrigem = "Fone"
					Case 2
						lsOrigem = "E-mail"
					Case 3
						lsOrigem = "Site"
					Case 4
						lsOrigem = "Outro"
				End Select
				
				msfgReclam.set_TextMatrix(llRow, 5, lsOrigem)
				
				Select Case rsConsulta.Fields("regiao").Value
					Case 0
						lsRegiao = "Urbana"
					Case 1
						lsRegiao = "Rural"
				End Select
				
				msfgReclam.set_TextMatrix(llRow, 6, lsRegiao)
				'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"'
				msfgReclam.set_TextMatrix(llRow, 7, IIf(IsDbNull(rsConsulta.Fields("nome").Value), "", rsConsulta.Fields("nome").Value))
				
				llRow = llRow + 1
				Call rsConsulta.MoveNext()
				Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 1)
			End While
		End If
		
		If rsConsulta.State = 1 Then Call rsConsulta.Close()
		'UPGRADE_NOTE: Object rsConsulta 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"'
		rsConsulta = Nothing
	End Sub
	
	Private Sub CarregaExecutor()
		Dim rsConsulta As ADODB.Recordset
		
		rsConsulta = New ADODB.Recordset
		
		cmbExec.Items.Add(New VB6.ListBoxItem("9999 - TODOS", 9999))
		
		strSql = "SELECT * FROM executor"
		Call Conectar(strSql, rsConsulta)
		
		If rsConsulta.RecordCount > 0 Then
			Call rsConsulta.MoveFirst()
			
			While Not rsConsulta.EOF
				cmbExec.Items.Add(New VB6.ListBoxItem(rsConsulta.Fields("Cod").Value & " - " & rsConsulta.Fields("Descricao").Value, Val(rsConsulta.Fields("Cod").Value)))
				Call rsConsulta.MoveNext()
			End While
		End If
		
		If rsConsulta.State = 1 Then Call rsConsulta.Close()
		'UPGRADE_NOTE: Object rsConsulta 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"'
		rsConsulta = Nothing
	End Sub
	
	Private Sub cbFechar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cbFechar.Click
		Me.Close()
	End Sub
	
	Private Sub cmdArquivo_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdArquivo.Click
		Me.dialArqOpen.DefaultExt = "CSV"
		'UPGRADE_WARNING: Filter has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
		Me.dialArqOpen.Filter = "*." & Me.dialArqOpen.DefaultExt
		Me.dialArqOpen.FileName = My.Application.Info.DirectoryPath & "\ListagemOS_" & VB6.Format(BuscaDataBD, "yyyymmddHHMMSS") & "." & Me.dialArqOpen.DefaultExt
		Me.dialArqOpen.Title = "Arquivo de exportação de O.S."
		Me.dialArqOpen.ShowDialog()
		Me.txtArquivo.Text = Me.dialArqOpen.FileName
	End Sub
	
	Private Sub cmdBusca_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdBusca.Click
		Call frmLocalizaUnidade.Show()
		Call frmLocalizaUnidade.SetaLocalizaUnidade("U", Me)
	End Sub
	
	Public Sub SetaCodigo(ByVal alngUnidId As Integer, ByVal astrZona As String, ByVal astrLivro As String, ByVal astrConta As String, ByVal astrGrupo As String)
		Me.txtZona.Text = astrZona
		Me.txtLivro.Text = astrLivro
		Me.txtConta.Text = astrConta
		Me.lblUnidId.Text = CStr(alngUnidId)
		Me.lblGrupo.Text = astrGrupo
	End Sub
	
	Private Sub cmdCancelaOS_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdCancelaOS.Click
		'  With Me.msfgSolServ
		'    If IsDate(Me.txtDataConclusao.Text) Then
		'      If .RowSel > 0 Then
		'        If MsgBox("Deseja realmente cancelar esta OS em " & Strings.Format(Me.txtDataConclusao.Text, "DD/MM/YYYY") & " " & Strings.Format(Me.txtHoraConclusao.Text, "HH:NN") & "?", vbQuestion + vbYesNo + vbDefaultButton1, "Confirme") = vbYes Then
		'          If Strings.Trim(Me.txtMotivo.Text) <> "" Then
		'            lstrSql = ""
		'            lstrSql = lstrSql & "UPDATE solserv SET "
		'            lstrSql = lstrSql & "       datasolu  = '" & Format(ldteConclusao, "yyyy-MM-dd") & "', "
		'            lstrSql = lstrSql & "       horasolu  = '" & Format(Me.txtHoraConclusao.Text, "HH:NN") & "', "
		'            lstrSql = lstrSql & "       executado = 'OS CANCELADA', "
		'            lstrSql = lstrSql & "       sit       = 'C', "
		'            lstrSql = lstrSql & "       txt_motivo = '" & Strings.Replace(Me.txtMotivo.Text, "'", "\'") & "', "
		'            lstrSql = lstrSql & "       sgdenvio  = 'E' "
		'            lstrSql = lstrSql & " WHERE protocolo = '" & .TextMatrix(.RowSel, 2) & "' "
		'            lstrSql = lstrSql & "   AND cod = " & .TextMatrix(.RowSel, 1) & " "
		'            Call Executar(lstrSql)
		'          Else
		'            Call MsgBox("Faltou informar o motivo!", vbExclamation, gstrTituloMensagem)
		'          End If
		'
		'        End If
		'      End If
		'    Else
		'      Call MsgBox("Data inválida!", vbCritical, gstrTituloMensagem)
		'    End If
		'  End With
	End Sub
	
	Private Sub cmdExporta_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdExporta.Click
		Dim lstrLin As String
		Dim lintARQ As Short
		Dim llngRow As Integer
		Dim llngCol As Integer
		If Trim(Me.txtArquivo.Text) <> "" Then
			lintARQ = FreeFile
			FileOpen(lintARQ, Me.txtArquivo.Text, OpenMode.Output)
			With Me.msfgSolServ
				For llngRow = 0 To .Rows - 1
					lstrLin = ""
					For llngCol = 0 To .Cols - 1
						lstrLin = lstrLin & .get_TextMatrix(llngRow, llngCol) & ";"
					Next llngCol
					PrintLine(lintARQ, lstrLin)
				Next llngRow
			End With
			FileClose(lintARQ)
			Call MsgBox("Arquivo gerado com sucesso!", MsgBoxStyle.Information, gstrTituloMensagem)
		Else
			Call MsgBox("Você precisa selecionar o caminho e o arquivo para exportação!", MsgBoxStyle.Information, gstrTituloMensagem)
		End If
	End Sub
	
	Private Sub cmdFiltrar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdFiltrar.Click
		Me.lblInfo.Text = " Aguarde buscando as informações solicitadas..."
		Call Me.lblInfo.Refresh()
		Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
		Call FormaGridSS()
		Me.msfgSolServ.Redraw = False
		Call EncheGridSS()
		Me.msfgSolServ.Redraw = True
		Call FormaGridRC()
		Me.msfgReclam.Redraw = False
		Call EncheGridRC()
		Me.msfgReclam.Redraw = True
		Me.lblInfo.Text = " Pronto!"
		Call Me.lblInfo.Refresh()
		Me.Cursor = System.Windows.Forms.Cursors.Default
	End Sub
	
	Private Sub cmdImprimir_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdImprimir.Click
		With Me.msfgSolServ
			If .RowSel > 0 Then
				If .Rows > 1 Then
					Call ReimprimirOS(.get_TextMatrix(.RowSel, 2), (Me.crpOs), (Me.crpCarga), (Me.crpCroqui), CInt(.get_TextMatrix(.RowSel, 1)))
				End If
			End If
		End With
	End Sub
	
	Private Sub cmdListagem_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdListagem.Click
		Dim lintCtrl As Short
		Dim lstrTab As String
		Dim lstrSql As String
		Dim llngRow As Integer
		Dim lstrGrupo As String
		Dim llngUnidId As Integer
		Dim lstrNomeUc As String
		Dim lstrZona As String
		Dim lstrLivro As String
		Dim lstrConta As String
		Dim lrstAux As ADODB.Recordset
		lrstAux = New ADODB.Recordset
		If Me.msfgSolServ.Rows > 1 Then
			Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
			Call LigDesBotoes(False)
			System.Windows.Forms.Application.DoEvents()
			istrTamCol = "<22mm    |>17mm|^15mm |^15mm    |<50mm    |<50mm      |<20mm        |<90mm;"
			istrCabCol = "Protocolo|Seq. |Pedido|Conclusão|Descrição|Solicitante|Identificador|Nome da Unidade"
			With ifrmSServ
				.quem_chama = Me
				.VS.Font = VB6.FontChangeName(.VS.Font, "Arial")
				.VS.TableBorder = VSVIEW6.TableBorderSettings.tbNone
				.VS.PageBorder = VSVIEW6.TableBorderSettings.tbNone
				.VS.ShowGuides = VSVIEW6.ShowGuideSettings.gdShow
				.VS.Orientation = VSVIEW6.OrientationSettings.orLandscape
				.VS.PhysicalPage = True
				.VS.PaperSize = VSVIEW6.PaperSizeSettings.pprA4
				.VS.MarginTop = "7mm"
				.VS.MarginRight = "7mm"
				.VS.MarginLeft = "7mm"
				.VS.MarginBottom = "5mm"
				.VS.MarginFooter = "0mm"
				.VS.MarginHeader = "0mm"
				.VS.TextColor = System.Drawing.Color.Black
				.VS.BrushStyle = VSVIEW6.BrushStyleSettings.bsSolid
				.VS.Font = VB6.FontChangeBold(.VS.Font, False)
				.VS.Font = VB6.FontChangeSize(.VS.Font, 7)
				.VS.StartDoc()
			End With
			With Me.msfgSolServ
				For llngRow = 1 To .Rows - 1
					llngUnidId = CInt(.get_TextMatrix(llngRow, 7))
					lstrGrupo = .get_TextMatrix(llngRow, 8)
					lstrSql = ""
					lstrSql = lstrSql & "SELECT `zona`, `livro`, `conta`, `nome` "
					lstrSql = lstrSql & "  FROM `unid" & LCase(VB.Left(lstrGrupo, 1)) & "` "
					lstrSql = lstrSql & " WHERE `unid_id` = " & llngUnidId
					Call Conectar(lstrSql, lrstAux)
					With lrstAux
						If .State > 0 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"'
								lstrNomeUc = 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"'
								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))
							End If
							Call .Close()
						End If
					End With
					lstrTab = ""
					lstrTab = lstrTab & .get_TextMatrix(llngRow, 2) & "|" 'Protocolo
					lstrTab = lstrTab & .get_TextMatrix(llngRow, 1) & "|" 'Código
					lstrTab = lstrTab & .get_TextMatrix(llngRow, 3) & "|" 'Data Ped.
					lstrTab = lstrTab & .get_TextMatrix(llngRow, 9) & "|" 'Data Conclusao.
					lstrTab = lstrTab & VB.Left(.get_TextMatrix(llngRow, 4), 32) & "|" 'Descrição do Serviço
					lstrTab = lstrTab & VB.Left(.get_TextMatrix(llngRow, 6), 30) & "|" 'Solicitante
					lstrTab = lstrTab & lstrZona & "." & lstrLivro & "." & lstrConta & "|" 'Identificacao
					lstrTab = lstrTab & VB.Left(lstrNomeUc, 59) 'Nome da Unidade Consumidora
					With ifrmSServ
						If lintCtrl = 1 Then
							.VS.PenStyle = VSVIEW6.PenStyleSettings.psTransparent
							.VS.BrushColor = System.Drawing.ColorTranslator.FromOle(&HE0E0E0)
							'UPGRADE_ISSUE: VBControlExtender method ifrmSServ.VS.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
							Call .VS.DrawRectangle("8mm", .VS.CurrentY, "288mm", .VS.CurrentY + 165)
							.VS.BrushColor = System.Drawing.Color.White
							.VS.PenStyle = VSVIEW6.PenStyleSettings.psSolid
							lintCtrl = 0
						Else
							lintCtrl = 1
						End If
						.VS.Table = istrTamCol & lstrTab
					End With
					System.Windows.Forms.Application.DoEvents()
				Next llngRow
			End With
			With ifrmSServ
				Call .VS.EndDoc()
				Call .Show()
			End With
			Call LigDesBotoes(True)
			Me.Cursor = System.Windows.Forms.Cursors.Default
		End If
	End Sub
	
	Public Function CabecaRel() As Object
		Dim lstrAux As String
		Dim lintIdx As Short
		For lintIdx = 0 To Me.chkAux.Count - 1
			If Me.chkAux(lintIdx).CheckState = 1 Then
				lstrAux = Me.chkAux(lintIdx).Text
			End If
		Next lintIdx
		With ifrmSServ
			Call Cabecalho_Relatorio(.VS, "LISTAGEM DAS ORDENS DE SERVIÇO (" & IIf(Me.opbAbertos.Checked, "ABERTAS", IIf(Me.opbEncerrados.Checked, "ENCERRADAS", IIf(Me.opbCancelados.Checked, "CANCELADAS", "TODAS"))) & ") ", "Filtro: " & lstrAux, "3", False, "")
			.VS.Font = VB6.FontChangeSize(.VS.Font, 7)
			Call LineFeed(.VS, 3)
			.VS.Table = istrTamCol & istrCabCol
			'UPGRADE_ISSUE: VBControlExtender method ifrmSServ.VS.CurrentY was not upgraded. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="CC4C7EC0-C903-48FC-ACCC-81861D12DA4A"'
			.VS.CurrentY = .VS.CurrentY + 100
		End With
	End Function
	
	Private Sub cmdVoltar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdVoltar.Click
		Me.fmeDetalheOs.Visible = False
	End Sub
	
	Private Sub dtpSolIni_Change(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles dtpSolIni.Change
		Call dtpSolIni_ClickEvent(dtpSolIni, New System.EventArgs())
	End Sub
	
	Private Sub dtpSolIni_ClickEvent(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles dtpSolIni.ClickEvent
		Me.dtpSolFim.value = CDate(VB6.Format(UltimoDiaMes((Me.dtpSolIni.Month), (Me.dtpSolIni.Year)) & "/" & VB6.Format(Me.dtpSolIni.value, "mm/yyyy"), "dd/mm/yyyy"))
	End Sub
	
	Private Sub FrmSolicAbert_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		Call CarregaExecutor()
		
		If cmbExec.Items.Count > 0 Then
			cmbExec.SelectedIndex = 0
		End If
		
		Call FormaGridSS()
		Call FormaGridRC()
		Call EncheTipoServicos()
		Me.cmbPriori.SelectedIndex = 0
		Me.cmbRegiao.SelectedIndex = 0
		Me.cmbSolicit.SelectedIndex = 0
		ifrmSServ = New FrmRelatorio
		Me.chkAux(0).CheckState = System.Windows.Forms.CheckState.Checked
		Me.dtpSolIni.value = BuscaDataBD
		Me.dtpSolIni.value = CDate(VB6.Format("01/" & VB6.Format(Me.dtpSolIni.value, "mm/yyyy"), "dd/mm/yyyy"))
		Me.dtpSolFim.value = CDate(VB6.Format(UltimoDiaMes((Me.dtpSolIni.Month), (Me.dtpSolIni.Year)) & "/" & VB6.Format(Me.dtpSolIni.value, "mm/yyyy"), "dd/mm/yyyy"))
		
		Me.txtDataConclusao.Text = VB6.Format(BuscaDataBD, "DD/MM/YYYY")
		Me.txtHoraConclusao.Text = VB6.Format(BuscaDataBD, "HH:NN")
		
	End Sub
	
	Private Sub lvsServico_ItemCheck(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.ItemCheckEventArgs) Handles lvsServico.ItemCheck
		Dim Item As System.Windows.Forms.ListViewItem = lvsServico.Items(eventArgs.Index)
		Dim lintConta As Short
		With Me.lvsServico
			If Item.Text = "Marcar Todos" Then
				'UPGRADE_WARNING: Lower bound of collection Me.lvsServico.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
				If .Items.Item(1).Checked = True Then
					For lintConta = 1 To .Items.Count
						'UPGRADE_WARNING: Lower bound of collection Me.lvsServico.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
						.Items.Item(lintConta).Checked = True
					Next lintConta
					'UPGRADE_WARNING: Lower bound of collection Me.lvsServico.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
				ElseIf .Items.Item(1).Checked = False Then 
					For lintConta = 1 To .Items.Count
						'UPGRADE_WARNING: Lower bound of collection Me.lvsServico.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
						.Items.Item(lintConta).Checked = False
					Next lintConta
				End If
			Else
				If Item.Checked = False Then
					'UPGRADE_WARNING: Lower bound of collection Me.lvsServico.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
					.Items.Item(1).Checked = False
				End If
			End If
		End With
	End Sub
	
	'UPGRADE_WARNING: Event chkAux.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 chkAux_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkAux.CheckStateChanged
		Dim Index As Short = chkAux.GetIndex(eventSender)
		Dim lblnAuxiliar(10) As Boolean
		Dim lintIdx As Short
		For lintIdx = 0 To 9
			lblnAuxiliar(lintIdx) = (Me.chkAux(lintIdx).CheckState = 1)
		Next lintIdx
		Me.cmbExec.Enabled = lblnAuxiliar(0)
		Me.txtZona.Enabled = lblnAuxiliar(1)
		Me.txtLivro.Enabled = lblnAuxiliar(1)
		Me.txtConta.Enabled = lblnAuxiliar(1)
		Me.cmdBusca.Enabled = lblnAuxiliar(1)
		Me.txtNomeSol.Enabled = lblnAuxiliar(2)
		Me.dtpSolIni.Enabled = lblnAuxiliar(3)
		Me.dtpSolFim.Enabled = lblnAuxiliar(3)
		Me.txtNrProtocolo.Enabled = lblnAuxiliar(4)
		Me.txtSeqOs.Enabled = lblnAuxiliar(5)
		Me.cmbPriori.Enabled = lblnAuxiliar(6)
		Me.cmbSolicit.Enabled = lblnAuxiliar(7)
		Me.cmbRegiao.Enabled = lblnAuxiliar(8)
		Me.lvsServico.Enabled = lblnAuxiliar(9)
	End Sub
	
	Private Sub msfgSolServ_DblClick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles msfgSolServ.DblClick
		Dim lintAux As Short
		With Me.msfgSolServ
			For lintAux = 0 To 41
				'Me.lblCapOs(lintAux).Caption = .TextMatrix(0, lintAux) & ":"
				Me.lblCapOs(lintAux).AutoSize = True
				Me.lblCapOs(lintAux).BorderStyle = System.Windows.Forms.BorderStyle.None
				Me.lblDados(lintAux).Text = .get_TextMatrix(.RowSel, lintAux)
			Next lintAux
		End With
		Me.fmeDetalheOs.Top = VB6.TwipsToPixelsY(45)
		Me.fmeDetalheOs.Left = VB6.TwipsToPixelsX(30)
		Me.fmeDetalheOs.Visible = True
	End Sub
	
	'UPGRADE_WARNING: Event opbAbertos.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub opbAbertos_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles opbAbertos.CheckedChanged
		If eventSender.Checked Then
			Me.chkAux(3).Text = IIf(Me.opbEncerrados.Checked, "Conc.:", "Solic.:")
		End If
	End Sub
	
	'UPGRADE_WARNING: Event opbCancelados.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub opbCancelados_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles opbCancelados.CheckedChanged
		If eventSender.Checked Then
			Me.chkAux(3).Text = IIf(Me.opbEncerrados.Checked, "Conc.:", "Solic.:")
		End If
	End Sub
	
	'UPGRADE_WARNING: Event opbEncerrados.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub opbEncerrados_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles opbEncerrados.CheckedChanged
		If eventSender.Checked Then
			Me.chkAux(3).Text = IIf(Me.opbEncerrados.Checked, "Conc.:", "Solic.:")
		End If
	End Sub
	
	'UPGRADE_WARNING: Event opbTodos.CheckedChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
	Private Sub opbTodos_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles opbTodos.CheckedChanged
		If eventSender.Checked Then
			Me.chkAux(3).Text = IIf(Me.opbEncerrados.Checked, "Conc.:", "Solic.:")
		End If
	End Sub
	
	Private Sub txtZona_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtZona.Enter
		txtZona.SelectionStart = 0
		txtZona.SelectionLength = Len(txtZona.Text)
	End Sub
	
	Private Sub txtZona_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtZona.Leave
		txtZona.Text = VB6.Format(txtZona.Text, "000")
	End Sub
	
	Private Sub txtLivro_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLivro.Enter
		txtLivro.SelectionStart = 0
		txtLivro.SelectionLength = Len(txtLivro.Text)
	End Sub
	
	Private Sub txtLivro_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtLivro.Leave
		txtLivro.Text = VB6.Format(txtLivro.Text, "00")
	End Sub
	
	Private Sub txtConta_Enter(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtConta.Enter
		txtConta.SelectionStart = 0
		txtConta.SelectionLength = Len(txtConta.Text)
	End Sub
	
	Private Sub txtConta_Leave(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtConta.Leave
		txtConta.Text = VB6.Format(txtConta.Text, "000000")
		' Call cbtBusca_Click
	End Sub
	
	Private Sub FrmSolicAbert_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		' ----- Se pressionar "Esc" fecha a janela
		If KeyAscii = System.Windows.Forms.Keys.Escape Then
			If Me.fmeDetalheOs.Visible Then
				KeyAscii = 0
				Me.fmeDetalheOs.Visible = False
			Else
				Call Me.Close()
			End If
			' ----- Altera as teclas Enter/Tab
		ElseIf KeyAscii = System.Windows.Forms.Keys.Return Then 
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub LigDesBotoes(ByVal ablnAux As Boolean)
		Me.cmdListagem.Enabled = ablnAux
		Me.cmdFiltrar.Enabled = ablnAux
		Me.cmdImprimir.Enabled = ablnAux
		Me.cmdExporta.Enabled = ablnAux
		Me.cbFechar.Enabled = ablnAux
	End Sub
	
	Private Function BuscaIdRamal(ByVal astrZona As String, ByVal astrLivro As String, ByVal astrConta As String) As Integer
		Dim llngIdU As Integer
		Dim llngIdR As Integer
		Dim lstrSql As String
		Dim lrstAux As ADODB.Recordset
		lrstAux = New ADODB.Recordset
		llngIdR = 0
		lstrSql = ""
		lstrSql = lstrSql & "SELECT * "
		lstrSql = lstrSql & "  FROM `unidade_consumidora` "
		lstrSql = lstrSql & " WHERE `unidade_consumidora`.`zona` = '" & astrZona & "' "
		lstrSql = lstrSql & "   AND `unidade_consumidora`.`livro` = '" & astrLivro & "' "
		lstrSql = lstrSql & "   AND `unidade_consumidora`.`conta` = '" & astrConta & "' "
		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"'
					llngIdU = CInt(IIf(IsDbNull(.Fields("id").value), 0, .Fields("id").value))
				End If
				Call .Close()
			End If
		End With
		lstrSql = ""
		lstrSql = lstrSql & "SELECT * "
		lstrSql = lstrSql & "  FROM `ramal_unidade_consumidora` as r1"
		lstrSql = lstrSql & " WHERE r1.idunidade_consumidora = " & llngIdU & " "
		lstrSql = lstrSql & "   AND r1.idsituacao = 1 "
		lstrSql = lstrSql & "   AND NOT EXISTS(SELECT * FROM `ramal_unidade_consumidora` r2 WHERE r2.idramal = r1.idramal AND r2.idsituacao = 3)"
		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"'
					llngIdR = CInt(IIf(IsDbNull(.Fields("idramal").value), 0, .Fields("idramal").value))
				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
		BuscaIdRamal = llngIdR
	End Function
End Class