Files
SIG/RH/CatTurno.aspx.vb
2023-07-03 12:09:45 -07:00

182 lines
6.7 KiB
VB.net

Option Explicit On
Option Strict On
Imports System.Data
Imports System.Linq
Imports Extensiones
Partial Class RH_CatTurno
Inherits ClsPaginas
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
CargaDdlChecadorHorario()
CargaDatos()
If UsuarioActual.CveEmpresa <> 158 Then
DvToleranciaSRetardo.Visible = True
End If
End If
End Sub
Private Sub CargaDdlChecadorHorario()
Dim ObjRH As New ClsRH()
If ObjRH.DdlChecadorHorarioGet() Then
DdlChecadorHorario.DataSource = ObjRH.DtResultados
DdlChecadorHorario.DataBind()
End If
ObjRH.Dispose()
UpDatos.Update()
End Sub
Private Sub CargaDatos()
Dim ObjRH As New ClsRH()
If ObjRH.GetTurnos(UsuarioActual.CveEmpresa) Then
GvTurno.DataSource = ObjRH.DtResultados.FiltraParametros(" CveEmpresa =" & UsuarioActual.CveEmpresa)
GvTurno.DataBind()
End If
ObjRH.Dispose()
UpDatos.Update()
End Sub
Private Sub BtnAgregarTurno_Click(sender As Object, e As EventArgs) Handles BtnAgregarTurno.Click
Using ObjRH As New ClsRH
Dim Estatus As Boolean = False
Dim comida As Integer = If(chkComida.Checked, 1, 0)
Dim ComidaDe As String = If(TxtComidade.Text.Trim = "", "00:00:00", TxtComidade.Text.Trim)
Dim ComidaA As String = If(TxtComidaA.Text.Trim = "", "00:00:00", TxtComidaA.Text.Trim)
If ChkEstatus.Checked Then Estatus = True
If HdnModalidad.Value = "A" Then
If ObjRH.AddTurno(TxtTurno.Text, TxtHorarioDe.Text, TxtHorarioA.Text, UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa, DdlChecadorHorario.SelectedValue.ToEntero(),
TxtRetardo.Text.ToEntero(), TxtFretardo.Text.ToEntero() - TxtRetardo.Text.ToEntero(), TxtToleranciaSRetardo.Text.ToEntero(), TxtFsalida.Text.ToEntero(), comida, ComidaDe, ComidaA, ddlDiaDescanso.SelectedValue.ToEntero()) Then
CargaDatos()
CargaGlobalDTTurno()
Alert("Agregado Correctamente.", TipoMensaje.MsgInformacion)
End If
ElseIf HdnModalidad.Value = "U" Then
If ObjRH.UpdateTurno(TxtTurno.Text, TxtHorarioDe.Text, TxtHorarioA.Text, Estatus, HdnID.Value.ToEntero(), UsuarioActual.CveUsuario, DdlChecadorHorario.SelectedValue.ToEntero(),
TxtRetardo.Text.ToEntero(), TxtFretardo.Text.ToEntero() - TxtRetardo.Text.ToEntero(), TxtToleranciaSRetardo.Text.ToEntero(), TxtFsalida.Text.ToEntero(), comida, ComidaDe, ComidaA, ddlDiaDescanso.SelectedValue.ToEntero()) Then
CargaDatos()
CargaGlobalDTTurno()
Alert("Actualizado Correctamente.", TipoMensaje.MsgInformacion)
End If
End If
End Using
RegistraScript(String.Format("$('#{0}').modal('hide');", "divAddTurno"))
UpDatos.Update()
End Sub
Public Sub Edit_Click(sender As Object, e As EventArgs)
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
HdnModalidad.Value = "U"
HdnID.Value = GvRow.DataKey("CveTurno")
UpDatos.Update()
BtnAgregarTurno.Text = "Actualizar"
DdlChecadorHorario.SelectedValueExist(GvRow.DataKey("CveChecadorHorario"))
TxtTurno.Text = GvRow.DataKey("Turno")
TxtHorarioDe.Text = GvRow.DataKey("HorarioDe")
TxtHorarioA.Text = GvRow.DataKey("HorarioA")
TxtRetardo.Text = GvRow.DataKey("ToleranciaERetardo")
TxtFretardo.Text = (GvRow.DataKey("ToleranciaEFalta2").ToEntero()).ToString()
TxtFsalida.Text = GvRow.DataKey("ToleranciaSFalta")
ChkEstatus.Checked = CBool(GvRow.DataKey("Estatus"))
chkComida.Checked = (GvRow.DataKey("Comida") = "1")
TxtComidade.Text = GvRow.DataKey("ComidaDe")
TxtComidaA.Text = GvRow.DataKey("ComidaA")
TxtToleranciaSRetardo.Text = GvRow.DataKey("ToleranciaSRetardo")
ddlDiaDescanso.SelectedValueExist(GvRow.DataKey("DiaDescanso"))
chkComida_CheckedChanged(Nothing, Nothing)
UpAddTurno.Update()
'CargaGlobalDTTurno()
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddTurno"))
End Sub
Public Sub Agregar()
HdnModalidad.Value = "A"
UpDatos.Update()
BtnAgregarTurno.Text = "Agregar"
TxtHorarioA.Text = ""
TxtHorarioDe.Text = ""
TxtTurno.Text = ""
TxtRetardo.Text = "15"
TxtFretardo.Text = "30"
TxtFsalida.Text = "15"
ddlDiaDescanso.SelectedValueExist("-1")
CargaDdlChecadorHorario()
ChkEstatus.Checked = True
DVHorarioComida.Visible = True
UpAddTurno.Update()
RegistraScript(String.Format("$('#{0}').modal('show');", "divAddTurno"))
End Sub
Private Sub CargaGlobalDTTurno()
Dim ObjRH As New ClsRH
If ObjRH.GetTurnos() Then
Application("GlobalDTTurno") = ObjRH.DtResultados
Else
Application("GlobalDTTurno") = Nothing
End If
ObjRH.Dispose()
End Sub
Public Sub Delete_Click(sender As Object, e As EventArgs)
Dim ObjRH As New ClsRH()
Dim GvRow As GridViewRow = DirectCast(DirectCast(sender, LinkButton).NamingContainer, GridViewRow)
HdnID.Value = GvRow.DataKey("CveTurno")
UpDatos.Update()
If ObjRH.RemoveTurno(HdnID.Value.ToEntero) Then
CargaDatos()
CargaGlobalDTTurno()
Alert("Eliminado Correctamente.", TipoMensaje.MsgInformacion)
End If
ObjRH.Dispose()
UpDatos.Update()
End Sub
Private Sub LnkTurno_Click(sender As Object, e As EventArgs) Handles LnkTurno.Click
Agregar()
End Sub
Private Sub GvTurno_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GvTurno.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If CBool(e.Row.DBCampo("Estatus")) = True Then
e.Row.FCLabel("LblEstatus").Text = "Activo"
e.Row.FCLabel("LblEstatus").ForeColor = Drawing.Color.Green
Else
e.Row.FCLabel("LblEstatus").Text = "Inactivo"
e.Row.FCLabel("LblEstatus").ForeColor = Drawing.Color.Red
End If
End If
End Sub
Protected Sub chkComida_CheckedChanged(sender As Object, e As EventArgs)
If chkComida.Checked Then
DVHorarioComida.Visible = True
Else
DVHorarioComida.Visible = False
End If
UpAddTurno.Update()
End Sub
End Class