Option Strict Off
Option Explicit On
Friend Class frmRelRendanaoFaturada
	Inherits System.Windows.Forms.Form
	'Option Explicit
	'
	'Dim irstFatura As ADODB.Recordset
	'Dim istrTabela      As String
	'Dim ibCabecDia      As Boolean
	'Dim fr              As New FrmRelatorio
	'Dim istrTamCol      As String
	'Dim istrBranco      As String
	'Dim istrCabec       As String
	'Dim istrTemp        As String
	'
	'Private Sub cmdImprimir_Click()
	'  Dim dtFaixa As Date
	'  Dim lstrSql As String
	'  Dim i As Integer
	'
	'  Me.MousePointer = vbHourglass
	'  Call LigDes(False)
	'  '              1     2     3     4     5     6
	'  istrTamCol = "<35mm|^25mm|^25mm|^25mm|^25mm|^25mm;"
	'  istrCabec = "Classe|" _
	''            & "Consumo|" _
	''            & "Valor |" _
	''            & "Demanda|" _
	''            & "Valor|" _
	''            & "Total"
	'
	'  istrTemp = "|0|0|0|0|0"
	'  istrBranco = "|||||"
	'  If SelecionaNFs Then
	'    Call MontaTabela
	'      lblInfo.Caption = "Montando Relatório..."
	'      lblInfo.Refresh
	'      Set fr.quem_chama = Me
	'      fr.VS.FontName = "Arial"
	'      fr.VS.FontSize = 5
	'      fr.VS.TableBorder = tbAll
	'    '  fr.VS.Orientation = orLandscape
	'      fr.VS.Orientation = orPortrait
	'      fr.VS.PhysicalPage = True
	'      fr.VS.PaperSize = pprA4
	'      fr.VS.MarginTop = "7mm"
	'      fr.VS.MarginRight = "7mm"
	'      fr.VS.MarginLeft = "7mm"
	'      fr.VS.MarginBottom = "5mm"
	'      fr.VS.TextColor = vbBlack
	'      fr.VS.BrushStyle = bsSolid
	'      fr.VS.FontBold = False
	'      fr.VS.StartDoc
	'      fr.VS.FontBold = True
	'      'fr.VS.FontSize = 10
	'      'fr.VS.Table = "<5mm|<50mm;|" & UCase(cmbOpcao.List(cmbOpcao.ListIndex))
	'       fr.VS.FontBold = False
	'       fr.VS.FontSize = 8
	'       fr.VS.CurrentY = fr.VS.CurrentY + 100
	'       fr.VS.TableBorder = tbBoxColumns
	'       fr.VS.Table = istrTamCol & istrCabec
	'       fr.VS.TableBorder = tbNone
	'       fr.VS.TableBorder = tbColumns
	'      Call ImprimeTotalGeral
	'      lblInfo.Caption = "Pronto!"
	'      lblInfo.Refresh
	'      fr.VS.EndDoc
	'      fr.Show
	'    End If
	'
	'  'Elimina as tabelas temporarias caso existir
	'  lstrSql = "DROP TABLE IF EXISTS "
	'  call executar( lstrSql & istrTabela)
	'
	'  Me.MousePointer = vbDefault
	'  Call LigDes(True)
	'
	'End Sub
	'
	'Private Function SelecionaNFs() As Boolean
	'  Dim lstrSql As String
	'  Set irstFatura = New ADODB.Recordset
	'  Me.lblInfo.Caption = " Limpando as tabelas auxiliares..."
	'  Call Me.lblInfo.Refresh
	'  Call executar("DROP TABLE IF EXISTS " & istrTabela)
	'  Me.lblInfo.Caption = " Buscando as faturas do mês/ano " & Format(Me.dtpMesAno.Value, "mm/yyyy") & "."
	'  Call Me.lblInfo.Refresh
	'  lstrSql = "SELECT * FROM nf FORCE WHERE mesano = """ & Format(Me.dtpMesAno.Value, "mm/yyyy") & """ "
	'  Call Conectar(lstrSql, irstFatura)
	'  With irstFatura
	'    If .RecordCount < 1 Then
	'      Call MsgBox("Não existem faturas no mês e ano informado!", vbInformation, gstrTituloMensagem)
	'      If .State = 1 Then Call .Close
	'    End If
	'  End With
	'  SelecionaNFs = irstFatura.RecordCount > 0
	'End Function
	'
	'
	'Private Sub ImprimeTotalGeral()
	'  Dim strTemp     As String
	'  Dim strSql      As String
	'  Dim strNmClass  As Variant
	'  Dim strCondicao As Variant
	'  Dim SomaMed     As Long
	'  Dim MedLig      As Long
	'  Dim MedDes      As Long
	'  Dim MedFixo     As Long
	'  Dim lngIni      As Long
	'  Dim lngFim      As Long
	'  Dim lngConta    As Long
	'  Dim zona        As String
	'  Dim i           As Integer
	'  Dim rsConsulta  As New ADODB.Recordset
	'  strNmClass = Array("Residencial", "Industrial", "Comercial", "Rural", "P.P.Municipal", "P.P.Estadual", "P.P.Federal", "I.Pública", "S.Público", "Cons.Livre", "Sub-Total")
	'  strCondicao = Array("mid(classe, 1, 1)= 9", "MID(classe, 1, 1) BETWEEN 0 AND 3 AND classe <> 100", "MID(classe, 1, 1)=4", "MID(classe, 1, 1)=5", "MID(classe, 1, 2) = 61", "MID(classe,1,2) = 62", "MID(classe,1,2) = 63 ", "MID(classe, 1, 2)=64", "MID(classe, 1, 1)=7", "classe=100", "MID(classe, 1, 1)<>8")
	'  lngIni = LBound(strNmClass)
	'  lngFim = UBound(strNmClass)
	'  istrTamCol = "<35mm|>25mm|>25mm|>25mm|>25mm|>25mm;"
	'
	'
	'  strSql = "SELECT SUM(consumo) consum, " _
	''         & "       SUM(vrcons)  vrcons, " _
	''         & "       SUM(demanda) demanda, " _
	''         & "       SUM(vrdemada) vrdemanda, " _
	''         & "       SUM(vrcons + vrdemada) total " _
	''         & "  FROM " & istrTabela
	'
	'  For lngConta = lngIni To lngFim
	'    Call Conectar(strSql & " WHERE " & strCondicao(lngConta), rsConsulta)
	'    If rsConsulta.RecordCount > 0 Then
	'      Call MontaTemp(strTemp, rsConsulta)
	'      If strNmClass(lngConta) = "Sub-Total" Then
	'        fr.VS.TableBorder = tbAll
	'      End If
	'      fr.VS.Table = istrTamCol & strNmClass(lngConta) & "|" & strTemp
	'      If strNmClass(lngConta) = "Sub-Total" Then
	'        fr.VS.TableBorder = tbColumns
	'      End If
	'    End If
	'    If rsConsulta.State = 1 Then rsConsulta.Close
	'    fr.VS.Table = istrTamCol & istrBranco
	'  Next lngConta
	'
	'  fr.VS.TableBorder = tbBox
	'
	'  '### TOTAL     ######
	'  Call Conectar(strSql & " WHERE mid(classe,1,1) <> 8 ", rsConsulta)
	'  If rsConsulta.RecordCount > 0 Then
	'    Call MontaTemp(strTemp, rsConsulta)
	'  '  SomaMed = rsConsulta(0) + rsConsulta(1) + rsConsulta(2) + rsConsulta(3)
	'    fr.VS.Table = istrTamCol & "Total Geral |" & strTemp
	'  End If
	'  fr.VS.TableBorder = tbNone
	'  If rsConsulta.State = 1 Then rsConsulta.Close
	'
	'
	'End Sub
	'Private Sub MontaTemp(ByRef astrTemp, ByVal arsConsulta As ADODB.Recordset)
	'  astrTemp = Format(arsConsulta!consum, "#######0") & "|" _
	''           & Format(arsConsulta!vrcons, "standard") & "|" _
	''           & Format(arsConsulta!demanda, "#######0") & "|" _
	''           & Format(arsConsulta!vrdemanda, "standard") & "|" _
	''           & Format(arsConsulta!total, "standard")
	'End Sub
	'
	'
	'
	'Public Function CabecaRel()
	'Call Cabecalho_Relatorio(fr.VS, _
	''                           "RELATORIO NÃO FATURADO", _
	''                           "PERIODO DE : " & Format(dtpIniB.Value, "dd/mm/yyyy") & " ATE " & Format(dtpFimB.Value, "dd/mm/yyyy"), "2", False, "")
	'Call LineFeed(fr.VS, 1)
	'End Function
	'
	'Private Sub MontaTabela()
	'  Dim lngContaInsert As Long
	'
	'  Dim strSqlAux      As String
	'
	'  Dim bInclui        As Boolean
	'
	'
	'  Dim intdias2 As Integer
	'   Dim intdias3 As Integer
	'    Dim intdias4 As Integer
	'
	'  Dim lstrSql As String
	'  Dim lstrClasse As String
	'  Dim lstrGrupo As String
	'  Dim lstrGrTar As String
	'  Dim lstrItens As String
	'
	'  Dim ldblVlrKWhFat As Double 'Consumo Faturado
	'  Dim ldblVlrKWhPonta As Double 'Consumo na Ponta
	'  Dim ldblVlrKWhForaPonta As Double 'Consumo Fora Ponta
	'  Dim ldblVlrKW As Double 'Demanda
	'
	'  Dim ldblQtdKWFat As Double           'Demanda Faturada
	'  Dim ldblQtdKWC As Double             'Demanda Convencional
	'  Dim ldblQtdKWPonta As Double         'Demanda na Ponta
	'  Dim ldblQtdKWForaPonta As Double     'Demanda Fora Ponta
	'  Dim ldblQtdKWUltrC As Double         'Demanda Ultrapassagem Convencional
	'  Dim ldblQtdKWUltrPonta As Double     'Demanda Ultrapassagem na Ponta
	'  Dim ldblQtdKWUltrForaPonta As Double 'Demanda Ultrapassagem Fora Ponta
	'
	'  Dim ldblQtdKWhFat As Double          'Consumo Faturado
	'  Dim ldblQtdKWhB As Double            'Consumo Grupo B
	'  Dim ldblQtdKWhC As Double            'Consumo Convencional
	'  Dim ldblQtdKWhPonta As Double        'Consumo na Ponta
	'  Dim ldblQtdKWhForaPonta As Double    'Consumo Fora Ponta
	'
	'
	'
	'
	'  Me.lblInfo.Caption = " Preparando as tabelas auxiliares..."
	'  Call Me.lblInfo.Refresh
	'  'Criando a tabela temporaria
	'  'Tabela Mãe
	'  lstrSql = "CREATE TABLE  `" & istrTabela & "` ("
	'  lstrSql = lstrSql & " `classe`   VARCHAR(4), "
	'  lstrSql = lstrSql & " `zona`     VARCHAR(3), "
	'  lstrSql = lstrSql & " `consumo`  DECIMAL(14)   DEFAULT '0' ,"
	'  lstrSql = lstrSql & " `demanda`  DECIMAL(14)   DEFAULT '0' ,"
	'  lstrSql = lstrSql & " `vrcons`   DECIMAL(14,2) DEFAULT '0.00' ,"
	'  lstrSql = lstrSql & " `vrdemada` DECIMAL(14,2) DEFAULT '0.00' ,"
	'  lstrSql = lstrSql & " KEY `keyclasse` (`classe`)"
	'  lstrSql = lstrSql & ") ENGINE=InnoDB DEFAULT CHARSET=latin1;"
	'  Call executar(lstrSql)
	'
	'  lngContaInsert = 0
	'
	'  With irstFatura
	'    Call BarraProgresso(me.ProgressBar,me.lblPerc,me.lblInfo,0, .RecordCount)
	'    While Not .EOF
	'      lstrClasse = Format(Trim(IIf(IsNull(.Fields("codclas").Value), "0", .Fields("codclas").Value)), "0000")
	'      lstrGrTar = Trim(IIf(IsNull(.Fields("ta").Value), "01B100", .Fields("ta").Value))
	'      lstrGrupo = UCase(Mid(lstrGrTar, 3, 2))
	'      lstrItens = Trim(IIf(IsNull(.Fields("itensserv").Value), "", .Fields("itensserv").Value))
	'
	'     ldblVlrKWhPonta = 0
	'     ldblVlrKWhForaPonta = 0
	'     ldblVlrKW = 0
	'     ldblQtdKWhPonta = 0
	'     ldblQtdKWhForaPonta = 0
	'     ldblQtdKWFat = 0
	'     ldblQtdKWhC = 0
	'     ldblQtdKWhB = 0
	'    'Quantidade de Consumo Faturado - kwh fat
	'
	'    If Mid(lstrGrupo, 1, 1) = "A" Then
	'      ldblQtdKWhC = BuscaVlrItem(lstrItens, "0302010009")         'Consumo Convencional
	'      ldblQtdKWhPonta = BuscaVlrItem(lstrItens, "0302010010")     'Consumo na Ponta
	'      ldblQtdKWhForaPonta = BuscaVlrItem(lstrItens, "0302010011") 'Consumo Fora da Ponta
	'      If lstrGrupo = "A4" Then
	'        ldblQtdKWFat = BuscaVlrItem(lstrItens, "0302010017")    'Demanda
	'        ldblQtdKWFat = ldblQtdKWFat + BuscaVlrItem(lstrItens, "0302010018")    'Demanda ultrap
	'      Else
	'        ldblQtdKWPonta = BuscaVlrItem(lstrItens, "0302010021")         'Demanda na Ponta
	'        ldblQtdKWUltrPonta = BuscaVlrItem(lstrItens, "0302010022")     'Demanda Ultrapassagem Ponta
	'        ldblQtdKWForaPonta = BuscaVlrItem(lstrItens, "0302010025")     'Demanda Fora da Ponta
	'        ldblQtdKWUltrForaPonta = BuscaVlrItem(lstrItens, "0302010026") 'Demanda Ultrapassagem Fora da Ponta
	'      End If
	'    Else
	'      ldblQtdKWhB = BuscaVlrItem(lstrItens, "030201009")  'Consumo Grupo B
	'    End If
	'
	'      intdias2 = DateDiff("d",Format(irstFatura!dataleitant, "dd/mm/yyyy"), Format(irstFatura!dataleit, "dd/mm/yyyy"))
	'      intdias3 = DateDiff("d",Format(irstFatura!dataleit, "dd/mm/yyyy"), Format(dtpFimB.Value, "dd/mm/yyyy"))
	'      intdias4 = DateDiff("d",Format(irstFatura!dataleit, "dd/mm/yyyy"), Format(dtpFimA.Value, "dd/mm/yyyy"))
	'
	'   If intdias4 < 0 And intdias3 < 0 Then
	'         GoTo pulaX
	'   End If
	'  '--------------------------------------------------------------------------------------------------------
	'     If lstrGrupo = "AV" Then
	'           ldblQtdKWhPonta = Int((ldblQtdKWhPonta / intdias2) * intdias4)
	'           ldblQtdKWhForaPonta = Int((ldblQtdKWhForaPonta / intdias2) * intdias4)
	'           ldblQtdKWFat = Int((ldblQtdKWFat / intdias2) * intdias4)
	'     End If
	'     If lstrGrupo = "A4" Then
	'           ldblQtdKWhC = Int((ldblQtdKWhC / intdias2) * intdias4)
	'           ldblQtdKWFat = Int((ldblQtdKWFat / intdias2) * intdias4)
	'     End If
	'     If Mid(lstrGrupo, 1, 1) = "B" Then
	'           ldblQtdKWhB = Int((ldblQtdKWhB / intdias2) * intdias3)
	'      End If
	'
	'     If lstrGrupo = "AV" Then
	'           ldblVlrKWhPonta = ldblQtdKWhPonta * (432.9 / 1000)
	'           ldblVlrKWhForaPonta = ldblQtdKWhForaPonta * (199.04 / 1000)
	'           ldblVlrKW = ldblQtdKWFat * 3.88
	'     End If
	'     If lstrGrupo = "A4" Then
	'           ldblVlrKWhPonta = ldblQtdKWhC * (194.29 / 1000)
	'           ldblVlrKW = ldblQtdKWFat * 13.34
	'     End If
	'     If Mid(lstrGrupo, 1, 1) = "B" Then
	'         If lstrClasse = "9101" Then
	'             ldblVlrKWhPonta = ldblQtdKWhB * (343.71 / 1000)
	'          ElseIf lstrClasse = "9104" And ldblQtdKWhB < 50 Then
	'              ldblVlrKWhPonta = ldblQtdKWhB * (119.1 / 1000)
	'          ElseIf lstrClasse = "9105" And ldblQtdKWhB < 50 Then
	'              ldblVlrKWhPonta = ldblQtdKWhB * (119.1 / 1000)
	'          ElseIf lstrClasse = "9104" And ldblQtdKWhB > 50 Then
	'              ldblVlrKWhPonta = ldblQtdKWhB * (254.25 / 1000)
	'          ElseIf lstrClasse = "9105" And ldblQtdKWhB > 50 Then
	'              ldblVlrKWhPonta = ldblQtdKWhB * (254.25 / 1000)
	'          ElseIf Mid(lstrClasse, 1, 1) = "5" Then
	'              ldblVlrKWhPonta = ldblQtdKWhB * (188.13 / 1000)
	'          Else
	'              ldblVlrKWhPonta = ldblQtdKWhB * (300.1 / 1000)
	'      End If
	'    End If
	'       ldblVlrKWhFat = ldblVlrKWhPonta + ldblVlrKWhForaPonta
	'       ldblQtdKWhB = ldblQtdKWhB + ldblQtdKWhC + ldblQtdKWhForaPonta + ldblQtdKWhPonta
	'   '----------------------------------------------------------------------------------------------------------
	'      lstrSql = "INSERT INTO " & istrTabela & " VALUES ("
	'      lstrSql = lstrSql & """" & lstrClasse & """," ' classe
	'      lstrSql = lstrSql & """" & irstFatura!zona & ""","
	'      lstrSql = lstrSql & """" & ldblQtdKWhB & ""","
	'      lstrSql = lstrSql & """" & ldblQtdKWFat & ""","
	'      lstrSql = lstrSql & """" & Replace(ldblVlrKWhFat, ",", ".") & ""","
	'      lstrSql = lstrSql & """" & Replace(ldblVlrKW, ",", ".") & """)"
	'    Call executar(lstrSql)
	'pulaX:
	'    irstFatura.MoveNext
	'    Call BarraProgresso(me.ProgressBar,me.lblPerc,me.lblInfo,1)
	'    DoEvents
	'  Wend
	'  'Call executar(strSql)
	'  If irstFatura.State = 1 Then irstFatura.Close
	'End Sub
	'
	'
	'Private Sub cmdCancelar_Click()
	'  Call Unload(Me)
	'End Sub
	'
	'Private Sub DTPIniA_Change()
	'  Me.dtpFimA.Value = CDate(Format(UltimoDiaMes(dtpIniA.Month, dtpIniA.Year) & "/" & Format(dtpIniA.Value, "mm/yyyy"), "dd/mm/yyyy"))
	'End Sub
	'
	'Private Sub DTPIniB_Change()
	'  Me.dtpFimB.Value = CDate(Format(UltimoDiaMes(dtpIniB.Month, dtpIniB.Year) & "/" & Format(dtpIniB.Value, "mm/yyyy"), "dd/mm/yyyy"))
	'End Sub
	'
	'Private Sub Form_KeyPress(KeyAscii As Integer)
	'  If KeyAscii = 27 Then
	'    Call Unload(Me)
	'  ElseIf KeyAscii = 13 Then
	'    Call SendKeysA(vbKeyTab, True)
	'  End If
	'End Sub
	'
	'Private Sub Form_Load()
	'  Dim lstrMesAno As String
	'  lstrMesAno = Trim(LeConfig("MESANOFATURAMENTO"))
	'  If Len(lstrMesAno) = "" Or lstrMesAno = "-1" Then
	'    lstrMesAno = Format(BuscaDataBD, "mm/yyyy")
	'  End If
	'  Me.dtpMesAno.Value = CDate(Format("01/" & lstrMesAno, "dd/mm/yyyy"))
	'  Me.dtpIniA.Value = Me.dtpMesAno.Value
	'  Me.dtpIniB.Value = Me.dtpMesAno.Value
	'  Me.dtpFimB.Value = CDate(Format(UltimoDiaMes(dtpIniB.Month, dtpIniB.Year) & "/" & Format(dtpIniB.Value, "mm/yyyy"), "dd/mm/yyyy"))
	'  Me.dtpFimA.Value = CDate(Format(UltimoDiaMes(dtpIniA.Month, dtpIniA.Year) & "/" & Format(dtpIniA.Value, "mm/yyyy"), "dd/mm/yyyy"))
	'  istrTabela = "temp_rendanft" & LCase(getComputer())
	'End Sub
	'
	'Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
	'  If irstFatura.State = 1 Then irstFatura.Close
	'End Sub
	'
	'Private Sub LigDes(abMode As Boolean)
	'  Me.dtpMesAno.Enabled = abMode
	'  Me.dtpIniA.Enabled = abMode
	'  Me.dtpIniB.Enabled = abMode
	'  Me.dtpFimB.Enabled = abMode
	'  Me.dtpFimA.Enabled = abMode
	'  Me.cmdImprimir.Enabled = abMode
	'  Me.cmdCancelar.Enabled = abMode
	'End Sub
	'
	'
	'
	Private Sub cmdImprimir_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdImprimir.Click
		
	End Sub
End Class