Option Strict Off
Option Explicit On
Friend Class frmCadTabIndDecFec
	Inherits System.Windows.Forms.Form
	'Option Explicit
	'Private irstRegiao As ADODB.Recordset
	'Private iblnNovo As Boolean
	'
	'Private Sub Form_Load()
	'  Me.Width = 6765
	'  Me.Height = 2790
	'  Call Me.cmbTipo.AddItem("DEC")
	'  Call Me.cmbTipo.AddItem("FEC")
	'  Call CarregaTabelaComboBox(Me.cmbTensao, "`tensao`", "`valor`", "`id`", "`valor` ASC", "", , "")
	'  Call CarregaTabelaComboBox(Me.cmbRegiao, "`regiao`", "`descricao`", "`id`", "`id` ASC", "", , "")
	'  Call CarregaTabelaComboBox(Me.cmbTabela, "`ic_dicficdmic`", " DISTINCT `id`", "`id`", "`id` ASC", "", , "")
	'  Call CarregaTabelaComboBox(Me.cmbFxDecFec, "`ic_dicficdmic`", " DISTINCT `id_codigo`", "`id_codigo`", "`id_codigo` ASC", "", , " `id` = " & Me.cmbTabela.List(Me.cmbTabela.ListIndex))
	'  With Me.fmePesquisa
	'    Call .Move(Me.fmeCadastro.Left)
	'    .Visible = False
	'    .Enabled = False
	'  End With
	'  Set irstRegiao = New ADODB.Recordset
	'  Call cmdLocalizar_Click
	'End Sub
	'
	'Private Sub Form_KeyPress(KeyAscii As Integer)
	'  If KeyAscii = vbKeyEscape Then
	'    Call cmdFechar_Click
	'  ElseIf KeyAscii = vbKeyReturn Then
	'    Call SendKeysA(vbKeyTab, True)
	'  End If
	'End Sub
	'
	'Private Sub cmdNovo_Click()
	'  iblnNovo = True
	'  Call limpaCampos
	'End Sub
	'
	'Private Sub cmdSalvar_Click()
	'  Dim lstrSql As String
	'
	'  On Error GoTo ErroSalvar
	'
	'  With myConC
	'    lstrSql = ""
	'    If Me.txtId.Text = "0" Or iblnNovo Then
	'      lstrSql = lstrSql & "INSERT INTO `ic_referencia` SET " & vbCrLf
	'      lstrSql = lstrSql & "       `id`               = " & CLng(Me.txtId.Text) & ", " & vbCrLf
	'      lstrSql = lstrSql & "       `tipo`             = """ & UCase(Left(Trim(Me.cmbTipo.List(Me.cmbTipo.ListIndex)), 1)) & """, " & vbCrLf
	'      lstrSql = lstrSql & "       `id_tensao`        = " & CLng(Me.cmbTensao.List(Me.cmbTensao.ListIndex)) & ", " & vbCrLf
	'      lstrSql = lstrSql & "       `id_regiao`        = " & CLng(Me.cmbRegiao.List(Me.cmbRegiao.ListIndex)) & ", " & vbCrLf
	'      lstrSql = lstrSql & "       `id_ic_dicficdmic` = " & CLng(Me.cmbTabela.List(Me.cmbTabela.ListIndex)) & ", " & vbCrLf
	'      lstrSql = lstrSql & "       `id_codigo`        = " & CLng(Me.cmbFxDecFec.List(Me.cmbFxDecFec.ListIndex)) & ", " & vbCrLf
	'    Else
	'      lstrSql = lstrSql & "UPDATE `ic_referencia` SET " & vbCrLf
	'    End If
	'    lstrSql = lstrSql & "       `dec_trimestral`   = """ & Trim(Me.txtDec(0).Text) & """, " & vbCrLf
	'    lstrSql = lstrSql & "       `dec_mensal`       = """ & Trim(Me.txtDec(1).Text) & """, " & vbCrLf
	'    lstrSql = lstrSql & "       `fec_trimestral`   = """ & Trim(Me.txtFec(0).Text) & """, " & vbCrLf
	'    lstrSql = lstrSql & "       `fec_mensal`       = """ & Trim(Me.txtFec(1).Text) & """ " & vbCrLf
	'
	'    If Not iblnNovo Then
	'      lstrSql = lstrSql & " WHERE `ic_referencia`.`id`               = " & CLng(Me.txtId.Text) & ", " & vbCrLf
	'      lstrSql = lstrSql & "   AND `ic_referencia`.`tipo`             = """ & UCase(Left(Trim(Me.cmbTipo.List(Me.cmbTipo.ListIndex)), 1)) & """, " & vbCrLf
	'      lstrSql = lstrSql & "   AND `ic_referencia`.`id_tensao`        = " & CLng(Me.cmbTensao.List(Me.cmbTensao.ListIndex)) & ", " & vbCrLf
	'      lstrSql = lstrSql & "   AND `ic_referencia`.`id_regiao`        = " & CLng(Me.cmbRegiao.List(Me.cmbRegiao.ListIndex)) & ", " & vbCrLf
	'      lstrSql = lstrSql & "   AND `ic_referencia`.`id_ic_dicficdmic` = " & CLng(Me.cmbTabela.List(Me.cmbTabela.ListIndex)) & ", " & vbCrLf
	'      lstrSql = lstrSql & "   AND `ic_referencia`.`id_codigo`        = " & CLng(Me.cmbFxDecFec.List(Me.cmbFxDecFec.ListIndex)) & ", " & vbCrLf
	'    End If
	'    Call executar(lstrSql)
	'    Call cmdLocalizar_Click
	'ErroSalvar:
	'    If .Errors.Count > 0 Then
	'      Call MsgBox("Código: " & .Errors.Item(.Errors.Count - 1).NativeError & vbCrLf & "Descrição:" & .Errors.Item(.Errors.Count - 1).Description)
	'    End If
	'  End With
	'End Sub
	'
	'Private Sub cmdExcluir_Click()
	'  Dim lstrSql As String
	'
	'  On Error GoTo ErroExcluir
	'
	'  With myConC
	'    If MsgBox("Deseja realmente excluir este registro!", vbYesNo + vbDefaultButton2, gstrTituloMensagem) = vbYes Then
	'      lstrSql = ""
	'      lstrSql = lstrSql & "DELETE FROM `ic_referencia` "
	'      lstrSql = lstrSql & " WHERE `ic_referencia`.`id`               = " & CLng(Me.txtId.Text) & ", " & vbCrLf
	'      lstrSql = lstrSql & "   AND `ic_referencia`.`tipo`             = """ & UCase(Left(Trim(Me.cmbTipo.List(Me.cmbTipo.ListIndex)), 1)) & """, " & vbCrLf
	'      lstrSql = lstrSql & "   AND `ic_referencia`.`id_tensao`        = " & CLng(Me.cmbTensao.List(Me.cmbTensao.ListIndex)) & ", " & vbCrLf
	'      lstrSql = lstrSql & "   AND `ic_referencia`.`id_regiao`        = " & CLng(Me.cmbRegiao.List(Me.cmbRegiao.ListIndex)) & ", " & vbCrLf
	'      lstrSql = lstrSql & "   AND `ic_referencia`.`id_ic_dicficdmic` = " & CLng(Me.cmbTabela.List(Me.cmbTabela.ListIndex)) & ", " & vbCrLf
	'      lstrSql = lstrSql & "   AND `ic_referencia`.`id_codigo`        = " & CLng(Me.cmbFxDecFec.List(Me.cmbFxDecFec.ListIndex)) & ", " & vbCrLf
	'      Call .Execute(lstrSql)
	'    End If
	'ErroExcluir:
	'    If .Errors.Count > 0 Then
	'      Call MsgBox("Código: " & .Errors.Item(.Errors.Count - 1).NativeError & vbCrLf & "Descrição:" & .Errors.Item(.Errors.Count - 1).Description)
	'    End If
	'  End With
	'End Sub
	'
	'Private Sub cmdLocalizar_Click()
	'  Call LigDesFrame(True)
	'  Call MontaGrid
	'End Sub
	'
	'Private Sub cmdFechar_Click()
	'  Set irstRegiao = Nothing
	'  Call Unload(Me)
	'End Sub
	'
	'Private Sub MontaGrid()
	'  With Me.mfgDados
	'    Call .Clear
	'    .Redraw = False
	'    .Rows = 1
	'    .Cols = 2
	'    .ColWidth(0) = 1000
	'    .ColWidth(1) = 5100
	'    .TextMatrix(0, 0) = "Id"
	'    .TextMatrix(0, 1) = "Descrição"
	'    Call PopulaGrid
	'    .Redraw = True
	'  End With
	'End Sub
	'
	'Private Sub PopulaGrid()
	'  Dim lstrSql As String
	'  Dim llngCodId As Long
	'  Dim lstrDescr As String
	'  Dim lstrSigla As String
	'
	'  On Error GoTo ErroPopulaGrid
	'
	''select ic_referencia.ano, ic_referencia.tipo, ic_referencia.id_tensao, tensao.valor, ic_referencia.id_regiao, regiao.descricao,
	''ic_referencia.id_ic_dicficdmic , ic_referencia.id_codigo
	''From ic_referencia
	''inner join tensao on(ic_referencia.id_tensao = tensao.id)
	''inner join regiao on(ic_referencia.id_regiao = regiao.id)
	''inner join ic_dicficdmic on(ic_referencia.id_ic_dicficdmic = ic_dicficdmic.id and ic_referencia.id_codigo = ic_dicficdmic.id_codigo)
	'
	'
	'  If irstRegiao.State = adStateOpen Then Call irstRegiao.Close
	'  lstrSql = ""
	'  lstrSql = lstrSql & "   SELECT `regiao`.`id`, "
	'  lstrSql = lstrSql & "          `regiao`.`descricao`, "
	'  lstrSql = lstrSql & "          `regiao`.`sigla` "
	'  lstrSql = lstrSql & "     FROM `regiao` "
	'  lstrSql = lstrSql & " ORDER BY `regiao`.`descricao` ASC "
	'  Call Conectar(lstrSql, irstRegiao)
	'  With irstRegiao
	'    If .RecordCount > 0 Then
	'      While Not .EOF
	'        llngCodId = CLng(IIf(IsNull(.Fields("id").Value), 0, .Fields("id").Value))
	'        lstrDescr = Trim(IIf(IsNull(.Fields("descricao").Value), "", .Fields("descricao").Value))
	'        lstrSigla = Trim(IIf(IsNull(.Fields("sigla").Value), "", .Fields("sigla").Value))
	'        With Me.mfgDados
	'          .Rows = .Rows + 1
	'          .TextMatrix(.Rows - 1, 0) = llngCodId
	'          .TextMatrix(.Rows - 1, 1) = lstrDescr
	'        End With
	'        Call .MoveNext
	'      Wend
	'    Else
	'      Call MsgBox("Não existe registros! ", vbExclamation, gstrTituloMensagem)
	'    End If
	'  End With
	'ErroPopulaGrid:
	'  With myConC
	'    If .Errors.Count > 0 Then
	'      Call MsgBox("Código: " & .Errors.Item(.Errors.Count - 1).NativeError & vbCrLf & "Descrição:" & .Errors.Item(.Errors.Count - 1).Description)
	'    End If
	'  End With
	'  DoEvents
	'End Sub
	'
	'Private Sub mfgDados_DblClick()
	'  With Me.mfgDados
	'    If .Rows > 1 Then
	'      Call LigDesFrame(False)
	'      Call irstRegiao.Find("id = " & .TextMatrix(.RowSel, 0), , adSearchForward, 1)
	'      Call PegaDados
	'    End If
	'  End With
	'End Sub
	'
	'Private Sub LigDesFrame(ByVal ablnModo As Boolean)
	'  Me.fmePesquisa.Visible = ablnModo
	'  Me.fmePesquisa.Enabled = ablnModo
	'  Me.fmeCadastro.Enabled = (Not ablnModo)
	'End Sub
	'
	'Private Sub limpaCampos()
	'  Dim lintIdx As Integer
	'
	'  Me.txtId.Text = Year(BuscaDataBD)
	'  For lintIdx = 0 To 1
	'    Me.txtDec(lintIdx).Text = "0,00"
	'    Me.txtFec(lintIdx).Text = "0,00"
	'  Next lintIdx
	'End Sub
	'
	'Private Sub PegaDados()
	'  With irstRegiao
	'    Me.txtId.Text = CLng(IIf(IsNull(.Fields("id").Value), 0, .Fields("id").Value))
	'    Me.txtDescricao.Text = Trim(IIf(IsNull(.Fields("descricao").Value), "0", .Fields("descricao").Value))
	'    Me.txtSigla.Text = Trim(IIf(IsNull(.Fields("sigla").Value), "B", .Fields("sigla").Value))
	'  End With
	'  iblnNovo = False
	'  Call Me.txtDescricao.SetFocus
	'  DoEvents
	' End Sub
	'
	'Private Sub txtId_GotFocus()
	'  With Me.txtId
	'    .SelStart = 0
	'    .SelLength = Len(.Text)
	'  End With
	'End Sub
	'
	'Private Sub txtId_KeyPress(KeyAscii As Integer)
	'  If KeyAscii = vbKeyReturn Then
	'    Call SendKeysA(vbKeyTab, True)
	'  ElseIf KeyAscii <> 8 And (KeyAscii < 48 Or KeyAscii > 57) Then
	'    KeyAscii = 0
	'  End If
	'End Sub
	'
	'Private Sub txtDec_GotFocus(Index As Integer)
	'  With Me.txtDec(Index)
	'    .Text = Replace(Replace(.Text, ".", ""), ",", "")
	'    .SelStart = 0
	'    .SelLength = Len(.Text)
	'  End With
	'End Sub
	'
	'Private Sub txtDec_KeyPress(Index As Integer, KeyAscii As Integer)
	'  If KeyAscii = vbKeyReturn Then
	'    Call SendKeysA(vbKeyTab, True)
	'  ElseIf KeyAscii <> 8 And (KeyAscii < 48 Or KeyAscii > 57) Then
	'    KeyAscii = 0
	'  End If
	'End Sub
	'
	'Private Sub txtDec_LostFocus(Index As Integer)
	'  With Me.txtDec(Index)
	'    .Text = FormatNumber(IIf(Len(.Text) = 0, 0, (.Text / 100)), 2)
	'  End With
	'End Sub
	'
	'Private Sub txtFec_GotFocus(Index As Integer)
	'  With Me.txtFec(Index)
	'    .Text = Replace(Replace(.Text, ".", ""), ",", "")
	'    .SelStart = 0
	'    .SelLength = Len(.Text)
	'  End With
	'End Sub
	'
	'Private Sub txtFec_KeyPress(Index As Integer, KeyAscii As Integer)
	'  If KeyAscii = vbKeyReturn Then
	'    Call SendKeysA(vbKeyTab, True)
	'  ElseIf KeyAscii <> 8 And (KeyAscii < 48 Or KeyAscii > 57) Then
	'    KeyAscii = 0
	'  End If
	'End Sub
	'
	'Private Sub txtFec_LostFocus(Index As Integer)
	'  With Me.txtFec(Index)
	'    .Text = FormatNumber(IIf(Len(.Text) = 0, 0, (.Text / 100)), 2)
	'  End With
	'End Sub
	'
End Class