Attribute VB_Name = "modFuncion"

Public Function LlenaCalendario(Grilla As MSHFlexGrid, MesProceso As String, AgnoProceso As Integer)
    Dim NumeroDia As Integer
    Dim i As Integer
    Dim j As Integer
    Dim AhoraSi As Boolean
    NumeroDia = 1
    For i = 1 To 6
        For j = 1 To 7
            If i = 1 Then
                If j = PrimerDia(MesToNumber(MesProceso), AgnoProceso) Then
                    AhoraSi = True
                End If
            End If
            If AhoraSi Then
                If NumeroDia <= FinMes(MesToNumber(MesProceso), AgnoProceso) Then
                    Grilla.Col = j
                    Grilla.Row = i
                    If j = 7 Then Grilla.CellBackColor = &H2050FF
                    Grilla.Text = NumeroDia
                    NumeroDia = NumeroDia + 1
                Else
                    Grilla.TextMatrix(i, j) = ""
                End If
            Else
                Grilla.TextMatrix(i, j) = ""
            End If
        Next
    Next
End Function

Public Function CargaNivelMes(cmbListaNiveles As ComboBox, strCodModal As String, strMes As String, agno As String)
    Dim rsNiveles As ADODB.Recordset
    Set rsNiveles = New ADODB.Recordset
    rsNiveles.LockType = adLockReadOnly
    rsNiveles.CursorLocation = adUseClient
    rsNiveles.CursorType = adOpenDynamic
    rsNiveles.Open GeneraConsulta(gesGradoXmes, Val(agno), strCodModal, , , , UCase(Left(strMes, 3))), conn
    cmbListaNiveles.Clear
    While Not rsNiveles.EOF
        cmbListaNiveles.AddItem rsNiveles("NUM_GRA")
        rsNiveles.MoveNext
    Wend
    rsNiveles.Close
End Function

Public Function CargaModalMes(cmbListaModal As ComboBox, strMes As String, agno As String)
    Dim rsModal As ADODB.Recordset
    Set rsModal = New ADODB.Recordset
    rsModal.CursorLocation = adUseClient
    rsModal.CursorType = adOpenDynamic
    rsModal.LockType = adLockReadOnly
    rsModal.Open GeneraConsulta(gesNombreModalXmes, Val(agno), , , , , UCase(Left(strMes, 3))), conn
    cmbListaModal.Clear
    While Not rsModal.EOF
        cmbListaModal.AddItem rsModal("COD_ENS") & " " & rsModal("DES_ENS")
        rsModal.MoveNext
    Wend
    rsModal.Close
End Function

Public Function CargaMesesCombo(cmbListaMeses As ComboBox, agno As String)
    Dim rsCale As ADODB.Recordset
    Dim mDupl As Boolean
    Dim i As Integer
    Dim sMesLeido As String
    Set rsCale = New ADODB.Recordset
    cmbListaMeses.Clear
    For i = 0 To 11
        cmbListaMeses.AddItem " ", i
    Next
    rsCale.CursorType = adOpenDynamic
    rsCale.LockType = adLockOptimistic
    rsCale.Open GeneraConsulta(gesNombreMes, Val(agno)), conn
    While Not rsCale.EOF
        sMesLeido = MesCortoLargo(rsCale("mes"))
        cmbListaMeses.List(MesToNumber(sMesLeido) - 1) = sMesLeido
        rsCale.MoveNext
    Wend
    rsCale.Close
    For i = 11 To 0 Step -1
        If Len(Trim(cmbListaMeses.List(i))) < 3 Then
            cmbListaMeses.RemoveItem i
        End If
    Next
End Function

