Imports DevExpress.Web

Public Class ucVistaPlaza
    Inherits ucBase
    Public ReadOnly Property GetForm As ASPxFormLayout
        Get
            Return FormPuesto
        End Get
    End Property

    Public ReadOnly Property GetCriterios As ASPxGridView
        Get
            Return gridEtapa
        End Get
    End Property
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


    End Sub

    Private Sub fechaInicio_DataBound(sender As Object, e As EventArgs) Handles fechaInicio.DataBound
        Dim label As ASPxLabel = CType(sender, ASPxLabel)
        If Not String.IsNullOrEmpty(label.Text) Then
            label.Text = DateTime.Parse(label.Text).ToShortDateString
        End If

    End Sub


    Protected Sub fechaFin_DataBound(sender As Object, e As EventArgs) Handles fechaFin.DataBound
        Dim label As ASPxLabel = CType(sender, ASPxLabel)
        If String.IsNullOrEmpty(label.Text) Then
            btnPostular.Enabled = False
        Else
            label.Text = DateTime.Parse(label.Text).ToShortDateString
            If Now.Date <= CDate(label.Text) And cmbEstado.Value = 2 Then
                btnPostular.Enabled = True
            End If
        End If
    End Sub

    Protected Sub cmbEstado_DataBound(sender As Object, e As EventArgs) Handles cmbEstado.DataBound
        Dim combo As ASPxComboBox = CType(sender, ASPxComboBox)
        Select Case combo.Value
            Case "1"
                combo.BackColor = ColorEstadoBorrador()
            Case "2"
                combo.BackColor = ColorEstadoInscripcion()
                'combo.ForeColor = Drawing.Color.Black
            Case "3"
                combo.BackColor = ColorEstadoEvaluacion()
                combo.ForeColor = Drawing.Color.White
            Case "4"
                combo.BackColor = ColorEstadoAdjudicada()
                combo.ForeColor = Drawing.Color.White
                lblCierre.Visible = True
                lblParticipantes.Visible = True
            Case "7"
                combo.BackColor = ColorEstadoDesierta()
                'combo.ForeColor = Drawing.Color.Black
                lblCierre.Visible = True
                lblParticipantes.Visible = True
            Case Else
                combo.BackColor = ColorEstadoDesierta()
                'combo.ForeColor = Drawing.Color.Black
        End Select

    End Sub

    Protected Sub txtSalario_DataBound(sender As Object, e As EventArgs) Handles txtSalario.DataBound
        Dim label As ASPxLabel = CType(sender, ASPxLabel)
        If Not String.IsNullOrEmpty(label.Text) Then
            label.Text = FormatCurrency(label.Text)
        End If

    End Sub

    Protected Sub gridEtapa_DataBound(sender As Object, e As EventArgs) Handles gridEtapa.DataBound
        CType(sender, ASPxGridView).DetailRows.ExpandAllRows()
    End Sub

    Protected Sub gridFactorPuntaje_BeforePerformDataSelect(sender As Object, e As EventArgs)
        Session("idEtapa") = CType(sender, ASPxGridView).GetMasterRowKeyValue()
    End Sub

    'Private Sub FormPuesto_DataBound(sender As Object, e As EventArgs) Handles FormPuesto.DataBound
    '    gridEtapa.DataBind()
    'End Sub

    'Private Sub cbpPlaza_Callback(sender As Object, e As CallbackEventArgsBase) Handles cbpPlaza.Callback
    '    If Not String.IsNullOrEmpty(Session("plaza")) Then
    '        Dim oPlaza As New PlazaBusinessObject(CInt(Session("plaza")))
    '        txtCorreo.Text = String.Format("<a href='mailto:{0}'>{0}</a>", oPlaza.Entity.correoelectronico)
    '        txtTelefono.Text = oPlaza.Entity.telefono
    '        txtDireccion.Text = oPlaza.Entity.direccion
    '        txtComentario.Text = oPlaza.Entity.comentario
    '    End If
    'End Sub

    Protected Sub gridArea_BeforePerformDataSelect(sender As Object, e As EventArgs)
        Session("idFactorPuntaje") = CType(sender, ASPxGridView).GetMasterRowKeyValue()
    End Sub

    Protected Sub gridFactorPuntaje_DataBound(sender As Object, e As EventArgs)
        CType(sender, ASPxGridView).DetailRows.ExpandAllRows()
    End Sub


    'Protected Sub btnPostular_Click(sender As Object, e As EventArgs) Handles btnPostular.Click
    '    Response.Redirect("~/Pages/wfPostular.aspx?plaza=" & Session("plaza").ToString)
    'End Sub

    Protected Sub lblParticipantes_DataBound(sender As Object, e As EventArgs) Handles lblParticipantes.DataBound
        Dim label As ASPxLabel = CType(sender, ASPxLabel)

        label.Text = String.Format("Número de Participantes: {0}", label.Text)

    End Sub
End Class