256 lines
13 KiB
VB.net
256 lines
13 KiB
VB.net
Option Strict On
|
|
Option Explicit On
|
|
|
|
Imports Extensiones
|
|
Imports System.Data
|
|
|
|
Partial Class Nomina_PreNomina
|
|
Inherits ClsPaginas
|
|
|
|
Private ReadOnly Property DTPeriodos As DataTable
|
|
Get
|
|
Return DirectCast(ViewState("DTPeriodos"), DataTable)
|
|
End Get
|
|
End Property
|
|
|
|
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
|
|
If Not IsPostBack Then
|
|
SetValues()
|
|
SetPermisos()
|
|
CargaTiposPeriodo()
|
|
CargaProyecto()
|
|
CargaTurnos()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub SetValues()
|
|
End Sub
|
|
|
|
Private Sub SetPermisos()
|
|
'Permisos
|
|
If UsuarioActual.EsSupervisorRH Then
|
|
BtnGuardarBono.Visible = False
|
|
BtnImpresion.Visible = False
|
|
|
|
For i As Integer = 25 To 28
|
|
GvDatos.Columns(i).Visible = False
|
|
Next
|
|
|
|
'TDAplica.Visible = False : TDBono.Visible = False : TDDescuento.Visible = False : TDPagoAdicional.Visible = False
|
|
|
|
End If
|
|
End Sub
|
|
|
|
#Region "CargaCombos"
|
|
|
|
Private Sub CargaTiposPeriodo()
|
|
DdlTipoPeriodo.DataSource = GlobalDTTipoPeriodo
|
|
DdlTipoPeriodo.DataBind()
|
|
End Sub
|
|
|
|
Private Sub CargaPeriodos()
|
|
Dim ObjPeriodos As New ClsNominas
|
|
If ObjPeriodos.GetPeriodos(DdlTipoPeriodo.SelectedValue.ToEntero, UsuarioActual.CveEmpresa, -1, -1, -1) Then
|
|
ViewState("DTPeriodos") = ObjPeriodos.DtResultados
|
|
DdlPeriodo.DataSource = DTPeriodos
|
|
Else
|
|
DdlPeriodo.DataSource = Nothing
|
|
End If
|
|
ObjPeriodos.Dispose()
|
|
DdlPeriodo.DataBind()
|
|
|
|
DdlPeriodo.Items.Clear()
|
|
DdlPeriodo.DataBind()
|
|
DdlPeriodo.Items.Insert(0, New ListItem("Seleccione", "-1"))
|
|
End Sub
|
|
|
|
Private Sub CargaProyecto()
|
|
DdlProyecto.DataSource = GlobalDTProyectos(UsuarioActual.Empresa.CveEmpresa).FiltraParametros("", DistinctColumns:={"CveProyecto", "Proyecto"})
|
|
DdlProyecto.DataBind()
|
|
End Sub
|
|
|
|
Private Sub CargaSubProyecto()
|
|
DdlSubProyecto.Items.Clear()
|
|
DdlSubProyecto.DataSource = GlobalDTSubProyectos(DdlProyecto.SelectedValue.ToEntero)
|
|
DdlSubProyecto.DataBind()
|
|
DdlSubProyecto.Items.Insert(0, New ListItem("Todos", "-1"))
|
|
End Sub
|
|
|
|
Private Sub CargaTurnos()
|
|
DdlTurno.DataSource = GlobalDTTurno(UsuarioActual.CveEmpresa)
|
|
DdlTurno.DataBind()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
Protected Sub DdlProyecto_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlProyecto.SelectedIndexChanged
|
|
CargaSubProyecto()
|
|
End Sub
|
|
|
|
Protected Sub DdlTipoPeriodo_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DdlTipoPeriodo.SelectedIndexChanged
|
|
CargaPeriodos()
|
|
End Sub
|
|
|
|
Protected Sub BtnConsultar_Click(sender As Object, e As System.EventArgs) Handles BtnConsultar.Click
|
|
If DdlPeriodo.SelectedValue <> "-1" Then
|
|
Dim ObjNomina As New ClsRH
|
|
|
|
Dim FechaI, FechaF As Date
|
|
FechaI = DTPeriodos.FiltraParametros("CvePeriodo = " & DdlPeriodo.SelectedValue).Rows(0)("FechaInicio").ToString.ToDate
|
|
FechaF = DTPeriodos.FiltraParametros("CvePeriodo = " & DdlPeriodo.SelectedValue).Rows(0)("FechaFin").ToString.ToDate
|
|
|
|
LtlLunes.Text = If(FechaI.Day.ToString.Length = 1, "0" & FechaI.Day.ToString, FechaI.Day.ToString)
|
|
LtlMartes.Text = If(FechaI.AddDays(1).Day.ToString.Length = 1, "0" & FechaI.AddDays(1).Day.ToString, FechaI.AddDays(1).Day.ToString)
|
|
LtlMiercoles.Text = If(FechaI.AddDays(2).Day.ToString.Length = 1, "0" & FechaI.AddDays(2).Day.ToString, FechaI.AddDays(2).Day.ToString)
|
|
LtlJueves.Text = If(FechaI.AddDays(3).Day.ToString.Length = 1, "0" & FechaI.AddDays(3).Day.ToString, FechaI.AddDays(3).Day.ToString)
|
|
LtlViernes.Text = If(FechaI.AddDays(4).Day.ToString.Length = 1, "0" & FechaI.AddDays(4).Day.ToString, FechaI.AddDays(4).Day.ToString)
|
|
LtlSabado.Text = If(FechaI.AddDays(5).Day.ToString.Length = 1, "0" & FechaI.AddDays(5).Day.ToString, FechaI.AddDays(5).Day.ToString)
|
|
LtlDomingo.Text = If(FechaI.AddDays(6).Day.ToString.Length = 1, "0" & FechaI.AddDays(6).Day.ToString, FechaI.AddDays(6).Day.ToString)
|
|
|
|
If ObjNomina.GetPreNomina(DdlProyecto.SelectedValue.ToEntero, DdlSubProyecto.SelectedValue.ToEntero, DdlTurno.SelectedValue.ToEntero, FechaI, FechaF, UsuarioActual.CveEmpresa) Then
|
|
GvDatos.DataSource = ObjNomina.DtResultados
|
|
Else
|
|
GvDatos.DataSource = Nothing
|
|
End If
|
|
|
|
ObjNomina.Dispose()
|
|
|
|
GvDatos.DataBind()
|
|
UPDatos.Update()
|
|
|
|
HLImgImprimir.NavigateUrl = String.Format("/Nomina/RepPreNomina.aspx?CveProyecto={0}&CveSubProyecto={1}&CveTurno={2}&FechaI={3}&FechaF={4}&Periodo={5}", DdlProyecto.SelectedValue, DdlSubProyecto.SelectedValue, DdlTurno.SelectedValue, FechaI.ToShortDateString, FechaF.ToShortDateString, DdlPeriodo.SelectedItem.Text)
|
|
UpnTools.Update()
|
|
|
|
Else
|
|
Alert("Debe de seleccionar el Período con el que se desea trabajar", TipoMensaje.MsgAdvertencia)
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub BtnImpresion_Click(sender As Object, e As System.EventArgs) Handles BtnImpresion.Click
|
|
'System.Threading.Thread.Sleep(1500)
|
|
|
|
Alert("La Prenómina se cerró correctamente y se generaron los importes de la nómina.", TipoMensaje.MsgInformacion)
|
|
End Sub
|
|
|
|
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.DBCampo("Turno") = "" AndAlso e.Row.DBCampo("Nombre") = "" Then
|
|
e.Row.FCLiteral("LtlNombre").Text = "<b>Sub Proyecto: " & e.Row.DBCampo("SubProyecto") & "<b>"
|
|
e.Row.Cells(0).ColumnSpan = 22
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
For i As Integer = 1 To 21
|
|
e.Row.Cells(i).Visible = False
|
|
Next
|
|
e.Row.FCCheckBox("ChkAplica").Visible = False : e.Row.FCTextBox("TxtBono").Visible = False : e.Row.FCTextBox("TxtPagoAdicional").Visible = False : e.Row.FCTextBox("TxtDescuentoAdicional").Visible = False
|
|
e.Row.FCLiteral("LtlAsistencias").Text = CType(CType(sender, GridView).DataSource, DataTable).SUM("Asistencias", "Nombre <> ''").ToString
|
|
e.Row.FCLiteral("LtlFaltas").Text = CType(CType(sender, GridView).DataSource, DataTable).SUM("Faltas", "Nombre <> ''").ToString
|
|
If e.Row.FCLiteral("LtlAsistencias").Text.ToDouble = 0 Then
|
|
e.Row.FCLiteral("LtlAsistencias").Text = ""
|
|
Else
|
|
e.Row.FCLiteral("LtlAsistencias").Text = "<b>" & e.Row.FCLiteral("LtlAsistencias").Text & "</b>"
|
|
End If
|
|
If e.Row.FCLiteral("LtlFaltas").Text.ToDouble = 0 Then
|
|
e.Row.FCLiteral("LtlFaltas").Text = ""
|
|
Else
|
|
e.Row.FCLiteral("LtlFaltas").Text = "<b>" & e.Row.FCLiteral("LtlFaltas").Text & "</b>"
|
|
End If
|
|
If e.Row.FCLiteral("LtlHorasExtras").Text.ToDouble = 0 Then
|
|
e.Row.FCLiteral("LtlHorasExtras").Text = ""
|
|
Else
|
|
e.Row.FCLiteral("LtlHorasExtras").Text = "<b>" & e.Row.FCLiteral("LtlHorasExtras").Text & "</b>"
|
|
End If
|
|
ElseIf e.Row.DBCampo("Turno") <> "" AndAlso e.Row.DBCampo("Nombre") = "" Then
|
|
e.Row.FCLiteral("LtlNombre").Text = "Turno: " & e.Row.DBCampo("Turno")
|
|
e.Row.Cells(0).ColumnSpan = 22
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
For i As Integer = 1 To 21
|
|
e.Row.Cells(i).Visible = False
|
|
Next
|
|
e.Row.FCCheckBox("ChkAplica").Visible = False : e.Row.FCTextBox("TxtBono").Visible = False : e.Row.FCTextBox("TxtPagoAdicional").Visible = False : e.Row.FCTextBox("TxtDescuentoAdicional").Visible = False
|
|
e.Row.FCLiteral("LtlAsistencias").Text = CType(CType(sender, GridView).DataSource, DataTable).SUM("Asistencias", "Turno = '" & e.Row.DBCampo("Turno") & "' AND Nombre <> ''").ToString
|
|
e.Row.FCLiteral("LtlFaltas").Text = CType(CType(sender, GridView).DataSource, DataTable).SUM("Faltas", "Turno = '" & e.Row.DBCampo("Turno") & "' AND Nombre <> ''").ToString
|
|
If e.Row.FCLiteral("LtlAsistencias").Text.ToDouble = 0 Then
|
|
e.Row.FCLiteral("LtlAsistencias").Text = ""
|
|
Else
|
|
e.Row.FCLiteral("LtlAsistencias").Text = "<b>" & e.Row.FCLiteral("LtlAsistencias").Text & "</b>"
|
|
End If
|
|
If e.Row.FCLiteral("LtlFaltas").Text.ToDouble = 0 Then
|
|
e.Row.FCLiteral("LtlFaltas").Text = ""
|
|
Else
|
|
e.Row.FCLiteral("LtlFaltas").Text = "<b>" & e.Row.FCLiteral("LtlFaltas").Text & "</b>"
|
|
End If
|
|
If e.Row.FCLiteral("LtlHorasExtras").Text.ToDouble = 0 Then
|
|
e.Row.FCLiteral("LtlHorasExtras").Text = ""
|
|
Else
|
|
e.Row.FCLiteral("LtlHorasExtras").Text = "<b>" & e.Row.FCLiteral("LtlHorasExtras").Text & "</b>"
|
|
End If
|
|
Else
|
|
e.Row.Cells(0).HorizontalAlign = HorizontalAlign.Left
|
|
Dim FechaI, FechaF As String
|
|
FechaI = String.Empty : FechaF = String.Empty
|
|
Dim Array() As String = DdlPeriodo.SelectedItem.Text.Split("-"c)
|
|
If Array.Length > 0 Then
|
|
FechaI = Array(1).Trim
|
|
FechaF = Array(2).Trim
|
|
End If
|
|
e.Row.FCLiteral("LtlNombre").Text = "<a class=""Texto"" href=""/RH/Personal.aspx?CvePersonal=" & e.Row.DBCampo("CvePersonal") & "&CveSubProyecto=" & e.Row.DBCampo("CveSubProyecto") & "&FechaI=" & FechaI & "&FechaF=" & FechaF & "&CveTurno=" & e.Row.DBCampo("CveTurno") & "&Opt=3"">" & e.Row.FCLiteral("LtlNombre").Text & "</a>"
|
|
If e.Row.DBCampo("Lu_HrsDobles").ToDouble = 0 Then e.Row.FCLiteral("LtlLu_HrsDobles").Text = ""
|
|
If e.Row.DBCampo("Ma_HrsDobles").ToDouble = 0 Then e.Row.FCLiteral("LtlMa_HrsDobles").Text = ""
|
|
If e.Row.DBCampo("Mi_HrsDobles").ToDouble = 0 Then e.Row.FCLiteral("LtlMi_HrsDobles").Text = ""
|
|
If e.Row.DBCampo("Ju_HrsDobles").ToDouble = 0 Then e.Row.FCLiteral("LtlJu_HrsDobles").Text = ""
|
|
If e.Row.DBCampo("Vi_HrsDobles").ToDouble = 0 Then e.Row.FCLiteral("LtlVi_HrsDobles").Text = ""
|
|
If e.Row.DBCampo("Sa_HrsDobles").ToDouble = 0 Then e.Row.FCLiteral("LtlSa_HrsDobles").Text = ""
|
|
If e.Row.DBCampo("Do_HrsDobles").ToDouble = 0 Then e.Row.FCLiteral("LtlDo_HrsDobles").Text = ""
|
|
If e.Row.DBCampo("Asistencias").ToDouble = 0 Then e.Row.FCLiteral("LtlAsistencias").Text = ""
|
|
If e.Row.DBCampo("Faltas").ToDouble = 0 Then e.Row.FCLiteral("LtlFaltas").Text = ""
|
|
If e.Row.DBCampo("HorasDobles").ToDouble = 0 Then e.Row.FCLiteral("LtlHorasExtras").Text = ""
|
|
e.Row.CssClass = "scrollwidthrow"
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Protected Sub ImgExcel_Click(sender As Object, e As EventArgs) Handles ImgExcel.Click
|
|
GvDatos.ExportToExcel("PreNomina", TblHeader)
|
|
End Sub
|
|
|
|
Protected Sub BtnGuardarBono_Click(sender As Object, e As System.EventArgs) Handles BtnGuardarBono.Click
|
|
Dim ObjPersonal As New ClsRH
|
|
ObjPersonal.IniciaTransacSQL()
|
|
|
|
Dim OcurrioError As Boolean = False
|
|
For Each Row As GridViewRow In GvDatos.Rows
|
|
If Row.DataKey("CvePersonal") <> "" Then
|
|
If Not ObjPersonal.AddConcepto(Row.DataKey("CvePersonal").ToEntero, 14, Row.FCTextBox("TxtBono").Text.ToDouble, If(Row.FCCheckBox("ChkAplica").Checked, 1, 0), 0, 0, UsuarioActual.CveUsuario) Then
|
|
OcurrioError = True
|
|
ObjPersonal.RollBack()
|
|
Exit For
|
|
End If
|
|
'Pago Adicional
|
|
If Not ObjPersonal.AddConcepto(Row.DataKey("CvePersonal").ToEntero, 11, Row.FCTextBox("TxtPagoAdicional").Text.ToDouble, 1, 0, 0, UsuarioActual.CveUsuario) Then
|
|
OcurrioError = True
|
|
ObjPersonal.RollBack()
|
|
Exit For
|
|
End If
|
|
'Descuentos Varios
|
|
If Not ObjPersonal.AddConcepto(Row.DataKey("CvePersonal").ToEntero, 10, Row.FCTextBox("TxtDescuentoAdicional").Text.ToDouble, 1, 0, 0, UsuarioActual.CveUsuario) Then
|
|
OcurrioError = True
|
|
ObjPersonal.RollBack()
|
|
Exit For
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
If Not OcurrioError Then
|
|
ObjPersonal.Commit()
|
|
Alert("La información se guardó correctamente.", TipoMensaje.MsgInformacion)
|
|
Else
|
|
Alert("Ocurrió un error al guardar la información.", TipoMensaje.MsgError)
|
|
End If
|
|
|
|
ObjPersonal.Dispose()
|
|
End Sub
|
|
|
|
|
|
End Class
|