Imports DevExpress.Web

Public Class ucVisorPostulante
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim id As String
            id = Request.QueryString("id")
            Dim oConcursoPostulante As New ConcursoPostulanteBusinessObject(CInt(id))
            litPostulante.Text = oConcursoPostulante.Entity.CodigoPostulante
        End If
        
    End Sub

    Protected Sub gridPostulanteExperiencia_CustomUnboundColumnData(sender As Object, e As DevExpress.Web.ASPxGridViewColumnDataEventArgs) Handles gridPostulanteExperiencia.CustomUnboundColumnData
        If e.Column.FieldName = "tiempo" Then
            Dim inicio As New Date(e.GetListSourceFieldValue("inicioAnio"), e.GetListSourceFieldValue("inicioMes"), 1)
            Dim fin As Date
            If Not e.GetListSourceFieldValue("activo") Is DBNull.Value Then
                If CBool(e.GetListSourceFieldValue("activo")) Then
                    fin = Date.Now
                Else

                    fin = New Date(e.GetListSourceFieldValue("finAnio"), e.GetListSourceFieldValue("finMes"), 1)
                End If
            Else
                fin = New Date(e.GetListSourceFieldValue("finAnio"), e.GetListSourceFieldValue("finMes"), 1)
            End If

            e.Value = GetTimeExperiencia(inicio, fin)

            'Dim anios As Integer = DateDiff(DateInterval.Year, inicio, fin)
            'Dim meses As Integer = DateDiff(DateInterval.Month, inicio, fin)
            'meses = meses Mod 12

            'e.Value = String.Format("{0} año(s), {1} mes(es)", anios, meses)
        End If
    End Sub

    Protected Sub gridPostulanteExperiencia_DataBound(sender As Object, e As EventArgs) Handles gridPostulanteExperiencia.DataBound
        Dim g As ASPxGridView = TryCast(sender, ASPxGridView)
        If g.VisibleRowCount = 0 Then
            g.ClientVisible = False
        End If
    End Sub

    Protected Sub gridPostulanteIdioma_CustomUnboundColumnData(sender As Object, e As DevExpress.Web.ASPxGridViewColumnDataEventArgs) Handles gridPostulanteIdioma.CustomUnboundColumnData
        If e.Column.FieldName = "calidad" Then
            e.Value = CInt(e.GetListSourceFieldValue("IDI_Lee")) + CInt(e.GetListSourceFieldValue("IDI_Escribe")) + CInt(e.GetListSourceFieldValue("IDI_Habla"))
        End If
    End Sub

    Protected Sub gridPostulanteIdioma_DataBound(sender As Object, e As EventArgs) Handles gridPostulanteIdioma.DataBound
        Dim g As ASPxGridView = TryCast(sender, ASPxGridView)
        If g.VisibleRowCount = 0 Then
            g.ClientVisible = False
        End If
    End Sub

    Protected Sub gridPostulanteCapacitaciones_DataBound(sender As Object, e As EventArgs) Handles gridPostulanteCapacitaciones.DataBound
        Dim g As ASPxGridView = TryCast(sender, ASPxGridView)
        If g.VisibleRowCount = 0 Then
            g.ClientVisible = False
        End If
    End Sub

    Protected Sub gridPostulanteConocimientos_DataBound(sender As Object, e As EventArgs) Handles gridPostulanteConocimientos.DataBound
        Dim g As ASPxGridView = TryCast(sender, ASPxGridView)
        If g.VisibleRowCount = 0 Then
            g.ClientVisible = False
        End If
    End Sub

    Protected Sub gridPostulanteExperiencia_HtmlRowCreated(sender As Object, e As ASPxGridViewTableRowEventArgs) Handles gridPostulanteExperiencia.HtmlRowCreated
        If e.RowType <> GridViewRowType.Data Then
            Return
        End If
        Dim lblactual As ASPxLabel = TryCast(gridPostulanteExperiencia.FindRowCellTemplateControl(e.VisibleIndex, Nothing, "lblactual"), ASPxLabel)
        Dim lblfechafin As ASPxLabel = TryCast(gridPostulanteExperiencia.FindRowCellTemplateControl(e.VisibleIndex, Nothing, "lblfechafin"), ASPxLabel)
        Dim actual As Boolean = False
        If Not gridPostulanteExperiencia.GetRowValues(e.VisibleIndex, "activo").ToString = "" Then
            actual = CBool(gridPostulanteExperiencia.GetRowValues(e.VisibleIndex, "activo"))
        End If

        If actual Then
            lblfechafin.Visible = False
            lblactual.Visible = True
        Else
            lblfechafin.Visible = True
            lblactual.Visible = False
        End If
    End Sub
End Class