Imports DevExpress.Web

Public Class ucUsuCapacitaciones
    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
            ObjectUsuCapacitaciones.SelectParameters("idUsuario").DefaultValue = CInt(Page.User.Identity.Name)
            ObjectUsuConocimiento.SelectParameters("idUsuario").DefaultValue = CInt(Page.User.Identity.Name)

        End If
    End Sub

    Protected Sub gridUsuCapacitacion_RowInserting(sender As Object, e As DevExpress.Web.Data.ASPxDataInsertingEventArgs) Handles gridUsuCapacitacion.RowInserting
        e.NewValues("idUsuario") = CInt(Page.User.Identity.Name)
    End Sub

    Protected Sub gridUsuCapacitacion_RowUpdating(sender As Object, e As DevExpress.Web.Data.ASPxDataUpdatingEventArgs) Handles gridUsuCapacitacion.RowUpdating
        e.NewValues("idCapacitacion") = (CType(sender, ASPxGridView)).GetRowValuesByKeyValue(e.Keys(0), New String() {"idCapacitacion"})
    End Sub

    Protected Sub gridUsuCapacitacion_CellEditorInitialize(sender As Object, e As ASPxGridViewEditorEventArgs) Handles gridUsuCapacitacion.CellEditorInitialize
        If e.Column.FieldName = "anio" Then
            Dim se As ASPxSpinEdit = CType(e.Editor, ASPxSpinEdit)
            se.MinValue = Now.Date.Year - 100
            se.MaxValue = Now.Date.Year
        End If
    End Sub

    Protected Sub gridUsuConocimientos_RowInserting(sender As Object, e As Data.ASPxDataInsertingEventArgs) Handles gridUsuConocimientos.RowInserting
        e.NewValues("idUsuario") = CInt(Page.User.Identity.Name)
    End Sub

    Protected Sub gridUsuConocimientos_RowUpdating(sender As Object, e As Data.ASPxDataUpdatingEventArgs) Handles gridUsuConocimientos.RowUpdating
        e.NewValues("idConocimiento") = (CType(sender, ASPxGridView)).GetRowValuesByKeyValue(e.Keys(0), New String() {"idConocimiento"})
    End Sub


    Protected Sub gridUsuConocimientos_CommandButtonInitialize(sender As Object, e As ASPxGridViewCommandButtonEventArgs) Handles gridUsuConocimientos.CommandButtonInitialize

        If e.ButtonType = ColumnCommandButtonType.New Then
            Dim cont As Integer = Convert.ToInt32(gridUsuConocimientos.GetTotalSummaryValue(gridUsuConocimientos.TotalSummary("idConocimiento", DevExpress.Data.SummaryItemType.Count)))
            If cont >= 20 Then
                e.Visible = False
            End If
        End If
    End Sub
End Class