366 lines
16 KiB
VB.net
366 lines
16 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.Linq
|
|
Imports Extensiones
|
|
Imports Microsoft.Reporting.WebForms
|
|
|
|
Partial Class Nomina_CatPeriodos
|
|
Inherits ClsPaginas
|
|
Private Property Comando As String
|
|
Get
|
|
Return ViewState("Comando").ToString()
|
|
End Get
|
|
Set(value As String)
|
|
ViewState("Comando") = 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") = ""
|
|
CargaTipoPeriodo()
|
|
cargaEjercicios()
|
|
CargaTurnos()
|
|
|
|
CargaDatos()
|
|
|
|
''Permiso Registro
|
|
'If PermisoRegistro Then
|
|
' LbAgregar.Enabled = True
|
|
'Else
|
|
' LbAgregar.Enabled = False
|
|
'End If
|
|
End If
|
|
End Sub
|
|
|
|
Public Sub CargaDatos()
|
|
Dim ObjNom_Periodos As New ClsNominas
|
|
If ObjNom_Periodos.GetPeriodos(DdlTipoPeriodo.SelectedValue.ToEntero(), UsuarioActual.CveEmpresa, DdlEjercicio.SelectedValue.ToEntero(), -1, -1, DdlEstatus.SelectedValue.ToEntero()) Then
|
|
ViewState("DTNom_Periodos") = ObjNom_Periodos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
|
|
Else
|
|
Me.GvDatos.DataSource = Nothing
|
|
End If
|
|
|
|
ObjNom_Periodos.Dispose()
|
|
|
|
If ViewState("Orden").ToString() <> String.Empty Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End Sub
|
|
|
|
|
|
#Region " C O M B O S"
|
|
Private Sub CargaTipoPeriodo()
|
|
DdlTipoPeriodo.DataSource = GlobalDTTipoPeriodo
|
|
DdlTipoPeriodoAdd.DataSource = GlobalDTTipoPeriodo
|
|
|
|
DdlTipoPeriodo.DataBind()
|
|
DdlTipoPeriodoAdd.DataBind()
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub cargaEjercicios()
|
|
Dim ObjNom_Periodos As New ClsNominas
|
|
If ObjNom_Periodos.GetEjercicios(UsuarioActual.CveEmpresa) Then
|
|
DdlEjercicio.DataSource = ObjNom_Periodos.DtResultados
|
|
Else
|
|
DdlEjercicio.DataSource = Nothing
|
|
End If
|
|
ObjNom_Periodos.Dispose()
|
|
DdlEjercicio.DataBind()
|
|
DdlEjercicio.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
|
|
End Sub
|
|
|
|
Private Sub CargaTurnos()
|
|
DdlTurno.DataSource = GlobalDTTurno(UsuarioActual.CveEmpresa)
|
|
DdlTurno.DataBind()
|
|
DdlTurno.Items.Insert(0, New ListItem("Seleccione uno", "-1"))
|
|
End Sub
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#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(100)
|
|
'e.Row.Cells(1).Width = Unit.Pixel(80)
|
|
'e.Row.Cells(2).Width = Unit.Pixel(80)
|
|
'e.Row.Cells(3).Width = Unit.Pixel(80)
|
|
'e.Row.Cells(4).Width = Unit.Pixel(100)
|
|
'e.Row.Cells(5).Width = Unit.Pixel(100)
|
|
'e.Row.Cells(6).Width = Unit.Pixel(80)
|
|
'e.Row.Cells(7).Width = Unit.Pixel(80)
|
|
'e.Row.Cells(8).Width = Unit.Pixel(80)
|
|
'e.Row.Cells(9).Width = Unit.Pixel(80)
|
|
'e.Row.Cells(10).Width = Unit.Pixel(80)
|
|
'e.Row.Cells(11).Width = Unit.Pixel(80)
|
|
'e.Row.Cells(12).Width = Unit.Pixel(80)
|
|
'e.Row.Cells(13).Width = Unit.Pixel(100)
|
|
'e.Row.Cells(14).Width = Unit.Pixel(53)
|
|
'e.Row.Cells(15).Width = Unit.Pixel(68)
|
|
'e.Row.Cells(15).Width = Unit.Pixel(100)
|
|
End If
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
e.Row.Cells(1).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(2).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(3).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(4).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(5).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(6).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(7).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(8).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(9).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(10).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(11).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(12).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(13).HorizontalAlign = HorizontalAlign.Center
|
|
e.Row.Cells(14).HorizontalAlign = HorizontalAlign.Center
|
|
|
|
e.Row.FCCheckBox("ChkEsInicioMes").Checked = Convert.ToBoolean(e.Row.DataKey("EsInicioMes").ToString())
|
|
e.Row.FCCheckBox("ChkEsFinMes").Checked = Convert.ToBoolean(e.Row.DataKey("EsFinMes").ToString())
|
|
e.Row.FCCheckBox("ChkEsInicioSS").Checked = Convert.ToBoolean(e.Row.DataKey("EsInicioSS").ToString())
|
|
e.Row.FCCheckBox("ChkEsFinSS").Checked = Convert.ToBoolean(e.Row.DataKey("EsFinSS").ToString())
|
|
e.Row.FCCheckBox("ChkEsInicioAño").Checked = Convert.ToBoolean(e.Row.DataKey("EsInicioAño").ToString())
|
|
e.Row.FCCheckBox("ChkEsFinAño").Checked = Convert.ToBoolean(e.Row.DataKey("EsFinAño").ToString())
|
|
e.Row.FCCheckBox("ChkFueCalculado").Checked = Convert.ToBoolean(e.Row.DataKey("FueCalculado").ToString())
|
|
|
|
If e.Row.DataKey("Estatus").ToString().ToEntero() = 1 Then
|
|
e.Row.FCLiteral("LtlEstatus").Text = "Actual"
|
|
ElseIf e.Row.DataKey("Estatus").ToString().ToEntero() = 2 Or e.Row.DataKey("Estatus").ToString().ToEntero() = 3 Then
|
|
e.Row.FCLiteral("LtlEstatus").Text = "Cerrado"
|
|
Else
|
|
e.Row.FCLiteral("LtlEstatus").Text = ""
|
|
End If
|
|
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub GvDatos_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GvDatos.RowDeleting
|
|
Dim ObjNom_Periodos As New ClsNominas
|
|
If ObjNom_Periodos.RemovePeriodo(GvDatos.DataKeys(e.RowIndex).Value.ToString().ToEntero()) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTNom_Periodos") = ObjNom_Periodos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTNominasPeriodos(-1, -1, UsuarioActual.CveEmpresa) = Nothing
|
|
Alert("El Periodo se eliminó correctamente.", TipoMensaje.MsgInformacion)
|
|
End If
|
|
|
|
ObjNom_Periodos.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
|
|
|
|
|
|
#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("DTNom_Periodos"), DataTable), "", Orden, DataViewRowState.CurrentRows)
|
|
GvDatos.DataSource = DV.ToTable()
|
|
DV.Dispose()
|
|
Else
|
|
GvDatos.DataSource = CType(ViewState("DTNom_Periodos"), DataTable)
|
|
End If
|
|
GvDatos.DataBind()
|
|
UpDatos.Update()
|
|
End Sub
|
|
#End Region
|
|
|
|
Private Sub LnkAddPeriodo_Click(sender As Object, e As EventArgs) Handles LnkAddPeriodo.Click
|
|
LimpiarModal()
|
|
Comando = "Agregar"
|
|
lblTiulomodal.Text = "Agregar Periodo"
|
|
RegistraScript("$('#divAddPeriodo').modal('show');")
|
|
End Sub
|
|
Protected Sub BtnAgregar_Click(sender As Object, e As System.EventArgs) Handles BtnAgregar.Click
|
|
Dim ObjNom_Periodos As New ClsNominas
|
|
|
|
Dim EsInicioMes As Boolean
|
|
Dim EsFinMes As Boolean
|
|
Dim EsInicioSS As Boolean
|
|
Dim EsFinSS As Boolean
|
|
Dim EsInicioAño As Boolean
|
|
Dim EsFinAño As Boolean
|
|
Dim FueCalculado As Boolean
|
|
Dim Numero As Integer = TxtNumeroAdd.Text.Trim.ToEntero()
|
|
Dim FechaInicio As Date = TxtFechaInicioAdd.Text.Trim.ToDate
|
|
Dim FechaFin As Date = TxtFechaFinAdd.Text.Trim.ToDate
|
|
Dim Mes As Integer = FechaFin.Month
|
|
Dim Ejercicio As Integer = FechaFin.Year
|
|
Dim CveTipoPeriodo As Integer = DdlTipoPeriodoAdd.SelectedValue.ToEntero()
|
|
Dim Estatus As Integer = DdlEstatusAdd.SelectedValue.ToEntero()
|
|
Dim CvePeriodo As Integer = hdnCvePerido.Value.ToEntero()
|
|
|
|
For Each item As ListItem In CBLchk.Items
|
|
Select Case item.Value.ToEntero()
|
|
Case 1
|
|
If item.Selected Then EsInicioMes = True Else EsInicioMes = False
|
|
Case 2
|
|
If item.Selected Then EsFinMes = True Else EsFinMes = False
|
|
Case 3
|
|
If item.Selected Then EsInicioSS = True Else EsInicioSS = False
|
|
Case 4
|
|
If item.Selected Then EsFinSS = True Else EsFinSS = False
|
|
Case 5
|
|
If item.Selected Then EsInicioAño = True Else EsInicioAño = False
|
|
Case 6
|
|
If item.Selected Then EsFinAño = True Else EsFinAño = False
|
|
Case 7
|
|
If item.Selected Then FueCalculado = True Else FueCalculado = False
|
|
End Select
|
|
Next
|
|
If Comando = "Agregar" Then
|
|
|
|
If ObjNom_Periodos.AddPeriodo(CveTipoPeriodo, Ejercicio, Mes, Numero, FechaInicio, FechaFin, EsInicioMes, EsFinMes, EsInicioSS, EsFinSS, EsInicioAño, EsFinAño, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlTurno.SelectedValue.ToEntero(), DdlEstatus.SelectedValue.ToEntero()) Then
|
|
|
|
Alert("El nuevo Periodo se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
UpDatos.Update()
|
|
ViewState("DTNom_Periodos") = ObjNom_Periodos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTNominasPeriodos(-1, -1, UsuarioActual.CveEmpresa) = Nothing
|
|
CargaDatos()
|
|
If String.IsNullOrEmpty(ViewState("Orden").ToString()) Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
|
|
End If
|
|
ElseIf Comando = "Actualizar" Then
|
|
|
|
If ObjNom_Periodos.UpdatePeriodo(FechaInicio, FechaFin, EsInicioMes, EsFinMes, EsInicioSS, EsFinSS, EsInicioAño, EsFinAño, FueCalculado, CveTipoPeriodo, Ejercicio, Mes, Numero, Estatus, CvePeriodo, UsuarioActual.CveEmpresa, DdlTurno.SelectedValue.ToEntero()) Then
|
|
|
|
Alert("Los cambios se guardaron correctamente.", TipoMensaje.MsgInformacion)
|
|
UpDatos.Update()
|
|
ViewState("DTNom_Periodos") = ObjNom_Periodos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTNominasPeriodos(-1, -1, UsuarioActual.CveEmpresa) = Nothing
|
|
CargaDatos()
|
|
If String.IsNullOrEmpty(ViewState("Orden").ToString()) Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
RegistraScript("$('#divAddPeriodo').modal('hide');")
|
|
|
|
'ObjNom_Periodos.Dispose()
|
|
End Sub
|
|
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click
|
|
CargaDatos()
|
|
End Sub
|
|
Protected Sub LnkEditar_Click(sender As Object, e As EventArgs)
|
|
LimpiarModal()
|
|
Comando = "Actualizar"
|
|
lblTiulomodal.Text = "Actualizar Periodo"
|
|
Dim GvRow As GridViewRow = DirectCast((DirectCast(sender, LinkButton)).NamingContainer, GridViewRow)
|
|
DdlTipoPeriodoAdd.SelectedValueExist(GvRow.DataKey("CveTipoPeriodo").ToString().ToEntero())
|
|
DdlTurno.SelectedValueExist(GvRow.DataKey("CveTurno").ToString().ToEntero())
|
|
TxtNumeroAdd.Text = GvRow.DataKey("Numero").ToString()
|
|
TxtFechaInicioAdd.Text = GvRow.DataKey("FechaInicio").ToString()
|
|
TxtFechaFinAdd.Text = GvRow.DataKey("FechaFin").ToString()
|
|
DdlEstatusAdd.SelectedValueExist(GvRow.DataKey("Estatus").ToString().ToEntero())
|
|
hdnCvePerido.Value = GvRow.DataKey("CvePeriodo").ToString()
|
|
For Each item As ListItem In CBLchk.Items
|
|
Select Case item.Value.ToEntero()
|
|
Case 1
|
|
item.Selected = Convert.ToBoolean(GvRow.DataKey("EsInicioMes").ToString())
|
|
Case 2
|
|
item.Selected = Convert.ToBoolean(GvRow.DataKey("EsFinMes").ToString())
|
|
Case 3
|
|
item.Selected = Convert.ToBoolean(GvRow.DataKey("EsInicioSS").ToString())
|
|
Case 4
|
|
item.Selected = Convert.ToBoolean(GvRow.DataKey("EsFinSS").ToString())
|
|
Case 5
|
|
item.Selected = Convert.ToBoolean(GvRow.DataKey("EsInicioAño").ToString())
|
|
Case 6
|
|
item.Selected = Convert.ToBoolean(GvRow.DataKey("EsFinAño").ToString())
|
|
Case 7
|
|
item.Selected = Convert.ToBoolean(GvRow.DataKey("FueCalculado").ToString())
|
|
End Select
|
|
Next
|
|
UpModalPerido.Update()
|
|
|
|
RegistraScript("$('#divAddPeriodo').modal('show')")
|
|
End Sub
|
|
|
|
Private Sub LimpiarModal()
|
|
DdlTipoPeriodoAdd.SelectedValueExist(-1)
|
|
TxtNumeroAdd.Text = ""
|
|
TxtFechaInicioAdd.Text = ""
|
|
TxtFechaFinAdd.Text = ""
|
|
DdlEstatusAdd.SelectedValueExist(-1)
|
|
DdlTurno.SelectedValueExist(-1)
|
|
For Each item As ListItem In CBLchk.Items
|
|
Select Case item.Value.ToEntero()
|
|
Case 1
|
|
item.Selected = False
|
|
Case 2
|
|
item.Selected = False
|
|
Case 3
|
|
item.Selected = False
|
|
Case 4
|
|
item.Selected = False
|
|
Case 5
|
|
item.Selected = False
|
|
Case 6
|
|
item.Selected = False
|
|
Case 7
|
|
item.Selected = False
|
|
End Select
|
|
Next
|
|
UpModalPerido.Update()
|
|
End Sub
|
|
End Class
|