243 lines
11 KiB
VB.net
243 lines
11 KiB
VB.net
Option Explicit On
|
|
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.Linq
|
|
Imports Extensiones
|
|
|
|
Partial Class Nomina_CatPeriodos
|
|
Inherits ClsPaginas
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not Page.IsPostBack Then
|
|
ViewState("Orden") = ""
|
|
CargaDatos()
|
|
CargaTipoPeriodo()
|
|
|
|
''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(-1, UsuarioActual.CveEmpresa, Now.Year, -1, -1) Then
|
|
ViewState("DTNom_Periodos") = ObjNom_Periodos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTNom_Periodos = ObjNom_Periodos.DtResultados
|
|
|
|
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
|
|
|
|
Protected Sub LbAgregar_Click(sender As Object, e As System.EventArgs) Handles LbAgregar.Click
|
|
Dim ObjNom_Periodos As New ClsNominas
|
|
Dim Numero As Integer = TxtNumero.Text.Trim.ToEntero
|
|
Dim EsInicioMes As Boolean = ChkEsInicioMes.Checked
|
|
Dim EsFinMes As Boolean = ChkEsFinMes.Checked
|
|
Dim EsInicioSS As Boolean = CBool(ChkEsInicioSS.Checked)
|
|
Dim EsFinSS As Boolean = ChkEsFinSS.Checked
|
|
Dim EsInicioAño As Boolean = ChkEsInicioAño.Checked
|
|
Dim EsFinAño As Boolean = ChkEsFinAño.Checked
|
|
Dim FueCalculado As Boolean = ChkFueCalculado.Checked
|
|
Dim FechaInicio As Date = TxtFechaInicio.Text.Trim.ToDate
|
|
Dim FechaFin As Date = TxtFechaFin.Text.Trim.ToDate
|
|
Dim Mes As Integer = FechaFin.Month
|
|
Dim Ejercicio As Integer = FechaFin.Year
|
|
Dim CveTipoPeriodo As Integer = DdlTipoPeriodo.SelectedValue.ToEntero
|
|
Dim Estatus As Integer = DdlEstatus.SelectedValue.ToEntero
|
|
|
|
If ObjNom_Periodos.AddPeriodo(CveTipoPeriodo, Ejercicio, Mes, Numero, FechaInicio, FechaFin, EsInicioMes, EsFinMes, ChkEsInicioSS.Checked, ChkEsFinAño.Checked, ChkEsInicioAño.Checked, ChkEsFinAño.Checked, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa) Then
|
|
|
|
Alert("El nuevo Periodo se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
UpDatos.Update()
|
|
ViewState("DTNom_Periodos") = ObjNom_Periodos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTNom_Periodos = ObjNom_Periodos.DtResultados
|
|
CargaDatos()
|
|
If String.IsNullOrEmpty(ViewState("Orden").ToString()) Then
|
|
CargaGrid(ViewState("Orden").ToString())
|
|
Else
|
|
CargaGrid("")
|
|
End If
|
|
|
|
End If
|
|
'ObjNom_Periodos.Dispose()
|
|
End Sub
|
|
|
|
#Region " C O M B O S"
|
|
Private Sub CargaTipoPeriodo()
|
|
DdlTipoPeriodo.DataSource = GlobalDTTipoPeriodo
|
|
DdlTipoPeriodo.DataBind()
|
|
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
|
|
If e.Row.RowState = DataControlRowState.Edit OrElse e.Row.RowState = 5 Then
|
|
e.Row.FCDropDownList("DdlTipoPeriodo").DataSource = GlobalDTTipoPeriodo
|
|
e.Row.FCDropDownList("DdlTipoPeriodo").DataBind()
|
|
e.Row.FCDropDownList("DdlTipoPeriodo").SelectedValue = e.Row.DBCampo("CveTipoPeriodo")
|
|
e.Row.FCDropDownList("DdlEstatus").SelectedItem.Text = e.Row.DBCampo("Estatus")
|
|
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)
|
|
GlobalDTNom_Periodos = ObjNom_Periodos.DtResultados
|
|
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
|
|
|
|
Protected Sub GvDatos_RowUpdating(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GvDatos.RowUpdating
|
|
Dim ObjNom_Periodos As New ClsNominas
|
|
Dim Numero As Integer = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtNumero"), TextBox).Text.Trim.ToEntero
|
|
Dim EsInicioMes As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkEsInicioMes").Checked
|
|
Dim EsFinMes As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkEsFinMes").Checked
|
|
Dim EsInicioSS As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkEsInicioSS").Checked
|
|
Dim EsFinSS As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkEsFinSS").Checked
|
|
Dim EsInicioAño As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkEsInicioAño").Checked
|
|
Dim EsFinAño As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkEsFinAño").Checked
|
|
Dim FueCalculado As Boolean = GvDatos.Rows(e.RowIndex).FCCheckBox("ChkFueCalculado").Checked
|
|
Dim FechaInicio As Date = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtFechaInicio"), TextBox).Text.Trim.ToDateTime
|
|
Dim FechaFin As Date = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("TxtFechaFin"), TextBox).Text.Trim.ToDateTime
|
|
Dim Mes As Integer = FechaFin.Month
|
|
Dim Ejercicio As Integer = FechaFin.Year
|
|
Dim CveTipoPeriodo As Integer = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("DdlTipoPeriodo"), DropDownList).SelectedValue.ToEntero
|
|
Dim Estatus As Integer = DirectCast(GvDatos.Rows(e.RowIndex).FindControl("DdlEstatus"), DropDownList).SelectedValue.ToEntero
|
|
|
|
Dim CvePeriodo As Integer = GvDatos.DataKeys(e.RowIndex).Value.ToString.ToEntero
|
|
|
|
If ObjNom_Periodos.UpdatePeriodo(FechaInicio, FechaFin, EsInicioMes, EsFinMes, EsInicioSS, EsFinSS, EsInicioAño, EsFinAño, FueCalculado,
|
|
CveTipoPeriodo, Ejercicio, Mes, Numero, Estatus, CvePeriodo, UsuarioActual.CveEmpresa) Then
|
|
GvDatos.EditIndex = -1
|
|
ViewState("DTNom_Periodos") = ObjNom_Periodos.DtResultados.FiltraParametros("CveEmpresa = " & UsuarioActual.CveEmpresa)
|
|
GlobalDTNom_Periodos = ObjNom_Periodos.DtResultados
|
|
Alert("Los cambios se guardaron 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_RowEditing(sender As Object, e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GvDatos.RowEditing
|
|
GvDatos.EditIndex = e.NewEditIndex
|
|
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
|
|
End Class
|