Commit inicial Ventas Productivo
This commit is contained in:
445
RH/CatPuesto.aspx.vb
Normal file
445
RH/CatPuesto.aspx.vb
Normal file
@@ -0,0 +1,445 @@
|
||||
Option Explicit On
|
||||
Option Strict On
|
||||
|
||||
Imports System.Data
|
||||
Imports System.Linq
|
||||
Imports Extensiones
|
||||
|
||||
Partial Class RH_CatPuesto
|
||||
Inherits ClsPaginas
|
||||
|
||||
|
||||
Private Property CvePuesto As Integer
|
||||
Get
|
||||
If ViewState("CvePuesto") Is Nothing Then
|
||||
Return -1
|
||||
Else
|
||||
Return DirectCast(ViewState("CvePuesto"), Integer)
|
||||
End If
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
ViewState("CvePuesto") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Private Property Actualizar As Boolean
|
||||
Get
|
||||
If ViewState("Actualizar") Is Nothing Then
|
||||
Return True
|
||||
Else
|
||||
Return Boolean.Parse((ViewState("Actualizar").ToString))
|
||||
End If
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
ViewState("Actualizar") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Private Property Ocupacion As String
|
||||
Get
|
||||
If ViewState("Ocupacion") Is Nothing Then
|
||||
Return "-1"
|
||||
Else
|
||||
Return ViewState("Ocupacion").ToString
|
||||
End If
|
||||
End Get
|
||||
Set(value As String)
|
||||
ViewState("Ocupacion") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Private Property DTOcupacionesRaw As DataTable
|
||||
Get
|
||||
If ViewState("DTOcupacionesRaw") Is Nothing Then
|
||||
Return New DataTable
|
||||
Else
|
||||
Return DirectCast(ViewState("DTOcupacionesRaw"), DataTable)
|
||||
End If
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DTOcupacionesRaw") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
|
||||
|
||||
Private Property DTArea As DataTable
|
||||
Get
|
||||
If ViewState("DTArea") Is Nothing Then
|
||||
Return New DataTable
|
||||
Else
|
||||
Return DirectCast(ViewState("DTArea"), DataTable)
|
||||
End If
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DTArea") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property DTSubArea As DataTable
|
||||
Get
|
||||
If ViewState("DTSubArea") Is Nothing Then
|
||||
Return New DataTable
|
||||
Else
|
||||
Return DirectCast(ViewState("DTSubArea"), DataTable)
|
||||
End If
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DTSubArea") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property DtModulo As DataTable
|
||||
Get
|
||||
If ViewState("DtModulo") Is Nothing Then
|
||||
Return New DataTable
|
||||
Else
|
||||
Return DirectCast(ViewState("DtModulo"), DataTable)
|
||||
End If
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DtModulo") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private Property DtOcupacion As DataTable
|
||||
Get
|
||||
If ViewState("DtOcupacion") Is Nothing Then
|
||||
Return New DataTable
|
||||
Else
|
||||
Return DirectCast(ViewState("DtOcupacion"), DataTable)
|
||||
End If
|
||||
End Get
|
||||
Set(value As DataTable)
|
||||
ViewState("DtOcupacion") = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
|
||||
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
||||
If Not Page.IsPostBack Then
|
||||
|
||||
CargaDatos()
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub CargaDatos()
|
||||
|
||||
Dim ObjPuestos As New ClsRH
|
||||
|
||||
CargaCatalogoOcupaciones()
|
||||
|
||||
|
||||
If ObjPuestos.GetPuestos(-1) Then
|
||||
GvPuestos.DataSource = ObjPuestos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
||||
|
||||
'GlobalDTRHPuestos(-1) = ObjPuestos.DtResultados
|
||||
Else
|
||||
Me.GvPuestos.DataSource = Nothing
|
||||
End If
|
||||
|
||||
ObjPuestos.Dispose()
|
||||
GvPuestos.DataBind()
|
||||
UpDatos.Update()
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub CargaCatalogoOcupaciones()
|
||||
|
||||
Dim objRH As New ClsRH
|
||||
|
||||
If objRH.GetCatalogoNacionalOcupaciones(-1, -1, -1) Then
|
||||
|
||||
DTOcupacionesRaw = objRH.DtResultados
|
||||
|
||||
If DTOcupacionesRaw.Rows.Count > 0 Then
|
||||
DdlArea.DataSource = DTOcupacionesRaw.FiltraParametros("", "", {"CveArea", "Area"})
|
||||
Else
|
||||
DdlArea.DataSource = Nothing
|
||||
End If
|
||||
|
||||
Else
|
||||
DTOcupacionesRaw = Nothing
|
||||
End If
|
||||
|
||||
objRH.Dispose()
|
||||
DdlArea.DataBind()
|
||||
DdlArea.Items.Insert(0, New ListItem("Seleccione una opción", "-1"))
|
||||
|
||||
UpModalPuesto.Update()
|
||||
End Sub
|
||||
|
||||
Protected Sub DdlArea_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlArea.SelectedIndexChanged
|
||||
|
||||
Dim objRH As New ClsRH
|
||||
ResetComos(1)
|
||||
If objRH.GetCatalogoNacionalOcupacionesCombos(-1, DdlArea.SelectedValue.ToEntero, -1, "-1") Then
|
||||
DTSubArea = objRH.DtResultados.FiltraParametros("", "", {"CveSubArea", "SubArea"})
|
||||
End If
|
||||
objRH.Dispose()
|
||||
|
||||
If DTSubArea.Rows.Count > 0 Then
|
||||
DdlSubArea.DataSource = DTSubArea
|
||||
Else
|
||||
DdlSubArea.DataSource = Nothing
|
||||
End If
|
||||
|
||||
DdlSubArea.DataBind()
|
||||
DdlSubArea.Items.Insert(0, New ListItem("Seleccione una opción", "-1"))
|
||||
|
||||
UpModalPuesto.Update()
|
||||
|
||||
End Sub
|
||||
Protected Sub DdlSubArea_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlSubArea.SelectedIndexChanged
|
||||
|
||||
Dim objRH As New ClsRH
|
||||
ResetComos(2)
|
||||
If objRH.GetCatalogoNacionalOcupacionesCombos(-1, -1, DdlSubArea.SelectedValue.ToEntero, "-1") Then
|
||||
DtModulo = objRH.DtResultados.FiltraParametros("", "", {"CveModulo", "Modulo"})
|
||||
End If
|
||||
objRH.Dispose()
|
||||
|
||||
|
||||
If DtModulo.Rows.Count > 0 Then
|
||||
DdlModulo.DataSource = DtModulo
|
||||
Else
|
||||
DdlModulo.DataSource = Nothing
|
||||
End If
|
||||
DdlModulo.DataBind()
|
||||
DdlModulo.Items.Insert(0, New ListItem("Seleccione una opción", "-1"))
|
||||
|
||||
|
||||
UpModalPuesto.Update()
|
||||
End Sub
|
||||
|
||||
Protected Sub DdlModulo_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DdlModulo.SelectedIndexChanged
|
||||
|
||||
Dim objRH As New ClsRH
|
||||
ResetComos(3)
|
||||
If objRH.GetCatalogoNacionalOcupacionesCombos(-1, -1, -1, DdlModulo.SelectedValue) Then
|
||||
DtOcupacion = objRH.DtResultados.FiltraParametros("", "", {"CveOcupacion", "Ocupacion"})
|
||||
End If
|
||||
objRH.Dispose()
|
||||
|
||||
|
||||
If DtOcupacion.Rows.Count > 0 Then
|
||||
DdlOcupacion.DataSource = DtOcupacion
|
||||
Else
|
||||
DdlOcupacion.DataSource = Nothing
|
||||
End If
|
||||
|
||||
DdlOcupacion.DataBind()
|
||||
DdlOcupacion.Items.Insert(0, New ListItem("Seleccione una opción", "-1"))
|
||||
|
||||
UpModalPuesto.Update()
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub LoadCombosPuestosConValor(_CveOcupacion As Integer)
|
||||
|
||||
Dim objRh As New ClsRH
|
||||
|
||||
If objRh.GetCatalogoNacionalOcupacionesCombos(1, -1, -1, "-1") Then
|
||||
DTArea = objRh.DtResultados.FiltraParametros("", "", {"CveArea", "Area"})
|
||||
End If
|
||||
|
||||
DdlArea.DataSource = DTArea
|
||||
DdlArea.DataBind()
|
||||
DdlArea.Items.Insert(0, New ListItem("Seleccine una opción", "-1"))
|
||||
|
||||
If _CveOcupacion > 0 Then
|
||||
|
||||
Dim DtTemp As New DataTable
|
||||
DtTemp = DTOcupacionesRaw.FiltraParametros(" CveOcupacion = " & _CveOcupacion)
|
||||
|
||||
Dim _CveArea As Integer = DtTemp(0)("CveArea").ToString.ToEntero
|
||||
Dim _CveSubArea As Integer = DtTemp(0)("CveSubArea").ToString.ToEntero
|
||||
Dim _CveModulo As String = DtTemp(0)("CveModulo").ToString
|
||||
|
||||
If objRh.GetCatalogoNacionalOcupacionesCombos(-1, _CveArea, -1, "-1") Then
|
||||
DTSubArea = objRh.DtResultados.FiltraParametros("", "", {"CveSubArea", "SubArea"})
|
||||
End If
|
||||
|
||||
If objRh.GetCatalogoNacionalOcupacionesCombos(-1, -1, _CveSubArea, "-1") Then
|
||||
DtModulo = objRh.DtResultados.FiltraParametros("", "", {"CveModulo", "Modulo"})
|
||||
End If
|
||||
|
||||
If objRh.GetCatalogoNacionalOcupacionesCombos(-1, -1, -1, _CveModulo) Then
|
||||
DtOcupacion = objRh.DtResultados.FiltraParametros("", "", {"CveOcupacion", "Ocupacion"})
|
||||
End If
|
||||
|
||||
objRh.Dispose()
|
||||
|
||||
DdlSubArea.DataSource = DTSubArea
|
||||
DdlSubArea.DataBind()
|
||||
DdlSubArea.Items.Insert(0, New ListItem("Selecione una opción", "-1"))
|
||||
DdlSubArea.SelectedValueExist(_CveSubArea)
|
||||
|
||||
DdlModulo.DataSource = DtModulo
|
||||
DdlModulo.DataBind()
|
||||
DdlModulo.Items.Insert(0, New ListItem("Seleccione una opción", "-1"))
|
||||
DdlModulo.SelectedValueExist(_CveModulo)
|
||||
|
||||
DdlOcupacion.DataSource = DtOcupacion
|
||||
DdlOcupacion.DataBind()
|
||||
DdlOcupacion.Items.Insert(0, New ListItem("Seleccione una opción", "-1"))
|
||||
DdlOcupacion.SelectedValueExist(_CveOcupacion)
|
||||
|
||||
DdlArea.SelectedValueExist(_CveArea)
|
||||
|
||||
End If
|
||||
|
||||
|
||||
|
||||
UpModalPuesto.Update()
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Private Sub ResetComos(opcion As Integer)
|
||||
|
||||
Select Case opcion
|
||||
Case 1
|
||||
DdlSubArea.Items.Clear()
|
||||
DdlModulo.Items.Clear()
|
||||
DdlOcupacion.Items.Clear()
|
||||
|
||||
DdlSubArea.Items.Insert(0, New ListItem("Seleccione una opción", "-1"))
|
||||
DdlModulo.Items.Insert(0, New ListItem("Seleccione una opción", "-1"))
|
||||
DdlOcupacion.Items.Insert(0, New ListItem("Seleccione una opción", "-1"))
|
||||
|
||||
Exit Select
|
||||
Case 2
|
||||
DdlModulo.Items.Clear()
|
||||
DdlOcupacion.Items.Clear()
|
||||
|
||||
DdlModulo.Items.Insert(0, New ListItem("Seleccione una opción", "-1"))
|
||||
DdlOcupacion.Items.Insert(0, New ListItem("Seleccione una opción", "-1"))
|
||||
Exit Select
|
||||
Case 3
|
||||
DdlOcupacion.Items.Clear()
|
||||
DdlOcupacion.Items.Insert(0, New ListItem("Seleccione una opción", "-1"))
|
||||
Exit Select
|
||||
End Select
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Protected Sub BtnAgregarPuestoModal_Click(sender As Object, e As EventArgs) Handles BtnAgregarPuestoModal.Click
|
||||
|
||||
Dim ObjPuestos As New ClsRH
|
||||
Dim estatus As Integer
|
||||
|
||||
If ChkEstatusPuesto.Checked Then
|
||||
estatus = 1
|
||||
Else
|
||||
estatus = 0
|
||||
End If
|
||||
|
||||
If CvePuesto = -1 And Actualizar = False Then
|
||||
If ObjPuestos.AddPuesto(TxtPuesto.Text.Trim, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlOcupacion.SelectedValue.ToEntero) Then
|
||||
If ObjPuestos.GetPuestos(-1) Then Application("GlobalDTRHPuestos") = ObjPuestos.DtResultados Else Application("GlobalDTRHPuestos") = Nothing
|
||||
Alert("Puesto agregado correctamente.")
|
||||
End If
|
||||
Else
|
||||
If ObjPuestos.UpdatePuesto(CvePuesto, TxtPuesto.Text.Trim, estatus, UsuarioActual.CveUsuario, DdlOcupacion.SelectedValue.ToEntero) Then
|
||||
If ObjPuestos.GetPuestos(-1) Then Application("GlobalDTRHPuestos") = ObjPuestos.DtResultados Else Application("GlobalDTRHPuestos") = Nothing
|
||||
Alert("Puesto actualizado correctamente.")
|
||||
End If
|
||||
End If
|
||||
|
||||
Actualizar = False
|
||||
CvePuesto = -1
|
||||
ObjPuestos.Dispose()
|
||||
UpModalPuesto.Update()
|
||||
|
||||
CargaDatos()
|
||||
|
||||
RegistraScript(String.Format("$('#{0}').modal('hide');", "divAgregarEditarPuesto"))
|
||||
End Sub
|
||||
|
||||
Public Sub Remove_ClickPuesto(sender As Object, e As EventArgs)
|
||||
|
||||
Dim objRH As New ClsRH
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
|
||||
Dim _CvePuesto As Integer = GvRow.DataKey("CvePuesto").ToEntero
|
||||
|
||||
If objRH.RemovePuesto(_CvePuesto) Then
|
||||
If objRH.GetPuestos(-1) Then Application("GlobalDTRHPuestos") = objRH.DtResultados Else Application("GlobalDTRHPuestos") = Nothing
|
||||
CargaDatos()
|
||||
Else
|
||||
Alert("Ocurrio un error al eliminar el puesto", TipoMensaje.MsgError)
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub Edit_ClickPuesto(sender As Object, e As EventArgs)
|
||||
|
||||
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
|
||||
Dim CveOcupacion As Integer = GvRow.DataKey("CveOcupacion").ToEntero
|
||||
Actualizar = True
|
||||
|
||||
CvePuesto = GvRow.DataKey("CvePuesto").ToEntero
|
||||
TxtPuesto.Text = GvRow.DataKey("Puesto")
|
||||
LtlTituloModalPuesto.Text = "Editar Puesto"
|
||||
|
||||
If Boolean.Parse(GvRow.DataKey("Estatus")) Then
|
||||
ChkEstatusPuesto.Checked = True
|
||||
Else
|
||||
ChkEstatusPuesto.Checked = False
|
||||
End If
|
||||
|
||||
BtnAgregarPuestoModal.Text = "Actualizar"
|
||||
|
||||
|
||||
Actualizar = True
|
||||
|
||||
ResetComos(1)
|
||||
LoadCombosPuestosConValor(CveOcupacion)
|
||||
|
||||
|
||||
|
||||
UpModalPuesto.Update()
|
||||
|
||||
RegistraScript(String.Format("$('#{0}').modal();", "divAgregarEditarPuesto"))
|
||||
|
||||
End Sub
|
||||
|
||||
Protected Sub GvDatos_RowDataBound(sender As Object, e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvPuestos.RowDataBound
|
||||
If e.Row.RowType = DataControlRowType.DataRow Then
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Protected Sub BtnAgregarPuesto_Click(sender As Object, e As EventArgs) Handles BtnAgregarPuesto.Click
|
||||
|
||||
|
||||
CvePuesto = -1
|
||||
TxtPuesto.Text = ""
|
||||
LtlTituloModalPuesto.Text = "Agregar Puesto"
|
||||
Actualizar = False
|
||||
|
||||
ChkEstatusPuesto.Checked = True
|
||||
|
||||
DdlArea.SelectedIndex = 0
|
||||
DdlSubArea.Items.Clear()
|
||||
DdlModulo.Items.Clear()
|
||||
DdlOcupacion.Items.Clear()
|
||||
|
||||
BtnAgregarPuestoModal.Text = "Agregar"
|
||||
|
||||
'Combos
|
||||
|
||||
UpModalPuesto.Update()
|
||||
|
||||
RegistraScript(String.Format("$('#{0}').modal();", "divAgregarEditarPuesto"))
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user