217 lines
9.1 KiB
VB.net
217 lines
9.1 KiB
VB.net
|
|
Imports System.Data
|
|
Imports System.Linq
|
|
Imports Extensiones
|
|
|
|
Partial Class RH_CatEstatusPersonal
|
|
Inherits ClsPaginas
|
|
|
|
Private Property CveEstatusPerAEditar() As Integer 'Guardamos el ID de registro para saber cual registro Editar
|
|
Get
|
|
Return If(IsNothing(ViewState("CveEstatusPerAEditar")), -1, CInt(ViewState("CveEstatusPerAEditar")))
|
|
End Get
|
|
Set
|
|
ViewState("CveEstatusPerAEditar") = Value
|
|
End Set
|
|
End Property
|
|
Public Property PuedeEditar As Boolean
|
|
Get
|
|
Return CBool(ViewState("PuedeEditar"))
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("PuedeEditar") = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property PuedeEliminar As Boolean
|
|
Get
|
|
Return CBool(ViewState("PuedeEditar"))
|
|
End Get
|
|
Set(value As Boolean)
|
|
ViewState("PuedeEditar") = value
|
|
End Set
|
|
End Property
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
ViewState("Orden") = ""
|
|
CargaDatos()
|
|
|
|
''Permiso Registro
|
|
'If PermisoRegistro Then
|
|
' LbAgregar.Enabled = True
|
|
'Else
|
|
' LbAgregar.Enabled = False
|
|
'End If
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub CargaDatos()
|
|
Dim ObjEstatusPersonal As New ClsRH
|
|
If ObjEstatusPersonal.GetEstatusPersonal() Then
|
|
ViewState("DTEstatusPersonal") = ObjEstatusPersonal.DtResultados
|
|
GlobalDTEstatusPersonal = ObjEstatusPersonal.DtResultados
|
|
Else
|
|
Me.GvDatos.DataSource = Nothing
|
|
End If
|
|
|
|
ObjEstatusPersonal.Dispose()
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
Protected Sub BtnAgregarMotivo_Click(sender As Object, e As EventArgs) Handles BtnAgregarMotivoD.Click 'Hacemos aparecer la ventana modal con los campos limpios
|
|
BtnEditarTiposDModal.Visible = False
|
|
BtnAgregarTiposDModal.Visible = True
|
|
CheckActiveSection.Visible = False
|
|
saltoDeLinea.Visible = False
|
|
PersonalEstatTxt.Text = ""
|
|
UpModalTiposD.Update()
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD"))
|
|
|
|
End Sub
|
|
|
|
Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles BtnAgregarTiposDModal.Click 'esta funcion es la que agrega un nuevo motivo de baja se activa con el boton "Agregar" de la ventana modal"
|
|
Dim ObjEstatusPersonal As New ClsRH
|
|
If ObjEstatusPersonal.AddEstatusPersonal(PersonalEstatTxt.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
PersonalEstatTxt.Text = ""
|
|
Alert("El nuevo Estatus de Personal se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
UpTitulos.Update()
|
|
ViewState("DTEstatusPersonal") = ObjEstatusPersonal.DtResultados
|
|
GlobalDTEstatusPersonal = ObjEstatusPersonal.DtResultados
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End If
|
|
ObjEstatusPersonal.Dispose()
|
|
End Sub
|
|
|
|
#Region "G V D A T O S"
|
|
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvDatos.RowDataBound
|
|
If e.Row.RowType = DataControlRowType.DataRow Then
|
|
If e.Row.RowIndex = 0 Then
|
|
e.Row.Cells(0).Width = Unit.Pixel(250)
|
|
e.Row.Cells(1).Width = Unit.Pixel(100)
|
|
e.Row.Cells(2).Width = Unit.Pixel(100)
|
|
e.Row.Cells(3).Width = Unit.Pixel(100)
|
|
e.Row.Cells(4).Width = Unit.Pixel(100)
|
|
e.Row.Cells(5).Width = Unit.Pixel(61)
|
|
End If
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
|
|
Dim ObjEstatusPersonal As New ClsRH
|
|
If ObjEstatusPersonal.RemoveEstatusPersonal(GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTEstatusPersonal") = ObjEstatusPersonal.DtResultados
|
|
GlobalDTEstatusPersonal = ObjEstatusPersonal.DtResultados
|
|
Alert("El Estatus de Personal se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjEstatusPersonal.Dispose()
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowCancelingEdit(sender As Object, e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GvDatos.RowCancelingEdit
|
|
GvDatos.EditIndex = -1
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowUpdating(sender As Object, e As EventArgs) Handles BtnEditarTiposDModal.Click '(Leer primero "GvDatos_RowEditing")Se manda la informacion a un procedmiento que hace la actualizacion
|
|
Dim ObjEstatusPersonal As New ClsRH
|
|
Dim EstatusPersonal As String = PersonalEstatTxt.Text
|
|
Dim Estatus As Boolean = ChkEstatus.Checked
|
|
Dim CveEstatusPersonal As Integer = CveEstatusPerAEditar 'aquí obtenemos el valor de la propiedad que utilizamos en el metodo "GvDatos_RowEditing"
|
|
If ObjEstatusPersonal.UpdateEstatusPersonal(EstatusPersonal, Estatus, CveEstatusPersonal, UsuarioActual.CveUsuario) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTEstatusPersonal") = ObjEstatusPersonal.DtResultados
|
|
GlobalDTEstatusPersonal = ObjEstatusPersonal.DtResultados
|
|
Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjEstatusPersonal.Dispose()
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Public Sub GvDatos_RowEditing(sender As Object, e As EventArgs) 'Este metodo muestra la pantalla modal con la información del renglon ya puesta en los campos del formulario
|
|
BtnAgregarTiposDModal.Visible = False
|
|
BtnEditarTiposDModal.Visible = True
|
|
CheckActiveSection.Visible = True
|
|
saltoDeLinea.Visible = True
|
|
|
|
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow) 'obtenemos el renglon que acabamos de seleccionar
|
|
PersonalEstatTxt.Text = GvRow.DataKey("EstatusPersonal")
|
|
ChkEstatus.Checked = If(GvRow.DataKey("Estatus") = "Activo", True, False)
|
|
CveEstatusPerAEditar = GvRow.DataKey("CveEstatusPersonal").ToEntero 'Guardamos en una propiedad el id del registro del cual haremos cambios, se guarda y se utiliza en el metodo "GvDatos_RowUpdating"
|
|
|
|
UpDatos.Update()
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
RegistraScript(String.Format("$('#{0}').modal();", "DivAgregarTiposD"))
|
|
End Sub
|
|
#End Region
|
|
|
|
#Region "O R D E N A M I E N T O"
|
|
Protected Sub LbOrden_Click(ByVal sender As Object, ByVal e As EventArgs)
|
|
Dim Orden As String = ""
|
|
Dim Campo As String = ""
|
|
Dim Literal As Literal = Nothing
|
|
Const OrdenInicial As String = ""
|
|
Dim Arg(2) As String
|
|
|
|
Arg = CType(sender, LinkButton).CommandArgument().ToString.Split(";"c)
|
|
Campo = Arg(0)
|
|
Literal = CType(CType(sender, LinkButton).NamingContainer.FindControl("Img" & Campo.Replace(",", "_")), Literal)
|
|
|
|
If ViewState(String.Format("O{0}", Campo)) IsNot Nothing AndAlso ViewState(String.Format("O{0}", Campo)).ToString = String.Format("{0} DESC", Campo) Then
|
|
ViewState(String.Format("O{0}", Campo)) = String.Format("{0} ASC", Campo)
|
|
Literal.Text = String.Format("<i class='fa fa-sort-asc' style='color:#999' ></i>")
|
|
Else
|
|
ViewState(String.Format("O{0}", Campo)) = String.Format("{0} DESC", Campo)
|
|
Literal.Text = String.Format("<i class='fa fa-sort-desc' style='color:#999' ></i>")
|
|
End If
|
|
Orden = OrdenInicial & ViewState(String.Format("O{0}", Campo)).ToString
|
|
ViewState("Orden") = Orden
|
|
CargaGrid(Orden)
|
|
End Sub
|
|
|
|
Private Sub CargaGrid(Orden As String)
|
|
If Orden <> String.Empty Then
|
|
Dim DV As New DataView(CType(ViewState("DTEstatusPersonal"), DataTable), "", Orden, DataViewRowState.CurrentRows)
|
|
GvDatos.DataSource = DV.ToTable()
|
|
DV.Dispose()
|
|
Else
|
|
GvDatos.DataSource = CType(ViewState("DTEstatusPersonal"), DataTable)
|
|
End If
|
|
GvDatos.DataBind()
|
|
UpDatos.Update()
|
|
End Sub
|
|
#End Region
|
|
End Class
|