Imports DevExpress.Web

Public Class ucEmpleosPaginaInicio
    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


            panelIns.Controls.Clear()
            Dim ListaInstitucion As EntityList(Of Institucion) = InstitucionBusinessObject.GetListInstitucionesByEstado("2")

            For Each oIns As Institucion In ListaInstitucion
                Dim btnIns = CrearBoton(oIns.idInstitucion, oIns.siglasInstitucion, oIns.nombreInstitucion)
                btnIns.ClientSideEvents.Click = String.Format("function(s, e)  {{ window.location = 'Concursos.aspx?ins={0}'; }}", oIns.idInstitucion)
                panelIns.Controls.Add(btnIns)

                'panelIns.Controls.Add(New LiteralControl("&nbsp;"))
            Next
        End If
    End Sub

    Protected Sub gridPuestosPublicados_HtmlDataCellPrepared(sender As Object, e As DevExpress.Web.ASPxGridViewTableDataCellEventArgs) Handles gridPuestosPublicados.HtmlDataCellPrepared
        Dim btn As ASPxButton = gridPuestosPublicados.FindRowCellTemplateControl(e.VisibleIndex, e.DataColumn, "btnAplicar")
        If Not btn Is Nothing Then
            btn.ClientSideEvents.Click = String.Format("function(s, e) {{OnMoreInfoClick('{0}');}}", e.KeyValue)
        End If
        Dim btn2 As ASPxButton = gridPuestosPublicados.FindRowCellTemplateControl(e.VisibleIndex, e.DataColumn, "btnProceso")
        If Not btn2 Is Nothing Then
            btn2.ClientSideEvents.Click = String.Format("function(s, e) {{Proceso('{0}');}}", e.KeyValue)
        End If
        If e.DataColumn.FieldName = "siglasInstitucion" Then
            If Not String.IsNullOrEmpty(e.CellValue) Then
                e.Cell.ToolTip = gridPuestosPublicados.GetRowValues(e.VisibleIndex, "nombreInstitucion").ToString
            End If
        End If
    End Sub

    Function CrearBoton(ID As String, texto As String, Tooltip As String) As ASPxButton
        Dim btn As New ASPxButton() With {.ID = ID, .Text = texto, .ToolTip = Tooltip, .Theme = "Glass", .AutoPostBack = False, .UseSubmitBehavior = False}
        Return btn
    End Function

    Protected Sub gridPuestosPublicados_HtmlRowPrepared(sender As Object, e As ASPxGridViewTableRowEventArgs) Handles gridPuestosPublicados.HtmlRowPrepared
        If (e.RowType <> GridViewRowType.Data) Then
            Return
        End If
        If Not e.GetValue("resaltar").ToString.Equals("") Then
            If CBool(e.GetValue("resaltar")) Then
                e.Row.Font.Bold = True
                'e.Row.Font.Italic = True
                'e.Row.ForeColor = Drawing.Color.DarkSlateBlue
            End If

        End If
    End Sub
End Class