Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class frmRelContratosGrupoB
	Inherits System.Windows.Forms.Form
	Private ifrmLocalizaUnidade As frmLocalizaUnidade
	
	'UPGRADE_WARNING: Event chkSitCortados.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 chkSitCortados_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkSitCortados.CheckStateChanged
		If Me.chkSitLigados.CheckState = System.Windows.Forms.CheckState.Unchecked And Me.chkSitDesligados.CheckState = System.Windows.Forms.CheckState.Unchecked And Me.chkSitCortados.CheckState = System.Windows.Forms.CheckState.Unchecked And Me.chkSitDesativados.CheckState = System.Windows.Forms.CheckState.Unchecked Then
			Me.chkSitCortados.CheckState = System.Windows.Forms.CheckState.Checked
		End If
	End Sub
	
	'UPGRADE_WARNING: Event chkSitDesativados.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 chkSitDesativados_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkSitDesativados.CheckStateChanged
		If Me.chkSitLigados.CheckState = System.Windows.Forms.CheckState.Unchecked And Me.chkSitDesligados.CheckState = System.Windows.Forms.CheckState.Unchecked And Me.chkSitCortados.CheckState = System.Windows.Forms.CheckState.Unchecked And Me.chkSitDesativados.CheckState = System.Windows.Forms.CheckState.Unchecked Then
			Me.chkSitDesativados.CheckState = System.Windows.Forms.CheckState.Checked
		End If
	End Sub
	
	'UPGRADE_WARNING: Event chkSitDesligados.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 chkSitDesligados_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkSitDesligados.CheckStateChanged
		If Me.chkSitLigados.CheckState = System.Windows.Forms.CheckState.Unchecked And Me.chkSitDesligados.CheckState = System.Windows.Forms.CheckState.Unchecked And Me.chkSitCortados.CheckState = System.Windows.Forms.CheckState.Unchecked And Me.chkSitDesativados.CheckState = System.Windows.Forms.CheckState.Unchecked Then
			Me.chkSitDesligados.CheckState = System.Windows.Forms.CheckState.Checked
		End If
	End Sub
	
	'UPGRADE_WARNING: Event chkSitLigados.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 chkSitLigados_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkSitLigados.CheckStateChanged
		If Me.chkSitLigados.CheckState = System.Windows.Forms.CheckState.Unchecked And Me.chkSitDesligados.CheckState = System.Windows.Forms.CheckState.Unchecked And Me.chkSitCortados.CheckState = System.Windows.Forms.CheckState.Unchecked And Me.chkSitDesativados.CheckState = System.Windows.Forms.CheckState.Unchecked Then
			Me.chkSitLigados.CheckState = System.Windows.Forms.CheckState.Checked
		End If
	End Sub
	
	Private Sub cmdFechar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdFechar.Click
		Call Me.Close()
	End Sub
	
	Private Sub cmdImprimir_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdImprimir.Click
		Dim lstrCri As String
		Dim llngUId As Integer
		Dim lstrUId As String
		Dim lstrSit As String
		Dim lstrSql As String
		Dim lrstAux As ADODB.Recordset
		lrstAux = New ADODB.Recordset
		Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
		Call LigDes(False)
		lstrUId = ""
		'Filtro situação U.C.
		lstrSit = ""
		If Me.chkSitLigados.CheckState = System.Windows.Forms.CheckState.Checked Then
			lstrSit = lstrSit & "'L',"
		End If
		If Me.chkSitDesligados.CheckState = System.Windows.Forms.CheckState.Checked Then
			lstrSit = lstrSit & "'D',"
		End If
		If Me.chkSitCortados.CheckState = System.Windows.Forms.CheckState.Checked Then
			lstrSit = lstrSit & "'C',"
		End If
		If Me.chkSitDesativados.CheckState = System.Windows.Forms.CheckState.Checked Then
			lstrSit = lstrSit & "'I',"
		End If
		lstrSit = VB.Left(lstrSit, CInt(Len(lstrSit)) - 1)
		lstrSql = ""
		lstrSql = lstrSql & "SELECT * "
		lstrSql = lstrSql & "  FROM `unidb` "
		lstrSql = lstrSql & " WHERE `situacao` IN (" & lstrSit & ")"
		If Me.opbTipIndividual.Checked Then
			lstrSql = lstrSql & "   AND `zona` = '" & Me.txtIndZona.Text & "' "
			lstrSql = lstrSql & "   AND `livro` = '" & Me.txtIndLivro.Text & "' "
			lstrSql = lstrSql & "   AND `conta` = '" & Me.txtIndConta.Text & "' "
		ElseIf Me.opbTipFaixa.Checked Then 
			lstrSql = lstrSql & "   AND `zona` = '" & Me.txtIniZona.Text & "' "
			lstrSql = lstrSql & "   AND `livro` = '" & Me.txtIniLivro.Text & "' "
			lstrSql = lstrSql & "   AND (`conta` BETWEEN '" & Me.txtIniConta.Text & "' AND '" & Me.txtFimConta.Text & "') "
		ElseIf Me.opbTipRota.Checked Then 
			lstrSql = lstrSql & MontaFiltroRotas
		End If
		Call Conectar(lstrSql, lrstAux)
		With lrstAux
			If .State = ADODB.ObjectStateEnum.adStateOpen Then
				If .RecordCount > 0 Then
					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"'
						llngUId = CInt(IIf(IsDbNull(.Fields("unid_id").value), 0, .Fields("unid_id").value))
						lstrUId = lstrUId & llngUId & ","
						Call .MoveNext()
					End While
				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
		If CInt(Len(lstrUId)) > 0 Then
			lstrUId = VB.Left(lstrUId, CInt(Len(lstrUId)) - 1)
			lstrCri = "{unidb.unid_id} in(MakeArray (" & lstrUId & "))"
			' ----- Chama o Report de Termo de nova ligação
			With Me.crpTermo
				.ReportFileName = My.Application.Info.DirectoryPath & "\" & LeConfig("DIR_RPT") & LeConfig("TERMO_LIGACAO")
				.DiscardSavedData = True
				.WindowState = Crystal.WindowStateConstants.crptMaximized
				.WindowControlBox = True
				.WindowControls = True
				.SelectionFormula = lstrCri
				.WindowShowPrintSetupBtn = True
				.WindowShowCloseBtn = True
				.WindowShowSearchBtn = True
				.WindowTitle = "Termo de Fornecimento de Energia Elétrica"
				.Destination = Crystal.DestinationConstants.crptToWindow
				If Me.opbOrdRota.Checked Then
					.set_SortFields(0, "+{unidb.rota}")
				ElseIf Me.opbOrdIdentificador.Checked Then 
					.set_SortFields(0, "+{unidb.zona}")
					.set_SortFields(1, "+{unidb.livro}")
					.set_SortFields(2, "+{unidb.conta}")
				ElseIf Me.opbOrdNome.Checked Then 
					.set_SortFields(0, "+{unidb.nome}")
				End If
				.Action = 0
			End With
		End If
		Call LigDes(True)
		Me.Cursor = System.Windows.Forms.Cursors.Default
	End Sub
	
	Private Sub cmdLocalizaUc_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLocalizaUc.Click
		Call ifrmLocalizaUnidade.Show()
		Call ifrmLocalizaUnidade.SetaLocalizaUnidade("U", Me)
	End Sub
	
	Private Sub frmRelContratosGrupoB_KeyPress(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
		Dim KeyAscii As Short = Asc(eventArgs.KeyChar)
		If KeyAscii = System.Windows.Forms.Keys.Escape Then
			Call cmdFechar_Click(cmdFechar, New System.EventArgs())
		ElseIf KeyAscii = System.Windows.Forms.Keys.Return Then 
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub frmRelContratosGrupoB_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		ifrmLocalizaUnidade = New frmLocalizaUnidade
		
		Call CenterForm(Me)
		Call RegraCampoTipos()
	End Sub
	
	Private Sub lsvRotas_ItemCheck(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.ItemCheckEventArgs) Handles lsvRotas.ItemCheck
		Dim aItem As System.Windows.Forms.ListViewItem = lsvRotas.Items(eventArgs.Index)
		Dim lintIdx As Short
		With Me.lsvRotas
			If aItem.Text = "Marcar Todas" Then
				For lintIdx = 1 To .Items.Count
					'UPGRADE_WARNING: Lower bound of collection Me.lsvRotas.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
					.Items.Item(lintIdx).Checked = .Items.Item(1).Checked
				Next lintIdx
			Else
				If aItem.Checked = False Then
					'UPGRADE_WARNING: Lower bound of collection Me.lsvRotas.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
					.Items.Item(1).Checked = False
				End If
			End If
		End With
	End Sub
	
	Private Sub CarregaRotas()
		Dim lstrRota As String
		Dim llngLigados As Integer
		Dim llngNaoLigados As Integer
		Dim lstrSql As String
		Dim lrstAux As ADODB.Recordset
		lrstAux = New ADODB.Recordset
		If Me.lsvRotas.Items.Count = 0 Then
			With Me.lsvRotas
				Call .Items.Clear()
				Call .Columns.Clear()
				If .Columns.Count <= 1 Then
					Call .Columns.Add("", "Rota", CInt(VB6.TwipsToPixelsX(2100)))
					Call .Columns.Add("Ligados", CInt(VB6.TwipsToPixelsX(1700)), System.Windows.Forms.HorizontalAlignment.Right)
					Call .Columns.Add("Não Ligados", CInt(VB6.TwipsToPixelsX(1700)), System.Windows.Forms.HorizontalAlignment.Right)
				End If
			End With
			Me.lblInfo.Text = " Aguarde carregando as rotas..."
			Call Me.lblInfo.Refresh()
			Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
			lstrSql = ""
			lstrSql = lstrSql & "SELECT LEFT(`unidb`.`rota`, 4) AS `rotaunid`, " & vbCrLf
			lstrSql = lstrSql & "       SUM(IF(`unidb`.`situacao` = 'L', 1, 0)) AS `ligados`, " & vbCrLf
			lstrSql = lstrSql & "       SUM(IF(`unidb`.`situacao` <> 'L', 1, 0)) AS `naoligados` " & vbCrLf
			lstrSql = lstrSql & "  FROM `unidb` " & vbCrLf
			lstrSql = lstrSql & " WHERE TRIM(`unidb`.`rota`) <> '' " & vbCrLf
			lstrSql = lstrSql & "   AND LEFT(`unidb`.`rota`, 4) <> '9999' " & vbCrLf
			lstrSql = lstrSql & " GROUP BY 1 " & vbCrLf
			lstrSql = lstrSql & " ORDER BY 1 ASC" & vbCrLf
			Call Conectar(lstrSql, lrstAux)
			' ----- Insere os dados na ListView de rotas
			With lrstAux
				If .State = ADODB.ObjectStateEnum.adStateOpen Then
					If .RecordCount > 0 Then
						Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 0, .RecordCount)
						With Me.lsvRotas
							Call .Items.Add("Marcar Todas")
							'UPGRADE_WARNING: Lower bound of collection Me.lsvRotas.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
							Call .Items.Item(.Items.Count).SubItems.Add("")
							'UPGRADE_WARNING: Lower bound of collection Me.lsvRotas.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
							Call .Items.Item(.Items.Count).SubItems.Add("")
						End With
						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"'
							lstrRota = VB6.Format(IIf(IsDbNull(.Fields("rotaunid").value), "0", .Fields("rotaunid").value), "0000")
							'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
							llngLigados = IIf(IsDbNull(.Fields("ligados").value), 0, .Fields("ligados").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"'
							llngNaoLigados = IIf(IsDbNull(.Fields("naoligados").value), 0, .Fields("naoligados").value)
							With Me.lsvRotas
								Call .Items.Add(lstrRota)
								'UPGRADE_WARNING: Lower bound of collection Me.lsvRotas.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
								Call .Items.Item(.Items.Count).SubItems.Add(CStr(llngLigados))
								'UPGRADE_WARNING: Lower bound of collection Me.lsvRotas.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
								Call .Items.Item(.Items.Count).SubItems.Add(CStr(llngNaoLigados))
							End With
							Call .MoveNext()
							Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 1)
						End While
					End If
					Call .Close()
				End If
			End With
			'UPGRADE_WARNING: Lower bound of collection Me.lsvRotas.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.lsvRotas.Items.Item(1).Font = VB6.FontChangeBold(Me.lsvRotas.Items.Item(1).Font, True)
			'UPGRADE_WARNING: Lower bound of collection Me.lsvRotas.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.lsvRotas.Items.Item(1).Checked = True
			'UPGRADE_WARNING: Lower bound of collection Me.lsvRotas.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
			Call lsvRotas_ItemCheck(lsvRotas, New System.Windows.Forms.ItemCheckEventArgs(Me.lsvRotas.Items.Item(1).Index, System.Windows.Forms.CheckState.Indeterminate, Me.lsvRotas.Items.Item(1).Checked))
			Me.lblInfo.Text = " Rotas carregadas."
			Call Me.lblInfo.Refresh()
			Me.Cursor = System.Windows.Forms.Cursors.Default
		End If
		'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
		System.Windows.Forms.Application.DoEvents()
	End Sub
	
	Private Function MontaFiltroRotas() As String
		Dim lstrAux As String
		Dim lintIdx As Short
		lstrAux = ""
		With Me.lsvRotas
			'UPGRADE_WARNING: Lower bound of collection Me.lsvRotas.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 lintIdx = 2 To .Items.Count
					'UPGRADE_WARNING: Lower bound of collection Me.lsvRotas.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(lintIdx).Checked = True Then
						'UPGRADE_WARNING: Lower bound of collection Me.lsvRotas.ListItems has changed from 1 to 0. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="A3B628A0-A810-4AE2-BFA2-9E7A29EB9AD0"'
						lstrAux = lstrAux & "'" & .Items.Item(lintIdx).Text & "',"
					End If
				Next lintIdx
				If Len(Trim(lstrAux)) > 0 Then
					lstrAux = " (" & VB.Left(lstrAux, Len(lstrAux) - 1) & ") "
				End If
				If Len(Trim(lstrAux)) > 0 Then
					lstrAux = " AND LEFT(`rota`, 4) IN " & lstrAux & " "
				End If
			End If
		End With
		MontaFiltroRotas = lstrAux
	End Function
	
	Public Sub SetaCodigo(ByVal alngCodigo As Integer, ByVal astrZona As String, ByVal astrLivro As String, ByVal astrConta As String, ByVal astrGrupo As String)
		Dim lstrSql As String
		Dim lrstAux As ADODB.Recordset
		lrstAux = New ADODB.Recordset
		If astrGrupo <> "B" Then
			Call MsgBox("A unidade consumidora selecionada não é do grupo baixa tensão!", MsgBoxStyle.Critical, gstrTituloMensagem)
			Me.txtIndZona.Text = ""
			Me.txtIndLivro.Text = ""
			Me.txtIndConta.Text = ""
			Me.lblNomeUc.Text = ""
		Else
			lstrSql = ""
			lstrSql = lstrSql & "SELECT * "
			lstrSql = lstrSql & "  FROM `unidb`"
			lstrSql = lstrSql & " WHERE `zona`    = '" & astrZona & "' "
			lstrSql = lstrSql & "   AND `livro`   = '" & astrLivro & "' "
			lstrSql = lstrSql & "   AND `conta`   = '" & astrConta & "' "
			If alngCodigo > 0 Then
				lstrSql = lstrSql & "   AND `unid_id` =  " & alngCodigo & " "
			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"'
						Me.txtIndZona.Text = Trim(IIf(IsDbNull(.Fields("zona").value), astrZona, .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"'
						Me.txtIndLivro.Text = Trim(IIf(IsDbNull(.Fields("livro").value), astrZona, .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"'
						Me.txtIndConta.Text = Trim(IIf(IsDbNull(.Fields("conta").value), astrZona, .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"'
						Me.lblNomeUc.Text = Trim(IIf(IsDbNull(.Fields("nome").value), "", .Fields("nome").value))
					End If
					Call .Close()
				End If
			End With
		End If
		'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
	End Sub
	
	'UPGRADE_WARNING: Event opbTipFaixa.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 opbTipFaixa_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles opbTipFaixa.CheckedChanged
		If eventSender.Checked Then
			Call RegraCampoTipos()
			If Me.txtIniZona.Enabled Then
				Call Me.txtIniZona.Focus()
			End If
		End If
	End Sub
	
	'UPGRADE_WARNING: Event opbTipIndividual.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 opbTipIndividual_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles opbTipIndividual.CheckedChanged
		If eventSender.Checked Then
			Call RegraCampoTipos()
			If Me.txtIndZona.Enabled Then
				Call Me.txtIndZona.Focus()
			End If
		End If
	End Sub
	
	'UPGRADE_WARNING: Event opbTipRota.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 opbTipRota_CheckedChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles opbTipRota.CheckedChanged
		If eventSender.Checked Then
			Call RegraCampoTipos()
			If Me.opbTipRota.Checked Then
				Call CarregaRotas()
			End If
			If Me.lsvRotas.Enabled Then
				Call Me.lsvRotas.Focus()
			End If
		End If
	End Sub
	
	Private Sub RegraCampoTipos()
		With Me.opbTipIndividual
			Me.txtIndZona.Enabled = .Checked
			Me.txtIndLivro.Enabled = .Checked
			Me.txtIndConta.Enabled = .Checked
			Me.txtIndZona.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Checked, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			Me.txtIndLivro.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Checked, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			Me.txtIndConta.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Checked, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			Me.cmdLocalizaUc.Enabled = .Checked
			Me.lblNomeUc.Enabled = .Checked
		End With
		With Me.opbTipFaixa
			Me.txtIniZona.Enabled = .Checked
			Me.txtIniLivro.Enabled = .Checked
			Me.txtIniConta.Enabled = .Checked
			Me.txtFimZona.Enabled = .Checked
			Me.txtFimLivro.Enabled = .Checked
			Me.txtFimConta.Enabled = .Checked
			Me.txtIniZona.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Checked, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			Me.txtIniLivro.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Checked, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			Me.txtIniConta.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Checked, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			Me.txtFimZona.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Checked, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			Me.txtFimLivro.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Checked, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
			Me.txtFimConta.BackColor = System.Drawing.ColorTranslator.FromOle(IIf(.Checked, System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Window), System.Drawing.ColorTranslator.ToOle(System.Drawing.SystemColors.Control)))
		End With
		With Me.opbTipRota
			Me.lsvRotas.Enabled = .Checked
		End With
	End Sub
	
	'UPGRADE_WARNING: Event txtIniLivro.TextChanged 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 txtIniLivro_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtIniLivro.TextChanged
		Me.txtFimLivro.Text = Me.txtIniLivro.Text
	End Sub
	
	'UPGRADE_WARNING: Event txtIniZona.TextChanged 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 txtIniZona_TextChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles txtIniZona.TextChanged
		Me.txtFimZona.Text = Me.txtIniZona.Text
	End Sub
	
	Private Sub LigDes(ByVal ablnModo As Boolean)
		Me.fmeTipos.Enabled = ablnModo
		Me.fmeSituacao.Enabled = ablnModo
		Me.fmeIndividual.Enabled = ablnModo
		Me.fmePorFaixa.Enabled = ablnModo
		Me.fmeRota.Enabled = ablnModo
		Me.fmeOrdem.Enabled = ablnModo
		Me.cmdImprimir.Enabled = ablnModo
		Me.cmdFechar.Enabled = ablnModo
	End Sub
End Class