Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class frmRelReclaConcluidas
	Inherits System.Windows.Forms.Form
	
	Private Sub cmdImprimir_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdImprimir.Click
		Dim lstrCriterio As String
		lstrCriterio = "{temp_reclamacao_percentual.nomemaquina} = """ & gstrNmEstacao & """"
		With Me.crpAux
			.ReportFileName = My.Application.Info.DirectoryPath & "\" & LeConfig("DIR_RPT") & "relpercentuaisreclamacao.rpt"
			.DiscardSavedData = True
			.WindowState = Crystal.WindowStateConstants.crptMaximized
			.WindowControlBox = True
			.WindowControls = True
			.WindowShowPrintSetupBtn = True
			.WindowShowCloseBtn = True
			.WindowShowSearchBtn = True
			.SelectionFormula = lstrCriterio
			.WindowTitle = "Relatório dos percentuais de reclamações"
			.Destination = Crystal.DestinationConstants.crptToWindow
			.Action = 0
		End With
	End Sub
	
	Private Sub cmdProcessar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdProcessar.Click
		Dim lstrProtocolo As String
		Dim llngSequencia As Integer
		Dim lstrZona As String
		Dim lstrLivro As String
		Dim lstrConta As String
		Dim lstrNome As String
		Dim ldteSol As Date
		Dim lstrHorSol As String
		Dim ldteCon As Date
		Dim lstrHorCon As String
		Dim ldteAux As Date
		Dim lstrProcedente As String
		Dim lintPrazoDias As Short
		Dim lintNivelGravidade As Short
		Dim lintResolvida As Short
		Dim lintTipoReclamacao As Short
		
		Dim llngDifDias As Integer
		
		Dim lstrSql As String
		Dim lrstAux As ADODB.Recordset
		lrstAux = New ADODB.Recordset
		Call MontaGrade()
		lstrSql = ""
		lstrSql = lstrSql & "SELECT "
		lstrSql = lstrSql & "       `protocolo`, "
		lstrSql = lstrSql & "       `cod`, "
		lstrSql = lstrSql & "       `zona`, "
		lstrSql = lstrSql & "       `livro`, "
		lstrSql = lstrSql & "       `conta`, "
		lstrSql = lstrSql & "       `nome`, "
		lstrSql = lstrSql & "       `dt_solicitacao`, "
		lstrSql = lstrSql & "       `hr_solicitacao`, "
		lstrSql = lstrSql & "       `dt_conclusao`, "
		lstrSql = lstrSql & "       `hr_conclusao`, "
		lstrSql = lstrSql & "       `procedente`, "
		lstrSql = lstrSql & "       `prazo_dias_resposta`, "
		lstrSql = lstrSql & "       `nivel_gravidade`, "
		lstrSql = lstrSql & "       `resolvida`, "
		lstrSql = lstrSql & "       `tipo_reclamacao` "
		lstrSql = lstrSql & "  FROM `reclamacao` "
		lstrSql = lstrSql & " WHERE `dt_solicitacao` BETWEEN '" & VB6.Format(Me.dtpSolIni.value, "yyyy-MM-dd") & "' AND '" & VB6.Format(Me.dtpSolFim.value, "yyyy-MM-dd") & "' "
		lstrSql = lstrSql & "   AND `resolvida` <> 2 "
		Call Conectar(lstrSql, lrstAux)
		With lrstAux
			If .State = ADODB.ObjectStateEnum.adStateOpen Then
				If .RecordCount > 0 Then
					Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 0, .RecordCount)
					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"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						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"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						llngSequencia = 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"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						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"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						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"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						lstrConta = Trim(IIf(IsDbNull(.Fields("conta").value), "", .Fields("conta").value))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						lstrNome = 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"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						ldteSol = CDate(IIf(IsDbNull(.Fields("dt_solicitacao").value), "1900-01-01", .Fields("dt_solicitacao").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"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						lstrHorSol = Trim(IIf(IsDbNull(.Fields("hr_solicitacao").value), "", .Fields("hr_solicitacao").value))
						ldteSol = CDate(ldteSol & " " & VB6.Format(lstrHorSol, "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"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						ldteCon = CDate(IIf(IsDbNull(.Fields("dt_conclusao").value), "1900-01-01", .Fields("dt_conclusao").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"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						lstrHorCon = Trim(IIf(IsDbNull(.Fields("hr_conclusao").value), "1900-01-01 00:00:00", .Fields("hr_conclusao").value))
						ldteCon = CDate(ldteCon & " " & VB6.Format(lstrHorCon, "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"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						lstrProcedente = Trim(IIf(IsDbNull(.Fields("procedente").value), "", .Fields("procedente").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"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						lintPrazoDias = CShort(IIf(IsDbNull(.Fields("prazo_dias_resposta").value), 0, .Fields("prazo_dias_resposta").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"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						lintNivelGravidade = CShort(IIf(IsDbNull(.Fields("nivel_gravidade").value), 0, .Fields("nivel_gravidade").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"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						lintResolvida = CShort(IIf(IsDbNull(.Fields("resolvida").value), 0, .Fields("resolvida").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"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						lintTipoReclamacao = CShort(IIf(IsDbNull(.Fields("tipo_reclamacao").value), 0, .Fields("tipo_reclamacao").value))
						llngDifDias = 0
						If lintResolvida = 1 Then
							ldteAux = ldteSol
							While ldteAux <= ldteCon
								If WeekDay(ldteAux, FirstDayOfWeek.Sunday) <> 7 And WeekDay(ldteAux, FirstDayOfWeek.Sunday) <> 1 Then
									If Not VerificaFeriado(ldteAux) Then
										llngDifDias = llngDifDias + 1
									End If
								End If
								ldteAux = System.Date.FromOADate(ldteAux.ToOADate + 1)
							End While
							'llngDifDias = DateTime.DateDiff("d", ldteSol, ldteCon)
							Call AdicionaGrade(lintTipoReclamacao, IIf(llngDifDias <= lintPrazoDias, 1, 0), IIf(llngDifDias > lintPrazoDias, 1, 0), 0)
						Else
							Call AdicionaGrade(lintTipoReclamacao, 0, 0, 1)
						End If
						Call .MoveNext()
						Call BarraProgresso((Me.ProgressBar), (Me.lblPerc), (Me.lblInfo), 1)
					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
		Call PercentualizaGrade()
		Call GravaGrade()
	End Sub
	
	Private Sub AdicionaGrade(ByVal aintTipoReclamacao As Short, ByVal aintDentroPrazo As Short, ByVal aintForaPrazo As Short, ByVal aintEmAberto As Short)
		Dim llngAux As Integer
		Dim llngRow As Integer
		llngRow = 0
		With Me.mfgDados
			For llngAux = 1 To .Rows - 1
				'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				If CShort(IIf(IsNumeric(.get_TextMatrix(llngAux, 0)), .get_TextMatrix(llngAux, 0), 0)) = aintTipoReclamacao Then
					llngRow = llngAux
					llngAux = .Rows - 1
				End If
			Next llngAux
			If llngRow = 0 Then llngRow = .Rows - 2
			'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			.set_TextMatrix(llngRow, 2, CShort(IIf(IsNumeric(.get_TextMatrix(llngRow, 2)), .get_TextMatrix(llngRow, 2), 0)) + 1)
			'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			.set_TextMatrix(llngRow, 3, CShort(IIf(IsNumeric(.get_TextMatrix(llngRow, 3)), .get_TextMatrix(llngRow, 3), 0)) + aintDentroPrazo)
			'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			.set_TextMatrix(llngRow, 5, CShort(IIf(IsNumeric(.get_TextMatrix(llngRow, 5)), .get_TextMatrix(llngRow, 5), 0)) + aintForaPrazo)
			'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			.set_TextMatrix(llngRow, 7, CShort(IIf(IsNumeric(.get_TextMatrix(llngRow, 7)), .get_TextMatrix(llngRow, 7), 0)) + aintEmAberto)
			'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			.set_TextMatrix(.Rows - 1, 2, CShort(IIf(IsNumeric(.get_TextMatrix(.Rows - 1, 2)), .get_TextMatrix(.Rows - 1, 2), 0)) + 1)
			'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			.set_TextMatrix(.Rows - 1, 3, CShort(IIf(IsNumeric(.get_TextMatrix(.Rows - 1, 3)), .get_TextMatrix(.Rows - 1, 3), 0)) + aintDentroPrazo)
			'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			.set_TextMatrix(.Rows - 1, 5, CShort(IIf(IsNumeric(.get_TextMatrix(.Rows - 1, 5)), .get_TextMatrix(.Rows - 1, 5), 0)) + aintForaPrazo)
			'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
			.set_TextMatrix(.Rows - 1, 7, CShort(IIf(IsNumeric(.get_TextMatrix(.Rows - 1, 7)), .get_TextMatrix(.Rows - 1, 7), 0)) + aintEmAberto)
		End With
	End Sub
	
	Private Sub PercentualizaGrade()
		Dim llngRow As Integer
		Dim lintQDP As Short
		Dim lintQFP As Short
		With Me.mfgDados
			For llngRow = 1 To .Rows - 1
				'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				lintQDP = CShort(IIf(IsNumeric(.get_TextMatrix(llngRow, 3)), .get_TextMatrix(llngRow, 3), 0))
				'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				lintQFP = CShort(IIf(IsNumeric(.get_TextMatrix(llngRow, 5)), .get_TextMatrix(llngRow, 5), 0))
				If lintQDP > 0 Then
					'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					.set_TextMatrix(llngRow, 4, FormatNumber((lintQDP / CShort(IIf(IsNumeric(.get_TextMatrix(.Rows - 1, 2)), .get_TextMatrix(.Rows - 1, 2), 0))) * 100, 2))
				End If
				If lintQFP > 0 Then
					'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
					.set_TextMatrix(llngRow, 6, FormatNumber((lintQFP / CShort(IIf(IsNumeric(.get_TextMatrix(.Rows - 1, 2)), .get_TextMatrix(.Rows - 1, 2), 0))) * 100, 2))
				End If
			Next llngRow
		End With
	End Sub
	
	Private Sub GravaGrade()
		Dim lstrSql As String
		Dim llngRow As Integer
		Call Executar("DELETE FROM `temp_reclamacao_percentual` WHERE `nomemaquina` = '" & gstrNmEstacao & "' ")
		lstrSql = ""
		With Me.mfgDados
			lstrSql = "INSERT INTO `temp_reclamacao_percentual` VALUES"
			For llngRow = 1 To .Rows - 1
				lstrSql = lstrSql & "(""" & gstrNmEstacao & ""","
				lstrSql = lstrSql & " """ & VB6.Format(Me.dtpSolIni.value, "yyyy-MM-dd") & ""","
				lstrSql = lstrSql & " """ & VB6.Format(Me.dtpSolFim.value, "yyyy-MM-dd") & ""","
				lstrSql = lstrSql & " """ & .get_TextMatrix(llngRow, 1) & ""","
				'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				lstrSql = lstrSql & " " & IIf(IsNumeric(.get_TextMatrix(llngRow, 2)), .get_TextMatrix(llngRow, 2), 0) & ","
				'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				lstrSql = lstrSql & " " & IIf(IsNumeric(.get_TextMatrix(llngRow, 3)), .get_TextMatrix(llngRow, 3), 0) & ","
				'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				lstrSql = lstrSql & " " & Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 4)), .get_TextMatrix(llngRow, 4), 0), ",", ".") & ","
				'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				lstrSql = lstrSql & " " & IIf(IsNumeric(.get_TextMatrix(llngRow, 5)), .get_TextMatrix(llngRow, 5), 0) & ","
				'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				lstrSql = lstrSql & " " & Replace(IIf(IsNumeric(.get_TextMatrix(llngRow, 6)), .get_TextMatrix(llngRow, 6), 0), ",", ".") & ","
				'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
				lstrSql = lstrSql & " " & IIf(IsNumeric(.get_TextMatrix(llngRow, 7)), .get_TextMatrix(llngRow, 7), 0) & "),"
			Next llngRow
		End With
		lstrSql = VB.Left(lstrSql, Len(lstrSql) - 1)
		Call Executar(lstrSql)
	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 dtpSolIni_Change(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles dtpSolIni.Change
		Me.dtpSolFim.value = CDate(UltimoDiaMes((Me.dtpSolIni.Month), (Me.dtpSolIni.Year)) & "/" & VB6.Format(Me.dtpSolIni.value, "mm/yyyy"))
	End Sub
	
	Private Sub frmRelReclaConcluidas_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.Return Then
			Call SendKeysA(System.Windows.Forms.Keys.Tab, True)
		ElseIf KeyAscii = System.Windows.Forms.Keys.Escape Then 
			Call cmdFechar_Click(cmdFechar, New System.EventArgs())
		End If
		eventArgs.KeyChar = Chr(KeyAscii)
		If KeyAscii = 0 Then
			eventArgs.Handled = True
		End If
	End Sub
	
	Private Sub frmRelReclaConcluidas_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
		Dim lstrSql As String
		Call CenterForm(Me)
		Me.dtpSolIni.value = BuscaDataBD
		Me.dtpSolFim.value = CDate(UltimoDiaMes((Me.dtpSolIni.Month), (Me.dtpSolIni.Year)) & "/" & VB6.Format(Me.dtpSolIni.value, "mm/yyyy"))
		Call MontaGrade()
		lstrSql = ""
		lstrSql = lstrSql & "CREATE TABLE IF NOT EXISTS `temp_reclamacao_percentual`(" & vbCrLf
		lstrSql = lstrSql & "  `nomemaquina`      varchar(255)  default '',          " & vbCrLf
		lstrSql = lstrSql & "  `inicial`          date          default '0000-00-00'," & vbCrLf
		lstrSql = lstrSql & "  `final`            date          default '0000-00-00'," & vbCrLf
		lstrSql = lstrSql & "  `tipo_reclamacao`  varchar(70)   default '',          " & vbCrLf
		lstrSql = lstrSql & "  `total`            int(11)       default 0,           " & vbCrLf
		lstrSql = lstrSql & "  `dentro_prazo_qtd` int(11)       default 0,           " & vbCrLf
		lstrSql = lstrSql & "  `dentro_prazo_per` decimal(11,2) default 0.00,        " & vbCrLf
		lstrSql = lstrSql & "  `fora_prazo_qtd`   int(11)       default 0,           " & vbCrLf
		lstrSql = lstrSql & "  `fora_prazo_per`   decimal(11,2) default 0.00,        " & vbCrLf
		lstrSql = lstrSql & "  `em_aberto`        int(11)       default 0           )" & vbCrLf
		Call Executar(lstrSql)
	End Sub
	
	Private Sub MontaGrade()
		Dim llngId As Integer
		Dim lstrNome As String
		Dim lstrSql As String
		Dim lrstAux As ADODB.Recordset
		lrstAux = New ADODB.Recordset
		With Me.mfgDados
			.Redraw = False
			Call .Clear()
			.Rows = 1
			.set_TextMatrix(0, 0, "Código")
			.set_TextMatrix(0, 1, "Descrição")
			.set_TextMatrix(0, 2, "Total")
			.set_TextMatrix(0, 3, "Dentro Prazo")
			.set_TextMatrix(0, 4, "%")
			.set_TextMatrix(0, 5, "Fora Prazo")
			.set_TextMatrix(0, 6, "%")
			.set_TextMatrix(0, 7, "Em Aberto")
			.set_ColWidth(0, 800)
			.set_ColWidth(1, 4150)
			.set_ColWidth(2, 1000)
			.set_ColWidth(3, 1000)
			.set_ColWidth(4, 1000)
			.set_ColWidth(5, 1000)
			.set_ColWidth(6, 1000)
			.set_ColWidth(7, 1000)
		End With
		lstrSql = "SELECT * FROM `tipo_reclamacao` "
		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"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						llngId = CInt(IIf(IsDbNull(.Fields("id").value), 0, .Fields("id").value))
						'UPGRADE_WARNING: Use of Null/IsNull() detected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
						'UPGRADE_WARNING: Couldn't resolve default property of object Interaction.IIf(). Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
						lstrNome = Trim(IIf(IsDbNull(.Fields("nome").value), "em branco", .Fields("nome").value))
						With Me.mfgDados
							.Rows = .Rows + 1
							.set_TextMatrix(.Rows - 1, 0, llngId)
							.set_TextMatrix(.Rows - 1, 1, lstrNome)
						End With
						Call .MoveNext()
					End While
					With Me.mfgDados
						.Rows = .Rows + 1
						.set_TextMatrix(.Rows - 1, 0, "")
						.set_TextMatrix(.Rows - 1, 1, "Indefinido")
						.Rows = .Rows + 1
						.set_TextMatrix(.Rows - 1, 0, "")
						.set_TextMatrix(.Rows - 1, 1, "Total")
					End With
				End If
				Call .Close()
			End If
		End With
		Me.mfgDados.Redraw = True
		'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
End Class