Option Strict Off
Option Explicit On
Friend Class frmAcertaReceitaBandeira
	Inherits System.Windows.Forms.Form
	Private ilngMesAno As Integer
	
	Private Sub cmdProcessar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdProcessar.Click
		Dim lintCtl As Short
		Dim ldblQtdConsumoLid(5) As Double
		Dim ldblVlrConsumoLid(5) As Double
		Dim ldblQtdConsumoFat(5) As Double
		Dim ldblVlrConsumoFat(5) As Double
		
		
		Dim ldblNnf As Double
		Dim lstrMAn As String
		Dim lstrIte As String
		Dim lstrSql As String
		Dim lrstAux As ADODB.Recordset
		lrstAux = New ADODB.Recordset
		ilngMesAno = CInt(VB6.Format(Me.dtpMesAno.value, "yyyyMM"))
		Me.lblInfo.Text = " Buscando as faturas aguarde..."
		Call Me.lblInfo.Refresh()
		lstrSql = ""
		lstrSql = lstrSql & "SELECT * "
		lstrSql = lstrSql & "  FROM `nf` "
		lstrSql = lstrSql & " WHERE `mesano_ref` = " & ilngMesAno
		lstrSql = lstrSql & "   AND `mesano` = '" & VB6.Format(Me.dtpMesAno.value, "MM/yyyy") & "' "
		Call Conectar(lstrSql, lrstAux, False)
		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"'
						ldblNnf = CDbl(IIf(IsDbNull(.Fields("numnf").value), 0, .Fields("numnf").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"'
						lstrMAn = Trim(IIf(IsDbNull(.Fields("mesano").value), "", .Fields("mesano").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"'
						lstrIte = Trim(IIf(IsDbNull(.Fields("itensserv").value), "", .Fields("itensserv").value))
						'Consumo Lido
						For lintCtl = 0 To 5
							ldblQtdConsumoLid(lintCtl) = BuscaValorItem(lstrIte, "030201008" & lintCtl) '0302110080
							ldblVlrConsumoLid(lintCtl) = BuscaValorItem(lstrIte, "030202008" & lintCtl) '0302120080
							ldblQtdConsumoFat(lintCtl) = BuscaValorItem(lstrIte, "030201009" & lintCtl) '0302110090
							ldblVlrConsumoFat(lintCtl) = BuscaValorItem(lstrIte, "030202009" & lintCtl) '0302120090
							'Tarifa
							'01B1011101
						Next lintCtl
						
						
						
						
						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
		
	End Sub
End Class