Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class frmRelIluminacao
	Inherits System.Windows.Forms.Form
	Private ifrmRelCIP As FrmRelatorio
	Private istrCabec(2) As String
	
	'UPGRADE_WARNING: Event chkAberto.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 chkAberto_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkAberto.CheckStateChanged
		If Me.chkAberto.CheckState = 0 Then
			If Me.chkFaturado.CheckState = 0 And Me.chkArrecadado.CheckState = 0 Then
				Me.chkAberto.CheckState = System.Windows.Forms.CheckState.Checked
			End If
		End If
	End Sub
	
	'UPGRADE_WARNING: Event chkArrecadado.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 chkArrecadado_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkArrecadado.CheckStateChanged
		If Me.chkArrecadado.CheckState = 0 Then
			If Me.chkAberto.CheckState = 0 And Me.chkFaturado.CheckState = 0 Then
				Me.chkArrecadado.CheckState = System.Windows.Forms.CheckState.Checked
			End If
		End If
	End Sub
	
	'UPGRADE_WARNING: Event chkFaturado.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 chkFaturado_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkFaturado.CheckStateChanged
		If Me.chkFaturado.CheckState = 0 Then
			If Me.chkAberto.CheckState = 0 And Me.chkArrecadado.CheckState = 0 Then
				Me.chkFaturado.CheckState = System.Windows.Forms.CheckState.Checked
			End If
		End If
	End Sub
	
	'UPGRADE_WARNING: Event chkReserva.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 chkReserva_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkReserva.CheckStateChanged
		If Me.chkReserva.CheckState = System.Windows.Forms.CheckState.Checked Then
			Me.chkArrecadado.CheckState = System.Windows.Forms.CheckState.Checked
			Me.chkArrecadado.Enabled = False
			Me.chkAberto.CheckState = System.Windows.Forms.CheckState.Unchecked
			Me.chkAberto.Enabled = False
			Me.chkFaturado.CheckState = System.Windows.Forms.CheckState.Unchecked
			Me.chkFaturado.Enabled = False
		Else
			Me.chkArrecadado.Enabled = True
			Me.chkAberto.Enabled = True
			Me.chkFaturado.Enabled = True
		End If
		
	End Sub
	
	Private Sub cmdImprimir_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdImprimir.Click
		Dim lstrSql As String
		
		Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
		Call LigDes(False)
		With ifrmRelCIP
			.quem_chama = Me
			.VS.Font = VB6.FontChangeName(.VS.Font, "Arial")
			.VS.TableBorder = VSVIEW6.TableBorderSettings.tbNone
			.VS.PageBorder = VSVIEW6.TableBorderSettings.tbNone
			.VS.Orientation = VSVIEW6.OrientationSettings.orPortrait
			.VS.PhysicalPage = True
			.VS.PaperSize = VSVIEW6.PaperSizeSettings.pprA4
			.VS.MarginTop = "7mm"
			.VS.MarginRight = "7mm"
			.VS.MarginLeft = "7mm"
			.VS.MarginBottom = "5mm"
			.VS.TextColor = System.Drawing.Color.Black
			.VS.BrushStyle = VSVIEW6.BrushStyleSettings.bsSolid
			.VS.Font = VB6.FontChangeSize(.VS.Font, 8)
			Call .VS.StartDoc()
		End With
		Me.mfgDados.Rows = 1
		Me.lblInfo.Text = " Aguarde.... "
		Call Me.lblInfo.Refresh()
		If Me.chkArrecadado.CheckState = 1 Then
			'
			'--- Arrecadado no período Informado
			lstrSql = ""
			lstrSql = lstrSql & "   AND `nf`.`datapag` BETWEEN '" & VB6.Format(Me.dtpInicial.value, "yyyy-MM-dd") & "' AND '" & VB6.Format(Me.dtpFinal.value, "yyyy-MM-dd") & "' "
			lstrSql = lstrSql & "   AND `nf`.`datapag` <> '0000-00-00' "
			If Me.chkReserva.CheckState = System.Windows.Forms.CheckState.Unchecked Then
				lstrSql = lstrSql & "   AND `nf`.`flgst` = 'P' "
				istrCabec(0) = "Resumo de custeio de iluminação pública arrecadado no período de " & VB6.Format(Me.dtpInicial.value, "dd/mm/yyyy") & " até " & VB6.Format(Me.dtpFinal.value, "dd/mm/yyyy")
			Else
				lstrSql = lstrSql & "   AND `nf`.`flgst` = 'R' "
				istrCabec(0) = "Baixados Reserva iluminação pública no período de " & VB6.Format(Me.dtpInicial.value, "dd/mm/yyyy") & " até " & VB6.Format(Me.dtpFinal.value, "dd/mm/yyyy")
			End If
			'  lstrSql = lstrSql & "   AND NOT EXISTS(SELECT * " & vbCrLf
			'  lstrSql = lstrSql & "                    FROM reserva " & vbCrLf
			'  lstrSql = lstrSql & "                   WHERE reserva.numnf    = nf.numnf  " & vbCrLf
			'  lstrSql = lstrSql & "                     AND reserva.mesano   = nf.mesano " & vbCrLf
			'  lstrSql = lstrSql & "                     AND reserva.zona     = nf.zona   " & vbCrLf
			'  lstrSql = lstrSql & "                     AND reserva.livro    = nf.livro  " & vbCrLf
			'  lstrSql = lstrSql & "                     AND reserva.conta    = nf.conta  " & vbCrLf
			'  lstrSql = lstrSql & "                     AND reserva.datares <= '" & Format(Me.dtpFinal.Value, "yyyy-MM-dd") & "')"
			
			
			Call MontaDados(lstrSql, 0)
		ElseIf Me.chkFaturado.CheckState = 1 Then 
			'
			'--- Faturados no período Informado
			lstrSql = ""
			'lstrSql = lstrSql & "   AND `nf`.`mesano_ref` BETWEEN " & CLng(Format(Me.dtpInicial.Value, "yyyymm")) & " AND " & CLng(Format(Me.dtpFinal.Value, "yyyymm"))
			lstrSql = lstrSql & "   AND `nf`.`dataem` BETWEEN '" & VB6.Format(Me.dtpInicial.value, "yyyy-MM-dd") & "' AND '" & VB6.Format(Me.dtpFinal.value, "yyyy-MM-dd") & "' "
			'lstrSql = lstrSql & "   AND `nf`.`mesano_ref` = " & CLng(Format(Me.dtpFinal.Value, "yyyymm"))
			'lstrSql = lstrSql & "   AND `nf`.`flgst` <> 'C' "
			lstrSql = lstrSql & " AND ((mesano_ref BETWEEN " & CInt(VB6.Format(Me.dtpInicial.value, "yyyymm")) & " AND " & CInt(VB6.Format(Me.dtpFinal.value, "yyyymm")) & ") OR" & vbCrLf
			lstrSql = lstrSql & "      (flgst='C' AND mesano_ref <> REPLACE(LEFT(datast, 7),'-','') AND datast BETWEEN '" & VB6.Format(Me.dtpInicial.value, "yyyy-MM-dd") & "' AND '" & VB6.Format(Me.dtpFinal.value, "yyyy-MM-dd") & "'))" & vbCrLf
			istrCabec(1) = "Resumo de custeio de iluminação pública faturado com emissão entre " & VB6.Format(Me.dtpInicial.value, "dd/mm/yyyy") & " até " & VB6.Format(Me.dtpFinal.value, "dd/mm/yyyy")
			Call MontaDados(lstrSql, 1)
		ElseIf Me.chkAberto.CheckState = 1 Then 
			'
			'--- Em Aberto até a data final informada
			lstrSql = ""
			lstrSql = lstrSql & "   AND `nf`.`mesano_ref` <= " & CInt(VB6.Format(Me.dtpFinal.value, "yyyymm")) & " "
			lstrSql = lstrSql & "   AND `nf`.`dataem` <= '" & VB6.Format(Me.dtpFinal.value, "yyyy-MM-dd") & "' "
			lstrSql = lstrSql & "   AND (`nf`.`datapag` > '" & VB6.Format(Me.dtpFinal.value, "yyyy-MM-dd") & "' OR `nf`.`datapag` = '0000-00-00' )"
			lstrSql = lstrSql & "   AND (`nf`.`flgst` <> 'C' OR " & vbCrLf
			lstrSql = lstrSql & "        ( (`nf`.`flgst`='C' AND `nf`.`datast` > '" & VB6.Format(Me.dtpFinal.value, "yyyy-MM-dd") & "') OR " & vbCrLf
			lstrSql = lstrSql & "          (`nf`.`flgst`='C' AND `nf`.`mesano_ref` <> REPLACE(LEFT(`nf`.`datast`, 7),'-','') AND `nf`.`datast` BETWEEN '" & VB6.Format(Me.dtpInicial.value, "yyyy-MM-dd") & "' AND '" & VB6.Format(Me.dtpFinal.value, "yyyy-MM-dd") & "')" & vbCrLf
			lstrSql = lstrSql & "         )" & vbCrLf
			lstrSql = lstrSql & "        )" & vbCrLf
			lstrSql = lstrSql & "   AND NOT EXISTS(SELECT * " & vbCrLf
			lstrSql = lstrSql & "                    FROM reserva " & vbCrLf
			lstrSql = lstrSql & "                   WHERE reserva.numnf    = nf.numnf  " & vbCrLf
			lstrSql = lstrSql & "                     AND reserva.mesano   = nf.mesano " & vbCrLf
			lstrSql = lstrSql & "                     AND reserva.zona     = nf.zona   " & vbCrLf
			lstrSql = lstrSql & "                     AND reserva.livro    = nf.livro  " & vbCrLf
			lstrSql = lstrSql & "                     AND reserva.conta    = nf.conta  " & vbCrLf
			lstrSql = lstrSql & "                     AND reserva.datares <= '" & VB6.Format(Me.dtpFinal.value, "yyyy-MM-dd") & "')"
			istrCabec(2) = "Resumo de custeio de iluminação pública em aberto até o dia " & VB6.Format(Me.dtpFinal.value, "dd/mm/yyyy")
			Call MontaDados(lstrSql, 2)
		End If
		Call RelIluminacao()
		'
		With ifrmRelCIP
			Call .VS.EndDoc()
			Call .Show()
		End With
		Me.lblInfo.Text = " Pronto!"
		Call Me.lblInfo.Refresh()
		Call LigDes(True)
		Me.Cursor = System.Windows.Forms.Cursors.Default
	End Sub
	
	Private Sub MontaDados(ByVal astrSql As String, ByVal aintTipo As Short)
		Dim lstrZona As String
		Dim lstrClas As String
		Dim lstrItem As String
		Dim ldblIlum As Double
		Dim lstrCdes As String
		Dim lstrSql As String
		Dim lrstAux As New ADODB.Recordset
		lrstAux = New ADODB.Recordset
		Me.lblInfo.Text = " Buscando faturas " & IIf(aintTipo = 0, "(Arrecadado)", IIf(aintTipo = 1, "(Faturado)", "(Abertos)"))
		Call Me.lblInfo.Refresh()
		lstrSql = ""
		lstrSql = lstrSql & "SELECT "
		lstrSql = lstrSql & "       `nf`.`codclas`, "
		lstrSql = lstrSql & "       `nf`.`itensserv`, "
		lstrSql = lstrSql & "       `nf`.`numnf`, "
		lstrSql = lstrSql & "       `nf`.`zona`, "
		lstrSql = lstrSql & "       `nf`.`datapag`, "
		lstrSql = lstrSql & "       `nf`.`flgst`, "
		lstrSql = lstrSql & "       `nf`.`mesano_ref`, "
		lstrSql = lstrSql & "       `nf`.`mesano` "
		lstrSql = lstrSql & "  FROM `nf` "
		lstrSql = lstrSql & " WHERE `nf`.`itensserv` LIKE '%0301000003%' "
		Call Conectar(lstrSql & astrSql, lrstAux)
		With lrstAux
			If .State = ADODB.ObjectStateEnum.adStateOpen Then
				If .RecordCount > 0 Then
					Me.mfgDados.Redraw = False
					Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 0, .RecordCount, IIf(aintTipo = 0, "(Arrecadado)", IIf(aintTipo = 1, "(Faturado)", "(Abertos)")))
					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"'
						lstrZona = Trim(IIf(IsDbNull(.Fields("zona").value), "000", .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"'
						lstrClas = Trim(IIf(IsDbNull(.Fields("codclas").value), "0000", .Fields("codclas").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"'
						lstrItem = Trim(IIf(IsDbNull(.Fields("itensserv").value), "", .Fields("itensserv").value))
						ldblIlum = BuscaVlrItem(lstrItem, "0301000003")
						Select Case CShort(VB.Left(lstrClas, 1))
							Case Is = 9
								lstrCdes = "0 RESIDENCIAL"
							Case Is < 4
								lstrCdes = "1 INDUSTRIAL"
							Case Is = 4
								lstrCdes = "2 COMERCIAL"
							Case Is = 5
								lstrCdes = "3 RURAL"
							Case Is = 6
								lstrCdes = "4 PODERES PÚBLICOS"
							Case Is = 7
								lstrCdes = "5 SERVIÇO PÚBLICO"
							Case Is = 8
								lstrCdes = "6 CONSUMO PRÓPRIO"
							Case Else
								lstrCdes = "7 INDEFINIDO"
						End Select
						Call AdicionaGrid(aintTipo, lstrZona, lstrCdes, ldblIlum)
						Call .MoveNext()
						Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 1,  , IIf(aintTipo = 0, "(Arrecadado)", IIf(aintTipo = 1, "(Faturado)", "(Abertos)")))
					End While
				End If
				Call .Close()
			End If
		End With
		With Me.mfgDados
			.Col = 5
			.Sort = MSFlexGridLib.SortSettings.flexSortGenericAscending
			.Redraw = True
		End With
	End Sub
	
	Private Sub RelIluminacao()
		Dim llngRow As Integer
		Dim lstrTam As String
		Dim lstrTab As String
		Dim lstrAux As String
		Dim lintAux As Short
		
		Dim lintTipo As Short
		Dim lstrZona As String
		Dim lstrCdes As String
		Dim llngQtde As Integer
		Dim ldblIlum As Double
		Dim llntSTQt As Integer
		Dim ldblSTot As Double
		Dim llntGTQt As Integer
		Dim ldblGTot As Double
		
		With Me.mfgDados
			If .Rows > 1 Then
				lintTipo = CShort(.get_TextMatrix(1, 0))
			End If
			With ifrmRelCIP
				.VS.CurrentLine = 1
				Call Cabecalho_Relatorio(.VS, istrCabec(lintTipo), "", "2")
				Call LineFeed(.VS, 3)
				.VS.Font = VB6.FontChangeBold(.VS.Font, True)
				.VS.BrushColor = System.Drawing.Color.White
				.VS.Font = VB6.FontChangeSize(.VS.Font, 8)
				lstrTam = "<10mm|<20mm|<70mm|>35mm|>60mm;"
				lstrTab = "|ZONA|CLASSE|QTD|Valor"
				.VS.Table = lstrTam & lstrTab
				.VS.Font = VB6.FontChangeBold(.VS.Font, False)
				Call LineFeed(.VS, 1)
			End With
			For llngRow = 1 To .Rows - 1
				lintTipo = CShort(.get_TextMatrix(llngRow, 0))
				lstrZona = Trim(.get_TextMatrix(llngRow, 1))
				lstrCdes = Trim(.get_TextMatrix(llngRow, 2))
				llngQtde = CInt(.get_TextMatrix(llngRow, 3))
				ldblIlum = CDbl(.get_TextMatrix(llngRow, 4))
				If llngRow = 1 Then
					lstrAux = lstrZona
					lintAux = lintTipo
				End If
				With ifrmRelCIP
					If lstrZona <> lstrAux Or lintTipo <> lintAux Then
						.VS.Font = VB6.FontChangeBold(.VS.Font, True)
						lstrTab = ""
						lstrTab = lstrTab & "|"
						lstrTab = lstrTab & "TOTAL" & "|"
						lstrTab = lstrTab & "|"
						lstrTab = lstrTab & FormatNumber(llntSTQt, 0) & "|"
						lstrTab = lstrTab & FormatNumber(ldblSTot, 2)
						.VS.Table = lstrTam & lstrTab
						.VS.Font = VB6.FontChangeBold(.VS.Font, False)
						Call LineFeed(.VS, 1)
						llntSTQt = 0
						ldblSTot = 0
					End If
					If lintTipo <> lintAux Then
						.VS.NewPage()
						.VS.CurrentLine = 1
						Call Cabecalho_Relatorio(.VS, istrCabec(lintTipo), "", "2")
						Call LineFeed(.VS, 3)
						.VS.Font = VB6.FontChangeBold(.VS.Font, True)
						.VS.BrushColor = System.Drawing.Color.White
						.VS.Font = VB6.FontChangeSize(.VS.Font, 8)
						lstrTam = "<10mm|<20mm|<70mm|>35mm|>60mm;"
						lstrTab = "|ZONA|CLASSE|QTD|Valor"
						.VS.Table = lstrTam & lstrTab
						.VS.Font = VB6.FontChangeBold(.VS.Font, False)
						Call LineFeed(.VS, 1)
					End If
					llntSTQt = llntSTQt + llngQtde
					ldblSTot = ldblSTot + ldblIlum
					llntGTQt = llntGTQt + llngQtde
					ldblGTot = ldblGTot + ldblIlum
					lstrTab = ""
					lstrTab = lstrTab & "|"
					lstrTab = lstrTab & lstrZona & "|"
					lstrTab = lstrTab & Mid(lstrCdes, 3) & "|"
					lstrTab = lstrTab & FormatNumber(llngQtde, 0) & "|"
					lstrTab = lstrTab & FormatNumber(ldblIlum, 2)
					.VS.Table = lstrTam & lstrTab
					If .VS.CurrentLine > 402 Then
						.VS.NewPage()
						.VS.CurrentLine = 1
						Call Cabecalho_Relatorio(.VS, istrCabec(lintTipo), "", "2")
						Call LineFeed(.VS, 3)
						.VS.Font = VB6.FontChangeBold(.VS.Font, True)
						.VS.BrushColor = System.Drawing.Color.White
						.VS.Font = VB6.FontChangeSize(.VS.Font, 8)
						lstrTam = "<10mm|<20mm|<70mm|>35mm|>60mm;"
						lstrTab = "|ZONA|CLASSE|QTD|Valor"
						.VS.Table = lstrTam & lstrTab
						.VS.Font = VB6.FontChangeBold(.VS.Font, False)
						Call LineFeed(.VS, 1)
					End If
					lstrAux = lstrZona
					lintAux = lintTipo
				End With
			Next llngRow
			With ifrmRelCIP
				.VS.Font = VB6.FontChangeBold(.VS.Font, True)
				lstrTab = ""
				lstrTab = lstrTab & "|"
				lstrTab = lstrTab & "TOTAL" & "|"
				lstrTab = lstrTab & "|"
				lstrTab = lstrTab & FormatNumber(llntSTQt, 0) & "|"
				lstrTab = lstrTab & FormatNumber(ldblSTot, 2)
				.VS.Table = lstrTam & lstrTab
				.VS.Font = VB6.FontChangeBold(.VS.Font, False)
				'      Call LineFeed(.VS, 2)
				'      .VS.FontBold = True
				'      lstrTab = ""
				'      lstrTab = lstrTab & "|"
				'      lstrTab = lstrTab & "TOTAL GERAL" & "|"
				'      lstrTab = lstrTab & "|"
				'      lstrTab = lstrTab & FormatNumber(llntGTQt, 0) & "|"
				'      lstrTab = lstrTab & FormatNumber(ldblGTot, 2)
				'      .VS.Table = lstrTam & lstrTab
				'      .VS.FontBold = False
			End With
		End With
	End Sub
	
	Private Sub LigDes(ByVal abModo As Boolean)
		Me.dtpInicial.Enabled = abModo
		Me.dtpFinal.Enabled = abModo
		Me.cmdImprimir.Enabled = abModo
		Me.cmdFechar.Enabled = abModo
		Me.chkReserva.Enabled = abModo
		If Me.chkReserva.CheckState = System.Windows.Forms.CheckState.Checked Then
			Me.chkArrecadado.Enabled = False
			Me.chkAberto.Enabled = False
			Me.chkFaturado.Enabled = False
		Else
			Me.chkArrecadado.Enabled = abModo
			Me.chkAberto.Enabled = abModo
			Me.chkFaturado.Enabled = abModo
		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 frmRelIluminacao_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		Me.dtpInicial.value = BuscaDataBD
		Me.dtpFinal.value = CDate(UltimoDiaMes((dtpInicial.Month), (dtpInicial.Year)) & "/" & dtpInicial.Month & "/" & dtpInicial.Year)
		ifrmRelCIP = New FrmRelatorio
		With Me.mfgDados
			.Rows = 1
			Call .Clear()
			.set_TextMatrix(0, 0, "Tipo")
			.set_TextMatrix(0, 1, "Zona")
			.set_TextMatrix(0, 2, "Classe")
			.set_TextMatrix(0, 3, "Qtde")
			.set_TextMatrix(0, 4, "Valor")
			.set_TextMatrix(0, 5, "Ordenação")
			.set_ColWidth(0, 500)
			.set_ColWidth(1, 500)
			.set_ColWidth(2, 2000)
			.set_ColWidth(3, 800)
			.set_ColWidth(4, 1000)
			.set_ColWidth(5, 2800)
			.set_ColAlignment(0, MSFlexGridLib.AlignmentSettings.flexAlignCenterCenter)
			.set_ColAlignment(1, MSFlexGridLib.AlignmentSettings.flexAlignLeftCenter)
			.set_ColAlignment(2, MSFlexGridLib.AlignmentSettings.flexAlignLeftCenter)
			.set_ColAlignment(3, MSFlexGridLib.AlignmentSettings.flexAlignRightCenter)
			.set_ColAlignment(4, MSFlexGridLib.AlignmentSettings.flexAlignRightCenter)
			.set_ColAlignment(5, MSFlexGridLib.AlignmentSettings.flexAlignLeftCenter)
		End With
	End Sub
	
	Private Sub frmRelIluminacao_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
		'UPGRADE_NOTE: Object ifrmRelCIP 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"'
		ifrmRelCIP = Nothing
	End Sub
	
	Private Sub AdicionaGrid(ByVal aintTipo As Short, ByVal astrZona As String, ByVal astrCdes As String, ByVal adblIlum As Double)
		Dim llngRow As Integer
		Dim llngPos As Integer
		llngPos = 0
		'Verifica se jé tem na grade
		With Me.mfgDados
			If .Rows > 1 Then
				For llngRow = 1 To .Rows - 1
					If CDbl(.get_TextMatrix(llngRow, 0)) = aintTipo Then
						If .get_TextMatrix(llngRow, 1) = astrZona Then
							If .get_TextMatrix(llngRow, 2) = astrCdes Then
								llngPos = llngRow
								llngRow = .Rows - 1
							End If
						End If
					End If
				Next llngRow
			End If
			If llngPos = 0 Then
				.Rows = .Rows + 1
				llngPos = (.Rows - 1)
				.set_TextMatrix(llngPos, 0, aintTipo) 'Tipo relatório
				.set_TextMatrix(llngPos, 1, astrZona) 'Cidade
				.set_TextMatrix(llngPos, 2, astrCdes) 'Classe Código/Descrição
				.set_TextMatrix(llngPos, 5, aintTipo & astrZona & astrCdes)
			End If
			.set_TextMatrix(llngPos, 3, FormatNumber(CInt(IIf(.get_TextMatrix(llngPos, 3) = "", 0, .get_TextMatrix(llngPos, 3))) + 1, 0)) 'Qtde
			.set_TextMatrix(llngPos, 4, FormatNumber(CDbl(IIf(.get_TextMatrix(llngPos, 4) = "", 0, .get_TextMatrix(llngPos, 4))) + adblIlum, 2)) 'valor
		End With
	End Sub
End Class