Imports DevExpress.Web
Module ModuloDotacion

    Public Function ColorEstadoBorrador() As Drawing.Color
        Return Drawing.Color.Yellow
    End Function

    Public Function ColorEstadoInscripcion() As Drawing.Color
        Return System.Drawing.Color.LimeGreen
    End Function

    Public Function ColorEstadoEvaluacion() As Drawing.Color
        Return Drawing.ColorTranslator.FromHtml("#125685")
    End Function

    Public Function ColorEstadoAdjudicada() As Drawing.Color
        Return System.Drawing.Color.FromArgb(&H66, &H33, &H66)
    End Function

    Public Function ColorEstadoDesierta() As Drawing.Color
        Return System.Drawing.Color.LightGray
    End Function

    Public Sub ColoresEstado(ByRef celda As ASPxGridViewTableDataCellEventArgs)
        Select Case celda.CellValue.ToString
            Case "1"
                celda.Cell.BackColor = ColorEstadoBorrador()
            Case "2"
                celda.Cell.BackColor = ColorEstadoInscripcion()
                'celda.Cell.ForeColor = Drawing.Color.Black
            Case "3", "5", "6"
                celda.Cell.BackColor = ColorEstadoEvaluacion()
                celda.Cell.ForeColor = Drawing.Color.White
            Case "4"
                celda.Cell.BackColor = ColorEstadoAdjudicada()
                celda.Cell.ForeColor = Drawing.Color.White
            Case Else
                celda.Cell.BackColor = ColorEstadoDesierta()
        End Select
    End Sub

    Public Function GetTimeExperiencia(ByRef inicio As Date, ByRef fin As Date) As String
        Dim anios As Integer = DateDiff(DateInterval.Year, inicio, fin)
        Dim meses As Integer = DateDiff(DateInterval.Month, inicio, fin)
        meses = meses Mod 12
        If meses <> 0 Then meses = meses + 1

        If meses = 12 Then
            anios = anios + 1
            meses = 0
        End If

        If inicio.Month > fin.Month Then anios = anios - 1

        Dim tiempo As String = ""

        If anios > 1 Then
            tiempo = anios & " años"
        Else
            If anios = 1 Then tiempo = anios & " año"
        End If

        If meses > 0 Then
            If Not tiempo.Equals("") Then
                If meses = 1 Then
                    tiempo = tiempo & ", " & meses & " mes"
                Else
                    tiempo = tiempo & ", " & meses & " meses"
                End If

            Else
                If meses = 1 Then
                    tiempo = meses & " mes"
                Else
                    tiempo = meses & " meses"
                End If

            End If
        End If
        Return tiempo
    End Function
End Module
